2025-05-12 10:05 AM
I'd like to adapt Openbootloader to the H523/H533 chip.
In STM32CubeIDE, there are example applications for several microcontrollers/development boards. I noticed there was an example for the STM32H5731-DK, but I'd like to use it on the H523/H533 chips.
Here is a link to the reference manual I'm referring to:
Is there anything else I need to change to adapt examples to a given chip?
2025-05-12 10:16 AM
P.S.
I have the bootloader successfully connecting and reading option bytes over UART on the H533 Nucleo with the attached openbootloader_conf.h. Some changes I had to make it work:
It's not working perfectly however, I'm getting the following error when connecting:
Response received from device: NACK
Error: Address not acknowledged: 0x8FFF80C
I attached the full log of this connection here.
2025-05-12 1:39 PM
2025-05-12 2:36 PM
2025-05-15 9:56 AM
I figured out one thing which was going wrong and preventing me from being able to erase sector 0x08008000.
It turns out that even though I was following the video tutorial series about OpenBootloader and they said it was fine to put the user app at this address, it turns out that the compiled size of OpenBootloader for me was greater than 32kb, and so I was actually erasing some of the bootloader when I tried to load the user app. After turning on size optimization and getting the bootloader within 32kb so that none of it was written beyond the 0x08008000 boundary, I was able to successfully upload and verify code.
I am still having an issue jumping to the user app however, and am getting a hard fault when setting the main stack pointer to the user app address.
/* Initialize user application's stack pointer */
Common_SetMsp(*(__IO uint32_t*) Address);
2025-05-15 9:48 PM
Some more information:
I think the issue may be with the Common_SetMsp() function. I tried the following test:
I started debugging a program, and checked the stack pointer register in the "Registers" tab. The stack pointer was at 0x20044000. I then tried to use the Common_SetMsp(0x20044000) function, expecting it to cause no effect. Instead, it immediately entered a hard fault. If I try to set the stack pointer to a lower value such as 0x20043000 it works. Now this value (0x20044000) is the same one calculated by line in the OPENBL_FLASH_JumpToAddress function at the following line "*(__IO uint32_t*) Address" when the address is 0x08008000 (this is because *hopefully* I successfully uploaded a valid program at that address, so I would hope it's stack pointer is correct, which it seems to be).
void OPENBL_FLASH_JumpToAddress(uint32_t Address) {
Function_Pointer jump_to_address;
/* De-initialize all HW resources used by the Open Bootloader to their reset values */
OPENBL_DeInit();
/* Enable IRQ */
Common_EnableIrq();
jump_to_address = (Function_Pointer) (*(__IO uint32_t*) (Address + 4U));
/* Initialize user application's stack pointer */
Common_SetMsp(*(__IO uint32_t*) Address);
jump_to_address();
}
My question is: Why does setting the stack pointer to something that is clearly a valid place for it to be, since I can see that the `sp` register is at that value when my program starts, cause a hard fault?