2021-11-26 11:51 AM
Using STM32H7B3I Discovery for program development.
Using stm32h7b3i_discovery_ospi.c thus BSP_OSPI_NOR_*** functions.
Which uses mx25lm51245g.c thus MX25LM51245G_*** functions.
Which uses stm32h7xx_hal_ospi.c thus HAL_OSPI_*** functions.
Can erase reliably calling BSP_OSPI_NOR_Erase_Block.
Can read reliably calling BSP_OSPI_NOR_Read.
Can write once to a particular offset reliably calling BSP_OSPI_NOR_Write.
But cannot rewrite to same offset.
Sometimes data is partly changed, sometimes not changed at all.
Writing 16 bytes of data each time.
Is there something about rewriting data that requires special handling?
Solved! Go to Solution.
2021-11-26 03:13 PM
If you have different record types you can chain them, or use a linked list.
Generally you'd leave the cells in an erased state, 0xFF, and go back and write them later. Or knock ONE bits down to ZERO
If you need a file system, you can use UDF like one one used on CDR/DVDR media, although there are perhaps simpler ones, and ones more targeted at NOR/NAND Flash
2021-11-26 01:27 PM
Isn't writing once, or knocking down to zero, how NOR Flash normally works?
You'll either need to journal across unused/unwritten memory, or erase the sector you want to rewrite.
2021-11-26 01:37 PM
Tesla: you are providing me with a NOR flash education!
If I want to rewrite a limited section of NOR flash, can I first write all zeros [or all ones] to the area, then write the updated data?
Here is my application:
I have a section of NOR flash, which is a circular event log buffer.
I have a first record which has accounting information.
That is followed with event log entries.
If I cannot rewrite NOR flash, then I'll have to make the final record the accounting information record.
Thanks for your time.
2021-11-26 02:09 PM
You need to erase flash before you can write to the same location again. FLASH cannot be used the same as RAM. Writing 0xFF is not the same as erasing.
2021-11-26 02:24 PM
Yes, I now realize the truth.
I did an experiment: I wrote a record, read it back, all OK.
I then wrote all zeros to the same area, read it back, all zeroes.
I then wrote all ones to the same area, read it back, all still zeroes.
Thus, as you say, you can clear bits in NOR flash but you can't set them, except by erasing.
Many thanks for your time.
2021-11-26 02:24 PM
Tesla and TDK have explained what can and cannot be done with NOR flash, many thanks.
2021-11-26 03:13 PM
If you have different record types you can chain them, or use a linked list.
Generally you'd leave the cells in an erased state, 0xFF, and go back and write them later. Or knock ONE bits down to ZERO
If you need a file system, you can use UDF like one one used on CDR/DVDR media, although there are perhaps simpler ones, and ones more targeted at NOR/NAND Flash