cancel
Showing results for 
Search instead for 
Did you mean: 

Problems writing bootloader on STM32107VC

Nadav Popplewell
Associate II
Posted on July 01, 2018 at 11:11

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 #stm32f107
3 REPLIES 3
STOne-32
ST Employee
Posted on July 01, 2018 at 12:57

Check this Discussion :

https://community.st.com/0D50X00009XkXh2SAF

 

Posted on July 01, 2018 at 13:50

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Nadav Popplewell
Associate II
Posted on July 02, 2018 at 13:02

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