[SOLVED] J-Link and STM32F405RG option byte

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] J-Link and STM32F405RG option byte

    Hello,
    I need to program a STM32F405RG with using an J-Flash ARM.
    Unfortunetly i have to use also option bytes, is there a possiblily to use them also on a STM32F405RG??
    It seems that J-Flash V5.12e supports only option bytes until STM32F398xx.
    Please help me,
    Regards
    Stefan
  • Hi Stefan,

    It seems that J-Flash V5.12e supports only option bytes until STM32F398xx.

    We stopped to implement specific chip functions like setting option bytes / securing the chip etc. some time ago.
    The J-Link software supports >6000 devices nowadays, so implementing special features for every chip is not realistic anymore.

    Instead, there is a generic way:
    Options bytes etc. can be set using J-Flash's init steps (before programming) or exit steps (after programming).
    This is described in the J-Flash manual. For instruction on how option bytes are set on your specific device, please refer to the technical documentation provided by ST.

    Best regards,
    Niklas
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Niklas,

    Ah okay I understand the background.

    I tried to use your mentioned generic way - but unfortunatly without good result.
    At init steps i add a "Write 16bit" which should write value 0xFFFC to address 0x1FFFC008 (option byte address for this STM32F405xx chip).
    But it doesnt write the data during auto programming or during some other exectuable actions.

    I always readback 0xFFFF at specific address.
    Generally question is when does the programmer execute the inserted "write 16bit"???

    Problem could be that the option bytes address 0x1FFFC008 is not specified in the sectors when using the standard STM32F405xx libary.

    Are there some other special settings needed???

    Regards
    Stefan

    The post was edited 3 times, last by Blake ().

  • Hi Stefan,

    a quick guess without looking in the ST manual:

    Usually, in order to write Options Bytes on ST targets you need to unlock the registers in the first place.
    This can be done by writing 1-2 magic values listed in the ST manual to a specific registers prior to writing the option bytes.

    Best regards,
    Niklas
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Niklas,

    For my point of view this is not the blocking topic.
    I use for debugging also a ST-Link and i fully unlock all registers at the test boards. I also use fresh boards from production without anything blocked.

    But for production programming i will use the J-LINK ARM, when it would work.
    The option bytes addresses should be somewhere specified as used addresses in the project file, or not??

    I tried to use "write 8bit", 16bit and 32bit also in the init steps or exit steps, but it doesnt work.
    Thanks
    Best Regards
    Stefan
    Images
    • Flash_settings.png

      18.24 kB, 471×497, viewed 1,810 times
    • write_option_byte.png

      6.15 kB, 456×223, viewed 1,693 times
  • In the meantime I also tried to write some data via the exit steps "write xbit" on a address which is normally used (0x0801D980) but nothing happens.

    The application code is programmed correctly, also verifiying. --> using Target - "Auto"

    How can i verify if the write action in the Exit steps was executed???

    Regards
    Stefan

    The post was edited 1 time, last by Blake ().

  • Hi Stefan,


    the registers are always locked after a powercycle or reset . This has nothing to do with the locking of the internal flash!

    For example, on a STM32F2 / STM32F4 target, you will need to write
    0x08192A3B -> 0x40023C08
    0x4C5D6E7F -> 0x40023C08
    in order to unlock the registers.

    Excerpt from RM0090:
    Programming user option bytes
    To run any operation on this sector, the option lock bit (OPTLOCK) in the Flash option
    control register (FLASH_OPTCR) must be cleared. To be allowed to clear this bit, you have
    to perform the following sequence:
    1. Write OPTKEY1 = 0x0819 2A3B in the Flash option key register (FLASH_OPTKEYR)
    2. Write OPTKEY2 = 0x4C5D 6E7F in the Flash option key register (FLASH_OPTKEYR)
    The user option bytes can be protected against unwanted erase/program operations by
    setting the OPTLOCK bit by software.


    Best regards,
    Niklas
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.