Skip to content

pipcet/m1lli

Repository files navigation

This repo has been restructured and is now part of https://github.com/pipcet/pearl.

m1lli is Linux loading itself

This is a bootloader for Linux on Apple M1 machines. The idea is to keep what the actual bootloader does to an absolute minimum, and do as much as possible in the Linux kernel, which then calls kexec() to load the real kernel.

Ordinary bootloaders follow the stay and play strategy, doing a lot of stuff like initializing hardware, having a frame buffer, and parsing and preparing device trees. M1lli follows the load and go strategy: jump into the kernel image with the minimum amount of fuss, telling it we don’t have a device tree yet (all we have are some Apple-specific boot args).

The name is inspired by m1n1.

The idea is that the initial kernel, which is all that we need to interact with MacOS for, will be stable enough so it doesn’t need to be flashed very often.

How small is the minimal bootloader code? My plan is to get it down to 68 bytes, which is all we need to realign an in-memory kernel image to the next 2 MiB boundary.

kernel configuration

included features

a single CPU core

keyboard (I’d like to get rid of this again)

USB gadget-mode code

excluded features

kernel modules

NVMe

wireless LAN

USB host-mode code

SMP code

SMC code

Stagestage1stage2Linux
SMPnonoyes
kernel modulesnoyesyes
uses devicetreenoyesyes
writes devicetreeyesnono
kexecyesyesno
can rebootnoyesyes
USBnosometimesyes
keyboardnosometimesyes
framebuffernoyesyes
StageSMPmodulesuses DTkexec
stage1nononoyes
stage2noyesyesyes
Linuxyesyesyesno