注意:該編譯方法生成的固件基於Chibios系統,如果想要Nuttx系統固件,需采用make編譯,步驟見make編譯說明部分。
軟件安裝准備
-
安裝Cygwin
-
安裝應用程序,在安裝界面中選擇網絡安裝和下載包服務器地址,直到進入下圖界面
-
在搜索框中搜索待安裝的包,並點擊skip按鈕選擇安裝版本,選擇成功后bin選擇被打鈎,表示選擇安裝有效。依次搜索下表中的包,並選擇安裝有效。全被選擇完成之后,點擊下一步進行安裝(下載包和安裝包過程需要一段比較長的時間,需耐心等待)。
Package Name Category / Name / Description autoconf Devel | autoconf: Wrapper scripts for autoconf commands automake Devel | automake: Wrapper scripts for automake and aclocal ccache Devel | ccache: A C compiler cache for improving recompilation gcc-g++ Devel | gcc-g++ GNU Compiler Collection (C++) git Devel | git: Distributed version control system libtool Devel | libtool: Generic library support script make Devel | make: The GNU version of the ‘make’ utility gawk Interpreters | gawk: GNU awk, a pattern scanning and processing language libexpat-devel Libs | libexpat-devel: Expat XML parser library (development files) libxml2-devel Libs | libxml2-devel: Gnome XML library (development) libxslt-devel Libs | libxslt-devel: XML template library (development files) python2-devel Python | python2-devel: Python2 language interpreter (python3 does not work yet) python2-future Python | python2-future: Clean single-source support for Python 3 and 2 python2-libxml2 Python | python2-libxml2: Gnome XML Library (Python bindings python2-pip Python | python2-pip: Python package installation tool procps-ng System | procps-ng: System and process monitoring utilities (required for pkill) gdb Devel | gdb: The GNU Debugger ddd Devel | ddd: DDD, the data display debugger zip Archive | zip: Info-ZIP compression utility -
打開Cygwin64 Terminal(從桌面快捷方式或者開始菜單中打開),輸入以下指令安裝依賴的python組件包。
pip2 install empy pip2 install pyserial pip2 install pymavlink
-
安裝GCC編譯器(http://firmware.ardupilot.org/Tools/STM32-tools/gcc-arm-none-eabi-6-2017-q2-update-win32-sha2.exe),安裝過程中選擇Add path to environment variable。
編譯目標程序
-
打開Cygwin64 Terminal,進入Ardupilot工程目錄下
-
查看能編譯目標板指令
./waf list_boards
-
配置目標板,以下列出常用的配置目標板指令:
./waf configure --board bebop --static # Bebop or Bebop2 ./waf configure --board edge # emlid edge ./waf configure --board fmuv3 # Pixhawk2/Cube using ChibiOS ./waf configure --board fmuv4 # Pixracer using ChibiOS ./waf configure --board navio2 # emlid navio2 ./waf configure --board Pixhawk1 # Pixhawk1 ./waf configure --board CubeBlack # Pixhawk2 ./waf configure --board Pixracer # Pixracer ./waf configure --board skyviper-v2450 # SkyRocket's SkyViper GPS drone using ChibiOS ./waf configure --board sitl # software-in-the-loop simulator ./waf configure --board sitl --debug # software-in-the-loop simulator with debug symbols
此處編譯pixhawk1為例。輸入指令
./waf configure --board Pixhawk1
。注意區分大小寫。 -
編譯目標指令。輸入以下指令編譯四旋翼固件,固件格式為apj和bin,其中apj可通過MissionPlaner地面站燒寫至目標板。
./waf --targets bin/arducopter
關於waf編譯詳細說明請見文檔:https://github.com/ArduPilot/ardupilot/blob/master/BUILD.md