This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to disable Read Out Protection with uVision and JTAG

Short version. How do I erase the option bytes on an STM10F103ZC using JTAG and Keil uVision IDE? I have tried Flash->Erase but it did not work. Details follow.
I have taken an extremely rare prototype and turned into a brick. Any help would be appreciated.

I installed and ran the following code using the Keil uVision suit on a STM10F103ZC

// configure Read protection
    Lcd_Clear();
    Lcd_WrStr("Boot Start");
    TIME_Delay(TIME_1S * 2);
    if (FLASH_GetReadOutProtectionStatus() == RESET){
      Lcd_Clear();
      Lcd_WrStr("Setting Read Prot");
      TIME_Delay (TIME_1S * 4);
      FLASH_Unlock();
      FLASH_ReadOutProtection(ENABLE);
      SCB->AIRCR = 0x05FA0004;   // send signal from Coretex core to external reset device
      while(1);                 //  stall until reset occurs. JTAG will mask this request
    } else {
      Lcd_Clear();
      Lcd_GotoXY(0,0);
      Lcd_WrStr("Read Prot On");
      TIME_Delay (TIME_1S * 4);
      while(1);
    }

I got the "boot start" message
followed by the "Setting Read Prot" message.

The chip reset and then I got "Read Prot On"

I then used chose Erase from the Flash menu on the Keil uVision IDE to bulk erase the chip. I assumed that includes the option bytes. But then when I went to reprogram so new code, I get two pop up messages boxes.

Flash Time out. Reset the device and try again
then
Error: Flash Download failed - "Cortex-M3"

I have tried adding code from a file called STM32F10xOPT.s
which I found in C:\Keil\ARM\Boards\Keil\MCBSTM32\Blinky (an example program).

But even when I install this in my project, it does not work.

I have tried adding a program algorithm for option byte memory area, but it didn't help and the Blinky example doesn't do that.

--
derik

  • I searched for hours before posting here. Then 10 minutes later I find this post and it explained what I was doing wrong.

    http://www.keil.com/forum/15489/

    The key part for me, in case it helps any one else....

    After loading the example project Blinky, you must use Project/Manage components to open a new dialog box. From there you can select "MCBSTM32+OPT" version of the project (be sure to hit the "set as target" button before you hit "ok". Inspection showed this added the programming algorithm (project options/Utilities/Settings) that I needed. I was able to erase the chip. program (download) the project. and then go back to my own project and have it work.

    That was a really scary 4 hours.

    I hope this helps someone.