STM32 learning record 18 IAP (1)

Publisher:SparkleMagicLatest update time:2016-08-28 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The project requires the development of a handheld device to upgrade the product software. Current products all use STM32, so it is very convenient to use the IAP function of STM32 to upgrade the software online.

The overall requirement is that the host Master sends data to the slave Slave through the CAN interface. After receiving the application APP, the slave overwrites the original application area with the received data, thereby realizing the online upgrade of the Master to the Slave.

 

Here we first introduce IAP, and have an understanding of the overall implementation of IAP, which is convenient for subsequent development. The Atomic STM32 development board is used as a reference to introduce the IAP function.

 

To implement IAP, two project codes are required. The first is called the Bootloader program, and the second is called the APP program. The Bootloader is responsible for guiding the APP program to start, and when the APP needs to be updated online, it receives the APP file sent by the host and overwrites the original APP with the received APP.

For the specific content of IAP, please refer to Chapter 53 of the Development Guide of the Atomic STM32 Development Board.

The following is an experiment I conducted after I had a general understanding of IAP. 1. Write a bootloader program test program to boot the APP in the specified location. 2. Modify an original application so that it can be booted with the bootloader. 3. Download the bootloader and APP separately through the jlink downloader.

 

1. Bootloader program.

The main code is as follows. After the running lights, execute the command to jump to the APP area

 

[cpp]  view plain copy
 
  1. int main(void)  
  2. {     
  3.     delay_init();  
  4.     LED_Init();  
  5.   
  6.     LED1 = 0;  
  7.     delay_ms(200); //delay  
  8.     LED2 = 0;  
  9.     delay_ms(200); //delay  
  10.     LED3 = 0;  
  11.     delay_ms(200); //delay  
  12.     LED4 = 0;  
  13.     delay_ms(200); //delay  
  14.       
  15.     LED1 = 1;          
  16.     delay_ms(200); //delay  
  17.     LED2 = 1;  
  18.     delay_ms(200); //delay  
  19.     LED3 = 1;  
  20.     delay_ms(200); //delay  
  21.     LED4 = 1;  
  22.     delay_ms(200); //delay      
  23.   
  24.     iap_load_app(FLASH_APP1_ADDR); //Execute FLASH APP code  
  25. }  
[cpp]  view plain copy
 
  1. #define FLASH_APP1_ADDR 0x08003C00 //The first application start address (stored in FLASH)  
  2.                      //Reserve the first 15K of space as the bootloader area  
The starting address of FLASH is 0x0800 0000, so 0x0800 0000~0x0800 3C00 is used to store Bootloader.

2. APP program area.

 

 

Complete the relocation of the interrupt vector table. Project configuration download location

 

[cpp]  view plain copy
 
  1. int main(void)  
  2. {  
  3.   SCB->VTOR = FLASH_BASE | 0x3C00;  
  4.   /* Infinite loop */  
  5.   while (1)  
  6.   {  
  7.     OSInit();  
  8.     OSTaskCreate(Start_Task,   
  9.                 (void*)0,   
  10.                 &Start_Task_Stk[START_TASK_STK_SIZE-1],   
  11.                  START_TASK_PRIO);  
  12.       
  13.     OSStart();  
  14.     return 0;  
  15.   }  
  16. }  
In the main function, add SCB->VTOR = FLASH_BASE | 0x3C00 at the beginning; the 0x3C00 here is the Bootloader area set in the bootloader.

 

 

The address of jlink download is configured to start at 0x0800 3C00. This way the bootloader area will not be erased during downloading.

 

Finally, download the bootloader and APP projects separately under Keil. You can see that at the end of the bootloader running light, the APP program is started.

Keywords:STM32 Reference address:STM32 learning record 18 IAP (1)

Previous article:STM32 learning record 19 timer trigger ADC
Next article:STM32 learning record 17 serial port one-click download

Recommended ReadingLatest update time:2024-11-16 13:50

Entering and waking up Stm32 standby mode
1. Basic Introduction 1-1: The "low power mode" of the microcontroller is like the standby mode of a mobile phone. It is different from the normal operating mode and is in a state of saving power and resources. 1-2: In operation, HCLK provides the clock for the CPU, and the cortex-m3 core executes the program code.
[Microcontroller]
Entering and waking up Stm32 standby mode
STM32-Library Development-Address Mapping
1. stm32 has AHB, APB2, and APB1 buses.    The APB2 peripheral address space is from 0x40010000 to 0x40013FFF. The first address is called the base address. 2. The port configuration register in the reference manual has an address offset of 0x04, so the address of GPIOC_CRH is GPIOC_BASE+0x04   GPIO_TypeDef structur
[Microcontroller]
STM32 internal FLASH operation summary
The FLASH of stm32 is divided into three parts: main storage block, information block and flash memory interface register. The main memory block is used to store specific program code and user data. The starting address is 0x08000000, b0 and b1 are connected to GND and the program starts here. The information bloc
[Microcontroller]
Reading and writing of EEPROM inside STM32 microcontroller
The STM32L series MCU provides an EEPROM storage area, but in fact, its FLASH is also an EEPROM type, but there is an area that is opened up for EEPROM operation. The STM32L EEPROM service life is designed to be more than 100,000 erase and write times, and the capacity is 2K-4K, which is ideal for parameter storage of
[Microcontroller]
STM32 IO configuration lighting
1. Specific code of led.c: /*----------------------------------------------------------*/ #include "led.h"   /* ------------------------------------------------------------------------- File name: led.c Description: Configure the LED port according to the hardware connection and open the corresponding register ----
[Microcontroller]
STM32 simple data transmission method and communication protocol (suitable for serial port and general bus)
introduction In the general project development process, two or more microcontrollers are often required to communicate to complete data transmission. For example, a quadcopter wirelessly transmits data back to the ground station during flight, therapeutic equipment needs to transmit the patient and machine operation
[Microcontroller]
STM32 precise delay (non-interrupt, non-ST library function)
     The day before yesterday, I learned about STM's Systick and found it quite useful for precise timing. When I used CVAVR before, I found that the delay.h in it was very useful. So, I used STM32's SysTick to make an accurate delay header function.      SysTick configuration is in void delay_init(u8 SYSCLK); the p
[Microcontroller]
Implementation of STM32+IAP solution under IAR environment
1. What is IAP and why do we need IAP?       IAP stands for In Application Programming. Generally, the devices with STM32F10x series chips as the main controller have already used J-Link emulator to burn the application code before leaving the factory. If the application code needs to be replaced or upgraded during th
[Microcontroller]
Implementation of STM32+IAP solution under IAR environment
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号