Our Latest News

STM32 Code Remote Upgrade for IAP Programming

What is IAP

Sometimes projects require remote upgrading of microcontroller programs, when you need to get in touch with IAP programming.

IAP is In ApplicaTIon Programming, which is explained as programming in application, where the user’s own program burns some areas of User Flash during operation. That is, it is a kind of programming scheme for microcontroller Flash erasure.

Normally, a piece of STM32 microcontroller Flash has only one user program, while IAP programming is to divide the microcontroller Flash into at least two major areas, a part called bootloader area, a part called app user code area, and a part of the area can be left for code backup area.

This image has an empty alt attribute; its file name is image-415.png

Where IAP is used

Usually we burn the updated program to the STM32 microcontroller through SWD, J-link or use the serial port to download the program after setting the BOOT pin.

However, when the product is put into practical application, after the package is completed, in the later use process encounter some program bugs or according to customer needs to increase some functions, using the traditional code burning method may need to remove the package, and the use of IAP programming in the bootloader area in advance to write the interface with the external communication for upgrading the microcontroller code, so that we do not have to have completed the package to dismantle the product. This saves cost and makes it easier and faster to update the code without disassembling the completed package.

IAP programming process

IAP programming divides Flash into two areas, the bootloader area and the app user code area, which have very different functions. bootloader area mainly receives program files and writes the program to a specific location in the Flash area. Here, on the other hand, receiving external program files requires real-time communication with the outside.

STM32 MCU and external communication is mostly through its own serial port to receive and send data, but the STM32 MCU serial port can be external to a variety of communication interfaces, such as 422, 485, GPRS and ESP8266, etc.. In other words, we can connect Bluetooth module, WiFi module or other network modules through the serial port, and then we can realize remote file transfer to update the microcontroller program.

The app user code area is mainly to realize the function operation we need. In addition, the app user code area also needs to check the code operation in real time and determine whether the program needs to be upgraded by judging the update program flag bit. If it is necessary to update the program, then enter the bootloader area to update the code; if not, then continue to run the function code.

Therefore, the operation flow of the microcontroller under IAP programming is as follows.

c0cb0f48-6590-11ed-8abf-dac502259ad0.png

Based on the runtime flow, we can summarize a few simple points to note in the bootloader design process.

Concise, the program as concise as possible. In the case of limited microcontroller Flash, the smaller the bootloader code occupies the space of Flash, the more APP program code can be occupied to achieve more functional functions.

The flag bits are not affected by the reset.

Try not to use interrupts in the bootloader.

    GET A FREE QUOTE

    FPGA IC & FULL BOM LIST

    We'd love to

    hear from you

    Highlight multiple sections with this eye-catching call to action style.

      Contact Us

      Exhibition Bay South Squre, Fuhai Bao’an Shenzhen China

      • Sales@ebics.com
      • +86.755.27389663