Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate flash and RAM size #32

Open
lars-t-hansen opened this issue Jan 19, 2023 · 2 comments
Open

Investigate flash and RAM size #32

lars-t-hansen opened this issue Jan 19, 2023 · 2 comments
Labels
ecosystem Impacting updates, fleet mgmt, cloud interaction

Comments

@lars-t-hansen
Copy link
Collaborator

Currently the firmware weighs in at 1013853 bytes flash and 48352 bytes RAM during upload (before dynamic allocation during operation). This is pretty hefty and we should look into what's going on. Especially data seems large, but this could just be eg string constants that are copied into RAM, there are a number of those, including help text for serial commands, which can be removed.

There's no need to have very stringent budgets at this time but the dev env says that the limit for flash is 1310720 bytes (0x140000), for some reason. The device has 4MB Flash, supposedly.

@lars-t-hansen
Copy link
Collaborator Author

lars-t-hansen commented Feb 28, 2023

A "production" configuration with MQTT + NTP + WEBCONFIG support; logging and serial command server disabled. Compiled with -DCORE_DEBUG_LEVEL=0 -O2.

Total Flash size 952925 bytes. Using platform.io "inspect memory" feature:

home/                        39KB  -- appears to be chip support code
users/                      569KB
  xtensa-esp32-elf           95KB -- mainly libc
  ficeto                    401KB -- esp32-idf
    tls, ip, wifi          ~250KB
    hal, freertos, drivers  ~50KB
    misc components        ~100KB
  lth
    firmware-arduino         38KB -- ie, this is SnappySense proper
    arduino                  34KB
unknown/                    161KB -- more than 1000 tiny text segments

That adds up to > 750KB. The rest is a little nebulous but corresponds closely to the figure reported for "RAM", 201KB. Anyway it's clear that the firmware proper is only about 75KB (ie, 10% of the Flash) and that the rest is "system" code, and a lot of that is the TLS/TCP/IP/WiFi stack.

(LoRa would allow us to ditch MQTT + NTP easily. But WEBCONFIG still requires WiFi, TCP/IP, and HTTP - getting rid of that probably means uploading the config to the device and storing it directly on flash. This impacts the ability to do end-user configuration but with LoRa that is really not much of a concern.)

@lars-t-hansen lars-t-hansen added the ecosystem Impacting updates, fleet mgmt, cloud interaction label Mar 8, 2023
@lars-t-hansen
Copy link
Collaborator Author

FWIW, with a stub LoRa implementation (basically zero bytes) the total code size drops to about 330KB (release build), as we exclude the entire web stack. This configuration will additionally require a small amount of code to implement i2c-based configuration (#55) and a larger and unknown amount of code to support LoRaWAN. The internet is not much help in figuring out how big the code for LoRa might be but for mbedos (presumably on ARM) there was a report of about 150KB added. That would bring us up to about 500KB for a LoRa build, which is pretty hefty for OTA-over-LoRa (while 1MB over WiFi is pretty trivial). See #26.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ecosystem Impacting updates, fleet mgmt, cloud interaction
Projects
None yet
Development

No branches or pull requests

1 participant