hello I'm making a bootloader Getting issue of hardfault & configuring stack pointer.
Doing :
start boot flash 0x00000000
start appflash 0x00001000
can any one suggest what's bad with the code ? I am new to bootloader.
typedef void (application_t) (void);
typedef struct vector
{
uint32_t stack_addr; // intvec[0] is initial Stack Pointer
application_t *func_p; // intvec[1] is initial Program Counter
} vector_t;
extern const uint32_t app_intvect; // Application vector address symbol from
// the linker configuration file
// value = 0x00001000
int main(void)
{
const vector_t * vector_p = (vector_t *) &app_intvect;
// volatile uint32_t stack_arr[100] = {0}; // Allocate some stack
__enable_interrupt();
printf("Hello from bootloader!\n");
printf("MSP BEFORE: %x \n", __get_MSP());
printf("PSP BEFORE: %x \n", __get_PSP());
__disable_interrupt(); // 1. Disable interrupts
__set_SP(vector_p->stack_addr); // 2. Configure stack pointer
SCB->VTOR = (uint32_t) &app_intvect; // 3. Configure VTOR
printf("MSP AFTER: %x \n", __get_MSP());
printf("PSP AFTER: %x \n", __get_PSP());
vector_p->func_p(); // 4. Jump to application
}