Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of STM32 remote firmware update

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail what is the method of STM32 remote firmware update, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

There are often projects that require remote firmware updates through serial port, GPRS, 4G, and so on. The following is the method of STM32 remote firmware update.

IAP is the acronym of In Application Programming. IAP is the user's own program that burns some areas of User Flash in the process of running, so that the firmware programs in the product can be easily updated and upgraded through the reserved communication port after the product is released.

Usually when the user needs to achieve the IAP function, that is, when the user program is running for its own update operation, two project codes need to be written when designing the firmware program. The first project program does not perform the normal functional operation, but only receives the program or data through some kind of communication pipeline (such as USB, USART), and performs the update to the second part code; the second project code is the real function code. These two parts of the project code are recorded in User Flash at the same time. When the chip is powered on, the first project code starts to run. It does the following:

1) check whether the second part of the code needs to be updated

2) if you do not need an update, go to 4)

3) perform update operation

4) Jump to the second part of code execution

The first part of the code must be burned through other means, such as JTAG or ISP; the second part of the code can be burned using the first part of the code IAP function, can also be burned with the first part of the code, later need to update the program is then updated through the first part of the IAP code.

For STM32, because its interrupt vector table is located in the lowest address area of the program memory, in order for the first part of the code to respond correctly to the interrupt, it is usually arranged for the first part of the code to be in the starting area of the Flash, followed by the second part of the code.

When the second part of the code starts to execute, you first need to map CPU's interrupt vector table to your own vector table, and then perform other operations.

If the IAP program is destroyed, the product must return to the factory to rewrite the program, which is troublesome and time-consuming and money-consuming. In response to this demand, STM32 automatically sets write protection for the first four pages of the user's Flash area while implementing read protection for the Flash area, which can effectively ensure that the IAP program (the first part of the code) area will not be accidentally destroyed.

The following focuses on these two programming points.

BootLoader program

The keil software program store is normally set up as follows

The IAP program mainly does jump, and the main loop is as follows

# define IOT_APP_Addr 0x8010000

Int main (void)

{

IO_config ()

Usart_config ()

Delay_ms (1000)

Spi_Init ()

Iap_load_app (IOT_APP_Addr)

While (1)

{

}

}

The jump function is as follows, where 0x8010000 is the starting address of the application.

Void iap_load_app (U32 appxaddr)

{

If ((appxaddr&0x8FC0000) = = 0x8000000)

{

Jump2app= (iapfun) * (vu32*) (appxaddr+4)

MSR_MSP (* (vu32*) appxaddr)

Jump2app ()

}

}

The user application program should set the starting address of the program, which should be the same as the starting address in the IAP program, as shown in the following figure

The address offset of the interrupt vector table should be set in the program.

Int main (void)

{

NVIC_SetVectorTable (NVIC_VectTab_FLASH,0x10000)

......

When burning the program, you can first burn the BootLoader program, and then burn the user application program to realize the firmware upgrade of the program.

What is the method of STM32 remote firmware update is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report