ArduPilot之开源代码waf-configure编译
·
ArduPilot之开源代码waf-configure编译
1. 源由
./waf configure --board Aocoda-RC-H743Dual
是配置Ardupilot目标板的命令,该命令将根据硬件配置文件生成相应用于编译的目标板源代码文件。
该部分内容涉及以下几点:
- 目标配置:飞控、配件模块等
- 系统配置:ESP32/ChibiOS等
- 编译、链接命令
2. configure
调用关系
$ ./waf configure --board Aocoda-RC-H743Dual
注:选择chibios相关重点进行研读,对于一些不太理解,暂时不需要考虑的(直接略过),有兴趣的朋友请留言讨论。
./waf
└──> ./modules/waf/waf-light
└──> ./wscript
├──> configure //wscript
│ └──> board.configure //boards.py
│ └──> board.configure_env //boards.py
│ └──> chibios.configure_env //boards.py
└──> ardupilotwaf.ap_autoconfigure //ardupilotwaf.py
└──> chibios.configure //chibios.py
└──> chibios.generate_hwdef_h //chibios.py
└──> ./libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py //chibios.py
3. chibios_hwdef.py
脚本
$ python chibios_hwdef.py -h
usage: chibios_pins.py [-h] [-D OUTDIR] [--bootloader] [--signed-fw]
[--params PARAMS]
hwdef [hwdef ...]
positional arguments:
hwdef hardware definition file
optional arguments:
-h, --help show this help message and exit
-D OUTDIR, --outdir OUTDIR
Output directory
--bootloader configure for bootloader
--signed-fw configure for signed FW
--params PARAMS user default params path
该脚本生成以下相关硬件配置文件:
- hw.dat //for ROMFS
- hwdef.h //for hardware definition
- ldscript.ld //for link script
调用关系:
chibios_hwdef.py
├──> args = parser.parse_args: "--outdir" "--bootloader" "--signed-fw" "--params" "hwdef"
├──> c = ChibiOSHWDef(
│ outdir=args.outdir,
│ bootloader=args.bootloader,
│ signed_fw=args.signed_fw,
│ hwdef=args.hwdef,
│ default_params_filepath=args.params)
└──> run
└──> process_file
└──> process_line
├──> get_config
├──> build_peripheral_list
├──> write_all_lines
├──> write_hwdef_header
├──> write_ldscript
├──> romfs_add_dir
├──> romfs_add_dir
├──> write_ROMFS
├──> copy_common_linkerscript
├──> <not args.bootloader> write_processed_defaults_file
└──> write_env_py
重要且唯一类ChibiOSHWDef
,重点函数方法:
- process_file
- process_line
- get_config
- build_peripheral_list
- write_all_lines
- write_hwdef_header
- write_ldscript
- romfs_add_dir
- romfs_add_dir
- write_ROMFS
- copy_common_linkerscript
- write_processed_defaults_file
4. 总结
到这里,重点看下chibios相关脚本文件,这些与MCU规格息息相关。
$ pwd
[略...]/ardupilot/libraries/AP_HAL_ChibiOS/hwdef/scripts
$ ls
addfunc_parse.py CKS32F407xx.py defaults_periph.h STM32F103xB.py STM32F412Rx.py STM32F767xx.py STM32G491xx.py STM32H757xx.py
af_parse_cubemx.py convert_betaflight_unified.py dma_parse.py STM32F105xC.py STM32F427xx.py STM32F777xx.py STM32H730xx.py STM32L431xx.py
af_parse.py defaults_bootloader.h dma_resolver.py STM32F303xC.py STM32F469xx.py STM32G431xx.py STM32H743xx.py STM32L476xx.py
bdshot_encoder.py defaults_iofirmware.h dma_resolver.pyc STM32F405xx.py STM32F732xx.py STM32G441xx.py STM32H750xx.py STM32L496xx.py
chibios_hwdef.py defaults_normal.h STM32F100xB.py STM32F407xx.py STM32F745xx.py STM32G474xx.py STM32H755xx.py STM32L4R5xx.py
如果我们回顾下之前Andrew Tridgell在ArduPilot UnConference 2018会议上的PPT文件和视频。
如果需要移植ChibiOS到新的MCU上,必须考虑这部分内容的配套修改,通过tabula建立相应的MCU规格数据库。
Anyway, it’s a small step from porting chibios to ardupilot AT32.
5. 参考资料
【1】ArduPilot开源飞控系统之简单介绍
【2】ArduPilot之开源代码框架
【3】Ardupilot开源飞控之ChibiOS简介
更多推荐
已为社区贡献12条内容
所有评论(0)