Confused by nor-flash page writes - Page 1
Forum section: electronics / projects

author: davidb
author_rank: Contributor
timestamp: December 07, 2021, 08:01:22 am
content: I have a project where I'm storing data on a MT25QL01GBBB8ESF-0SIT nor-flash memory chip. Datasheet:https://media.digikey.com/pdf/Data%20Sheets/Micron%20Technology%20Inc%20PDFs/MT25QL01GBBB.pdfOn page 60, it says this about writing to it.QuoteEach page is 256 bytes, so they start on every 256 byte boundary (ie, 0x00, 0x100, 0x200, 0x300, 0xDEADBE00, etc)That makes it sound like if I start writing at one of those boundaries (like 0x100), I can write more than 256 bytes, and it will continue sequentially through the memory.Or, if I start somewhere within a page (ie, 0x115), and write more than the remaining bytes in the page, it will wrap around and start writing at 0x100.But, I'm not seeing that in practice? One of the things I'm storing is a ~1k data structure with some variables (with a checksum), and if I start the write at the start of a page, or the middle, it writes all of the data sequentially with no apparent wrapping.If I do a smaller write over a page boundary, it doesn't wrap either.I'm also logging data, and each data log is 32 bytes long, with a header indicating this record is used. In the same write, I actually write 33 bytes, with byte 33 being a "magic" value, indicating that is the next open spot. Then when the next data record is written, it ANDs the magic byte to make the new header, showing that it's used. A quick binary search on power up finds the magic byte, and thus the next open record. But, writing 33 bytes puts it over the 256 byte page boundary (on every 8th write), and I don't want to rely on it if the datasheet says not to do it.I'm just confused why doing everything wrong seems to work

author: ace1903
author_rank: Regular Contributor
timestamp: December 07, 2021, 08:13:47 am
content: By default memory from factory is in erased state. That is why your test pass ok.There is no address wrapping. Simply writing continues in next page.If you try to write new content over that that is already written you will get errors(only if new content has more bit zeros than older one).If you want to write new content over old one you need to erase old one first. And here page size matters.You can not erase one byte and write new data over it. Smallest chunk is one page.If you want to change only one byte for example you need to read whole page then erase page and after you need to store back modified data.

author: davidb
author_rank: Contributor
timestamp: December 07, 2021, 06:07:45 pm
content: Quote from: ace1903 on December 07, 2021, 08:13:47 amComments in bold.Quote

author: davidb
author_rank: Contributor
timestamp: December 29, 2021, 06:52:49 pm
content: Bump.Anyone else have any idea why writing across a page boundary does not loop, like the datasheet says it should?

author: amyk
author_rank: Super Contributor
timestamp: December 29, 2021, 10:21:56 pm
content: What is the actual sequence of commands you're sending to it?

author: davidb
author_rank: Contributor
timestamp: December 30, 2021, 06:31:44 am
content: Quote from: amyk on December 29, 2021, 10:21:56 pmSo I started to look into this... and I must apologize because apparently I'm a moronThe project included a driver file that handles the reads and writes... Including checking for page boundaries and breaking them into multiple writes, so it avoids the wrapping issue. Sooooo, my higher-level code doesn't need to worry about it, since the lower level stuff handles it. Lesson learned: look at everything, all the way down. Don't get preoccupied with the higher-level code that you miss the lower level stuff.At least I can sleep well now

author: amyk
author_rank: Super Contributor
timestamp: December 30, 2021, 10:32:18 pm
content: Abstraction strikes again.