Skip to main content
Explorer
March 3, 2024
Solved

Need assistance with modifying option bytes on STM32H7 using c# bootloader

  • March 3, 2024
  • 1 reply
  • 1395 views

I'm encountering difficulties modifying option bytes on an STM32H723VEH6 microcontroller using a custom C# bootloader. Although the bootloader successfully loads firmware onto the microcontroller, it fails to modify option bytes BOOT_CM7_ADD0 and BOOT_CM7_ADD1 despite following the correct sequence outlined in the reference manual.
If anyone has a code example demonstrating the correct implementation of modifying option bytes using a custom C# bootloader?

public void ModifyOptionBytes(uint bootCm7Add0, uint bootCm7Add1)
{
      UnlockFlashCR();
      UnlockFlashOPTCR();

      // Write the desired new option byte values in the corresponding option registers
      WriteOptionBytes(bootCm7Add0, bootCm7Add1);

     // Set the option byte start change OPTSTART bit to 1 in the FLASH_OPTCR register
     SetOptionByteStartChange();
}

    This topic has been closed for replies.
    Best answer by Pavel A.

    Here is example of C# interface to a STM32 bootloader:

    https://www.feaser.com/en/blog/2021/03/develop-your-own-firmware-update-tool-in-c-with-libopenblt/

    AFAIK the CubeProgrammer API library is intended for C++ and you need to write a C# wrapper to call it from C#.

    The API function for OB manipulation is sendOptionBytesCmd. The parameter is a string similar to the OB parameter for CubeProgrammer CLI.

    The functions in your source snippet, WriteOptionBytes and SetOptionByteStartChange, are not the public APIs of  the CubeProgrammer library.

     

     

    1 reply

    Pavel A.Answer
    Super User
    March 4, 2024

    Here is example of C# interface to a STM32 bootloader:

    https://www.feaser.com/en/blog/2021/03/develop-your-own-firmware-update-tool-in-c-with-libopenblt/

    AFAIK the CubeProgrammer API library is intended for C++ and you need to write a C# wrapper to call it from C#.

    The API function for OB manipulation is sendOptionBytesCmd. The parameter is a string similar to the OB parameter for CubeProgrammer CLI.

    The functions in your source snippet, WriteOptionBytes and SetOptionByteStartChange, are not the public APIs of  the CubeProgrammer library.