https://toitlang.org/ logo
🛠 Remaining memory
# help
a
Is there a way to get feedback on how much space is still available (taking into account a safety margin for operation if possible)? I haven't found anything other than the amount of KB the program is taking up. https://cdn.discordapp.com/attachments/1366439943345274940/1366439943555121262/image.png?ex=6810f3dd&is=680fa25d&hm=0c882cac6da12ad00bf59b57eb29c90b16678ebedd06d0618ca825d26c463327&
f
This space is the flash on the device. You typically want to look at the partition table to know how much space you have for the OTA image, and then for the installed apps.
This is the default partition table when using Jaguar. https://github.com/toitlang/toit/blob/master/toolchains/esp32/partitions.csv
Note that partition tables can not be updated OTA (except with some hacks). So choosing the correct one when flashing is important.
The correct partition table depends a lot on your use case.
If you bundle your programs with the system, then having a bigger ota_0 and ota_1 is important (which is why Artemis uses the
partitions-esp32-ota-1c0000.csv
by default (an asset of the envelopes repository https://github.com/toitlang/envelopes/releases/tag/v2.0.0-alpha.179)
Jaguar, on the other hand, writes programs into the
programs
partition, and thus doesn't need a bigger `ota_0`/`ota_1` partition.
If you store data (sensor values...) in flash, you might have additional constraints.
In addition, the system firmware's size can vary a lot depending on the features that are enabled. For example, the
no-ble
(without Bluetooth) envelope will use less space than one that includes BLE.
And to answer your actual question: I think Jaguar doesn't have a way to know the size of installed programs yet.
The default
programs
partition is 655360 bytes.
That said: normally you don't want to ship programs with Jaguar, but with Artemis (or your own OTA solution). So for Jaguar I wouldn't worry for the size yet.
Things only get interesting when you switch from Jaguar to your deployement solution.
a
I use Jag directly, but it's mainly to know how close I am to the limit ^^ I saw the story of the no-ble, I'll keep that in mind if I'm ever on the edge, thank you. I thought Artemis would take up more memory, and I don't need it. Once my program is complete, I won't be touching it again for a long time. My current use is for my home automation via MQTT, since I use Zigbee2MQTT. Currently, I control the devices in my bedroom with an IKEA STYRBAR switch. But eventually, if there's no lag and enough memory, I'll install all the switches in the house. I'd find it amusing to know that the whole house is controlled by such a small device 🤣
My code will be released on GitHub if I find it sufficiently complete, and I'll post the link here if anyone is interested. I'm trying to do this as cleanly as possible using classes 😁
f
I wouldn't worry about the size just yet. You have 4MB of flash, and there are many knobs to tune the system. However, the partition table is pretty much the only thing you can't change OTA, so before you put your device in an inaccessible location you need to think about the correct partition table.
I have a few shelly devices inside my light switches, and I really don't want to take them out again.
In that case I made sure that I have a partition table that allows me to grow the system over time.
Off-topic: I would avoid the term "memory" when referring to flash, as "memory" is usually used for the RAM.
a
I understand, but my ESP will be directly in my home automation bay and therefore accessible even for reprogramming (everything goes through MQTT), via a simple USB cable. For the term I understand, so the appropriate term would be "flash memory"?
f
Or just "flash".
If you have easy access to your device, don't worry about program size. You will be able to fix things if you really run into size issues.