19
\$\begingroup\$

I like to ask to the experts out there.. What is the best embedded linux distro for:

  • Flash memory ~ 700Kb
  • Ram ~ 256Kb
  • Processor: High end arm cortex M3 (something from STM32 family for eg)

Required modules: - Kernel core - Basic driver set: USB/Networking (for WiFi - No AP, just client, no security)/SPI/Uart/I2C

Is this at all possible or am I dreaming?

The idea is to use a 5$ high end CortexM3 and don't use any external memories so that I can enjoy the ready drivers for SDIO/WiFi etc.

  • I updated the question with clarification on WiFi. WiFi in the sense that it is a simple, run of the mill client. Nothing fancy, perhaps wep if I can fit it.

  • Another update: How about uCLinux?

\$\endgroup\$
26
\$\begingroup\$

I'd say you're dreaming. The main problem will be the limited RAM.

In 2004, Eric Beiderman managed to get a kernel booting with 2.5MB of RAM, with a lot of functionality removed.

However, that was on x86, and you're talking about ARM. So I tried to build the smallest possible ARM kernel, for the 'versatile' platform (one of the simplest). I turned off all configurable options, including the ones that you're looking for (USB, WiFi, SPI, I2C), to see how small it would get. Now, I'm just referring to the kernel here, and this does not include any userspace components.

The good news: it will fit in your flash. The resulting zImage is 383204 bytes.

The bad news: with 256kB of RAM, it won't be able to boot:

$ size obj/vmlinux
  text     data     bss     dec     hex filename
734580    51360   14944  800884   c3874 obj/vmlinux

The .text segment is bigger than your available RAM, so the kernel can't decompress, let alone allocate memory to boot, let alone run anything useful.

One workaround would be to use the execute-in-place support (CONFIG_XIP), if your system supports that (ie, it can fetch instructions directly from Flash). However, that means your kernel needs to fit uncompressed in flash, and 734kB > 700kB. Also, the .data and .bss sections total 66kB, leaving abut 190kB for everything else (ie, all dynamically-allocated data structures in the kernel).

That's just the kernel. Without the drivers you need, or any userspace.

So, yes, you're going to need a bit more RAM.

\$\endgroup\$
  • 1
    \$\begingroup\$ Great answer.. I am surprised to see that the bare linux kernel is this heavy.. I have sort of a follow up question.. Is there any wrappers out there that allows me to use linux drivers with other OS'es? What I like about Linux is the driver availability.. Every single hardware I touch has a linux driver and it is always pain to port these, the only reason I am interested in Linux is the drivers really, hence the question. \$\endgroup\$ – Frank Jul 22 '11 at 9:24
  • \$\begingroup\$ Just a note there about kernel booting link, I saw in the following posts by Eric that he managed to get the compressed kernel image to 190K and uncompressed around 360K so theoretically you might fit it into your flash uncompressed. More info: elinux.org/Linux_Tiny however I don't know what's the status of the project. \$\endgroup\$ – Mihailo Jul 22 '11 at 11:02
5
\$\begingroup\$

IMO, you're dreaming. Especially with USB, networking and 802.11/wifi. I just don't think you can do that and M3 is really a stretch.

OpenWRT is one of the smallest and most embeddable Linux distro I know of for networking and it's hard to get that under 2MB, esp with Wifi.

Try looking into higher-end ARM chips if that's what you really want or go with the Broadcom or Atheros SoC's that are currently common in routers.

\$\endgroup\$
  • \$\begingroup\$ you may very well be right, however I updated the question with clarification on WiFi.. I wouldn't need all the protocols, dchp/ip and basic sockets.. \$\endgroup\$ – Frank Jul 22 '11 at 5:59
4
\$\begingroup\$

Do you have MMU on the processor? If you don't you might want to look at: http://www.uclinux.org/ that should give you much smaller kernel size than mentioned. It works for some CortexM3 Atmel chips so it might work for yours. I haven't used it so this is only speculative. Doh, I just saw that question had been updated - well if you don't have MMU (which you probably don't) you can't use "normal" kernel and you would need to use ucLinux.

\$\endgroup\$
  • \$\begingroup\$ @mihalo thanks for pointing out uclinux +1 for that. I have asked a question about that.. Appreciate if you can lend a hand.. \$\endgroup\$ – Frank Jul 23 '11 at 8:14
  • \$\begingroup\$ Unfortunately I don't have much experience with this, I looked at ucLinux ports and all boards mentioned there have external RAM. The smallest kernel (uncompressed) I saw was for ADI Blackfin - something like 400KB but that is not ARM and for ARM could be significantly bigger. For Atmels ARM microprocessors it was around 1.5 MB and they all used external RAM. \$\endgroup\$ – Mihailo Jul 25 '11 at 10:59
  • \$\begingroup\$ Mihailo thanks for taking the time to look around.. \$\endgroup\$ – Frank Jul 25 '11 at 23:31
2
\$\begingroup\$

You might want to consider NuttX as an alternative if you really want POSIX compliance in a small, non-MMU platform.

\$\endgroup\$
  • 3
    \$\begingroup\$ That looks pretty neat, but it might be worth including some of the pros / cons compared against Linux to make it a more complete answer. \$\endgroup\$ – PeterJ Jul 24 '14 at 13:13
2
\$\begingroup\$

I don't remember the specifics, but there is a company which makes boards with STM32F4s running uCLinux, the software is downloadable, but they do have both external RAM and flash on those boards.

As a side note the price is so high that you are better off getting a Pi or Pine64, unless you want this as a learning experience. Our company looked into it and considering developement cost and such decided that if we were to run anything on embedded Linux using stm32f4 is infeasible economically, just counting the cost of parts.

\$\endgroup\$
0
\$\begingroup\$

uCLinux will probably work. However you'll have no memory protection on the system as you have no MMU. This means any crash in any application could bring down the whole system. You can also encounter memory fragmentation problems without the MMU. Why not look at one of the TI Sitaras? They are still pretty cheap and you can run full Linux on them which will be much more flexible.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.