cancel
Showing results for 
Search instead for 
Did you mean: 

Custom BootLoader jump to FreeRTOS application

pfifre
Associate II
Posted on May 19, 2014 at 10:23

Hi all,

I've develop a specific bootloader which calling my application.

My application is based on FreeRTOS.

When the application starts after the jump, the firmware crashes in hardfault.

It works fine when I don't use the FreeRTOS scheduler.

I've tested my application (with FreeRTOS enabled) by loading it with the debugger and it works fine.

FreeRTOS starts their tasks by calling SVC.

Then, i've try also to replace the FreeRTOS scheduler starting by a simply __asm volatile (''svc 0'') and I reproduce the same issue.

The application address is 0x0800C000.

Like clive suggested, I have use a system call in my bootloader :

void SVC_Handler(void)

{

pFunction  Jump_To_Application;

uint32_t  JumpAddress;

/* Jump to user application */

JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);

Jump_To_Application = (pFunction) JumpAddress;

__disable_irq();

/* Initialize user application's Stack Pointer */

__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);

Jump_To_Application();

}

I've checked the VECT_TAB_OFFSET in system_stm32f4xx.c to set it to 0xC000.

Can anybody help me ?

Thanks a lot,

Pascal

#stm32-freertos
30 REPLIES 30
pfifre
Associate II
Posted on May 19, 2014 at 16:52

I put a breakpoint on the SVCHandler in my application.

In fact, when the FreeRTOS launch the svc call, the SVChandler has never been called.

What does it mean ?

Thanks

Pascal

Posted on May 19, 2014 at 17:06

What does it mean ?

I don't know, do you have linkage via the vector table? Does your Hard Fault handler output any diagnostic information? What debugger are you using?My example didn't disable interrupts, the expectation at the hand-over is that you've cleaned up the operating environment, and that the application can handle whatever is left.

Other Thread

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

 

EDIT: Fixed DEAD LINK, Original from 14-May-2014

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
chen
Associate II
Posted on May 19, 2014 at 17:28

Hi

Reading the thread from top to bottom - I think you are confused as to what is doing what.

''I've develop a specific bootloader which calling my application.

My application is based on FreeRTOS.''

It is unclear now whether the bootloader is running FreeRTOS.

Does the bootloader run with FreeRTOS?

If so - why?

The bootloader only needs to :

download application code binary via USB

Program code into Flash.

Check if valid application code is in Flash

If Application code is valid - start it.

There is no need for the bootloader to run FreeRTOS - it only complicates the bootloader.

If the bootloader does not run FreeRTOS - the jump does not need to be in the SVC - simplifying your problem.

pfifre
Associate II
Posted on May 19, 2014 at 17:43

How can I see if I have the linkage with the vector table?

I can read memory or the registers via the debugger.

I'm using GDB under Eclipse IDE.

Yes, I think your're right, the processor call the HardFault Handler because it didn't find any handler for SVC.

But, I'm sure that the VTOR points on 0x800C000.

''the expectation at the hand-over is that you've cleaned up the operating environment''

But the systemInit and main initialisation has been called before launch SVC.

Thanks for your help.

Pascal

pfifre
Associate II
Posted on May 19, 2014 at 17:52

No, my bootloader doesn't run with FreeRTOS, but, my application does.

OK, I try a call from bootloader without SVC.

But, I do that before and I have the same problem.

Best regards,

Pascal

Posted on May 19, 2014 at 17:59

But, I'm sure that the VTOR points on 0x800C000.

If you are in the boot loader, then SCB->VTOR should point at THAT, the application should fix up it's vector address in SystemInit()

You are attempting to start an application image at 0x0800C000 from a boot loader at 0x08000000, right?

''the expectation at the hand-over is that you've cleaned up the operating environment''

 

But the systemInit and main initialization has been called before launch SVC.

Ok, but my point is that you shouldn't be leaving the kitchen messy, ie no random SysTick or TIM IRQ firing, and no DMA mid transaction.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
chen
Associate II
Posted on May 19, 2014 at 18:03

''No, my bootloader doesn't run with FreeRTOS, but, my application does.

OK, I try a call from bootloader without SVC''

You will definitely get a HardFault if you try to execute a SVC before the software has set up the ARM core with an ISR for the SVC.

If the bootloader is not running FreeRTOS - it should not be doing anything with SVC (unless it has set up a context switching system - again why would a simple bootloader do this?)

The application (with FreeRTOS) should set up the ARM core with context switching. The bootloader MUST not do anything that interfers with FreeRTOS.

One point which I tripped over - my bootloader does use the SysTick - the application MUST disable the SysTick as soon as possible, so that FreeRTOS can re-configure the SysTick for it's own use.

pfifre
Associate II
Posted on May 20, 2014 at 08:57

Clive,

You are attempting to start an application image at 0x0800C000 from a boot loader at 0x08000000, right?

Yes, that's right.

And the SystemInit in BootLoader fixes up the VTOR to 0x8000000 and the Application fixes up to 0x800C000 in SystemInit to.

Ok, but my point is that you shouldn't be leaving the kitchen messy, ie no random SysTick or TIM IRQ firing, and no DMA mid transaction.

How can avoid these? Disable irq is not sufficient?

Thanks,

Pascal

pfifre
Associate II
Posted on May 20, 2014 at 09:01

sung.chen_chung,

OK, I definitivly don't use the SVC in my bootloader.

The application MUST disable the SysTick as soon as possible

 

OK, I will try it.

Thanks for your support,

Pascal

pfifre
Associate II
Posted on May 20, 2014 at 10:52

I've disabled SysTick at starting in my application.

Nothing change, I still have the same issue.

I simplify my application to not use FreeRTOS but simply call SVC at the beginning (__asm volatile(''svc 0'')).

The HardFault Handler is called immediatly.

It looks like that no handler will be load for treating SVC interrupt.

How can I verify that the vector table is loaded?

Best regards,

Pascal