search inside this forum
 search inside all forums
 Wednesday, June 23, 2021 STM32 set option bytes with Cyclone: error 33 Joshua D. Jun 23, 2021 at 09:50 AM (09:50 hours) Staff: Johnny N. 6 comments 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. Comment #1 Joshua D. - June 23, 2021 - 09:50 AM (09:50 hours) Comments I just updated the image creator software to the latest (8.36.00.00) and the problem persists. Comment #2 Joshua D. - June 23, 2021 - 11:00 AM (11:00 hours) 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.arpSU C:\path\to\option_bytes.OPTRU ;READ/WRITE UNPROT.PU ;Program User OptionsVU ;Verify User OptionsCM C:\PEMicro\cyclone\supportfiles\supportFiles_ARM\ST\STM32F3\ST_STM32F303RD_1x32x96k.arpSS C:\path\to\application.elfEN ;Erase if not BlankPM ;Program ModuleVC ;Verify ChecksumLO ;LAUNCH OPTIONGO ;Run Comment #3 Joshua D. - June 23, 2021 - 03:41 PM (15:41 hours) 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.arpRU ;READ UNPROTECTCM C:\PEMicro\cyclone\supportfiles\supportFiles_ARM\ST\STM32F3\ST_STM32F303RD_1x32x96k.arpSS C:\path\to\application.elfEN ;Erase if not BlankPM ;Program ModuleVC ;Verify ChecksumCM C:\PEMicro\cyclone\supportfiles\supportFiles_ARM\ST\STM32F3\ST_STM32F303RD_1x32x4_OptionBytes.arpSU C:\path\to\option_bytes.OPT ;contains value to enable read protectPU ;Program User OptionsLO ;LAUNCH OPTIONVU ;Verify User OptionsGO ;Run Comment #4 Johnny N. (PEmicro Staff) - June 24, 2021 - 09:37 AM (09:37 hours) That makes sense.Why the CM back to the target's main flash just before calling GO? Was that intentional? Comment #4.1 Joshua D. - June 24, 2021 - 09:47 AM (09:47 hours) 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. Comment #4.1.1 Johnny N. (PEmicro Staff) - June 24, 2021 - 09:56 AM (09:56 hours) Add comment    Want to comment? Please login or create a new PEmicro account.

© 2021 P&E Microcomputer Systems Inc.