-
Notifications
You must be signed in to change notification settings - Fork 3k
STM32L4: clear error programming flags before erase & program operations #8263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Flash test results with this patch for STM32L4 NUCLEO boards:
|
@@ -137,6 +137,9 @@ int32_t flash_erase_sector(flash_t *obj, uint32_t address) | |||
return -1; | |||
} | |||
|
|||
/* Clear error programming flags */ | |||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you clear all flash error, maybe you can remove next __HAL_FLASH_CLEAR_FLAG ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be OK now. FLASH_FLAG_ALL_ERRORS includes also FLASH_FLAG_OPTVERR
Need to check other STM32 families |
Any update? |
Sorry, this is "only" a reminder for my todo list |
For information, it seems that L4 FLASH driver is different from other STM32 families. |
To next patch release, please. |
/morph build |
Build : SUCCESSBuild number : 3293 Triggering tests/morph test |
Exporter Build : FAILUREBuild number : 2917 |
exporter / mbed2 build seems to have failed because of IAR license shortage - re-=running: |
Exporter Build : SUCCESSBuild number : 2919 |
Test : SUCCESSBuild number : 3099 |
Description
On STM32L486 when using dual bank operation where the program code was in bank 0 and BlockDevice in bank1 the erase and program operations would fail with Flash_error: 32.
From the reference manual: Bit 7 PGSERR: Programming sequence error Set by hardware when a write access to the Flash memory is performed by the code while PG or FSTPG have not been set previously. Set also by hardware when PROGERR, SIZERR, PGAERR, MISSERR or FASTERR is set due to a previous programming error. Cleared by writing 1.
The suggested write sequence can be found from reference: en.DM00083560.pdf 3.3.7 Flash main memory programming sequences - 2. Check and clear all error programming flags due to a previous programming.
The code change performs just that, clears the flags as per instructions. With the change it is possible to use bank 0 for running the program code while writing data to bank 1. I have tested this change on STM32L486 where OTA FW image was loaded to bank 1 and successfully updated from therein to bank 0.
Further reference: MBEDOSTEST-206
Pull request type