您的位置:首页 > 其它

crazyflie2_nrf51822程序分析--总体结构

2015-08-27 17:56 148 查看
为了尊重原始版本,将英文原文贴出来,同时将一些需要注意的地方加上我的注释

Source code of the firmware running in the Crazyflie 2.0 nRF51822. This microcontroller have a couple of roles:
Power management (ON/OFF logic and battery handling),功耗管理,打开/关闭stm32
Radio communication 无线通信
Enhanced Shockburst compatible with Crazyradio (PA) --- ESB
Bluetooth low energy using the Nordic Semiconductor S110 stack --- BLE也就是蓝牙

One-wire memory access 同时支持一线存储器访问,美信官方又看到类似DS18B20一总线的存储器芯片,这里扩展板会用到

Compiling with bluetooth support requires the nRF51_SDK and S110 packages.

官方的虚拟机中没有下载nRF51_SDK和蓝牙协议包S110,所以需要用下面的sh文件下载
./tools/build/download_deps.sh


will download the zips and unpack them. If you want to download manually from the Nordic semiconductor website, you will find the details in nrf51_sdk/readme and s110/readme.


Compiling

To compile arm-none-eabi- tools from https://launchpad.net/gcc-arm-embedded should be in the path.

Compilation options can be saved in config.mk. Main targets:

下载可以用make factory_reset,直接会将mbs, bootloader,S110和firmware全部下载进去
make                 # Make with BLE support
make BLE=0           # Make without BLE support
make BLE=0 S110=0    # Make without BLE and without Softdevice in flash (see bellow)

make flash           # Flash firmware with jtag
make factory_reset   # Erase device and flash softdevice, bootloaders, and firmware


Architecture

下面是重点,256K的flash,crazyflie2竟然分成了这么多块,好累!

When running without softdevice (S110=0) the firmware is loaded at the beginning of the flash and is running alone in the CPU.

When running with Softdevive (S110=1) independent of if BLE is activated or not, the flash is filled as follow:
+--------------+ 256k
|     MBS      |    Write protected
+--------------+ 252k
|  Bootloader  |
+--------------+ 232k
|              |
|              |
|              |
|              |
|              |
|  Firmware    |
+--------------+ 88K
|              |
|              |
|              |
|              |
|              |
|              |
|  Softdevice  |
+--------------+ 4K
|     MBR      |    Write protected
+--------------+ 0

MBR Softdevice Master Boot Record.  这个不用管
SoftDevice S110 Bluetooth stack  这个code看不到,用官方的hex文件就可以了,还有s120,s130等等
Firmware This firmware  飞行的时候用到的程序
Bootloader Bluetooth/Shockburst bootloader  下载Firmware用到的固件程序,通过长按按键可以进入bootloader
MBS Master Boot Switch  这个应该是可以更新bootloader

Boot sequence:(还好有这个上电之后程序走的顺序,要不然就搞蒙了)
MBR ----> MBS ----> Bootloader ----> Firmware


The MBR is part of the Softdevice. It boots the CPU and jump to MBS. The MBR contains methods to start the Softdevice and can flash softdevice and bootloader.

The MBS handles the ON/OFF button and comunicate the duration of the press to the bootloader so that the bootloader knows what to boot. The reason for the MBS is to allow updating the bootloader over the air while still having a write-protected piece of software
that can start the STM32 in USB DFU mode for recovery (the STM32 has access to the NRF51 SWD programming port). The boot switch is as follow:

按键按住时间的长短不同会进入不同的程序,同时可以观察Blue LED,注意是nrf51822这边的LED,不是STM32的
Press timeBlue LED stateProgram booted
ShortStillFirmware
Long (>3s)Slow blinkBootloader
Very long (>5s)Fast blinkStays in MBS and power STM32 in USB DFU mode
The bootloader, if selected, starts the STM32 in bootloader mode and initialize both BLE and Shockburst (ESB) radio. It can flash everything but MBR and MBS. It also acts as a bridge to the STM32 bootloader.

If not selected, the bootloader jumps to the firmware.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: