Quadcopter Bootloader and Firmware Update

In the quadcopter, in order to facilitate the user to upgrade the firmware of the aircraft later, the Bootloader technology is generally used. The so-called Bootloader refers to a piece of code that runs first after the microcontroller is started. Its main function is to check whether the user wants to update the flight control firmware. If yes, enter the flight control firmware update process, if not, run the current flight control firmware directly. In addition, some Bootloaders also include some basic hardware detection functions. If the hardware detection fails, the flight control function will not be entered. Usually, the Bootloader is used in conjunction with the upper computer software of the aircraft.

The following is a further description of the Bootloader by taking Dr. Dot's small quadcopter as an example. In the PC software of Dr. Dot's small quadcopter, the firmware update function of the aircraft and the remote controller is provided. In this way, the user can directly update the firmware of the aircraft and the remote control through the host computer without the need for other MCU download tools. The small quadcopter of Dr. Dot provides the firmware source code of the aircraft and the remote controller. When users recompile and update these firmware, they need to pay attention to the following issues:

1. The firmware update of the host computer of Dr. Dot’s quadcopter only supports data files with the suffix bin, so the user should convert other formats of firmware (such as hex) into bin format files. For the keil compiler, the software already comes with this function, and the user only needs to set it according to the following figure.

bootloader_bin

Since Keil generates firmware with the suffix axf by default, the fromelf command means to convert axf firmware to bin firmware. It is of the form: fromelf.exe -bin -o destination path source path.

2. At the same time, we need to set the starting address of the program so that these recompiled firmware can work with the Bootloader. The following figure is the setting interface of the starting address of the Keil software setting program:

bootloader_size

For the small four-axis remote control of Dr. Dot, because the STM32F103C8 chip is used, its ROM capacity is 64K, and its RAM capacity is 20K, so the ROM size converted into hexadecimal is 0x10000, and the RAM size converted into 16-input The system is 0x5000. Since the program start address of the STM32 is 0x8000000, and then the Bootloader occupies the space of 0x8000, the start of the ROM is set to 0x8008000, while the start address of the RAM remains at 0x20000000.

For the small quadcopter of Dr. Dot, since it uses the STM32F103RC chip, its ROM capacity is 256K, and its RAM capacity is 48K, so the ROM size converted into hexadecimal is 0x40000, and the RAM size converted into hexadecimal It is 0xC000. Similarly, since the program start address of STM32 is 0x8000000, and then the Bootloader occupies 0x8000 space, the start of ROM is set to 0x8008000, while the start address of RAM remains at 0x20000000.

3. In the previous step, we modified the program start address on the compiler. We also need to make some modifications in the code to make the compiled firmware work normally. The small quadcopter of Dr. Dotpoint uses STM32 microcontroller, so it is necessary to add the following code at the start of the main function in the firmware source code, and align the start position of the program's interrupt vector with the start position of the code. The meaning of this code is to offset the starting address of the interrupt vector of the STM32 microcontroller from the position of 0x8000000 back by 0x8000 to 0x8008000.

NVIC_SetVectorTable(NVIC_VectTab_FLASH,(u32)0x8000);

After these three steps, the code written by the user can be downloaded to the aircraft and the remote control through the PC of Dr. Dot's small quadcopter and used normally.

 

This article is from Dr. Dot Drone www.bspilot.com

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324796780&siteId=291194637