flashbdev and flash size

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

flashbdev and flash size

Post by devnull » Tue Jun 13, 2017 2:36 am

in flashbdev, the flash size appears to be hard-coded to 512MB:

Code: Select all

(2048 * 1024) / 4096 = 512MB
But given that devices have different size flash, can this be calculated automagically ?

As the esp32 wroom and esp32-thing both 4MB of flash space, how much can I safely define ?

If I correctly understand, this would be 2MB ?

Code: Select all

SEC_SIZE = 4096
MB1 = 2   ## Megabytes
bdev = FlashBdev(((MB1 * 4096) * 1024) // FlashBdev.SEC_SIZE)
When I perform this calc using micropython console, the result is 2MB:

Code: Select all

>>> MB1 = 2   ## Megabytes
>>> SEC_SIZE = 4096
>>> ((MB1 * 4096) * 1024) // SEC_SIZE
2048
>>> 
However, after building and flashing the device, the flash size is actually 8MB ??

Code: Select all

>>> import os
>>> s = os.statvfs('//')
>>> ('{0} MB'.format((s[0]*s[3])/1048576))
'7.972656 MB'
>>> 


User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: flashbdev and flash size

Post by devnull » Tue Jun 13, 2017 4:58 am

Well I am a little confused over the built-in flash size for the ESP32-WROOM.

I thought it was 4MB, however during erase flash, it takes less than half the time to erase (4 secs) than the esp32 thing takes (10 secs) ?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: flashbdev and flash size

Post by Roberthh » Tue Jun 13, 2017 5:03 am

In flashbdev.py, the size is hard coded to 2 MByte.
(2048 * 1024) / 4096 = 512 is the number of blocks of 4k each, not MBytes, and that's to be told to FlashBdev()
In the flashbdev.py version here viewtopic.php?f=12&t=3456 the size is calculated from the flash size, like it#s been done on the esp8266.

Post Reply