Skip to main content
Associate III
October 17, 2025
Solved

Writing Key in OP Byte

  • October 17, 2025
  • 3 replies
  • 486 views

Hello Team,

I want to store encryption Key - 4 byte into Option Byte OR any other memory Except in-built Flash Memory.

Is it possible to write in Option Memory ? 

If not what could be the other option ? 

Best answer by mƎALLEm

@bsuthar wrote:

Can we Program those bytes with Cube Programmer and Read using Firmware code ?

I am using RDP1 after Flashing Firmware.


This is what the reference manual is saying. It's accessible over this address: 0x1FFF F804

mALLEm_1-1760781630661.png

But it can contain only two bytes and their opposite (Datax and nDatax) and you need 4-bytes storage!

In the CubeProgrammer I've written 0x12 in Data0, 0x78 in Data1:

 

mALLEm_1-1760790160599.png

Read in software:

key = *(uint32_t*)0x1FFFF804;

key contains 0x8778ED12

ED the bitwise inversion of 12 and 87 is the bitwite inserion of 78.

 

3 replies

TDK
Super User
October 17, 2025

There are no spare addresses in option bytes for this.

The usual method for doing this is writing them to the last page of FLASH. If you don't want to do that, you'll need to use an external memory chip.

"If you feel a post has answered your question, please click ""Accept as Solution""."
mƎALLEm
Technical Moderator
October 17, 2025

Hello,

I think you can store only two bytes in the option bytes in STM32F3. (By the way you didn't mention the exact part number you are using)

mALLEm_0-1760716900743.png

The only possibility in your case (4 bytes) is to use the RTC backup registers where you need an external battery.

I'm not in favor to save the keys in an external memory as it may "breach" the security by sniffing the communication between the chips ;).

 

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
bsutharAuthor
Associate III
October 18, 2025

Thanks , mƎALLEm

Exact Device is : STM32F303Rbt6

"I'm not in favor to save the keys in an external memory as it may "breach" the security by sniffing the communication between the chips ;). "

Yes , you catched the point, :). 

Can we Program those bytes with Cube Programmer and Read using Firmware code ?

I am using RDP1 after Flashing Firmware.

 

@TDK 

Whole idea is no body Should sniff the Key.

 

Thank you,

 

mƎALLEm
mƎALLEmBest answer
Technical Moderator
October 18, 2025

@bsuthar wrote:

Can we Program those bytes with Cube Programmer and Read using Firmware code ?

I am using RDP1 after Flashing Firmware.


This is what the reference manual is saying. It's accessible over this address: 0x1FFF F804

mALLEm_1-1760781630661.png

But it can contain only two bytes and their opposite (Datax and nDatax) and you need 4-bytes storage!

In the CubeProgrammer I've written 0x12 in Data0, 0x78 in Data1:

 

mALLEm_1-1760790160599.png

Read in software:

key = *(uint32_t*)0x1FFFF804;

key contains 0x8778ED12

ED the bitwise inversion of 12 and 87 is the bitwite inserion of 78.

 

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
bsutharAuthor
Associate III
October 29, 2025

Oh , Okay.

I was not aware about that.

Tell me if I can reverese it ?

mƎALLEm
Technical Moderator
October 29, 2025

@bsuthar wrote:

Oh , Okay.

I was not aware about that.

Tell me if I can reverese it ?


That's OK now :)

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."