Flash Memory Size

Here’s a good tip if you’re building FluidNC manually via Platformio to take advantage of the extra space with the 8MB V1E ESP32:

Create a file called platformio_override.ini and put this as the contents:

[common_esp32_base]
board_build.partitions = FluidNC/ld/esp32/app3M_spiffs1M_8MB.csv  ; For 8Meg ESP32
board_upload.maximum_size = 8388608 ; For 8Meg ESP32
board_upload.flash_size = 8MB ; For 8Meg ESP32

This allows you to leave the existing platformio.ini alone and just override the needed values. I just did this to build and upload 3.9.0. Before, I was modifying platformio.ini and if they touched it, it caused issues when pulling the latest changes.

This works because of this in platformio.ini:

extra_configs=
    platformio_override.ini

The extra_configs parameter allows for additional configuration files which will override existing settings in the base platformio.ini file. Since this file is excluded from checkin via the gitignore file, this means that your local file won’t be overwritten.

https://docs.platformio.org/en/latest/projectconf/sections/platformio/options/generic/extra_configs.html

4 Likes

I bookmarked that for the docs.

1 Like

I just used the install package instead of the webinstaller, it looks like it autodetects the right size. Have you tried this, offhand do you know the command to check, is it $heap or something else?

1 Like

$LocalFS/Size
LocalFS Total:192.00 KB Used:148.00 KB

or

$LocalFS/List

should give you something like this at the bottom

[/littlefs/ Free:44.00 KB Used:148.00 KB Total:192.00 KB]

2 Likes

That says 192kb. But that isn’t the 4 vs 8mb stuff is it?

1 Like

yeah, the 4 MB gets split into multiple partitions, and you end up with like 200Kb of space.
image

spiffs is the part that defines the actual storage area we have access to

0x30000 is 196,608 byte, or 192KB

The 8MB also gets split similarly, and you end up with a little over 1MB

This is because you need a section of Flash for the actual program, and then an equivalent section to support OTA updates saving the firmware copy locally before replacing (or however that happens…).

My understanding is it has to do with how it allocates the memory. With the 8MB config, you get 1.77 MB.

So the default partition file that is in there for the 4MB board, give 1.875MB per partition to the program.

The default for the 8MB board gives a little over 3MB per partition.

that file could probably be edited to take down those partition sizes by about 500KB each, and that would return an extra MB back to addressable space.

You don’t want to take it down too far though, because that loses some of the benefit of the increased size allowing the actual firmware to grow if necessary.

I can’t remember offhand, but I believe we currently use between 80-85% of available disk space currently for the firmware.

However, 1.7MB of FLASH is a lot given the amount of space we currently actually use there, so it gives a lot of headroom as is.

Yes, doubling the flash gives around 9.2 times the usable space for user files, which is a HUGE increase.

So since mine say 192k even though it recognized the 8mb it did not divided it up, or put it to use?

I am not too concerned about it, I could use platformio to do it but I thought the bat files might actually be doing it. I combined all three bat files into one so it is very fast for me to prep boards now, I just use the web installer to load the V1 config files.

correct. You got 4 lonely MB hanging around in there

1 Like

So, the disk partition data and the firmware are built separately.

Once you build the larger partition file, you only have to replace that file in the download, and the scripts should layout the bigger board correctly for you, as well as use the officially built firmware…

Which you could also integrate into your wrapper script to make it easier…

1 Like

Until they order one flashed to take advantage of the extra space, then lose that space when they upgrade.

That should only happen if they choose the ‘fresh-install’ option.

If the new versions are better with OTA updates, and/or flash problems become less frequent, the disk layout shouldn’t ever have to change

2 Likes

I hope so the web installer is getting worse.

So much so I started looking at making my own version of the regular installer. That is why I combined them. I have a lot to learn yet but it seems like I might be able to manage it.

1 Like

So we can use Chrome, edge, opera. I just loaded up edge, so far so good. I have flashed and loaded up 6 boards so far without even refreshing. No issues. Chrome gives me an issue after one usually, even in incognito mode.

3.9.1 webui has a new menu option to load webui v2 or not…looks like v3 as an option is getting closer or easier at least.

WebUI? or web installer?

I see Joacim committed this yesterday, which I guess is a follow-on from this conversation

1 Like

yup, this.

1 Like

Hmm, for whatever reason I woke up in the middle of the night and then started thinking about this. I think I understand ESP32 partition tables now.

I’m pretty sure that on a 4MB ESP32, I can get 2 MB of flash storage (up from 192KB) by creating a partition table that gets rid of the secondary OTA partition. That would disable the ability to flash OTA but I’m not sure anyone does that.

I also now understand why you only get 1.77 MB with an 8MB ESP32. That partition table allocates more memory for the app which isn’t used. So, it should be possible to get 4 MB of flash keeping the OTA partition or 6MB if you get rid of it.

I’ll have to poke this after work. This would be useful given the uncertain availability around the V1 8MB ESP32s.

1 Like

That’s all correct. That’s all what I was saying up above

OTA updates were rarely used because they didn’t work. I think this is better in WebUI-3 and the later firmware versions and is a viable option now.

I would be careful about trying to squeeze too much space out the FLASH, as part of the reason for the increased space is so that the firmware can grow.

If I were going to change the partition to gain a little more space, I would be more inclined to leave the OTA partition, but just size the application and OTA partition to the same size as the 4MB partition file. That means it would always be able to fit the firmware FluidNC puts out, as long as they aren’t targeting the 8MB.

I would also be careful about trying to jam so much stuff into FLASH, as it is known to cause instability reading from it while the CNC is moving.

If it’s for other projects, then so be it, but I would be careful about pushing that idea into the broader community and risking destabilizing the CNCs.

You can order official ESP32 DevKits with 8MB as well, even after Ryan sells out, or order from his EasyEDA