My embedded system is based on LPC11E68JBD48E. I'm using MCUXpresso IDE. Linker script is auto generated. The entry point is specified in the beginning of linker script, ENTRY(ResetISR)
How does linker know this is the first instruction to execute?
ResetISR is declared, defined, and is entry in vector table in my .cpp file as follows:
void ResetISR(void);
ResetISR(void) {
/* some reset initialization code here */
}
//*****************************************************************************
//
// The vector table. Note that the proper constructs must be placed on this to
// ensure that it ends up at physical address 0x0000.0000.
//
//*****************************************************************************
extern void (* const g_pfnVectors[])(void);
__attribute__ ((used,section(".isr_vector")))
void (* const g_pfnVectors[])(void) = {
&_vStackTop, // The initial stack pointer
ResetISR, // The reset handler
NMI_Handler, // The NMI handler
...
….
….
When reset is released this microcontroller executes at address 0x0000 0000. Looking at the vector table &_vStackTop is at address 0x0000 0000. What is the result of executing code at address 0x0000 0000?
When I reset microcontroller from the debugger, breakpoint in the function ResetISR is hit.
How does linker know program entry point is ResetISR?
I would expect ResetISR to be the first entry in the vector table but it is second entry?
On ARM Cortex-M, the first entry in the vector table is the initial SP (Stack Pointer), followed by the initial PC (Program Counter) or the reset vector (see as well ARM Cortex-M, Interrupts and FreeRTOS: Part 1 | MCU on Eclipse).
I'm not sure why you think in your case &_vStackTop is zero: check your linker file (.ld) as the linker usually is placing a symbol for the _vStackTop.
I hope this helps,
Erich
>> why you think in your case &_vStackTop is zero
I meant &_vStackTop is at internal flash memory address 0x0. The address of stack Top isn't 0x0.