Thursday, 22 May 2014

Rebuilding Firmware

Rebuilding

When changes to the source code are made, the firmware must be rebuilt. Not all changes require a full rebuild, however; several scenarios are shown below.
If changes are made remotely to the PX4 firmware or NuttX that you would like to use, first ensure that you have a clean working copy (git checkout – . or git stash save –keep-index or git commit) and then:
cd Firmware
make distclean
git pull origin master
cd NuttX
git pull origin master 
cd .. 
make archives
make
If changes are made to anything within the Firmware/nuttx folder, everything must be rebuilt:
cd Firmware
make distclean
make archives
make
If changes are made to any headers within the Firmware/src folder, NuttX does not need to be rebuilt, but clean before rebuilding the firmware:
cd Firmware
make clean
make
Changes to any other part of the source code do not require rebuilding NuttX:
cd Firmware
make upload px4fmu-v1_default
To upload the newly-built firmware to the FMU:
make upload px4fmu-v1_default
Any time two make commands follow each other, the second one can be run automatically after the first one completes successfully by adding && between the two commands on the same line. Also the -j8 flag can be added to parallelize the build across 8 cores. When combined, this command may be a useful replacement for rebuilding the archives above:
make archives && make -j8