cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 G0 Setting Read Protection With Batch(.bat) File

SSone.1
Associate III

Hi, I am trying activate read protection to level-1 with using batch(.bat) file. I am commanding to ST- Link Utility via batch file. My batch file code is like that:

@ECHO OFF

"C:\Program Files (x86)\STMicroelectronics\STM32 ST-LINK Utility\ST-LINK Utility/ST-Link_CLI.exe" -c SWD -OB RDP=0 -ME -P C:\gok.hex -V "after_programming" -OB RDP=1 

PAUSE

Explanation of code is;

-c SWD : connects to device

-OB RDP=0 : sets read protection level to 0

-ME: mass erase

-P c:\gok.hex : program hex file to flash

-V "after_programming": verify if programmed correctly

-OB RDP=1 : set read protection to level 1

When I execute batch file it's programming and verifying the selected .hex file and setting read protection to level 1 but my code is not running in the mcu. I tried reseting after executing the batch file but it didn't help. If I erase the "-OB RDP=1" command at the end, code is running.

I have done same things with ST-Link Utility(not with batch file this time- manually), I programmed the hex file and then set the read protection level to 1 and code runned without problem. I can't see what is the difference between my batch file code and doing it manually with ST-Link Utility. I need help at that point.

2 REPLIES 2
TDK
Guru

Maybe do it in two separate calls instead of one call. Having two -OB RDP values may be confusing the program.

Could also try with STM32CubeProgrammer CLI. Probably the same result.

If you feel a post has answered your question, please click "Accept as Solution".
SSone.1
Associate III

Thanks for answer. Cube Programmer solved my problem.