apple-mac-aarch64: new device
I chose this device pkg name because it's descriptive, this pkg doesn't support the 'idevice' things or x86_64 or PPC Macs. I didn't include "generic" because, while it supports Macbooks, (in theory) Mac Minis and something called Mac Studio, it's not really *that* generic for Mac computers AND by having the manufacturer be "Apple" it'll show up in pmb init under "apple." This will make it more intuitive to find, I think. Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/7048>
This commit is contained in:
parent
eddbe346c9
commit
3c93972ece
5 changed files with 201 additions and 0 deletions
53
device/testing/device-apple-mac-aarch64/APKBUILD
Normal file
53
device/testing/device-apple-mac-aarch64/APKBUILD
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# Maintainer: Clayton Craft <clayton@craftyguy.net>
|
||||
# Reference: <https://postmarketos.org/devicepkg>
|
||||
pkgname=device-apple-mac-aarch64
|
||||
pkgdesc="Apple M-series Macs"
|
||||
pkgver=1
|
||||
pkgrel=0
|
||||
url="https://postmarketos.org"
|
||||
license="MIT"
|
||||
arch="aarch64"
|
||||
options="!check !archcheck"
|
||||
depends="
|
||||
alsa-ucm-conf-asahi
|
||||
asahi-audio
|
||||
asahi-fwextract
|
||||
asahi-scripts
|
||||
linux-postmarketos-asahi
|
||||
postmarketos-base
|
||||
systemd-boot
|
||||
u-boot-asahi
|
||||
"
|
||||
makedepends="devicepkg-dev systemd-boot"
|
||||
source="
|
||||
deviceinfo
|
||||
initramfs_copy_vendorfw.sh
|
||||
initramfs_setup_vendorfw.sh
|
||||
modules-initfs
|
||||
"
|
||||
|
||||
build() {
|
||||
devicepkg_build $startdir $pkgname
|
||||
}
|
||||
|
||||
package() {
|
||||
devicepkg_package $startdir $pkgname
|
||||
|
||||
# vendor firmware management scripts
|
||||
install -Dm755 "$srcdir"/initramfs_setup_vendorfw.sh \
|
||||
-t "$pkgdir"/usr/share/mkinitfs/hooks/
|
||||
install -Dm755 "$srcdir"/initramfs_copy_vendorfw.sh \
|
||||
-t "$pkgdir"/usr/share/mkinitfs/hooks-cleanup/
|
||||
|
||||
# u-boot-asahi has a trigger that installs m1n1+u-boot and expects this dir to
|
||||
# exist, or else it crashes. This dir won't exist when building a new
|
||||
# install/image so we have to create it manually.
|
||||
mkdir -p "$pkgdir/boot/m1n1"
|
||||
}
|
||||
|
||||
sha512sums="
|
||||
42a8fe25e024a9cec7b900ddbb2bd1275810b80bafadc043e571e060c76c8aa0eb545c5ad4714aa6ce0354785187ae987827dfc3b3948d7d9901575bbc2a70b0 deviceinfo
|
||||
f111ddc0484f079af23520dcc9b4d909b55da327aec91545921a4ceafc52b21d88f37fbdb702e51ca1e49440b6afc2011ada8b681c1801f572bddc9cd34c9d9e initramfs_copy_vendorfw.sh
|
||||
11d5d6af50ed73e7e6940f7d56730f94a1bb42990d5dba9a798522060e7717c410c025b12def0345b4f43c97da268dabcb484c3004d23c1ac39b1eeaaefd2967 initramfs_setup_vendorfw.sh
|
||||
0191bc032cf8c72b397955d51f42249cd43d4aef263608a58d68e6e0764fd89bd589df97a5af22201930f289a64af7eb798cef5938cb6cc32d2382a627e6c10f modules-initfs
|
||||
"
|
||||
19
device/testing/device-apple-mac-aarch64/deviceinfo
Normal file
19
device/testing/device-apple-mac-aarch64/deviceinfo
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Reference: <https://postmarketos.org/deviceinfo>
|
||||
# Please use double quotes only. You can source this file in shell
|
||||
# scripts.
|
||||
|
||||
deviceinfo_format_version="0"
|
||||
deviceinfo_name="Apple M-series Macs"
|
||||
deviceinfo_manufacturer="Apple"
|
||||
deviceinfo_codename="apple-mac-aarch64"
|
||||
deviceinfo_year="2020"
|
||||
deviceinfo_arch="aarch64"
|
||||
|
||||
# Device related
|
||||
deviceinfo_chassis="laptop"
|
||||
deviceinfo_external_storage="false"
|
||||
deviceinfo_drm="true"
|
||||
|
||||
# Bootloader related
|
||||
deviceinfo_generate_systemd_boot="true"
|
||||
deviceinfo_boot_filesystem="fat32"
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
# Initramfs hook to copy vendor firmware to final rootfs before switchroot
|
||||
|
||||
set -e
|
||||
|
||||
# Check if vendor firmware was extracted
|
||||
if [ ! -d /vendorfw ] || [ -z "$(ls -A /vendorfw 2>/dev/null)" ]; then
|
||||
echo "No vendor firmware found, skipping copy"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Copying vendor firmware to target rootfs..."
|
||||
|
||||
# Create vendor firmware directory in target rootfs
|
||||
mkdir -p /sysroot/usr/lib/firmware/vendor
|
||||
|
||||
# Mount tmpfs for vendor firmware
|
||||
if ! mount -t tmpfs -o mode=0755 vendorfw /sysroot/usr/lib/firmware/vendor; then
|
||||
echo "Error: Failed to mount tmpfs at /sysroot/usr/lib/firmware/vendor" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Copy vendor firmware
|
||||
if ! cp -a /vendorfw/* /vendorfw/.vendorfw.manifest /sysroot/usr/lib/firmware/vendor/; then
|
||||
umount /sysroot/usr/lib/firmware/vendor
|
||||
echo "Error: Failed to copy vendor firmware" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Vendor firmware copied to /usr/lib/firmware/vendor"
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
#!/bin/sh
|
||||
# Initramfs hook to setup vendor firmware from ESP for Apple Silicon Macs
|
||||
# Extracts firmware.cpio from ESP to /vendorfw in initramfs
|
||||
# Also see: https://asahilinux.org/docs/platform/open-os-interop/#os-handling
|
||||
|
||||
set -e
|
||||
|
||||
DT_ESP_FILE="/proc/device-tree/chosen/asahi,efi-system-partition"
|
||||
|
||||
# Check if we're on Apple Silicon Mac
|
||||
if [ ! -f "$DT_ESP_FILE" ]; then
|
||||
echo "Error: Not on Apple Silicon Mac or missing device tree property" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Read ESP PARTUUID as string
|
||||
ESP_PARTUUID=$(cat "$DT_ESP_FILE")
|
||||
|
||||
if [ -z "$ESP_PARTUUID" ]; then
|
||||
echo "Error: Failed to read ESP PARTUUID from device tree" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Found ESP PARTUUID: $ESP_PARTUUID"
|
||||
|
||||
# Find block device by PARTUUID
|
||||
ESP_DEVICE="/dev/disk/by-partuuid/$ESP_PARTUUID"
|
||||
|
||||
if [ ! -b "$ESP_DEVICE" ]; then
|
||||
echo "Error: ESP device not found: $ESP_DEVICE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Found ESP device: $ESP_DEVICE"
|
||||
|
||||
# Mount ESP
|
||||
if ! mount -t vfat "$ESP_DEVICE" /boot; then
|
||||
echo "Error: Failed to mount ESP" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Mounted ESP to /boot"
|
||||
|
||||
cleanup() {
|
||||
if mountpoint -q /boot 2>/dev/null; then
|
||||
umount /boot || echo "Warning: Failed to unmount ESP" >&2
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Check if firmware.cpio exists
|
||||
if [ ! -f "/boot/vendorfw/firmware.cpio" ]; then
|
||||
umount /boot
|
||||
echo "Error: Firmware CPIO not found: /boot/vendorfw/firmware.cpio" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for existing content and warn
|
||||
if [ -n "$(ls -A /vendorfw 2>/dev/null)" ]; then
|
||||
echo "Warning: /vendorfw already contains files, overwriting..." >&2
|
||||
fi
|
||||
|
||||
# Extract firmware CPIO
|
||||
echo "Extracting vendor firmware..."
|
||||
cd /
|
||||
if ! cpio -dui -F "/boot/vendorfw/firmware.cpio"; then
|
||||
echo "Error: Failed to extract firmware CPIO" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ln -s /vendorfw /usr/lib/firmware/vendor
|
||||
|
||||
echo "Vendor firmware setup complete"
|
||||
27
device/testing/device-apple-mac-aarch64/modules-initfs
Normal file
27
device/testing/device-apple-mac-aarch64/modules-initfs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
adpdrm
|
||||
apple-mfi-fastcharge
|
||||
apple_nvmem_spmi
|
||||
appledrm
|
||||
appletouch
|
||||
asahi
|
||||
dockchannel-hid
|
||||
dwc3
|
||||
dwc3-pci
|
||||
hid-apple
|
||||
hid-magicmouse
|
||||
macsmc-hwmon
|
||||
mux-apple-display-crossbar
|
||||
mux-gpio
|
||||
nvme
|
||||
nvmem-rmem
|
||||
phy-apple-atc
|
||||
phy-apple-dptx
|
||||
sdhci
|
||||
sdhci-pci
|
||||
tg3
|
||||
tps6598x
|
||||
typec
|
||||
xhci-hcd
|
||||
xhci-pci
|
||||
xhci-pci-renesas
|
||||
xhci-plat-hcd
|
||||
Loading…
Add table
Add a link
Reference in a new issue