Skip to main content
mn_it
Associate II
May 28, 2015
Question

STM32F103, erase a function that define in spesial section

  • May 28, 2015
  • 3 replies
  • 907 views
Posted on May 28, 2015 at 11:13

hi

in my software, define a section named ''My_SECTION'' and put just a function on it.

in IAR .icf file define that section write in address 0x08050000.

I used debugger, function is correctly wrote in 0x08050000 and has 16 byte length. All other functions are wrote from address 0x08003000.

when MCU power on , In main() function, I want to erase function that wrote in address 0x08050000. when erase page at address

0x08050000, page doesn't erase, but if erase just page after or before that, it is erase correctly . I think pages that programed, is locked.

Is it possible to erase a page that some of execution code write on it?

#flash #stm32f103 #erase
This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
May 28, 2015
Posted on May 28, 2015 at 16:04

Should erase the same way any other sector.

You'd want to double check if you have write protected any of the sectors, and that you are correctly unlocking, and clearing pending status.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
mn_it
mn_itAuthor
Associate II
May 30, 2015
Posted on May 30, 2015 at 05:51

my erase function:

    FLASH_Unlock();

    delay_us(100);    

    FLASHStatus = FLASH_ErasePage(PgAdd);

-----

this code execute from flash memory and correctly erase pages 0x08050800 and 0x0804f800;

mn_it
mn_itAuthor
Associate II
May 30, 2015
Posted on May 30, 2015 at 11:39

OK, thanks clive1.

when i use this code:

    FlashRead((uint32_t)(0x08050000),SecSize,Buffer_In);

    FLASH_Unlock();

    FLASH_ErasePage(0x50000);

    FlashRead((uint32_t)(0x08050000),SecSize,Buffer_Out);

//-----------------

Buffer_Out equal Buffer_In, page does not erase.

but when use below code page

erase correctly

:

    FlashRead((uint32_t)(0x08050000),SecSize,Buffer_In);

    FLASH_Unlock();

    FLASH_ErasePage(0x50000);

    FLASH_Lock();  // difference

with above code.

    FlashRead((uint32_t)(0x08050000),SecSize,Buffer_Out);

//------------