Below is another informative thread on nvram layout
1) Yes, for the purpose of otp fw upgrade. Check out ws_upgrade.c for more details.
I am not aware that we have such provisions in our codes for (2) and (3). What is the brand and size of your flash?
We are using Macronix MX25R1035F serial flash, which is a 1Mb bits Serial Flash. It just has "Typical 100,000 erase/program cycles" in data sheet.
If we use bleprofile_WriteNVRAM() to write a 1 byte structure, what will happen? The ROM code just erase the 4KB sector each time or it will mark the place as garbage and write the other place in NV area? If not, how do you guarantee the NV item can be kept for a long time?
For example, we are using deep sleep and wakeup every 5 second for advertising. Since we need to record the advertising times, so each time wakeup will cause at least an NV write for the data. By the limitation of 100K erase/program cycles, the flash will be broken after 6 days if the NV write address is an absolute flash address, right?
There are two forms of Flash Memory cell architecture: NAND and NOR.
For NAND Flash, the SW/Controller of the NAND is expected to handle tasks such as bit error correction, bad block handling, and wear leveling.
However, on NOR flash like the Macronix MX25R1035F http://www.macronix.com/en-us/Support/CrossReferenceSearch/Documents/NOR_and_NAND_Flash_CRG.pdf, these aspects are all handled onboard the NOR flash itself.
I believe Macronix would be the right party to direct these forms of specificWear Leveling questions.
You are right but we just want to ask the ROM code in BCM20737, if we write the same structure through bleprofile_WriteNVRAM(), what is the detail actions for flash the ROM code will do?
Erase whole sector and rewrite all NVs? Or else?
We will talk to the developers later this week when we meet.
1. The VS1 and VS2 are only used for Consolidation or Defragmentation
2. VS is never updated during OTA Upgrade
3. Yes there is garbage collection in the ROM Code - That is the purpose of VS2 - for consolidation
4. Writing every 5 seconds is a bad idea.
Hope this helps
Thanks for replying.
1. We know writing every 5 seconds is a bad idea, we just want to test the worst case.
2. For our product, we are using deep sleep, normally timed wakeup for advertising every 10 minutes.
3. We need a 4 bytes sequence number in the advertising data, but since #2, we need to record the sequence number in NVRAM before going to sleep for next increment.
If there is no garbage collection, the flash sector will become unavailable after 50Kth rewriting. (Program count 1, erase count 1). For 10 minutes period it just works for about 347days(aka almost a year.). It's not enough for our product life cycle. We hope it can keep alive longer.
So here now our question is, since the ROM code has the garbage collection, what is the estimate times the 4 bytes NV can be written? (Assume we just have these 4-bytes data as NV item.)
Here is the math:
1. If you assume 4 bytes, then you always write a page which is 32 bytes
2. If you assume VS is 4K - 4096 - How many pages can you R/W
3. So, 4096/32 pages for a single R/W, so before a single R/W it is 128 times
4. Now, multiplied by 50,000, because of Garbage collection and then a Write
5. So you can do this 6,400 times doing every 10 minutes,
6. 64000/60 minutes = 1066 hours/24....
7. You can double it by allocating 8K or 16K for VS
8. So if you want to achieve 10 minutes, you will need to think of another procedure.
Hope this helps
I think there is a mistake in your step #5.
1. After multiplied by 50,000, we can do 6,400,000 times for every 10 minutes update the single value.
2. 64,000,000/60 minutes = 1,066,666.67 hours /24 = 44,444.44 days /365 = 121.77 years
I think it is enough for our product life cycle, even if some crazy test like update every 6 seconds, the flash still can keep alive for 1.2 year.
It's just like what I guess before asking you about the garbage collection of ROM code.
Here is another thing I need to confirm with you:
In #1, the page unit is base on 32 bytes data content.
Is this means, the times calculation result are the same if we write 32 bytes data every 10 minutes?
Thanks for the correction - tried to do the math in my head
We have a 3 byte header so we actually have 29 bytes.
So if you write 32bytes, then that will take 2 pages
Hope this helps
So the 4-bytes data structure has the same write/erase consumption with 29-bytes structure, right?
(aka both of them used 1 page as a garbage collection unit, right?)