Bad flash writes with v1.5.1 (increased power usage???)

spants
Posts: 1
Joined: Wed Apr 06, 2016 6:10 pm

Re: Bad flash writes with v1.5.1 (increased power usage???)

Postby spants » Wed Apr 06, 2016 6:12 pm

Also having the same issue. With 50 devices worldwide that use OTA, this is a big problem for me.
Tony

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: Bad flash writes with v1.5.1 (increased power usage???)

Postby ESP_Faye » Wed Apr 06, 2016 6:30 pm

Hi,

In your reboot-ota.c, flash_write_flash function

Code: Select all

   if (len > SECTOR_SIZE) {
      // to support larger writes we would need to erase current
      // (if not already done), next and possibly later sectors too
   } else {
      // check if the sector the write finishes in has been erased yet,
      // this is fine as long as data len < sector size
      if (status->last_sector_erased != (status->start_addr + len) / SECTOR_SIZE) {
         status->last_sector_erased = (status->start_addr + len) / SECTOR_SIZE;
         spi_flash_erase_sector(status->last_sector_erased);
      }
   }


You need to deal with the situation that "len > SECTOR_SIZE", otherwise, it will cause the problem.

rab
Posts: 8
Joined: Fri Apr 17, 2015 7:00 pm

Re: Bad flash writes with v1.5.1 (increased power usage???)

Postby rab » Wed Apr 06, 2016 9:28 pm

Oh wow, that's a little embarrassing. Of course I was aware of that limitation, I wrote the comment in the code afterall, but I didn't think this situation could ever occur! I had never seen packets of data arrive longer than about mid 1400s previously. I assumed these were limited to the MSS, or something similar, which would always be much smaller than the 4k sector size. Since you suggested looking at this I've done some more detailed testing in this area and found an occasional packet of 5744 arrive with SDK v1.5.2. Is this a new increased limit? Or has something just changed the timing in the SDK which allows a few packets to build up occasionally? Interestingly 5744 is still the only other size I have seen, after my previous max of 1436 - no other values have occurred yet.

To test further I created interference at the RF level to try and affect the internal working of the receive and was successful in causing these large packets to occur more frequently (still all 5744 though, odd!). This allowed me to confirm the problem and the fix.

Thank you very much for your help. I'll update rBoot and get some users to test it for real. If you can shed some light on why it's just started happening after v1.5.1 and a bit more on the inner workings of the network stack that would be interesting.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: Bad flash writes with v1.5.1 (increased power usage???)

Postby ESP_Faye » Thu Apr 07, 2016 3:16 pm

Hi,

The TCP window is 4 x MSS = 4 x 1460 = 5840 > 4096 (Sector size).
So the received data length may be larger than the sector size.

Thanks for your interest in ESP8266 !

rab
Posts: 8
Joined: Fri Apr 17, 2015 7:00 pm

Re: Bad flash writes with v1.5.1 (increased power usage???)

Postby rab » Sat Apr 09, 2016 5:22 pm

Thank you, useful to know what the maximum could be.

scargill
Posts: 70
Joined: Sun Nov 02, 2014 8:09 pm

Re: Bad flash writes with v1.5.1 (increased power usage???)

Postby scargill » Wed Jul 19, 2017 7:15 am

I don't have a flash_write_flash function... I have an rboot-ota.c rboot_write_flash function - I'm still (SDK 2.1.0) getting occasional E:M 5600 or thereabouts messages which mess up the OTA which of course makes RBOOT's OTA code fail...

Any ideas? I can't see a fix incorporated anywhere.

Who is online

Users browsing this forum: No registered users and 64 guests