Skip to content

Project documentation

Thibaut VIARD edited this page Aug 12, 2015 · 3 revisions

Board startup flow

This module is dedicated to some ARM Cortex-M3 and Cortex-M4 based devices and according boards. These cores look at memory mapping absolute address 0x00000000 to obtain the Stack Pointer and at 0x00000004 for the Reset vector.

Once powered up, the core will load the Stack Pointer value into SP core register and the Reset vector address (usually void Reset_Handler(void)) is then loaded in PC (Program Counter) core register to begin code execution.

Reset_Handler can be found in variant_startup (e.g. ExperimentalCore-sam\variants\atmel_sam4s_xplained\variant_startup.c). This goal is mainly to copy symbols present in flash (e.g. initialized variables, RAM functions) to internal or external RAM, depending on the system/board. Right after these memory copies, we can find two interesting function calls SystemInit() and main():

/**
 * \brief This is the code that gets called on processor reset.
 * Initializes the device and call the main() routine.
 */
void Reset_Handler( void )
{
  uint32_t *pSrc, *pDest;

  /* Initialize the initialized data section */
  pSrc = &__etext;
  pDest = &__data_start__;

  if ( (&__data_start__ != &__data_end__) && (pSrc != pDest) )
  {
    for (; pDest < &__data_end__ ; pDest++, pSrc++ )
    {
      *pDest = *pSrc ;
    }
  }

  /* Clear the zero section */
  if ( &__bss_start__ != &__bss_end__ )
  {
    for ( pDest = &__bss_start__ ; pDest < &__bss_end__ ; pDest++ )
    {
      *pDest = 0ul ;
    }
  }

  /* Initialize the system */
  SystemInit() ;

  /* Branch to main function */
  main() ;

  /* Infinite loop */
  while ( 1 )
  {
  }
}

Cortex-M3 and Cortex-M4 vectors

Module version numbering

The module versioning will follow Semantic Versioning 2.0.0.