I’m trying to figure out how to create a single binary that contains both the particle firmware and my application code (to make it easier to burn firmware with a JTAG programmer on a large number of boards), while still maintaining my application source code in a directory outside of the firmware directory. It wasn’t obvious to me how to do this after looking at the readme in the firmware repo. Can anyone point me in the right direction?
@alanwells, while Mat will definetly give you the pro answer, I can only point you to the make parameter MODULAR=n when building locally, which generates a combined bin for system-part1, system-part2 and your user-part.
So this should help out till Mat gets your input to provide the pro answer
cd <repo-root>/main
make clean all PLATFORM=<yourPlatform> MODULAR=n ...
It’s best to keep the system and application firmware separate (i.e. use our modular system) so that your electron follows the standard layout for devices, allowing application code to be separately compiled without also needing to flash the system firmware, which avoid additional data usage.
To create a complete image for the electron, we use
This combines the bootloader, as well as system and default application firmware for flashing via JTAG on a manufacturing line.
To use the makefile, pull the firmware repo, checkout the branch and then run:
cd hal/src/electron
make -f combined.mk
This will build the manufacturing image to firmware/build/releases/release-0.4.9-p10/
Flashing the manufacturing image
Ensure OPENOCD_HOME is defined that points to the location of your openOCD installation.
Hook up the Electron to the programmer shield and run
make -f combined.mk all openocd-flash
This will build the manufacturing image and flash it to the device, erasing all previous flash contents.
@mdma The above instructions made sense, but I’m getting a file error on the user-part.bin file:
dd if=../../../../firmware/build/target/user-part/platform-10-m/user-part.bin of=../../../../firmware/build/releases/release-0.4.8-rc.6-p10/user-part.bin conv=notrunc
dd: ../../../../firmware/build/target/user-part/platform-10-m/user-part.bin: No such file or directory
make: *** [user] Error 1
It appears the makefile is attempting to copy user-part.bin from /firmware/build/target/user-part.bin to /firmware/build/releases/release-0.4.8-rc.6-p10/user-part.bin. This file exists in the location where it is trying to copy it to, but not where it is trying to copy it from. Is it possible the paths for these two locations are accidentally reversed in this line: https://github.com/spark/firmware/blob/develop/hal/src/stm32/combined.mk#L90?
I removed the three (extra?) $(USER_MEM) statements (there were 4 total on the line, which I think added 4 copies of our app firmware to the final binary.
Is there a reason there should be 4 copies of the app binary added to the combined binary?
This looks like an intermediate problem - sometimes firmware overflows the space available until we have time to optimize.
It's recommended you stick to use release branches unless there is a specific reason to use development branches. The latest release is found under master with other releases found under release/vX.Y.Z.
Apologies for the ambiguous post, I had tried several branches including develop and latest.
I’ve just tried again on the master branch and still getting the overflow error.
I’m using arm-none-eabi-gcc version 4.9.3
I’ve managed to upload the firmware separately anyway so no dramas, would be a useful feature if I could get it working though.
@mdma Can you confirm that you intended to refer to 2 different make files in this post?
You refer to: hal/src/electron/combined.mk for making a combined binary hal/src/stm32/combined.mk for flashing the image
Which combined-build code path does Particle use for official manufacturing binaries? Both the above seem to be throwing errors in the latest release branch for the electron.