[pixhawk筆記]1-編譯過程


好久沒有編譯過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 --recursive
make 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口連接,即可完成編譯並上傳,如無錯誤,輸出如下:

    spy@ubuntu:~/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,編譯完工。

 

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM