How to reduce embedded Linux memory footprint from hundreds of MB to <32 MB?

Q: How to reduce embedded Linux memory footprint from hundreds of MB to <32 MB?

Answer

Memory reduction strategies: (1) Use Buildroot with musl libc instead of glibc (saves 5-10 MB). (2) Remove unnecessary daemons: systemd -> OpenRC or runit. (3) Strip binaries with strip –strip-unneeded. (4) Use static linking for simple utilities. (5) Disable glibc locales (locales-all is huge). (6) Compile with -Os (optimize for size). (7) Remove debug symbols: gcc -g0. (8) Use BusyBox for shell utilities instead of GNU coreutils. (9) Use shared libraries efficiently – use ldd to find unnecessary dependencies. (10) Enable MMU-less mode (no-MMU e.g. uClinux) for Cortex-M class SoCs. (11) Reduce kernel size: disable unused subsystems enable INITRAMFS_COMPRESSION. (12) Use compressed filesystem (squashfs ~50% of ext4). Typical result: minimal embedded Linux with BusyBox + musl + kernel fits in <16 MB RAM + 32 MB flash.

Filed under: FAQ

Leave a Reply

Your email address will not be published. Required fields are marked *