好久没有编译过PIXHAWK了,由于项目需要,又买了一个pixhawk2,由于每次编译都会出现新的问题,这次写帖子将过程记录下来。
环境:WIN10+Ubuntu16.04 64位(VMware Workstation 12 Pro虚拟机)。
基本按照pixhawk的Devguide里面给的步骤,将遇到的问题和解决方法给出,希望能帮助到遇到这些问题的同学。
使用下列命令将用户加入dialout用户组:
sudo usermod -a -G dialout $USER
然后,下载并运行工具链安装脚本:
为简便起见,我使用wget命令行下载。
wget https://raw.githubusercontent.com/PX4/Devguide/master/build_scripts/ubuntu_sim_nuttx.sh source ubuntu_sim_nuttx.sh
待一串提示完成之后,即完成工具链安装。
之后是下载并编译代码:
mkdir -p ~/src cd ~/src git clone https://github.com/PX4/Firmware.git
然后更新子模块(官网的文档以前有这一步,但不知为何,现在将这一步去掉了,加入该步可以在编译时更省时并免且排错时更容易):
cd Firmware git submodule update --init --recursivemake posix jmavsim
编译通过后会弹出jmavsim的界面仿真界面
但是题主的老弹出Gyro和Accel fail的错误,据说是因为电脑配置太差,虚拟机太慢所致( ˇ?ˇ ),所以建议大家有条件还是用单独的机子装Ubuntu玩。
然后编译V2固件,为pixhawk一代用的标准固件:
make px4fmu-v2_default
题主在编译V2固件时,遇到如下问题:
- 创建编译目录的权限问题
处理方法如下:修改src目录的权限
sudo chmod -R 777 src
- python的em模块以及catkin_pkg包找不到
经检查是因为题主之前用anaconda装了python3.5,默认的用的python3.5,而pixhawk中的包貌似用的python2,将默认的改为python2.7,修改方法将.bashrc中的python路径改为python2.7的即可。
并安装对应的pip和python-empy。注意,安装pip时,按照官网给出的方法通过下载get-pip.py,然后安装,下载时速度很慢。可以用apt安装,代码如下:
sudo apt-get install python-pip
以上两个问题处理之后,可以编译通过,由于题主用的pixhawk2,所以使用
make px4fmu-v3_default upload
编译并上传代码
用usb线将pixhawk2和电脑usb口连接,即可完成编译并上传,如无错误,输出如下:[email protected]:~/src/Firmware$ make px4fmu-v3_default upload [ 0%] Built target git_genmsg [ 0%] Built target mixer_gen [ 0%] Built target git_nuttx [ 0%] Built target git_gencpp [ 1%] Built target git_matrix [ 1%] Built target git_uavcan [ 1%] Built target git_mavlink [ 2%] Built target git_ecl [ 2%] Built target libuavcan_dsdlc [ 3%] Built target ver_gen [ 3%] Built target airframes_xml [ 3%] Built target parameters_xml [ 3%] Built target nuttx_copy_px4fmu-v3 [ 4%] Built target nuttx_copy_px4io-v2 [ 5%] Built target px4fmu-v3-nuttx_patch_00001-REJECTED-add-math.h.patch [ 5%] Built target px4io-v2-nuttx_patch_00001-REJECTED-add-math.h.patch [ 5%] Built target px4fmu-v3-nuttx_patch_00002-REJECTED-fix-shadow-wanings.patch [ 5%] Built target px4io-v2-nuttx_patch_00002-REJECTED-fix-shadow-wanings.patch [ 5%] Built target px4io-v2-nuttx_patch_00003-REJECTED-add-var-expansion-in-nsh-parse.patch [ 5%] Built target px4fmu-v3-nuttx_patch_00003-REJECTED-add-var-expansion-in-nsh-parse.patch [ 5%] Built target px4io-v2-nuttx_patch_00004-REJECTED-avoid-export-copy-with-export-insitu.patch [ 5%] Built target px4fmu-v3-nuttx_patch_00004-REJECTED-avoid-export-copy-with-export-insitu.patch [ 5%] Built target px4io-v2-nuttx_patch_00005-REJECTED-support-c++11.patch [ 5%] Built target px4fmu-v3-nuttx_patch_00005-REJECTED-support-c++11.patch [ 5%] Built target px4io-v2-nuttx_patch_00006-REJECTED-cstdint-fix.patch [ 5%] Built target px4fmu-v3-nuttx_patch_00006-REJECTED-cstdint-fix.patch [ 5%] Built target px4io-v2-nuttx_patch_00007-REJECTED-silence-jobserver-warnings.patch [ 6%] Built target px4io-v2-nuttx_patch_00008-REJECTED-static-assert-fix.patch [ 6%] Built target px4fmu-v3-nuttx_patch_00007-REJECTED-silence-jobserver-warnings.patch [ 6%] Built target px4io-v2-nuttx_patch_00009-REJECTED-ctype-fix-shadow-wanings.patch [ 6%] Built target px4fmu-v3-nuttx_patch_00008-REJECTED-static-assert-fix.patch [ 6%] Built target px4io-v2-nuttx_patch_00010-BACKPORT-stm32-flash-F4-dcache-corruption-fix-no-HSI-on.patch [ 6%] Built target px4io-v2-nuttx_patch_00011-BACKPORT-priority-restoration-fix.patch [ 7%] Built target px4fmu-v3-nuttx_patch_00009-REJECTED-ctype-fix-shadow-wanings.patch [ 7%] Built target px4io-v2-nuttx_patch_00012-BACKPORT-stack-coloration-overreach-fix.patch [ 7%] Built target px4fmu-v3-nuttx_patch_00010-BACKPORT-stm32-flash-F4-dcache-corruption-fix-no-HSI-on.patch [ 7%] Built target px4io-v2-nuttx_patch_00013-BACKPORT-stm32-serial-dma-hotfix.patch [ 7%] Built target px4fmu-v3-nuttx_patch_00011-BACKPORT-priority-restoration-fix.patch [ 7%] Built target px4io-v2-nuttx_patch_00014-BACKPORT-i2c-hotfix.patch [ 7%] Built target px4fmu-v3-nuttx_patch_00012-BACKPORT-stack-coloration-overreach-fix.patch [ 8%] Built target px4io-v2-nuttx_patch_00015-BACKPORT-stm32f7-DTCM.patch [ 8%] Built target px4fmu-v3-nuttx_patch_00013-BACKPORT-stm32-serial-dma-hotfix.patch [ 8%] Built target px4io-v2-nuttx_patch_00016-BACKPORT-fix-CRTSCTS-defines.patch [ 8%] Built target px4io-v2-nuttx_patch_00017-BACKPORT-cdcacm.patch [ 8%] Built target px4fmu-v3-nuttx_patch_00014-BACKPORT-i2c-hotfix.patch [ 8%] Built target px4io-v2-nuttx_patch_00018-BACKPORT-stm32-serial-break.patch [ 8%] Built target px4fmu-v3-nuttx_patch_00015-BACKPORT-stm32f7-DTCM.patch [ 8%] Built target px4io-v2-nuttx_patch_00019-BACKPORT-stm32-rcc-keep-HSI-on.patch [ 8%] Built target px4fmu-v3-nuttx_patch_00016-BACKPORT-fix-CRTSCTS-defines.patch [ 8%] Built target px4io-v2-nuttx_patch_00020-BACKPORT-ramtron-CONFIG-prefix.patch [ 9%] Built target px4fmu-v3-nuttx_patch_00017-BACKPORT-cdcacm.patch [ 9%] Built target px4io-v2-nuttx_patch_00021-BACKPORT-stm32f3x-add-BKP.patch [ 9%] Built target px4fmu-v3-nuttx_patch_00018-BACKPORT-stm32-serial-break.patch [ 9%] Built target px4io-v2-nuttx_patch_00022-BACKPORT-stm32-bkp-reference-fix.patch [ 9%] Built target px4fmu-v3-nuttx_patch_00019-BACKPORT-stm32-rcc-keep-HSI-on.patch [ 10%] Built target px4io-v2-nuttx_patch_00023-BACKPORT-stm32f7-bkp-reference-fix.patch [ 10%] Built target px4fmu-v3-nuttx_patch_00020-BACKPORT-ramtron-CONFIG-prefix.patch [ 10%] Built target px4io-v2-nuttx_patch_00024-BACKPORT-stm32f7-serial-dma-hotfix.patch [ 10%] Built target px4fmu-v3-nuttx_patch_00021-BACKPORT-stm32f3x-add-BKP.patch [ 10%] Built target px4io-v2-nuttx_patch_00025-BACKPORT-add-set-ex-to-nsh.patch [ 10%] Built target px4fmu-v3-nuttx_patch_00022-BACKPORT-stm32-bkp-reference-fix.patch [ 10%] Built target px4io-v2-nuttx_patch_00026-BACKPORT-stm32fX-serial-fix-freezing.patch [ 10%] Built target px4fmu-v3-nuttx_patch_00023-BACKPORT-stm32f7-bkp-reference-fix.patch [ 10%] Built target px4io-v2-nuttx_patch_00027-BACKPORT-stm32-sdio-1-bit-and-16G-fix.patch [ 10%] Built target px4fmu-v3-nuttx_patch_00024-BACKPORT-stm32f7-serial-dma-hotfix.patch [ 10%] Built target px4io-v2-nuttx_patch_00030-BACKPORT-fix-arm-none-eabi-gcc-7-warnings-nuttx.patch [ 11%] Built target px4fmu-v3-nuttx_patch_00025-BACKPORT-add-set-ex-to-nsh.patch [ 11%] Built target px4io-v2-nuttx_patch_00031-BACKPORT-fix-arm-none-eabi-gcc-7-warnings-apps.patch [ 11%] Built target px4io-v2-nuttx_patch_90000-PENDING-wip-inflight-to-upstream.patch [ 11%] Built target px4fmu-v3-nuttx_patch_00026-BACKPORT-stm32fX-serial-fix-freezing.patch [ 11%] Built target nuttx_patch_px4io-v2 [ 11%] Built target px4fmu-v3-nuttx_patch_00027-BACKPORT-stm32-sdio-1-bit-and-16G-fix.patch [ 11%] Built target nuttx_configure_px4io-v2 [ 11%] Built target px4fmu-v3-nuttx_patch_00030-BACKPORT-fix-arm-none-eabi-gcc-7-warnings-nuttx.patch [ 11%] Built target nuttx_export_px4io-v2 [ 11%] Built target px4fmu-v3-nuttx_patch_00031-BACKPORT-fix-arm-none-eabi-gcc-7-warnings-apps.patch [ 11%] Built target io_prebuild_targets [ 11%] Built target px4fmu-v3-nuttx_patch_90000-PENDING-wip-inflight-to-upstream.patch [ 11%] Built target nuttx_patch_px4fmu-v3 [ 11%] Built target nuttx_configure_px4fmu-v3 [ 11%] Built target nuttx_export_px4fmu-v3 [ 11%] Built target prebuild_targets [ 23%] Built target msg_gen [ 23%] Built target generate_topic_listener [ 24%] Built target platforms__common [ 24%] Built target drivers__airspeed [ 24%] Built target drivers__blinkm [ 28%] Built target px4io-v2 [ 29%] Built target drivers__bmi160 [ 29%] Built target drivers__bmp280 [ 31%] Built target drivers__boards__px4fmu-v2 [ 32%] Built target drivers__camera_trigger [ 32%] Built target drivers__bst [ 33%] Built target drivers__device [ 33%] Built target drivers__ets_airspeed [ 33%] Built target drivers__hott [ 33%] Built target drivers__frsky_telemetry [ 34%] Built target drivers__hmc5883 [ 35%] Built target drivers__gps [ 35%] Built target drivers__iridiumsbd [ 36%] Built target drivers__hott__hott_telemetry [ 36%] Built target drivers__hott__hott_sensors [ 36%] Built target drivers__l3gd20 [ 36%] Built target drivers__led [ 36%] Built target drivers__lsm303d [ 37%] Built target drivers__lis3mdl [ 38%] Built target drivers__ll40ls [ 38%] Built target drivers__mb12xx [ 38%] Built target drivers__mkblctrl [ 39%] Built target drivers__mpu6000 [ 39%] Built target drivers__ms4525_airspeed [ 40%] Built target drivers__mpu9250 [ 41%] Built target drivers__ms5525_airspeed [ 41%] Built target drivers__oreoled [ 41%] Built target drivers__ms5611 [ 41%] Built target drivers__pwm_out_sim [ 42%] Built target drivers__pwm_input [ 42%] Built target drivers__px4flow [ 42%] Built target drivers__px4fmu [ 42%] Built target lib__led [ 42%] Built target drivers__sf0x [ 43%] Built target drivers__px4io [ 44%] Built target drivers__sdp3x_airspeed [ 44%] Built target drivers__sf1xx [ 44%] Built target drivers__srf02 [ 44%] Built target drivers__stm32__adc [ 44%] Built target drivers__snapdragon_rc_pwm [ 45%] Built target drivers__stm32 [ 46%] Built target drivers__stm32__tone_alarm [ 46%] Built target drivers__tap_esc [ 47%] Built target drivers__trone [ 48%] Built target drivers__vmount [ 49%] Built target modules__sensors [ 49%] Built target systemcmds__config [ 49%] Built target systemcmds__bl_update [ 49%] Built target systemcmds__esc_calib [ 50%] Built target systemcmds__dumpfile [ 50%] Built target systemcmds__hardfault_log [ 50%] Built target systemcmds__led_control [ 51%] Built target systemcmds__mixer [ 51%] Built target systemcmds__motor_ramp [ 51%] Built target systemcmds__mtd [ 51%] Built target systemcmds__perf [ 52%] Built target systemcmds__param [ 52%] Built target systemcmds__nshterm [ 52%] Built target systemcmds__pwm [ 52%] Built target systemcmds__reboot [ 53%] Built target systemcmds__sd_bench [ 53%] Built target systemcmds__top [ 53%] Built target systemcmds__ver [ 54%] Built target systemcmds__topic_listener [ 55%] Built target drivers__sf0x__sf0x_tests [ 55%] Built target drivers__test_ppm [ 55%] Built target lib__controllib__controllib_test [ 56%] Built target modules__commander__commander_tests [ 56%] Built target modules__unit_test [ 56%] Built target modules__mc_pos_control__mc_pos_control_tests [ 57%] Built target modules__mavlink__mavlink_tests [ 57%] Built target modules__uORB__uORB_tests [ 57%] Built target modules__gpio_led [ 58%] Built target modules__uORB [ 60%] Built target modules__commander [ 61%] Built target modules__land_detector [ 62%] Built target modules__load_mon [ 66%] Built target systemcmds__tests [ 66%] Built target platforms__nuttx [ 66%] Built target modules__camera_feedback [ 67%] Built target modules__mavlink [ 69%] Built target modules__navigator [ 69%] Built target modules__attitude_estimator_q [ 69%] Built target modules__ekf2 [ 70%] Built target modules__position_estimator_inav [ 71%] Built target modules__local_position_estimator [ 71%] Built target lib__external_lgpl [ 71%] Built target modules__mc_att_control [ 72%] Built target modules__mc_pos_control [ 75%] Built target lib__ecl [ 76%] Built target modules__vtol_att_control [ 77%] Built target modules__logger [ 77%] Built target modules__sdlog2 [ 77%] Built target modules__dataman [ 78%] Built target modules__systemlib__param [ 79%] Built target modules__systemlib__mixer [ 81%] Built target lib__controllib [ 81%] Built target lib__conversion [ 83%] Built target modules__systemlib [ 84%] Built target df_driver_framework [ 84%] Built target lib__geo [ 85%] Built target lib__geo_lookup [ 85%] Built target lib__launchdetection [ 86%] Built target lib__mathlib [ 86%] Built target lib__mathlib__math__filter [ 86%] Built target lib__runway_takeoff [ 87%] Built target lib__tailsitter_recovery [ 87%] Built target lib__version [ 87%] Built target lib__terrain_estimation [ 87%] Built target examples__rover_steering_control [ 87%] Built target platforms__nuttx__px4_layer [ 87%] Built target modules__bottle_drop [ 88%] Built target examples__segway [ 89%] Built target examples__fixedwing_control [ 89%] Built target examples__px4_mavlink_debug [ 90%] Built target examples__px4_simple_app [ 90%] Built target examples__px4_daemon_app [ 90%] Built target fw_io [ 90%] Built target examples__hwtest [ 90%] Built target examples__ekf_att_pos_estimator [ 90%] Built target drivers__rgbled [ 90%] Built target modules__fw_att_control [ 91%] Built target modules__fw_pos_control_l1 [ 92%] Built target modules__events [ 92%] Built target modules__gnd_pos_control [ 92%] Built target modules__gnd_att_control [ 92%] Built target lib__DriverFramework__framework [ 96%] Built target uavcan [ 97%] Built target romfs [ 97%] Built target uavcan_stm32_driver [100%] Built target modules__uavcan [100%] Built target firmware_nuttx [100%] uploading /home/spy/src/Firmware/build_px4fmu-v3_default/src/firmware/nuttx/px4fmu-v3_default.px4 Loaded firmware for 9,0, size: 1492196 bytes, waiting for the bootloader... If the board does not respond within 1-2 seconds, unplug and re-plug the USB connector. Attempting reboot on /dev/serial/by-id/usb-3D_Robotics_PX4_FMU_v2.x_0-if00 with baudrate=57600... If the board does not respond, unplug and re-plug the USB connector. Found board 9,0 bootloader rev 5 on /dev/serial/by-id/usb-3D_Robotics_PX4_BL_FMU_v2.x_0-if00 ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff type: ???? idtype: =FF vid: ffffffff pid: ffffffff coa: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8= sn: 005000253036510b31353833 chip: 20016419 family: STM32F42x revision: 3 flash 2080768 Erase : [====================] 100.0% (timeout: 7 seconds) Program: [====================] 100.0% Verify : [====================] 100.0% Rebooting. [100%] Built target upload
over,编译完工。