# Ardupilot port to the esp32 series mcu
## Building instructions
0. Build currently tested on linux
1. Checkout this branch https://github.com/ardupilot/ardupilot/tree/master
2. Use this to install ardupilot requirements:
```
Tools/environment_install/install-prereqs-ubuntu.sh
```
or
```
Tools/environment_install/install-prereqs-arch.sh
```
3. install esp-idf python deps:
```
# from: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/linux-setup.html
sudo apt-get install git wget flex bison gperf python-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util
sudo apt-get install python3 python3-pip python3-setuptools
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
#or
sudo pacman -S --needed gcc git make flex bison gperf python-pip cmake ninja ccache dfu-util libusb
cd ardupilot
git submodule update --init --recursive
# ensure the idf exists in modules/esp_idf (supports pre-existing submodules and/or cloning it for you)
./Tools/scripts/esp32_get_idf.sh
cd modules/esp_idf
# use it:
./install.sh
unset IDF_PATH
source ./export.sh
cd ../../..
```
4. Configure and run build:
```bash
cd ardupilot
./waf configure
./waf configure --board=esp32buzz --debug
[ or ./waf configure --board=esp32diy --debug ]
./waf plane
or
./waf copter
```
```
Do NOT use "./waf build", it's broken right now.
```
TIPS:
- ninja: error: loading 'build.ninja': No such file or directory
You need to run a plain './waf configure' FIRST, THEN run it with the --board type you want.
- we use toolchain and esp-idf from espressif , as a 'git submodule', so no need to preinstall etc.
https://docs.espressif.com/projects/esp-idf/en/latest/get-started/ -
(note we currently use https://github.com/espressif/esp-idf/tree/release/v4.0 )
- if you get compile error/s to do with CONFIG... such as
in expansion of macro 'configSUPPORT_STATIC_ALLOCATION'
warning: "CONFIG_SUPPORT_STATIC_ALLOCATION" is not defined
this means your 'sdkconfig' file that the IDF relies on is perhaps a bit out of date or out of sync with your IDF.
So double check you are using the correct IDF version ( buzz's branch uses v3.3 , sh83's probably does not.. and then if you are sure:
```
cd build/esp32{BOARD}/esp-idf_build
ninja menuconfig
```
navigate to [save] (tab,tab,tab,enter)
press [tab] then [ok] to update the sdkconfig file
'config written' press [enter] to exit this dialog
press [tab] then enter on the [exit] box to exit the app
done. the 'sdkconfig' file in this folder should have been updated
cd ../../../..
OR locate the 'libraries/AP_HAL_ESP32/targets/esp32/esp-idf/sdkconfig' and delete it, as it should call back to the 'sdkconfig.defaults' file if its not there.
'cd libraries/AP_HAL_ESP32/targets/esp32/esp-idf ; idf.py defconfig' is the command that updates it, but that shouldn't be needed manually, we don't think.
... try ./waf plane"
5. Recommanded way to flash the firmware :
```
ESPBAUD=921600 ./waf plane --upload
```
6. The espressif esp-idf original project is built at `cd build/esp32{BOARD}/esp-idf_build/`.
You can use your default build system (make or ninja) to build other esp-idf target.
For example :
- ninja flash
- ninja monitor
If you want to specify the port, specify before any command:
```
ESPTOOL_PORT=/dev/ttyUSB1
```
If you want to specify a wanted baudrate :
```
ESPTOOL_BAUD=57600
ESPTOOL_BAUD=921600
```
You can find more info here : [ESPTOOL](https://github.com/espressif/esptool)
You can also find the cmake esp-idf project at `libraries/AP_HAL_ESP32/targets/esp32/esp-idf` for idf.py command. But see next section to understand how ardupilot is compiled on ESP32.
For flashing from another machine you need the following files:
```
build/<board>/esp-idf_build/bootloader/bootloader.bin
build/<board>/esp-idf_build/ardupilot.bin
build/<board>/esp-idf_build/partition_table/partition-table.bin
```
see build/<board>/esp-idf_build/flash_project_args (after building) for hints on what arguments to use
---
OLD
Alternatively, the "./waf plane' build outputs a python command that y can cut-n-paste to flash... buzz found that but using that command with a slower baudrate of 921600 instead of its recommended 2000000 worked for him:
cd ardupilot
python ./modules/esp_idf/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xf000 ./build/esp32buzz/idf-plane/ota_data_initial.bin 0x1000 ./build/esp32buzz/idf-plane/bootloader/bootloader.bin 0x20000 ./build/esp32buzz/idf-plane/arduplane.bin 0x8000 ./build/esp32buzz/idf-plane/partitions.bin
---
## How is compiled Ardupilot on esp32
The ESP-IDF os is compiled as a library to the project.
First waf configure the esp-idf cmake and run a target to get all esp-idf includes.
Waf compile all ardupilot parts in libardusub.a and libArduSub_libs.a (for example for subs, but similarly for planes, copter, rover).
Then waf execute the esp-idf cmake to compile esp-idf itself.
And the cmake link the final ardupilot.elf against previous built libraries.
The ardupilot.elf contains all symbol. The cmake provide a stripped version as ardupilot.bin.
## Test hardware
Currently esp32 dev board with connected gy-91 10dof sensor board is supported. Pinout (consult UARTDriver.cpp and SPIDevice.cpp for reference):
### Uart connecion/s
Internally connected on most devboards, just for reference.
After flashing the esp32 , u can connect with a terminal app of your preference to the same COM port ( eg /dev/ttyUSB0) at a baud rate of 115200, software flow control, 8N1 common uart settings, and get to see the output from hal.console->printf("...") and other console messages.
### Console/usb/boot-messages/mavlink telem aka serial0/uart0:
| ESP32 | CP2102 |
| --- | --- |
| GPIO3 | UART_TX | AKA UART0_RX |
| GPIO1 | UART_RX | AKA UART0_TX |
### GPS aka serial1/uart1:
| ESP32 | GPS |
| --- | --- |
| GPIO17 (TX) | GPS (RX) |
| GPIO16 (RX) | GPS (TX) |
| GND | GND |
| 5v | Pwr |
### RC receiver connection:
|ESP32| RC Receiver |
| --- | --- |
| D4 | CPPM-out |
| GND | GND |
| 5v | Pwr |
### I2C connection ( for gps with leds/compass-es/etc onboard, or digital airspeed sensorrs, etc):
| ESP32 | I2C |
| --- | --- |
| GPIO12 | SCL |
| GPIO13 | SDA |
| GND | GND |
| 5v | Pwr |
### Compass (using i2c)
- u need to set the ardupilot params, and connected a GPS that has at least one i2c compass on it.. tested this with a HMC5883 and/or LIS3MDL
COMPASS_ENABLE=1
COMPASS_EXTERNAL=1
COMPASS_EXTERN2=1
COMPASS_EXTERN3=1
### Analog input/s
2nd column is the ardupilot _PIN number and matches what u specify in the third column of HAL_ESP32_ADC_PINS #define elsewhere :
if HAL_ESP32_ADC_PINS == HAL_ESP32_ADC_PINS_OPTION1:
| ESP32 | AnalogIn |
| --- | --- |
| GPIO35 | 1 |
| GPIO34 | 2 |
| GPIO39 | 3 |
| GPIO36 | 4 |
| GND | GND |
eg, set ardupilot params like this:
RSSI_ANA_PIN = 3 - and it will attempt to read the adc value on GPIO39 for rssi data
BATT_CURR_PIN = 2 - and it will attempt to read the adc value on GPIO34 for battery current
BATT_VOLT_PIN = 1 - and it will attempt to read the adc value on GPIO35 for battery voltage
ARSPD_PIN = 4 - and it will attempt to read the adc value on GPIO36 for analog airspeed data
if HAL_ESP32_ADC_PINS == HAL_ESP32_ADC_PINS_OPTION2:
| ESP32 | AnalogIn |
| --- | --- |
| GPIO35 | 35 |
| GPIO34 | 34 |
| GPIO39 | 39 |
| GPIO36 | 36 |
| GND | GND |
eg, set ardupilot params like this:
RSSI_ANA_PIN = 39 - and it will attempt to read the adc value on GPIO39 for rssi data
BATT_CURR_PIN = 34 - and it will attempt to read the adc value on GPIO34 f
没有合适的资源?快使用搜索试试~ 我知道了~
Ardupilot Firmware 镜像.zip
共2000个文件
h:830个
cpp:822个
md:135个
需积分: 5 1 下载量 26 浏览量
2023-12-31
19:52:50
上传
评论
收藏 87.19MB ZIP 举报
温馨提示
ardupilot
资源推荐
资源详情
资源评论
收起资源包目录
Ardupilot Firmware 镜像.zip (2000个子文件)
ESCPackets.c 191KB
ECUPackets.c 152KB
ServoPackets.c 73KB
scaledencode.c 58KB
pnet.c 50KB
scaleddecode.c 44KB
ESCDefines.c 33KB
flash.c 28KB
ECUDefines.c 24KB
calcP.c 22KB
ECUSettings.c 22KB
crashdump.c 20KB
ESCCommands.c 20KB
ESCVelocityProtocol.c 19KB
usbcfg_dualcdc.c 18KB
ServoDefines.c 18KB
ServoCommands.c 16KB
stm32_util.c 16KB
malloc.c 15KB
ardupilot_SITL_TRICOPTER.c 15KB
usbcfg.c 14KB
fieldencode.c 13KB
ardupilot_SITL_QUAD.c 13KB
fielddecode.c 13KB
ServoProtocol.c 11KB
board.c 10KB
ardupilot_SITL_ROVER.c 10KB
sensors.c 6KB
stubs.c 6KB
sensors.c 6KB
ECUProtocol.c 6KB
bouncebuffer.c 5KB
eedump_apparam.c 5KB
sensors.c 5KB
sitl_physics_env.c 3KB
watchdog.c 3KB
usbcfg_common.c 3KB
hrt.c 3KB
sockets.c 3KB
sockets.c 2KB
sockets.c 2KB
calcH_MAG.c 2KB
moduletest.c 2KB
calcSF.c 1KB
calcSP.c 1KB
calcTmn.c 1KB
calcQ.c 1008B
calcTms.c 23B
calcF.c 0B
GyroFrame.cpp 217KB
GCS_Common.cpp 210KB
AP_AHRS.cpp 95KB
AP_Param.cpp 94KB
AP_GPS.cpp 86KB
AP_NavEKF2_core.cpp 82KB
RCOutput.cpp 81KB
AP_GPS_UBLOX.cpp 75KB
AP_NavEKF2.cpp 68KB
AP_Arming.cpp 64KB
AC_Avoid.cpp 63KB
AP_NavEKF2_MagFusion.cpp 62KB
AP_DroneCAN.cpp 56KB
AP_MotorsMatrix.cpp 55KB
AP_Radio_bk2425.cpp 55KB
AP_Logger.cpp 54KB
UARTDriver.cpp 53KB
RC_Channel.cpp 52KB
AP_NavEKF2_PosVelFusion.cpp 51KB
spm_srxl.cpp 51KB
AP_Radio_cypress.cpp 50KB
SITL.cpp 49KB
AP_Radio_cc2500.cpp 47KB
AP_NavEKF2_Measurements.cpp 47KB
SCurve.cpp 45KB
AP_AHRS_DCM.cpp 43KB
AP_MotorsUGV.cpp 41KB
CANFDIface.cpp 40KB
AP_Baro.cpp 39KB
AP_Mount_Xacti.cpp 39KB
AP_OADijkstra.cpp 39KB
AP_Mount_Siyi.cpp 38KB
AP_FlashIface_JEDEC.cpp 38KB
AP_RunCam.cpp 38KB
SoloGimbalEKF.cpp 37KB
AC_WPNav.cpp 37KB
AP_IOMCU.cpp 37KB
iofirmware.cpp 37KB
SIM_Aircraft.cpp 36KB
AP_BattMonitor.cpp 36KB
AP_Mount_Viewpro.cpp 34KB
AP_NavEKF2_OptFlowFusion.cpp 34KB
CanIface.cpp 33KB
AP_Mount.cpp 33KB
AP_SmartRTL.cpp 32KB
AP_SerialManager.cpp 32KB
AC_PrecLand.cpp 32KB
AP_Airspeed.cpp 32KB
AP_GPS_DroneCAN.cpp 32KB
AP_OABendyRuler.cpp 32KB
AP_GPS_NMEA.cpp 31KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
YOLO数据集工作室
- 粉丝: 468
- 资源: 1567
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功