Building and install ArduPilot firmware for Pixhawk on Mac
NOTE: This is for Copter v3.2.1 and earlier. For v3.3 and later, things have been simplified greatly.
Use Homebrew to install various packages
brew tap PX4/homebrew-px4 brew update brew install genromfs brew install gcc-arm-none-eabi brew install gawk
This is a little risky and may not be necessary...
sudo rm -f /usr/bin/awk sudo ln -s `which gawk` /usr/bin/awk
easy_install pip pip install pyserial empy numpy catkin_pkg
Install ardupilot and dependencies
mkdir px4 cd px4 git clone https://github.com/diydrones/ardupilot.git git clone https://github.com/diydrones/PX4Firmware.git git clone https://github.com/diydrones/PX4NuttX.git git clone git://github.com/diydrones/uavcan.git
Configure (This will generate ../config.mk file)
cd ardupilot/ArduCopter/ make configure
On a Mac, change the following line so that make can find proper arduino files
vim ../config.mk # Comment out the following line # BOARD = mega2560 # HAL_BOARD ?= HAL_BOARD_APM2 HAL_BOARD ?= HAL_BOARD_PX4 # If you want make to upload the built firmware, specify the tty as well. PORT = /dev/tty.usbmodem1 # ARDUINO = /path/to/Arduino¬ ARDUINO = /Applications/ArduPilot.app/Contents/Resources/Java/
Install ccache to speed up compilation
brew install ccache ln -s ccache /usr/local/bin/gcc ln -s ccache /usr/local/bin/g++ ln -s ccache /usr/local/bin/cc ln -s ccache /usr/local/bin/c++
Run make twice as indicated in the official guide (first time to build PX4Firmware and Nuttex, 2nd time to build ArduCopter)
make px4-v2 make px4-v2
Finally build the arducopter firmware for pixhawk
There should be 2 firmware files now. ArduCopter-v1.px4 for the original PX4, ArduCopter-v2.px4 for Pixhawk.
To enable parallel builds and specifically build pixhawk quad firmware
make px4-v2-quad -j2
To build for other frame types, use make commands (substitute quad, tri, hexa, y6, octa, octa-quad, heli for [frame type])
make px4-clean make px4-[frame type]
NOTE: make clean only cleans non-px4 targets
To cleanup just the dependencies
Upload compiled firmware to your px4 board
make px4-quad-upload -j4
For pixhawk, specify v2
make px4-v2-quad-upload -j4
Connect to Pixhawk to see if the firmware is working properly
screen /dev/tty.usbmodem1 115200 8N1 # OR sudo cu -l /dev/tty.usbmodem1 -s 115200
Note: You have to connect to the serial interface right after Pixhawk finish booting and press
Enter key 3 times to start the shell.
Or use MAVProxy
mavproxy.py --setup --master=/dev/tty.usbmodem1
--setup option was used to get raw serial data without MAVLink mode parsing, but it seems like the whole console has been removed from newer version and it doesn't work, so omit
If you get a build error in one of the submodules, force update submodules. Since ArduPilot started tracking submodule versions, it's become pretty common. Make sure you set
--recursive option as many submodules have their own submodules.
git submodule update --init --recursive --force