cancel
Showing results for 
Search instead for 
Did you mean: 

How to programming ROP option byte via swim?

yskim2
Associate II
Posted on March 17, 2011 at 04:09

How to programming ROP option byte via swim?

#programmer #stm8
5 REPLIES 5
brazov22
Associate II
Posted on May 17, 2011 at 15:12

to write on option byte area you need to set7reset bit 7 of FLASH_CR2/FLASH_NCR2 register. Remenber to enter keys on FLASH_DUKR register before.

If ROP is activated, remove it writing 00h on 4800h then reprogram option bytes as you prefer. Note that removing ROP, whole program memory is erased.

brazov2

yskim2
Associate II
Posted on May 17, 2011 at 15:12

Thanks Mr brazov.

I Solved this problem

STM8L15x devices are some different than others.

My code is below.

  swim_enter();

  delay_10xus(Time_us(10000));

  icp_eeprom_unlock();

  

  swim_write_register(STM8_FLASH_CR2, (STM8_FLASH_CR2_ERASE)); 

  swim_write_register(0x4800, 0x00);

  

  delay_10xus(Time_us(6000));

   

  swim_write_register(STM8_FLASH_CR2, (STM8_FLASH_CR2_OPT));

  swim_write_register(0x4800, 0xAA);

Thanks a lot..

ajacobo
Associate
Posted on May 17, 2011 at 15:12

Hi Kim yongsu,

Please could I have a copy of your code, I am trying to make my own programmer but I cannot make it yet, I would like to know if you can share your code to implement it in my programmer.

Thank you very much

ncliv2001
Associate
Posted on May 17, 2011 at 15:12

Hello,

Do you have any schematic for such a STM8 programmer? I'd like to build one for me.

Thanks

pripoy08
Associate
Posted on October 18, 2013 at 12:00

Hello!

Help please!

STM8S003F3

The sequence of operations Read out protection ENABLED

''

write_Byte(FLASH_DUKR,0xAE);

  write_Byte(FLASH_DUKR,0x56);

write_Byte(FLASH_CR2,0x80); 

    write_Byte(FLASH_NCR2,0x7F);

uint32_t time_set = 3000;

    while(time_set-- != 0)

    {

      if(read_Byte(FLASH_IAPSR)&(1<<3))

      {

        wait_time(2000);

        write_Byte(OPTION_BYTE,0xAA);

      }

    }

''

Upon reboot, the MC, reading OPTION_BYTE returns 0xAA,

after the restart, reading OPTION_BYTE and the Flash returns 0x71

The sequence of operations Read Out Protection DISABLED

''

write_Byte(FLASH_DUKR,0xAE);

  write_Byte(FLASH_DUKR,0x56);

write_Byte(FLASH_CR2,0x80); 

    write_Byte(FLASH_NCR2,0x7F);

uint32_t time_set = 3000;

    while(time_set-- != 0)

    {

      if(read_Byte(FLASH_IAPSR)&(1<<3))

      {

        wait_time(2000);

        write_Byte(OPTION_BYTE,0x00);

      }

    }

''

After recording OPTION_BYTE MC stop responding to any action. SWIM interface does not work.