STM32 IAP implementation process

Publisher:InspiredDreamerLatest update time:2018-09-08 Source: eefocusKeywords:STM32  IAP  Process Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Concept

IAP: In-Application Programming, which is interpreted as "programming in the program" in Chinese. ICP (In-Circuit Programming) technology is to program the microcontroller through an online emulator, while ISP technology is a programming technology guided by the built-in bootloader program of the microcontroller.

2. Framework Design

Brief description: STM32's Flash 512Kb is divided into two parts, one 256Kb is used to store the minimum system, and the other 256Kb is used to store the APP code. The specific Flash size of the minimum system and APP can be adjusted according to the actual situation.

Difficulty analysis:

  1. Storage address of the minimum system and APP

    To find the storage address of the minimum system and APP, you need to understand the Flash storage space of STM32, as follows: 
    Flash

  2. Minimum system and APP jump

    After the system starts, it first enters the minimum system, which is determined by the hardware. After entering the minimum system, it determines whether the stack top pointer of the address burned by the APP system is correct to determine whether the APP is burned and start the APP. The official routine code is as follows:

/* Test if user code is programmed starting from address "ApplicationAddress" */

if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)

  /* Jump to user application */

  JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);

  Jump_To_Application = (pFunction) JumpAddress;

  /* Initialize user application's Stack Pointer */

  __set_MSP(*(__IO uint32_t*) ApplicationAddress);

  Jump_To_Application();

}


The above is the first method. There is also a second method: after writing the APP program into Flash, write the relevant information in Flash. The minimum system program continuously detects and reads the information. If the information is read, write a flag to SRAM and restart the MCU. The rest also uses the above code, but the judgment condition is changed to the flag in SRAM.

  1. Startup sequence 
    Regarding the startup sequence, there are more detailed instructions on the Internet

    No IAP 
    Write the picture description here

    Using IAP

    Write the picture description here

  2. Compilation of the minimum system and APP

    The compilation of the minimum system can be done directly according to the normal project compilation, while the compilation of the APP requires special processing: the settings in keil are as follows: 
    Write the picture description here
    The above is for the Flash address where the program is stored, and the interrupt vector table needs to be reset. You can use the function

    void NVIC_SetVectorTable(u32 NVIC_VectTab, u32 Offset); 
    Call this function in the APP main function to set the offset. The offset should be equal to the offset of the program Flash.


Keywords:STM32  IAP  Process Reference address:STM32 IAP implementation process

Previous article:Porting STemWin to FreeRTOS on STM32F103RCT6
Next article:STM32L152 external interrupt configuration

Recommended ReadingLatest update time:2024-11-16 11:37

STM32 interrupt control process
For STM32 (still taking Timer2 as an example), external interrupt channel position 28 (priority 35) is for external device TIME2, but TIME2 itself has many interrupt sources or events that can cause interrupts, such as update events (overflow/underflow), input capture, output match, DMA application, etc. All TIME2 int
[Microcontroller]
STM32 clock system
If you do not use an external crystal oscillator on the STM32, how to connect OSC_IN and OSC_OUT If you use the internal RC oscillator instead of an external crystal oscillator, please follow the steps below: 1) For products with 100 or 144 pins, OSC_IN should be grounded and OSC_OUT should be left floating.
[Microcontroller]
STM32 clock system
【stm32f407】stm32 serial port experiment
1. Serial port theory As an important external interface of MCU, the serial port is also an important debugging method for software development. Its importance is self-evident. Now almost all MCUs have serial ports, and STM32 is no exception. STM32F407VGT6 embeds four universal synchronous/asynchronous receivers (
[Microcontroller]
【stm32f407】stm32 serial port experiment
STM32 Series Part 3 --GPIO Initialization
Enable and initialize the IO port:     GPIO_InitTypeDef GPIO_InitStructure;     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);     GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;     GPIO_InitStructure.GPIO_Pin=GPIO_Pin_2;     GPIO_InitStructure.GPIO_Speed=
[Microcontroller]
stm32 independent watchdog IWDG
Independent Watchdog IWDG  The independent watchdog is simply a 12-bit down counter. When the counter decrements from a certain value to 0, the system will generate a reset. The independent watchdog is driven by a dedicated low-speed clock LSI, whose frequency is generally between 30-60KHz, and 40KHz is usually sele
[Microcontroller]
STM32 uses the official library to output garbled characters on the serial port
I recently learned STM32 development and applied for a free development board. I followed the content in the book and learned USART. I found that the serial port output was always garbled. Damn, I don’t understand why. The code and everything are all according to the book. Finally, after searching for a long time, I f
[Microcontroller]
stm32 BKP register operation [operation register + library function]
BKP is the abbreviation of "BACKUP". The stm32f103RCTE is equipped with 10 16-bit BKP registers. When the main power is cut off or the system generates a reset time, the BKP register can still maintain its content with the support of the backup power supply.  In practical applications, BKP can store important data to
[Microcontroller]
STM32 simulates SPI interface
When developing single-chip microcomputers, you often need to use an analog SPI interface. This writing method is good. There are many similar ones on the Internet, so I also used it.   #define MOSI_H GPIO_SetBits(GPIOB, GPIO_Pin_10) #define MOSI_L GPIO_ResetBits(GPIOB, GPIO_Pin_10) #define SCLK_H GPIO_SetBits(GPIOB
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号