File size differences

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
mwalimu
Posts: 6
Joined: Sat Jul 02, 2016 5:55 pm

File size differences

Post by mwalimu » Sat Jun 26, 2021 7:11 pm

I have been experimenting with MicroPython and CircuitPython on rpi Pico. The Adafruit Pico Feather and QTPY 2040 have 8MB flash storage . In CircuitPython shows up as 7MB, but Micropython shows up as 3 MB. The Pico board has 4MB, but in Micropython storage shows up as 1.3MB.

Is this an error?

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

Re: File size differences

Post by Roberthh » Sat Jun 26, 2021 7:54 pm

For the Adafruit boards the board definition seems wrong. The are all listed wih 8 MByte flash. Maybe Adafruit changed the board specs. The Raspberry Pi Pico has 2 MB flash, at least the devices I have here. So 1.3MB is fine.

mwalimu
Posts: 6
Joined: Sat Jul 02, 2016 5:55 pm

Re: File size differences

Post by mwalimu » Sat Jun 26, 2021 10:00 pm

Circuitpython reports 7mb storage while micropython reports 3mb for the same board.

hippy
Posts: 130
Joined: Sat Feb 20, 2021 2:46 pm
Location: UK

Re: File size differences

Post by hippy » Sat Jun 26, 2021 11:46 pm

mwalimu wrote:
Sat Jun 26, 2021 7:11 pm
Is this an error?
Seems to be. Sparkfun's ThingPlus and ProMicro have a 16MB Flash chip fitted and those expose 15MB for the file system.

I don't like that one has to specify a board when building firmware; it would be much nicer if MicroPython could figure out how much Flash there was at power-up and configure itself appropriately. That would also avoid having to jump through hoops when the firmware is extended and the supposed file system size won't fit.

tannewt
Posts: 51
Joined: Thu Aug 25, 2016 2:43 am

Re: File size differences

Post by tannewt » Mon Jun 28, 2021 11:59 pm

I think the flash definition in the pico-sdk is wrong for some of the Adafruit boards. I think we've fixed it upstream. We don't use those specs in CircuitPython (we dynamically detect it, which messes up the arduino...). We were originally going to ship with 4MB flash but 8MB was in stock so we switched it at the last minute.

mwalimu
Posts: 6
Joined: Sat Jul 02, 2016 5:55 pm

Re: File size differences

Post by mwalimu » Tue Aug 03, 2021 3:43 pm

I noticed that an update was made to the github file for Adafruit's QTYPY_RP2040 where the size of the flash was increased. When I ran it, however I got this error:

[ 70%] Building C object CMakeFiles/firmware.dir/rp2_flash.c.obj
In file included from /home/chris/micropython/py/obj.h:29,
from /home/chris/micropython/py/mpstate.h:35,
from /home/chris/micropython/py/runtime.h:29,
from /home/chris/micropython/ports/rp2/rp2_flash.c:29:
/home/chris/micropython/ports/rp2/rp2_flash.c:45:1: error: static assertion failed: "MICROPY_HW_FLASH_STORAGE_BYTES too big"
45 | static_assert(MICROPY_HW_FLASH_STORAGE_BYTES <= PICO_FLASH_SIZE_BYTES, "MICROPY_HW_FLASH_STORAGE_BYTES too big");
| ^~~~~~~~~~~~~
make[3]: *** [CMakeFiles/firmware.dir/build.make:2900: CMakeFiles/firmware.dir/rp2_flash.c.obj] Error 1
make[2]: *** [CMakeFiles/Makefile2:1498: CMakeFiles/firmware.dir/all] Error 2
make[1]: *** [Makefile:84: all] Error 2
make: *** [Makefile:19: all] Error 2

Now it's too big?

hippy
Posts: 130
Joined: Sat Feb 20, 2021 2:46 pm
Location: UK

Re: File size differences

Post by hippy » Wed Aug 04, 2021 3:40 pm

mwalimu wrote:
Tue Aug 03, 2021 3:43 pm
/home/chris/micropython/ports/rp2/rp2_flash.c:45:1: error: static assertion failed: "MICROPY_HW_FLASH_STORAGE_BYTES too big"
45 | static_assert(MICROPY_HW_FLASH_STORAGE_BYTES <= PICO_FLASH_SIZE_BYTES, "MICROPY_HW_FLASH_STORAGE_BYTES too big");
| ^~~~~~~~~~~~~

Now it's too big?
Not surprising because I would expect PICO_FLASH_SIZE_BYTES to be set at 2MB, because that's what the Raspberry Pi PIco actually has. However, who knows.

~/pico/micropython/lib/pico-sdk/src/boards/include/boards/adafruit_qtpy_rp2040.h

Code: Select all

#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024)
#endif
Would seem to be correct, so presumably something, somewhere, is providing a smaller "PICO_FLASH_SIZE_BYTES" value.

The practice of naming things "Pico" when that should be a generic "RP2" with "Pico" being a sub-set of that was a nightmare waiting to happen in my view.

It's even worse when something called "Pico" means some other board entirely.

IMO that should be BOARD_FLASH_SIZE_BYTES or similar and be set in the MicroPython board definition file - Though I still favour having no board definitions at all with MicroPython figuring it out at runtime.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: File size differences

Post by jimmo » Fri Aug 06, 2021 2:12 am

hippy wrote:
Wed Aug 04, 2021 3:40 pm
The practice of naming things "Pico" when that should be a generic "RP2" with "Pico" being a sub-set of that was a nightmare waiting to happen in my view.
Yeah even rp2 is problematic because the "2" here refers to the number of cores. I don't think there's a generic name for the family of chips?

Post Reply