The so-called IAP is actually equivalent to a small bootloader used to update the program.
Many products are basically programmed once on the production line, but BUGs are sometimes unavoidable. There are often painful experiences where the product has to be removed from the shell and the board and put back on the programming rack for programming after it is installed. Therefore, IAP is very necessary in this case. As long as there is an external interface, it can be updated online. The commonly used one is the USB port. Of course, if you must use the serial port, it is also possible, but the hardware is a little more troublesome. The following is the routine program
typedef void (*pFunction)(void);
pFunction Jump_To_Application;
unsigned long JumpAddress;
if(!Check_Whether_Enter_UpdateMode()) //This function is custom and determines whether to enter the bootloader or the APP application by judging the key
{
if (((*(__IO uint32_t*)FLASH_START_ADDR_NORMAL_FIRMWARE) & 0x2FFE0000 ) == 0x20000000) // Check the top of the stack pointer
{
/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (FLASH_START_ADDR_NORMAL_FIRMWARE + 4); //Get the RESET address of APP
Jump_To_Application = (pFunction) JumpAddress; // pass the address to the function pointer
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) FLASH_START_ADDR_NORMAL_FIRMWARE); //Set the top of the stack pointer
Jump_To_Application(); // Jump into APP
}
}
FLASH_START_ADDR_NORMAL_FIRMWARE is the starting address of the APP
This is the basic idea of IAP. If you don't enter the APP, enter IAP to update the code. Add USB processing in IAP. At this point, the IAP program is basically completed (but the related processing of USB protocol is still a bit troublesome and difficult,
You have to understand it before you can start, otherwise it’s easy to get confused. I often get confused myself...)
In fact, many people have written similar blogs about IAP. The reason why I write it here is that there is something that is easy to overlook. I encountered it myself. Maybe I am careless and others have reminded me but I didn’t notice it, or maybe it’s because of the article I read.
Not enough, I'm being long-winded again... Oh, let's get to the point
The APP address of the above example is set to 0x08003000; the program base address of the APP project should also be set to 0x08003000 and the FLASH SIZE should also be subtracted by 0x3000 accordingly.
There is one more thing to note here. We all know that in general, after STM32 is reset, it starts fetching instructions from 0x08000000, and the interrupt vector starts from 0x08000004. The first one is the RESET vector. The interrupt vector of the APP project cannot be like this. The vector address of the APP should start from 0x08003000. This is easy to be overlooked, but it may be my own stupid problem. Maybe most people understand it, but I am still in the dark. As shown in the following figure
Previous article:STM32 interrupt usage
Next article:The relationship between multiplexing and re-imaging of STM32 pins
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- GD32F350 is easy to use
- Industrial and Automation Solutions Collection
- Award-winning live broadcast | Use ModusToolbox to build a system to flexibly meet IoT design challenges
- Verilog009
- 5G is a revolutionary advancement in mobile communications
- 【GD32E503 Review】 ADC Experiment
- How to achieve ZigBee fast networking?
- Using LTC2380 as a data acquisition card, the data jumps greatly
- EEWORLD University Hall ---- Low-speed ADC Hardware Trio
- Three failure modes of high-voltage connectors for new energy vehicles