Menu

#159 Hard Faul in Blinky App generated with the F1 Template when use with bootloader

Version 1.x
closed
None
5
2015-08-05
2015-08-04
mathias
No

Hello,
I have a problem with a Blinky App :-) .. used with a bootloader. It´s a test only before moving to the big app. So I think the Problem is the Stack Pointer - which is not set in the ResetHandler. So I tried to set it ...

at the beginn of the reset handler ..

__asm(" ldr r1, =_estack\n"
" mov sp, r1");

but that doesn´t help so far. So doese anyone use the Startup Code generted with the Plugin on a project with a custum bootloader?
I think the jump from the bootloader to the blinky app i correct.
So I cannot figured it out why i get an hardfault so far but if change the Flash Adress an use it without an bootloader the blinky works :-).

This is the Jump funktion....

void CpuStartUserProgram(void)
{
void (*pProgResetHandler)(void);

/ check if a user program is present by verifying the checksum /
if (NvmVerifyChecksum() == BLT_FALSE)
{
/ not a valid user program so it cannot be started /
return;
}

#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
/ invoke callback /
if (CpuUserProgramStartHook() == BLT_FALSE)
{
/ callback requests the user program to not be started /
return;
}
#endif
#if (BOOT_COM_ENABLE > 0)
/ release the communication interface /
ComFree();
#endif
/ reset the timer /
TimerReset();

/ remap user program's vector table /
SCB_VTOR = CPU_USER_PROGRAM_VECTABLE_OFFSET & (blt_int32u)0x1FFFFF80;
/ set the address where the bootloader needs to jump to. this is the address of
* the 2nd entry in the user program's vector table. this address points to the
* user program's reset handler.
/
pProgResetHandler = (void()(void))(((blt_addr*)CPU_USER_PROGRAM_STARTADDR_PTR));

// / Initialise master stack pointer. /
asm volatile ("msr msp, %0"::"g"((volatile blt_int32u)CPU_USER_PROGRAM_STARTADDR));

/ start the user program by activating its reset interrupt service routine /
pProgResetHandler();
} / end of CpuStartUserProgram /

I can debug from the jump to the app and then it crashes after the _start() ...

thanks for your help
mathias

Discussion

  • Liviu Ionescu (ilg)

    • status: open --> accepted
    • assigned_to: Liviu Ionescu (ilg)
     
  • Liviu Ionescu (ilg)

    did you try launching the application with the standard ST bootloader, or only with your own custom bootloader?

    generally the bootloader should set the SP and VTOR, then jump to the new Reset_Handler.

    are you running from RAM, or you are programming the flash?

     
  • mathias

    mathias - 2015-08-04

    Hello, Thanks for your fast reply. No I only tried the custom bootloader "openblt". So as you can see the loader sets the VTOR and also sets the msp so therefore I thought I also need to set the sp as the openblt homepage pointed out. http://feaser.com/openblt/doku.php?id=manual:ports:armcm3_stm32

    The problem starts on the function call of _star() function. So I think ther is something wrong with my SP setting. I am running from flash => programming the flash but also after a hard reset the jump to the app crashes in the reset handler after the _start().

     

    Last edit: mathias 2015-08-04
  • Liviu Ionescu (ilg)

    asm volatile ("msr msp, %0"::"g"((volatile blt_int32u)CPU_USER_PROGRAM_STARTADDR));

    this doesn't look like a RAM address.

    what value do you see in SP when you stop at _start()?

     
  • mathias

    mathias - 2015-08-05

    Hello I have checked the SP the adress seems to be okay the SP stays on 0x20005000 before the jump. Before I jump I load the symbols of the USER App and then I break on _start() there the SP stays on 0x20004ff8 so this should be okay or not.

     
  • Liviu Ionescu (ilg)

    SP stays on 0x20004ff8 so this should be okay or not.

    if it is within the actual RAM space it should be ok.

     
  • mathias

    mathias - 2015-08-05

    Yes I think so I have 20K RAM. So what I now figured out is that wenn I start with the debugger step by step it works but only with the debugger. So that´s really strange.

     
  • mathias

    mathias - 2015-08-05

    Hello, Pleas close the ticket I found the error. It was the checksum which is used in openblt. Please close the ticket.

     
  • Liviu Ionescu (ilg)

    • status: accepted --> closed