I used a picture to understand the virtual serial port IAP

  在项目的开发与应用中,尤其是一个设计好的硬件都具备了在线升级功能。所以学习在线升级功能相关知识应该是一个必备的知识

1. Communication method

The so-called online upgrade is to write the program only once, upgrade the program or change the version or change the program through a certain communication method. A certain communication method can be the communication method possessed by any one-chip computer, which can be a serial port, usb, iic, network port, wifi, etc.
Next is to upgrade the firmware through the USB virtual serial port. The serial port upgrade can be found on the Internet, but upgrading through the serial port will add a peripheral to your board, which takes up a lot of space, not to mention the transmission speed is limited. Therefore, it is recommended to use other communication methods. Of course, this is a one-stop solution. If you master one method, the other will be skilled.

2. Basic concepts

First put forward a concept, online upgrade is actually two procedures. One program is a bootloader program, and the other program is an app program. The first thing to burn into the board is the bootloader program, which is the program we use to perform the upgrade operation. The APP program is the actual application program, and it is up to him to implement specific functions.

3. Upgrade process

Online upgrade process
1) The execution of the program starts from the address we set. As shown in the above figure, this program starts from 0x08000000. After power on, it starts from the top address of the FLASH stack +4, which is the interrupt vector table. Reset the interrupt first Vector table.
2) After the reset operation is completed, the program jumps to the main function for execution, and then the upgrade program in the main function is executed. The main function first determines whether to perform the upgrade operation. The method (virtual serial port) sends the bin file generated by the program to the microcontroller, and if it is not executed, it directly enters the original app program.
3) The MCU receives the bin file into the buffer, and then moves from the buffer to the flash specified address, executes the command to jump to the APP program, and then jumps to the start address of the app program we set. Then reset the interrupt vector table of the app program, and jump to the main function of the app program after the reset. update completed

4. Summary

The final summary is:
1. Reset the bootloader interrupt vector table
2. Execute the main function of the bootloader
3. Send and receive
the bin file 4. Write the bin file to the FLASH designated area
5. Jump the execution program
6. Jump after the jump Reset APP's interrupt vector table
7. Execute APP's main function
This is a complete online upgrade process. The next few details about the upgrade procedure will be mentioned in a later article.

Published 3 original articles · Likes2 · Visits 117

Guess you like

Origin blog.csdn.net/cs111211/article/details/105142049