2021-09-24 12:01 PM
Hello,
I am attempting to write a first stage bootloader that will load a second stage from SD card into RAM and then jump to this application.
The program works when I load the second stage to flash and jump to it and when I run it in RAM with the Debugger.
However when I change the linker script to RAM.ld and place the program in RAM manually at location 0x20008000 and to a size of 64k and then jump to it I get a hard fault.
One note is that I am also failing my CRC check when I load ram and run CRC on the data loaded, However the same code will pass when CRC is run through the loaded flash.
Please see the code used to jump to flash 0x08008000 and then ram 0x20008000
/**
* @brief A new UserApp Fw was available. Start to download it
* @param None
* @note This function must set the next State Machine State
* @retval None
*/
uint8_t jump_to_application(uint32_t address)
{
// uint32_t jump_address ;
typedef void (*Function_Pointer)(void);
Function_Pointer p_jump_to_function;
deinitEverything();
__disable_irq();
/* Initialize address to jump */
uint32_t jump_address = *(__IO uint32_t *)(((uint32_t)address + 4));
p_jump_to_function = (Function_Pointer) jump_address;
/* Initialize loader's Stack Pointer */
__set_MSP(*(__IO uint32_t *)(address));
/* Jump into loader */
__enable_irq();
p_jump_to_function();
/* The point below should NOT be reached */
return 1;
}
Thanks,
Any help would be appreciated.
Solved! Go to Solution.
2021-09-24 03:06 PM
The issue was in the RAM, while transposing the flash code, I misplaced a index increment.
Thank you for the response, let me figure out much easier that the issue was my own.
2021-09-24 12:12 PM
Understand why the data/code in RAM is corrupted.
Use a debugger, step into the code.
Review the processor registers at the fault, and review the instructions being executed.
For GNU/GCC watch where it parks the stack pointer initially.
Issue likely not with the code you're showing.
2021-09-24 03:06 PM
The issue was in the RAM, while transposing the flash code, I misplaced a index increment.
Thank you for the response, let me figure out much easier that the issue was my own.