为了尊重原始版本,将英文原文贴出来,同时将一些需要注意的地方加上我的注释
Source code of the firmware running in the Crazyflie 2.0 nRF51822. This microcontroller have a couple of roles:
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.
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
下面是重点,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
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 time | Blue LED state | Program booted |
---|---|---|
Short | Still | Firmware |
Long (>3s) | Slow blink | Bootloader |
Very long (>5s) | Fast blink | Stays 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.