2018-07-01 02:11 AM
I'm working on STM32F107VC and I'm trying to create a simple bootloader.
All the boot-loader have to do is check two places in the flash where the application can be and jump to one of the applications.
(currently I manually burn the application and boot-loader images separately)
The code I've got so far is:
void* imgPtr[]= {&_img0_ptr, &_img1_ptr};
typedef void(*pFunction)(void);
int isValidImage(uint32_t* ptr) {
uint32_t val = ptr[0]; return (val & 0x2FFE0000) == 0x20000000;}int bspMain(void)
{ for (int i = 0;i < 2;i++) { uint32_t* ptr = (uint32_t*)imgPtr[i]; if (isValidImage(ptr)) { pFunction JumpToApplication = (pFunction)ptr[1];asm('cpsid i');
asm('ldr sp, =_estack'); __set_MSP(ptr[0]); JumpToApplication(); } }}Now I've debugged the application and the application's Reset_Handler starts running.
I've also made sure that SCB->VTOR is set to the correct value (0x08002000)
The problem is that at some point the application calls HAL_DELAY() and gets stuck there....
Can anybody please help me?
Thanks,
Nadav
#bootloadder #stm32f1072018-07-01 03:57 AM
Check this Discussion :
2018-07-01 04:50 AM
asm('cpsid i');
So do you enable the interrupts on the other side?
What you want to do really is disable the *sources* of the interrupts, not all interrupts.
2018-07-02 04:02 AM
The code on the other side is the startup code generated byvisual gdb.
i.e. it calls theReset_Handler() which inits the system and the c library and then calls the main function.
shouldthe
Reset_Handler() be called with interrupts enabled or not?
I've tried adding the code suggested in
https://community.st.com/0D50X00009XkXh2SAF
__enable_interrupt();__enable_irq();
but the compilation fails because there is no __enable_interrupt().
Please forgive me if I'm asking stupid questions...
Nadav