Skip to main content
Explorer
October 17, 2025
Solved

Writing Key in OP Byte

  • October 17, 2025
  • 3 replies
  • 485 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 ? 

    This topic has been closed for replies.
    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

    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.

    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 ;).

     

    bsutharAuthor
    Explorer
    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ƎALLEmAnswer
    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.

     

    bsutharAuthor
    Explorer
    October 29, 2025

    Oh , Okay.

    I was not aware about that.

    Tell me if I can reverese it ?

    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 :)