12 Replies Latest reply on Sep 30, 2015 5:09 PM by jota_1939431

    How does BCM20737 manage the flash?

      Hi all,

      Current we are using the Serial flash with BCM20737. After reviewing the page http://community.broadcom.com/community/wiced-smart/wiced-smart-forums/blog/2014/06/22/memory-map-explanation#comment-3251 .

      We have some question below:

      1. Since we are using SFlash, the NV should be 4k-bit area, what is the purpose for 2 area? For OTA only? (VS1 and VS2)

      2. The SFlash only guarantee the 100K rewrite ability, is there any garbage collection in the ROM code? Say, if we write an 1-byte NV item every 5 seconds. Does the byte become broken after 6 days?( 5*100000 / (60*60*24) = 5.787)

      3. If the byte become broken, does the ROM code have the bad-block check ability in NV area?

       

      Thanks.

        • 1. Re: How does BCM20737 manage the flash?
          BoonT_56

          Below is another informative thread on nvram layout

           

          WICED Smart BCM92073X EEPROM and SFLASH 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?

          • 2. Re: How does BCM20737 manage the flash?

            Hi Boont,

            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?

             

            Thanks.

            • 3. Re: How does BCM20737 manage the flash?
              MichaelF_56

              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.

              • 4. Re: How does BCM20737 manage the flash?

                Hi mwf_mmfae,

                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?

                • 5. Re: How does BCM20737 manage the flash?
                  MichaelF_56

                  We will talk to the developers later this week when we meet.

                  • 6. Re: How does BCM20737 manage the flash?

                    Hello Henry,

                     

                    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

                    JT

                    • 7. Re: How does BCM20737 manage the flash?

                      Hi JT,

                      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.)

                      • 8. Re: How does BCM20737 manage the flash?

                        Hello Henry,

                         

                        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

                        JT

                        • 9. Re: How does BCM20737 manage the flash?

                          Hi JT,

                          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.

                          • 10. Re: How does BCM20737 manage the flash?

                            Hello Henry,

                             

                            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

                            • 11. Re: How does BCM20737 manage the flash?

                              Hi JT,

                              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?)

                              • 12. Re: How does BCM20737 manage the flash?

                                Yes, Correct

                                 

                                JT