cancel
Showing results for 
Search instead for 
Did you mean: 

How to add option bytes in binary file .

TKopp.67
Associate II

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

4 REPLIES 4
Uwe Bonnes
Principal III

I do not know any gdb server that handles the option area with a normal write call. Extra commands are needed

TKopp.67
Associate II

Hello,

Sorry but i didn't get your answer why are you talking about GDB ? I just want to include option bytes as i want to configure them while programming. So they need to be include in the binary file. As i don't use IDE, etc i tried to add this section in the ld file and to write directly the value that i want at the good address.

TKopp.67
Associate II

No one wants to include option bytes in it's binary file ?

TKopp.67
Associate II

Finally it was working but my binary was like 4GO Oo however i changed the binary to hex and this one had a normal size. The option bytes are programmed as expected.