Custom size erase of Internal Flash or Override of existing data for STM32U585 series Internal flash
I am working with an STM32U585 microcontroller, and I need to perform read, write, and erase operations on the internal flash memory (Bank 1) with TrustZone security enabled. The page size is 8 KB, and I am encountering an issue when trying to write data.
Problem Overview:
- When attempting to write data to flash without erasing, the write operation fails.
- If I erase the entire 8 KB page and then write, the operation is successful.
- However, my requirement is to write smaller amounts of data (e.g. 4 bytes) without erasing the remaining (8 KB - 4 bytes) bytes of the page. I only need to erase the specific location that will be written to, not the whole page, to avoid erasing other data within the same page.
Current Findings:
- The flash memory only allows erasing entire pages, so when I need to erase a small portion, it results in the entire 8 KB page being erased, which is not ideal for my use case.
Questions:
- Is there any way to perform a partial erase in STM32U585 internal flash, specifically for small data sizes like 32 bytes or 4 bytes?
- Can I limit the erase operation to a smaller portion of the page, while preserving the other data within that same page?
- Are there specific functions or approaches that allow for targeted erasing of a section within a larger flash page without erasing the entire page?
- and last but not least, Is it possible to override those 4 bytes of data by new data so that we can achieve the requirement without erasing previously existing data.
I would appreciate any guidance, tips, or best practices that you can share to achieve partial page erasure in the STM32U575 microcontroller.
Thank you for your assistance!
