Closed gojimmypi closed 4 months ago
@gojimmypi
Is there any particular reason the flash is [limited to 1MB] -> Future implementation of LCM, and a small footprint as posible, so it can be used on "any" ESP32 module.
@gojimmypi
FAILED: esp-idf/esptool_py/CMakeFiles/app_check_size /project/examples/led/build/esp-idf/esptool_py/CMakeFiles/app_check_size
cd /project/examples/led/build/esp-idf/esptool_py && /opt/esp/python_env/idf5.4_py3.10_env/bin/python /opt/esp/idf/components/partition_table/check_sizes.py --offset 0x8000 partition --type app /project/examples/led/build/partition_table/partition-table.bin /project/examples/led/build/main.bin
Error: app partition is too small for binary main.bin size 0x101d90:
- Part 'factory' 0/0 @ 0x10000 size 0x100000 (overflow 0x1d90)
ninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the /project/examples/led/build/log/idf_py_stderr_output_9436 and /project/examples/led/build/log/idf_py_stdout_output_9436
root@372ae019b7c0:/project/examples/led#
a small footprint as possible, so it can be used on "any" ESP32 module
Yes, I completely agree that working on any module is important. Are you aware of modules with only 1MB of flash? The docs indicate that most chips with built-in flash have at least 4MB:
Even your link to LCM mentions "Cheap ESP32 devices have only 2 or 4 Mbyte of flash"
The smallest I could find (other than zero) on the production selection page is 2MB. So unless doing a dual partition for OTA, it seems unlikely that someone has a device with only 1MB, no?
For the zero chips where someone adds their own, I wonder how many people would actually choose less than 2MB, when the SoC is available with that? I'd expect most people to be adding more flash.
I'm happy to set the defaults all to disable hardware encryption to save space, but it seems like a broad penalty for a corner case given all the chips with substantially more flash.
Perhaps there's a way to set conditional defaults, based on the flash configuration?
In any case, if you run idf.py menuconfig
and disable all of the hardware acceleration for wolfSSL, does it fit into your 1MB? Compiled for me with ESP-IDF, I still have 1% flash free for a 1MB partition.
@gojimmypi Your points are well taken regarding the flash memory capacity of ESP32 modules. Indeed, the majority of ESP32 modules on the market come with at least 2MB or 4MB of flash memory. The documentation and general market availability seem to support this, making a module with only 1MB of flash quite rare.
I also have to look into LCM's partitions setup...
@gojimmypi There is some room when using LCM with a 4 MB module:
partition
Hexadecimal: 0x1000
Decimal: 4096 bytes
Megabytes: 40961048576≈0.0039062510485764096≈0.00390625 MB
otadata
Hexadecimal: 0x2000
Decimal: 8192 bytes
Megabytes: 81921048576≈0.007812510485768192≈0.0078125 MB
phy_init
Hexadecimal: 0xb000
Decimal: 45056 bytes
Megabytes: 450561048576≈0.04296875104857645056≈0.04296875 MB
lcmcert_1
Hexadecimal: 0xc000
Decimal: 49152 bytes
Megabytes: 491521048576≈0.046875104857649152≈0.046875 MB
lcmcert_2
Hexadecimal: 0xd000
Decimal: 53248 bytes
Megabytes: 532481048576≈0.05078125104857653248≈0.05078125 MB
nvs
Hexadecimal: 0x11000
Decimal: 69632 bytes
Megabytes: 696321048576≈0.06640625104857669632≈0.06640625 MB
homekit
Hexadecimal: 0x1000
Decimal: 4096 bytes
Megabytes: 40961048576≈0.0039062510485764096≈0.00390625 MB
ota_1
Hexadecimal: 0xd0000
Decimal: 851968 bytes
Megabytes: 8519681048576≈0.81251048576851968≈0.8125 MB
ota_0
Hexadecimal: 0x310000
Decimal: 3211264 bytes
Megabytes: 32112641048576≈3.062510485763211264≈3.0625 MB
To summarize:
partition: 0.00390625 MB
otadata: 0.0078125 MB
phy_init: 0.04296875 MB
lcmcert_1: 0.046875 MB
lcmcert_2: 0.05078125 MB
nvs: 0.06640625 MB
homekit: 0.00390625 MB
ota_1: 0.8125 MB
ota_0: 3.0625 MB
So when setting up the OTA partitions sizes as follwing should work, wil try it lateron after work.
Convert 1.5 MB to bytes:
1.5×1048576=15728641.5×1048576=1572864 bytes
Convert 1572864 bytes to hexadecimal:
157286410=0x180000157286410=0x180000
Now update the partition table with the new size:
# ESP-IDF Partition Table for ESP32
# Name, Type, SubType, Offset, Size, Flags
# partition table 0x8000, 0x1000,
otadata, data, ota, 0x9000, 0x2000,
phy_init, data, phy, 0xb000, 0x1000,
lcmcert_1, 0x65, 0x18, 0xc000, 0x1000,
lcmcert_2, 0x65, 0x18, 0xd000, 0x1000,
nvs, data, nvs, 0xe000, 0x11000,
homekit, data, homekit, 0x1f000, 0x1000,
ota_1, app, ota_1, 0x20000, 0x180000,
ota_0, app, ota_0, 0x1a0000, 0x310000,
Note that the offset of ota_0 has been adjusted to start after ota_1:
ota_1 now starts at 0x20000 and has a size of 0x180000 (1.5 MB).
The new offset for ota_0 is calculated by adding the offset and size of ota_1: 0x20000+0x180000=0x1a00000x20000+0x180000=0x1a0000.
@gojimmypi made some more changes, with succes!
# Name, Type, SubType, Offset, Size, Flags
# partition table 0x8000, 0x1000,
otadata, data, ota, 0x9000, 0x2000,
phy_init, data, phy, 0xb000, 0x1000,
lcmcert_1, 0x65, 0x18, 0xc000, 0x1000,
lcmcert_2, 0x65, 0x18, 0xd000, 0x1000,
nvs, data, nvs, 0xe000, 0x11000,
homekit, data, homekit, 0x1f000, 0x1000,
ota_1, app, ota_1, 0x20000, 0x140000,
ota_0, app, ota_0, 0x160000, 0x240000,
So problem solved.
This PR needs https://github.com/AchimPieters/esp32-homekit/pull/1 (adding support for renamed wolfssl component called
mywolfssl
in the staging instance).https://components-staging.espressif.com/components/gojimmypi/mywolfssl
Note the menuconfig has options to disable hardware acceleration (saving flash space at the penalty of performance)
Is there any particular reason the the flash is limited to 1MB?