2025-01-13 02:16 AM
Hi everyone,
I’m working on a custom bootloader for an STM32H750 and need some help. My goal is to be able to update the unit from USB and for doing so I use an external eeprom to store the MCU FW and load it into RAM at startup. The main reason to use the RAM to execute the code is that the h750 flash is 128KB and it can only be erased by 128KB sector.
I can succesfully write the code into the eeprom and load into ram at startup (address 0x20000000). However, when I try to jump to it, the debugger shows a 0x2xxxxxxx address but it get stuck.
For the application code, I took the original flash based code, modified the scatter file for the linker as follows:
; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
LR_IROM1 0x20000000 0x00020000 { ; load region size_region
ER_IROM1 0x20000000 0x00020000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
.ANY (+XO)
}
RW_IRAM2 0x24020000 0x00080000 { ; RW data
.ANY (+RW +ZI)
}
}
I also tried setting the VTOR to 0x20000000 in the application, but it didn’t help. Looking at the .bin file, the stack pointer (SP) and program counter (PC) appear to point to valid addresses within the 0x20000000 range.
Here is the part of the code which is supposed to jump to the app.
#define APP_BASE_RAM (0x20000000)
uint32_t *p;
void (*jmp)();
----------
.....
__disable_irq();
p = (uint32_t *)(APP_BASE_RAM);
SCB->VTOR = (uint32_t)p; // Set Vector Table Offset Register (VTOR) to RAM base
__set_MSP(*p);
__DSB(); // Data Synchronization Barrier
__ISB(); // Instruction Synchronization Barrier
jmp = (void (*)())p[1];
__enable_irq();
while (true) ;
I’m not sure if there’s something I’m missing in the application code or bootloader setup. Has anyone encountered a similar issue or have suggestions on what I could check next?
Thanks in advance!
2025-01-13 02:52 AM
Hello @dc_matt ,
Make sure that you are using the correct start address to jump to the bootloader for STM32H7 devices (0x1FF09800).
For more details, please check the AN2606.
In addition, please have a look on this FAQ "Jump to Bootloader from application on STM32H7 devices":
Jump to bootloader from application on STM32H7 dev... - STMicroelectronics Community
2025-01-13 03:40 AM - edited 2025-01-13 03:43 AM
Hello,
I accidentally clicked on "SOLUTION" by mistake. This isn't the first time it's happened, so there might be an issue with the forum's user interface.Should I create a new thread? Last time my post was left uncommented afer accepting the answer by mistake ...
Regarding your comment, I'm not sure I fully understand it. My goal is to run the code from RAM, and the address I'm using is 0x20000000. And my bootloader is fully custom. Is there a fundamental mistake in my understanding?
2025-01-13 07:29 AM
Hi @dc_matt
I removed the Accept Solution, and I will report your feedback internally to the Community team. No need to create a new post. We can continue the discussion here.
Maybe you should check the security Settings and ensure that there are no security settings or option bytes that might prevent the code from executing in RAM.
2025-01-13 07:55 AM
Hi @Imen.D , from STM32CubeProgrammer, checked the following:
No security options enabled.
2025-01-13 08:50 AM
Hi @dc_matt,
Welcome to the ST Community and thanks for reporting this.
If you click the “Accept as Solution” by mistake, you can revert the action by choosing “Not the Solution”.
Important: to apply the action of “Accept as Solution” or revert to “Not the Solution” is permitted only to the author of the post and the community moderators.
If you face any difficulties, please mark the post “Report Inappropriate Content” and the forum moderators will take the respective action.
You can find more on this feature here: Help others to solve their issues
In the future, you can share you feedback or questions about the community platform here: Feedback forum.
Let me know if there is anything else you need,
Lina - ST Community team
2025-01-13 09:18 AM - edited 2025-01-13 09:20 AM
Can it be related to the VTOR setting in the application code? I set it to 0x20000000. Is it correct?
Can the scatter file I shared above be wrong?
After the jmp() instruction the step by step debugger gets stuck and when I press STOP, the Disassembly shows the CPU stuck at the line
0x2000D3C6 B 0x2000D3C6