Stm32 IAP programming and user programming

Stm32 IAP programming and user programming

  (2016-03-02 23:55:09)

label: 

stm32

 

bootloader

 

iap

 

userapplication

 

Firmware upgrade

Category:  Technical Documents

Stm32f10x series MCU Bootloader process

Chip: stm32f103ze

Required software: SecureCRT (used to send Application files using the Ymode protocol). In fact, we should write a host computer by ourselves. Here we use SecureCRT to act as our own application (used to verify the success of the Bootloader).

Keil version: μVision V5.11.0.0

Purpose: Use the communication interface for software update (avoid the tedious process of dismantling the machine).

BootLoader actually looks quite complicated, but it’s okay~ Look up the information on the Internet carefully.

There are a lot of introductions, the following is the process of making a bootloader for yourself and the matters you should pay attention to, to help

Everyone don't take detours~

Please download the resources I uploaded first: 

http://download.csdn.net/detail/jimoxiaosage/9451290

First of all, make sure to make a serial port to update the firmware program~, I heard that the name is Bootloader, and there are a lot of information on the Internet. I searched for the information on the Internet and looked at the basic process:

Write the Bootloader program at the start position of the program (0x0800 0000), and write the application program at another offset position (such as 0x0800 3000, then the program space of the bootloader can only be limited to 0x3000 size, if it exceeds, it won't work). In the Bootloader program, it is judged whether to update by detecting the flag bit (button press, or data in Flash, etc.). (The update here refers to updating the user application area, that is, the flash data after 0x0800 3000) Through the serial port, use the Ymodem protocol to burn the image to be updated --xxx.bin into the Flash. After the programming is completed, the program jumps to Application (0x0800 3000), firmware update is complete.

 

BootLoader project Stm32 official website has, of course, you can also use mine (with simple modifications):

Points to note in this project:

1. User program starting address: #define ApplicationAddress 0x8003000. (This address needs to be the same as the start address of another project-user application, see later for details).

2. Need to configure the erase position during programming, as shown in the figure:

 

Stm32 <wbr>IAP programming and user programming
 

 

3. The default program address is 0x8000 0000, and the size needs to be modified to 0x3000, as shown below:

 

Stm32 <wbr>IAP programming and user programming
 

 

4. Pay attention to whether the serial port is available, the project's serial port pins PA9, PA10, pay special attention to whether the clock is configured correctly (main frequency 72M), otherwise garbled characters will appear~~~.

5. With the program flowchart that I modified, the button is PA0,

Stm32 <wbr>IAP programming and user programming
 

//----------------------------------- The above BootLoader is ready-------- ---------------------------

Next, you need to write an application to verify the BootLoader~~

The following is the place to pay attention to my project:

1. Modify the keil configuration, modify the starting address to 0x0800 3000, and set the size according to your own flash size, as shown in the figure:

Stm32 <wbr>IAP programming and user programming
 

 

2. The Flash area to be erased should also be checked (otherwise the Bootloader originally written in will be erased during debugging~) as shown in the figure:

 

Stm32 <wbr>IAP programming and user programming
 

 

 

3. Since we changed the start address of the program to 0x0800 3000, it still runs from 0x0800 0000 when resetting~ So add at the top of the main function: NVIC_SetVectorTable(NVIC_VectTab_FLASH,0x3000); At the same time, you need to modify the following definitions Value:

#define VECT_TAB_OFFSET                  0x3000

The changed value was originally 0, and it was changed to offset.

4. Use the fromelf that comes with keil to output the ***.bin file~, this part of the Internet finds a lot of them can not be used, it may be related to the keil software version, detailed questions or check the keil help document will be clearer, the following Paste my settings:

Stm32 <wbr>IAP programming and user programming
 

 

fromelf --bin --output=1s.bin ..\OutPut\Stm32f103Templete.axf

, So that a file of 1s.bin will appear after compiling~

Take a simple look at my main function~actually it is a flashing light program~ (you can modify the time to 500ms, and then generate a 500ms.bin file to verify our Bootloader)

//-------------------------------- The above is the user application part ---------- --------------------

After the above steps, we will have:

1.Stm3210xIAP   (Bootloader)

2.Stm3210xIapApplication (user application)

3.1s.bin   500ms.bin

4.SecureCRT software

First compile the project of 1 and burn it into the chip~, then compile and burn the project of 2 into the chip~ At this time, if PA2 is connected to an LED light, you will see the lights flashing alternately.

Then open the SecureCRT software, set the corresponding baud rate, and open the serial port~,

Then PA0 is connected to the ground (simulating a button press) and then the development board is powered on. At this time, it will enter the firmware upgrade and print the relevant information. At this time, the chip waits for the Ymodem protocol to send the file, use the secureCRT software, send Ymodem, select us The file that needs to be updated is such as: 1s.bin. After the programming is completed, the LED lights will flash alternately every 1s.

You can repeat the above process and try to write the 500ms.bin file~.

 

The whole process above ends.

share it:

Guess you like

Origin blog.csdn.net/geggegeda/article/details/109173861