cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f107 CL : freeze after jump from bootloader

Greusard Alexandre_2
Associate II

Hi!

I have a project with a custom bootloader (I cannot change it), the issue I have is that my main app freezes after the jump from the bootloader.

I have a USART connection to debug it easily.

I know some Interruptions are set in the bootloader, so I tried to disable it at the beginning of my application, but still freezing.

I also know that the vector is in The RAM for the bootloader, and in the flash for my application. Could it comes from here?

Here is what I do in my main application:

=====================

   __disable_irq();

   SetupLeds();

   SetSysClockTo72();

   SetupTimers();

   FLASH_Init();

   Setup_USARTS();

   Send_USART3("System Initialised, ENABLE IRQs\r\n");

   __enable_irq();

__________________________

==> FREEZE HERE <==

------------------------------------

   Send_USART3("LAUNCH !\r\n"); // never appears

while(1)

{

/* Applicative code */

}

=====================

I have my Faults_handlers set up (hardfault, memfault...) and none of them occurs...

I also tried to disable interruptions one by one like this:

=====================

   for(uint8_t la=0;la<OTG_FS_IRQn;la++)

   {

      NVIC_DisableIRQ((IRQn_Type)la);

   }

===================== Not successfull...

I try a lot of things but I dont know what to search, and how to make a diagnostic of it.

If whoever has an idea I am a taker...

Alexander

3 REPLIES 3

If you can't change the loader you need to understand it.

Are you sure it freezes and doesn't just fault? If you stop the debugger where is it?

Write a proper Hard Fault Handler, one that outputs diagnostic information so you know it ended up there.

Make sure your vector table location is reflected in SCB->VTOR

Where did you disable the interrupts generated by the loader?

Determine which peripherals/interrupts the loader enabled and services, and then deal with those in your app.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Greusard Alexandre_2
Associate II

Thanks for your answer.

Write a proper Hard Fault Handler, one that outputs diagnostic information so you know it ended up there.

I set up all the faults handlers, My Hard_Fault_Handler is programmed to send through USART some informations on the issue, it is working:

   uint8_t* BytePtr = (uint8_t)0x20002000;

   *BytePtr = 0x5a;       //generate hardfault IRQ

The HardFault handler is toggled if my hardfault test is before __enable_irq() , otherwise not...

Make sure your vector table location is reflected in SCB->VTOR If I plot SCB->VTOR it returns the rigth adress so I think its ok !?

Where did you disable the interrupts generated by the loader? Well I tried to stop it with :

   for(uint8_t la=0;la<OTG_FS_IRQn;la++)

   {

      NVIC_DisableIRQ((IRQn_Type)la);

   }

But I'm not sure it works. How should I do?

Greusard Alexandre_2
Associate II

Ok I solved my problem:

I looked on the SCB->ICSR , the PENDSTSET bit was high:

I think systick interruptions was configured in the bootloader, and after the jump to my application the µC crash because there where no handlers in my code.

I just configured the SysTick_Handler() and it solved my problem, I'll try to disable the interruption to be cleaner.