PEmicro logo
Cart New Account Login

Logo image
HomeAbout usProductsSupportForumsBlogCustomer Service

search inside this forum
search inside all forums
STM32 set option bytes with Cyclone: error 33
Joshua D. Jun 23, 2021 at 09:50 AM (09:50 hours)
Staff: Johnny N.

  • I am attempting to program a STM32F303RD With a Universal Cyclone. I want to protect the flash from readout so I am attempting to write a value into the Read Protection register (RDP Option byte). The Image Creation Utility (version 8.06.00.00) lets me add the "SU" command to select an .OPT file, and the "PU" command to program the file onto the target. When I try to save the image to the Cyclone I get the error:

    "Error code 33: Command is inactive for this algorithm file."

    If I remove the "SU" and "PU" commands, I am able load the image onto the cyclone and verify the Cyclone is able to program the target device.




    Comments

  • I just updated the image creator software to the latest (8.36.00.00) and the problem persists.

  • I figured out the problem. The Image creation tool allows you to use the SU and PU commands for the part I selected (an STM32F303RD), but they are only valid if the last selected algorithm is the option byes .arp file. I managed to get it working with the following programming sequence:

    CM C:\PEMicro\cyclone\supportfiles\supportFiles_ARM\ST\STM32F3\ST_STM32F303RD_1x32x4_OptionBytes.arp
    SU C:\path\to\option_bytes.OPT
    RU ;READ/WRITE UNPROT.
    PU ;Program User Options
    VU ;Verify User Options
    CM C:\PEMicro\cyclone\supportfiles\supportFiles_ARM\ST\STM32F3\ST_STM32F303RD_1x32x96k.arp
    SS C:\path\to\application.elf
    EN ;Erase if not Blank
    PM ;Program Module
    VC ;Verify Checksum
    LO ;LAUNCH OPTION
    GO ;Run

  • Correct. The user option commands (SU, PU, VU) are only valid if the last selected algorithm is the option bytes arp.

    Your sequence works for this specific setup, but I have a suggestion to avoid a potential issue. I will detail it for anyone else who might be looking for help in the future and find this thread.

    Your option bytes are programmed by the PU command. After programming them, the new settings do not take effect until you set the OBL_LAUNCH bit in the FLASH_CR register which is done by the LO command. Setting the OBL_LAUNCH bit forces a system reset and loads the new settings into the option byte registers.

    Our CM command also performs a system reset automatically. With your sequence, the following may potentially happen leading to an error.

    1) The option bytes to enable readout protection are programmed by PU.
    2) Then CM of the internal flash arp.
    3) There is a system reset. Flash is immediately protected.
    4) Then there is a EN or PM of the internal flash.
    5) Because the flash is already protected, you will get an erase or programming error.

    This is the sequence I recommend:

    CM C:\PEMicro\cyclone\supportfiles\supportFiles_ARM\ST\STM32F3\ST_STM32F303RD_1x32x4_OptionBytes.arp
    RU ;READ UNPROTECT
    CM C:\PEMicro\cyclone\supportfiles\supportFiles_ARM\ST\STM32F3\ST_STM32F303RD_1x32x96k.arp
    SS C:\path\to\application.elf
    EN ;Erase if not Blank
    PM ;Program Module
    VC ;Verify Checksum
    CM C:\PEMicro\cyclone\supportfiles\supportFiles_ARM\ST\STM32F3\ST_STM32F303RD_1x32x4_OptionBytes.arp
    SU C:\path\to\option_bytes.OPT ;contains value to enable read protect
    PU ;Program User Options
    LO ;LAUNCH OPTION
    VU ;Verify User Options
    GO ;Run

    • That makes sense.

      Why the CM back to the target's main flash just before calling GO? Was that intentional?

      • That was a mistake. You should be able to call GO without loading the main flash arp. GO causes a system reset but does not reenter debug mode so the application runs. I'll update my sequence.

Add comment


   Want to comment? Please login or create a new PEmicro account.







© 2021 P&E Microcomputer Systems Inc.
Website Terms of Use and Sales Agreement