Close

Linux 4.4 On A 68008? Technically, Yes!

A project log for Mackerel-68k Linux SBCs

A series of m68k-based single-board computers built to run Linux

colin-mColin M 07/20/2024 at 04:340 Comments

Edit: Oops! This issue has been fixed... see my next post: https://hackaday.io/project/183861-mackerel-68k-computer/log/231396-uclinux-44-fully-working-on-68008

---

I lied in my last update when I said my next post would be board bring-up for a Mackerel-08 SBC. That still is the plan, but I couldn't shake the feeling that I should give Linux 4.4 another chance. I didn’t want to finish a PCB design only to realize I missed some small thing needed to run the newer kernel. Long story short, Mackerel runs Linux 4.4, but only just barely.

# mount -t proc proc /proc
# hostname mackerel-08
# uname -a
uClinux mackerel-08 4.4.0-uc0 #2 Fri Jul 19 23:45:06 EDT 2024 m68k GNU/Linux
# cat /proc/cpuinfo
CPU:        MC68000
MMU:        none
FPU:        none
Clocking:    13.4MHz
BogoMips:    1.67
Calibration:    838400 loops

While Linux 2.0 boots and runs indefinitely with good stability, 4.4 is functional for a time, but very quickly runs into a number of memory-related issues. Typically after running a handful of commands from the shell, I will see a page allocation failure, or an OOM message from the kernel, or sometimes the system will just throw an address exception or stop responding entirely.

Although it seems obvious that the problem is just a lack of RAM, I wanted to be sure. I wrote some test applications in userspace to stress a few different areas of the system. I checked the newly-written serial driver. I looped malloc and free and looked for issues, but one-off programs ran for hours without any problems. Running new commands from the shell seemed to be the cause of the memory issues.

Mackerel-08 has 3.5MB of RAM installed in its maximum configuration. The kernel takes up about 1MB of that, the root filesystem is between 256KB and 512KB. Down to 2MB before init even starts…

Memory: 2040K/3072K available (723K kernel code, 35K rwdata, 96K rodata, 40K init, 42K bss, 1032K reserved, 0K cma-reserved)
Virtual kernel memory layout:
    vector  : 0x00000000 - 0x00000400   (   1 KiB)
    kmap    : 0x00000000 - 0xffffffff   (4095 MiB)
    vmalloc : 0x00000000 - 0xffffffff   (4095 MiB)
    lowmem  : 0x00000000 - 0x00300000   (   3 MiB)
      .init : 0x000d6000 - 0x000e0000   (  40 KiB)
      .text : 0x00000400 - 0x000b5120   ( 724 KiB)
      .data : 0x000b5120 - 0x000d5d20   ( 131 KiB)
      .bss  : 0x000e0000 - 0x000eab8c   (  43 KiB)

I stripped userspace to the absolute minimum – no init, just boot right to /bin/nwsh (a minimalist shell). Even with this setup, the kernel eats up some additional free RAM and Mackerel is left with barely 800KB of free RAM.

# free
             total         used         free       shared      buffers
Mem:          2080         1264          816            0            0
-/+ buffers:               1264          816

 Very simple programs run just fine, but anything even slightly complex (like cat or mount) can potentially request enough RAM or cause a page allocation to OOM the system. This is all a long-winded way to say that Mackerel just does not have enough RAM! The problem, of course, is that the 68008 can only address up to 4MB (slightly less with ROM and I/O mapped) by design. I think I’ve found the limits of the system. Just for my own sanity, I looked for any examples online of the 68000 series running Linux with less than 4MB of RAM. I couldn’t find any. 68 Katy runs 2.0 and Luis Alve’s Alcetronics M68k runs 3.x, but his board had 8 MB of RAM.

I’m still far from a Linux kernel expert. Maybe there are some tweaks I could do to the allocator or kernel config that would improve the memory situation, but to be honest, I don’t think it’s worth much more time. I proved that Linux 4.4 can run a 68008 and that’s enough for now. Even all of the old SBCs used as examples in the uClinux source code seems to have 8MB or more.

from https://linuxdevices.org/teeny-weeny-linux-sbcs/

For the record, I ran all of these same tests on 3.x and had the same issues. The difference in size and RAM usage between 3.x and 4.x is negligible.

Meanwhile, I have continued to improve the config for my Linux 2.0 build. I’m quite happy with how well it functions as a self contained little system. I’m able to fit the kernel, sash, some useful busybox tools, and vi into a single 512KB ROM. This includes a ramfs that gets mounted automatically on boot to provide some (temporary) writable storage. I even got the 68008 running at 16 MHz. I'd like to find some kind of BASIC or simple interpreted language that I could compile and run so that Mackerel-08 is fully programmable without the help of a build PC, possibly Lua or MicroPython.

Immediate plans are still the same then – design and build a Mackerel-08 SBC. The good news is that don’t have to stress about the board not supporting some hypothetical Linux build. I’ll target 2.0 and that’s enough. I’ll revisit more modern kernels when I upgrade the CPU and lift the 4MB memory limit.

Discussions