How to add option bytes in binary file .
Hello everyone,
We are using STM32G070 on a prototype board which will be in production soon. My problem is that when the board comes from the subcontractor, we can't program the microcontroller from UART.
We succeeded to program it from UART after using an ST-Link to uncheck the nBOOT_SEL bit from the option bytes.
But this solution is not suitable for us. The contractor will program the firmware before to send us the board. So i am trying to include the option bytes configuration directly in the firmware so that when the boards come we can directly update it from UART by another chip. But this operation is quite confusing for me.
Important information : I do not use IDE and compile with GCC.
Here is what i did :
in the .ld file :
MEMORY
{
rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 36K
option (rw) : ORIGIN = 0x1FFF7800, LENGTH = 4
}
down in the same file in the SECTIONS i added between text and bss :
.optionb : {
*(.optionb*)
} >option
and in the main file of my code i added :
const uint32_t optionbytes1 __attribute__(( section(".optionb") )) = 0xDEFFE1AA;
But it seems not working at all even if all compiles etc..
Does someone have any experience with that ? Do i miss a step ?my values are wrong ? Isn't it the good way to do it?
Thanks in advance for your answer,
Best Regards,
Thomas