Recently I want to do something that can be updated remotely, so I have to use bootloader to split flash into multiple regional programs.
The next step is to do the test to prove the feasibility. The stm32f103 discover board used in this test, the flash size is 512 K, enough for simple demo development.
Firstly:
Create two project files, each of which only provides one serial output for detection. (Printf ("test! \ N ");).
Second:
Set the flash burning address.
Project 1 starts from 0x0800000, sets the burning write size to 0x10000, and allocates 64 K memory as the bootloader area.
Project 2 follows project 1 from 0x08010000 and sets the size to 0x6ffff (the size after the bootloader area is subtracted) (the total size is 0x80000 ).
Third:
In Project 1, set the specified jump address. This is only a demo. In actual applications, the application should be stored in the off-chip memory (such as the SD card), and the bootloader should be read. the binfile is then burned and written into the program itself to achieve automatic updates. After the update is complete, the command is redirected (this demo directly skips the process of burning and writing the local machine ), after the jump is complete, run the application.
The redirection command on stm32 is:
(* (Void (*) (void) (* (vu32 *) (0x08010000 + 4) (); // (0x08010000 is the address to jump, as for why I want to add 4, I don't really understand it. The explanation is as follows: "What is saved here is the reset interrupt address of the interrupt vector table ").
Bootloader learning experience