OpenWrt on Intel Mac Mini (Late 2014)

Not much (at all) out there on people actually getting this to work with OpenWrt. After many an hour hunting and trying different configurations primarily with kernel and setpci parameters in grub.conf finally got it working. I wanted to document it here to help anyone wanting to make use of an old Mac Mini of this vintage.

Note, to make any decent use of a mac mini 2014 or similar, you would want 1 or 2 thunderbolt-to-1gb-ethernet dongles to use alongside the built-in 1gbe. Forget Wifi, not only is its BCRM chipset not supported on OpenWrt it also doesn't have AP functionality in hardware. So it is basically limited to being a small server. I haven't decided on the exact use for mine as yet, but it could become a dmz server host.

There is a major issue to be solved in which the straight OpenWrt firmware image on SD card will not work. The SDHCI MMC module goes into a hard loop on bootup. To solve it I had to do this:

  1. Download the latest generic x86/64 combined efi (ext4) image and flash to an SD card.
  2. Mount up the boot partition (/dev/sdb1 onto /mnt when mounted off my linux server) and cd into the /mnt/boot/grub directory. Do mkdir x86_64-efi and cd into it.
  3. You need to copy a grub setpci.mod file from the linux system's /boot/grub/x86_64-efi/ into the directory on the SD card. No guarantee this will work everywhere but it worked for me thankfully.
  4. Update grub.cfg like this:
menuentry "OpenWrt" {
   insmod setpci
   setpci -s 00:1c.3 0x50.B=0x41
   linux [various parameters after which you append] sdhci.debug_quirks=0x40 sdhci.debug_quirks2=0x4
   setpci -s 00:1c.3 0x50.B=0x41
}
  1. Unmount the SD card and you are ready to boot your mini
  2. Hold down the option key (or alt key on non-mac keyboard) at power-up to select the SD image
  3. Happiness.

The key here is the setpci commands as well as the quirks. Honestly, I don't know if setpci is needed both before and after booting the linux kernel but it works for me. The 00:1c.3 setpci parameter was arrived at partially by examining internet posts from over the years of people solving similar SDHCI boot issues but randomly trying a 3 instead of 2 and then everything actually worked. (my rationale was that the SD card reader was on secondary PCI bridge #3 on this model - as determined by lspci from a succeeded bootup).

A few more details.

  1. My HDD was mostly dead anyway so I didn't care to use it, but I wanted the system to automatically boot from SD card rather than going first to HDD where the efi boot partition was still live. So I made all partitions formatted with ext4 fs including the efi boot partition. No longer do I have to hold the option or alt key on bootup, but it takes maybe 30 seconds before booting.
  2. If you want the mini to autoboot from power-outage you need to add this setpci in /etc/rc.local (this one comes from the pciutils package you must add from apk and is NOT the same as the one we got from grub)
    setpci -s 0:1f.0 0xa4.b=0
  3. I was able to force a bootup without solving the SDHCI issue mentioned in the first post by booting first from the mini's SD card slot and once stuck, pulling the card and inserting into a USB SD card reader (It didn't work trying to boot direct from the USB card reader). It automatically finished booting from there by doing that. From there I could lspci (from prebuilt custom image but probably could have apk'ed it once booted) and examine the SD card reader's detailed PCI setup.

Finally, some links to resources for background on the particular mmc sdhci loop problem: