-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
flash sector erase fails on stm32f412 #18263
Comments
@erwango could you take over this, or re-assign if needed? |
@StefJar could you send up a PR if you already have a fix for that? |
This fix only addresses the stm32f4 part of the stm32 flash driver. Think @erwango needs to check the other stm MCUs. |
@StefJar, well is that a bug actually? This should rather be an enhancement. |
@StefJar the bootloader that you are using is the mcuboot? I'm having a similar problem when I swap images between slot0 and slot1 with mcuboot. My board is nucleo_f091rc. My error is a HARD FAULT like the one below:
I realized that my problem is when the mcuboot calls the flash_write_protection_set function that is inside both flash_area_erase and flash_area_write functions. I created a blank project with these statements in the main and I didn't get errors.
So I realized that the problem is just when I'm trying to manipulate(write/erase) flash in the mcuboot project. If you are using mcuboot, where it is setting the FLASH_OPTCR register? Maybe something similar is happening to me. |
Priority? |
@lucaspeixotot I don't use mcuboot. I have a "beautiful" in company written legacy bootloader that I need to deal with. |
I think that my problem is different. Today I realized that the hard fault occurs when the semaphore in flash_write_protection_set function is being given. What is curious is that this driver works properly in other projects than are not mcuboot. |
Since optcr is not supported (so not modified) within zephyr driver, there is no bug here but a compatibility issue with an eternal component. |
Looking to it more in detail, I don't think requested modification would even be an enhancement that would be acceptable in flash driver. |
after discussing it with @erwango we decided to close this issue. Key points for not merging the proposed commit workaround to the stm32 flash driver: I put the code to a git repro. so everyone can use this as a blueprint for similar problems. |
Hi @erwango and @StefJar, I am facing a similary problem with my disco_l475_iot1 board which has stm32l475 MCU. I am using mcuboot for updatehub app. flash_write_protection_set works fine but flash_erase() is not successful. I checked carefully all the partition sizes they are perfectly according to DTS file. Now I tried to see OPTCR register but could not find it. could you please suggest a workout or solution to this issue. thanks Tahir |
@mtahirbutt, please raise a new issue and explain your problem. |
Hi @erwango, I tried flash_shell command and tried to erase partitions. it returns here with -5 again. similar problem as that with updatehub. |
I running my zephyr based firmware. Before it is run a boot loader selects the firmware image. This bootloader sets the FLASH_OPTCR register. All sectors are disabled for writing(erasing).
using
flash_write_protection_set
function doesn't fail when enabling writing - but afterflash_erase
fails because of the FLASH_OPTCR bootloader preset.The current problem with the stm32 flash driver is, that it assumes that its runs after a reset.
I done a fix for the stm32f4xxx code. It's below:
Think all the other stm32 flash driver implementations may need some attention.
The text was updated successfully, but these errors were encountered: