User Tools

Site Tools


manual:ports:armcm3_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:armcm3_stm32 [2019/08/09 11:58]
voorburg
manual:ports:armcm3_stm32 [2022/11/07 11:27] (current)
voorburg [Checksum location]
Line 11: Line 11:
 Note that the space needed by the bootloader could be different than 0x2000 (8 kbyte), depending on the selected communication interface and compiler. The demo programs are working examples that you can refer to, to determine the exact vector table relocation. Note that the space needed by the bootloader could be different than 0x2000 (8 kbyte), depending on the selected communication interface and compiler. The demo programs are working examples that you can refer to, to determine the exact vector table relocation.
  
-Because ​the bootloader ​remaps ​the base address of the interrupt vector table, make sure that your program'​s initialization routine does not set it back to its original locationThis is the case if you use function SystemInit() from ST's driver library. To correct this you need to remove ​the following lines from function ​SystemInit():+Before ​the bootloader ​starts your firmware, it automatically reconfigured ​the start address of the interrupt vector table. ​Unfortunately, ​the default system initialization ​function SystemInit() from ST's driver library, overwrites this change. This function is implemented in source file system_stm32f1xx.c. To correct this you need to explicitly set the start address of the interrupt vector table as the first thing in function ​main(). Here is an example of how this can be done when using STM32CubeIDE:
  
-<​code>​+Add the following function to main.c:
  
-#ifdef VECT_TAB_SRAM+<code c> 
 +static void VectorBase_Config(void) 
 +
 +  /* The constant array with vectors of the vector table is declared externally in the 
 +   * c-startup code. 
 +   */ 
 +  extern const unsigned long g_pfnVectors[];​
  
-  SCB->​VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */+  ​/* Remap the vector table to where the vector table is located for this program. */ 
 +  ​SCB->​VTOR = (unsigned long)&​g_pfnVectors[0]; 
 +
 +</code> ​
  
-#else+And call this newly added function at the start of main():
  
-  SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; ​/* Vector Table Relocation in Internal FLASH. */+<code c> 
 +int main(void) 
 +
 +  ​/* Configure the vector table base address. */ 
 +  VectorBase_Config();​
  
-#​endif ​+  ...
  
 +}
 </​code>​ </​code>​
  
Line 31: Line 45:
 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 bootloader programs this value at the end of the user program'​s vector table. Its exact location is configured by macro 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 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 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. 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/armcm3_stm32.1565344703.txt.gz · Last modified: 2019/09/24 22:14 (external edit)