User Tools

Site Tools


manual:ports:armcm0_stm32

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
manual:ports:armcm0_stm32 [2016/04/29 16:23]
voorburg
manual:ports:armcm0_stm32 [2022/11/07 11:27] (current)
voorburg [Checksum location]
Line 1: Line 1:
 +====== ARM Cortex-M0 for STM32F0xx ======
 +
 ===== Bootloader size ===== ===== Bootloader size =====
  
 Due to the presence of the bootloader in the on-chip flash memory, the start address of the user program needs to be adjusted so make sure both programs do not overlap. Additionally,​ the bootloader'​s flash driver needs to be properly configured to prevent accidental erasure of the bootloader during firmware updates. Due to the presence of the bootloader in the on-chip flash memory, the start address of the user program needs to be adjusted so make sure both programs do not overlap. Additionally,​ the bootloader'​s flash driver needs to be properly configured to prevent accidental erasure of the bootloader during firmware updates.
  
-To reserve flash memory for the bootloader and protect it from being erased and/or reprogrammed,​ comment out lines in table flashLayout[] in source-file flash.c. Refer to the demo bootloader program for an example.+To reserve flash memory for the bootloader and protect it from being erased and/or reprogrammed ​during firmware updates, comment out lines in table flashLayout[] in source-file ​**flash.c**. Refer to the demo bootloader program for an example.
  
 {{:​manual:​ports:​stm32_cm0_flash_layout.png?​|}} {{:​manual:​ports:​stm32_cm0_flash_layout.png?​|}}
  
 +
 +Adjusting the start address of the user program in flash to make sure it doesn'​t overlap with the bootloader, is achieved by changing the program'​s ROM start address in the linker descriptor file. Set it to the start address as present in the first line in table flashLayout[] that is not commented out. In the previous example, this is 0x08002000:
  
 {{:​manual:​ports:​stm32_cm0_rom_reservation.png?​|}} {{:​manual:​ports:​stm32_cm0_rom_reservation.png?​|}}
  
-For typical HCS12 bootloader ​the flash memory from 0xe800 ​to 0xfff (6 kbyte) ​is reservedThe linker descriptor file of the user program ​should ​be modified ​to make sure no code or data is placed ​in this memory ​region ​by the linker:+ 
 +===== Vector table RAM reservation ===== 
 +The ARM Cortex-M0 always uses the interrupt vector table that is mapped to memory address 0x00000000. After microcontroller reset, ​the on-chip ​flash is remapped ​to also appear at address 0x00000000 in the memory map. This is where the bootloader'​s vector table is located 
 + 
 +When the user program ​runs, the user program'​s vector table must be used. This means that somehow the user program'​s vector table must be remapped ​to appear at address 0x00000000 ​in the memory map. The only possible way to achieve ​this on the ARM Cortex-M0, is by copying the 192 bytes long vector table of the user program to the start of RAM and then remapping the RAM to also appear at address 0x00000000 in the memory ​map.  
 + 
 +This procedure is automatically performed ​by the bootloader, right before it starts the user program. The only requirement for the user program is that it does not use the first 192 bytes of RAM. This can be achieved by editing ​the linker ​descriptor file and changing the RAM start address from 0x20000000 to 0x200000C0. Refer to the demo user program for an example. 
 + 
 +{{:manual:​ports:​stm32_cm0_ram_reservation.png?​|}} 
 + 
  
  
Line 18: Line 32:
 A 32-bit checksum value is programmed by the bootloader at the end of a programming session. Upon startup, the bootloader verifies the correctness of this checksum to determine if a valid user program is present and can be started. A 32-bit checksum value is programmed by the bootloader at the end of a programming session. Upon startup, the bootloader verifies the correctness of this checksum to determine if a valid user program is present and can be started.
  
-The user program must reserve space for this 32-bit checksum value. The bootloader programs this value at the end of the interrupt vector table. To reserve this space, simply enter one extra dummy entry into the interrupt vector table. This reserves space for the checksum at memory address ​0x080020C0 (0xC0 + flash reserved for bootloader ​ + flash base address). Refer to the demo program for an example.+The bootloader programs this value at the end of the user program'​s vector table. Its exact location is configured by macro BOOT_FLASH_VECTOR_TABLE_CS_OFFSET in flash.c. The vector table size can vary based on the microcontroller derivative you are using. Please verify that the default value of BOOT_FLASH_VECTOR_TABLE_CS_OFFSET is correct. If not, you can simply override the value by adding the macro with the correct value to the blt_conf.h configuration header file. 
 + 
 +The user program must reserve space for this 32-bit checksum value. To reserve this space, simply enter one extra dummy entry into the interrupt vector table. This reserves space for the checksum at memory address: flash base address ​+ flash reserved for bootloader ​ + FLASH_VECTOR_TABLE_CS_OFFSET. Refer to the demo program for an example.
  
 {{:​manual:​ports:​stm32_cm0_checksum_reservation.png?​|}} {{:​manual:​ports:​stm32_cm0_checksum_reservation.png?​|}}
manual/ports/armcm0_stm32.1461939793.txt.gz · Last modified: 2019/09/24 22:14 (external edit)