cancel
Showing results for 
Search instead for 
Did you mean: 

Nucleo-L4r5zi - Flash Erase and Write - Dual Bank

devtty
Associate III

I had no issue writing to and erasing the banks on my nucleo a couple times but all of a sudden it started failing. I unlock the flash successfully clear flash error flags and try do a bank erase:

	FLASH_EraseInitTypeDef erase;
	erase.TypeErase = FLASH_TYPEERASE_MASSERASE;
	erase.Banks = bank_to_erase;
 
 
	if(HAL_FLASHEx_Erase(&erase, &err) != HAL_OK) {
		uint32_t retcode = HAL_FLASH_GetError();
	}

retcode gets set to 0x20000 which corresponds to PEMPTY flag. However the area (bank 2) which I try to erase is not empty when i look at it with StmCubeProgrammer. Furthermore, although I see HAL_FLASH_GetError() return 0x20000 looking at SFR for Flash in the debugger does not show PEMPTY set:0693W00000Nqfg9QAB.pngI'm not sure if OB are important here but these are my current settings:

0693W00000NqfgEQAR.pngAny pointers or ideas appreciated. Thank you.

3 REPLIES 3
Aziz BRIGUI
ST Employee

Hello @devtty​ ,

Thank you for your feedback,

I suggest checking the WRP Option Bytes .

If the write protection is disabled for bank 2, could you try to do the erase using CubeProgrammer and see if it works ?

Your response will better help us in diagnosing the issue.

Best regards,

Aziz


In order 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.

Hello thank you for the respone. Within stcube programmer here are my values:

0693W00000Nqii3QAB.png0693W00000NqiiIQAR.png 

I have done a full chip erase a couple times now.

Thanks.

Hello, are there any updates on this? Thanks!