Luftboot 讲解【不断更新】

/*

作者简介:

南京惊鸣航空科技有限公司创始人

先后于2010年,2013年获得南京航空航天大学学士学位、硕士学位,

现于东南大学毫米波国家重点实验室攻读博士学位。

发表SCI期刊论文多篇;获得校级奖学金两次,国家奖学金两次;

江苏省科研创新基金、东南大学优秀博士论文基金获得者。

学术主页:https://scholar.google.com/citations?user=zUngf3oAAAAJ&hl=zh-CN

淘宝店铺主页:http://shop115844451.taobao.com/

文档版本:1.1

修改记录:1.1 添加启动顺序描述

如需进一步交流请加QQ群:34528825

*/

 


阅读官方的解释:


Luftboot

This software is part of the Paparazzi UAV Project.

Luftboot is the bootloader for stm32 based autopilots to enable upgrading the autopilotfirmwareusing usb. It implements thedfu standard.

 

讲解:Luftboot实质是针对PPZ硬件STM32设计的bootloader,bootloader指的是引导程序,该程序负责在硬件上电后初始化CPU等硬件设备,再将OS(操作系统)镜像或者固化的APP(应用程序)加载到内存中,然后跳转到OS/APP所在空间,执行之

具体来说,PPZ对应的是把什么“加载到内存中呢”?——称为“firmware”的APP。(简单插一句,firmware严格来讲是介于“软件”和“硬件”之间的概念,大陆称为“固件”,湾湾称为“韧件”)。

那么,把PPZ代码下载后,对应firmware在哪?——在sw目录下的一个叫airborne的目录里面。根据配置方式不同,会选择性编译出fixwing(固定翼)或者rotocraft(旋翼)的firmware出来。

 

小结概念

bootloader=luftboot

APP=firmware=airborne

 

这里特别强调了USB更新firmware又是怎么回事?bootloader可以选择更新或者不更新firmware:1.如果不更新,则从某个存储器内将firmware加载运行,这种模式被称为“自启动”;2.如果更新,则通过USB从主机(Ubuntu)下载,这种模式被称为“交互启动”。

Luftboot在更新firmware时候所用的标准的是DFU,DFU全称Device Firmware Upgrade,PPZ使用了一个叫dfu-util的开源工具。

Building

Call 'make' inside the src directory.

Luftboot needs libopencm3 and an appropriate arm-none-eabi gcc cross compiler. If you don't have these in your PATH, specify them with e.g.

make LIBOPENCM3=path/to/libopencm3 PREFIX=path/to/bin/arm-none-eabi

By default, Luftboot uses a 12MHz external clock to PLL it to 72MHz. If no external clock is available, or for any other reason, one can build Luftboot to use the 8MHz internal RC oscillator to PLL it to 48MHz. Call make as follows from inside ./src:

make LUFTBOOT_USE_48MHZ_INTERNAL_OSC=1

讲解:Luftboot源代码位置在paparazzi\sw\ext\luftboot\文件夹,核心是luftboot.c代码,五百多行。使用了第三方的库LIBOPENCM3(http://www.libopencm3.org/wiki/Main_Page),第三方代码若有更新,luftboot可能需要同步,否则会有bug,例如:http://lists.paparazziuav.org/Problem-with-luftboot-on-Lisa-M-2-1-td16468.html 所反应的问题:Failed to read device state! Assuming APP_IDLE

由于编译环境是PC,因此还需要一个交叉编译工具,即可生成能投在PPZ MCU能够执行的机器代码(ap.bin之类)。

Startup sequence

At bootup, Luftboot uses several criteria (in this order) to decide whether to jump to the payload or to initiate the bootloader:

  • On boot, if the payload is NOT valid, start the bootloader
  • If the flag is set indicating we just downloaded a payload, jump to payload
  • If the payload is forcing the bootloader (using GPIO state after core-only reset) start the bootloader
  • If the ADC2 pin on Lisa/M is grounded, jump to payload (i.e. "skip bootloader" jumper)
  • If voltage is present on the USB vbus, start the bootloader
  • Otherwise, jump to payload

此段文字将的是启动顺序,极具迷惑性。与官网的描述不一样,官网是这么说的:

 

 


已经前后矛盾了。实际上现有的luftboot版本不必关心这么多。简而言之,如果接了USB,则自动跳转到luftboot模式,下载/更新代码后如果不拔下USB,则可以停留在飞控程序执行过程里。如果拔掉了USB外接电源,则是执行飞控程序,不会停留在luftboot模式。


你可能感兴趣的:(Luftboot 讲解【不断更新】)