I used to hear that boot upgrades OS, OS upgrades boot, and feels very advanced. It is actually very easy to make a discovery.
Boot is a piece of startup code. The chip has a default boot address. Download boot to the default boot address, and boot will be started by default. If there is a jump command in Boot, it will jump to the OS startup system.
Introduction to the Boot Code
# Define app_start_addr0x1c010000ulint main () {// some configurations are required for system initialization, such as USB port for serial port reception; // jump to SCB-> vtor = app_start_addr here; // The address to jump to exceuteapplication (); // Assembly command to achieve the jump }__ ASM void exceuteapplication (void) {/* load main Stack pointer with Application Stack pointer initial value, stored at first location of application area */LDR r0, = 0x1c01_ldr r0, [R0] mov sp, R0/* load program counter with application Reset vector address, located at second word of application area. */LDR r0, = 0x1c010004ldr r0, [R0] BX R0}
Boot is downloaded to the default boot address of the system (because it is stored in flash, data will be stored forever, so the boot starts from boot every time ).
Then, download the OS. There are two methods
First, the OS file is received in boot, and then written to the address to jump to app_start_addr. After writing, the system jumps.
Second, configure Keil to directly download to app_start_addr, which is mainly used in the R & D stage for convenient debugging and download.
Key configurations of Keil download
1. The start address of Keil irom1 start is app_start_addr.
2. Modify the start address of a distributed file
LR_IROM1 0x1C010000 0x00400000 { ; load region size_region ER_IROM1 0x1C010000 0x00400000 { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) } RW_IRAM1 0x10080000 0x0000A000 { ; RW data .ANY (+RW +ZI) }}
Now, you can download the OS to app_start_addr through Keil,
Add the interrupt offset SCB-> vtor = 0x1c010000 & 0x3fffff80 in the OS;
Here, the OS upgrade boot has been completed.
The operating system upgrades boot in the same way. The OS receives the boot file through the serial port USB, and then writes it to the default CPU startup address, so that the boot will be replaced. Of course, some knowledge about flash erasure algorithms is involved here.