cancel
Showing results for 
Search instead for 
Did you mean: 

f407 read/write flash error

jimmjimmshen
Associate III
Posted on November 13, 2013 at 11:03

i use my own board and try to use SD card to update IAP when i try to erase/write flash the function always return ''flash_error_program''

i checked flash->sr value is 0xC0, but i just follow the step with stm32f4_iap_using_usart program which download from st.com

and i try to run this code without otherthings the same problem occur

                FLASH_Unlock();        

                FLASH_ClearFlag(FLASH_FLAG_PGSERR | FLASH_FLAG_PGPERR |   FLASH_FLAG_PGAERR | FLASH_FLAG_WRPERR |    FLASH_FLAG_OPERR | FLASH_FLAG_EOP);        

                FLASH_OB_Unlock();

                FLASH_OB_WRPConfig(OB_WRP_Sector_4, DISABLE);

                FLASH_OB_WRPConfig(OB_WRP_Sector_5, DISABLE);

                FLASH_OB_WRPConfig(OB_WRP_Sector_6, DISABLE);

                FLASH_OB_WRPConfig(OB_WRP_Sector_7, DISABLE);

                

                FLASH_EraseSector(FLASH_Sector_4,VoltageRange_3);

                FLASH_EraseSector(FLASH_Sector_5,VoltageRange_3);

                FLASH_EraseSector(FLASH_Sector_6,VoltageRange_3);

                FLASH_EraseSector(FLASH_Sector_7,VoltageRange_3);

every function return flash_error_program status

i really dont understand why this happen

my chips is stm32f407ze

please somebody help

update:i try to use stm32f4_iap_using_usart staff on my board and i comment all usart things which my board didnt use, when i run to erase function the same problem occur, it return flash_error_program again. is it hardware problem? but i tried 2 boards, it always same 

update2: found where the problem is. when i change the data of flash register like when i call flash_unlock() the flash->ack didnt change same as clear flag so the sr didnt be clear that the problem occur.

still confuse what makes this problem

update3: i found i make a mistake i cant read the flash->keyr, the flash_unlock works fine the flash has been unlock when i check flash->cr, i found where the problem is i can clear flag manually on keil debug view but when i run any step of my code the PGPERR and PGSERR back to high. It should be set by hardware but i didnt run any code

4 REPLIES 4
Amel NASRI
ST Employee
Posted on November 14, 2013 at 12:00

Did you tried to use the ST-Link Utility tool for Flash erase?

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

jimmjimmshen
Associate III
Posted on November 15, 2013 at 02:22

Nope, i dont have stlink but i use Jlink to erase/download program on flash all work

Posted on November 15, 2013 at 03:42

Wouldn't you need to FLASH_OB_Launch() to commit the changes of the Option Bytes, prior to doing an erase?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jimmjimmshen
Associate III
Posted on November 15, 2013 at 03:50

i tried but still not work