-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initramfs-tools implementation for cpio firmware loading #30
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,8 +54,19 @@ install-arch: install install-mkinitcpio | |
install -dD $(DESTDIR)$(PREFIX)/share/libalpm/hooks | ||
install -m0644 -t $(DESTDIR)$(PREFIX)/share/libalpm/hooks libalpm/hooks/95-m1n1-install.hook | ||
|
||
install-initramfs: install | ||
install -d $(DESTDIR)/etc/initramfs-tools/hooks/ | ||
install -m0755 -t $(DESTDIR)/etc/initramfs-tools/hooks/ initramfs/hooks/asahi | ||
install -d $(DESTDIR)/etc/initramfs-tools/scripts/init-top | ||
install -m0755 -t $(DESTDIR)/etc/initramfs-tools/scripts/init-top initramfs/scripts/init-top/asahi | ||
install -d $(DESTDIR)/etc/initramfs-tools/scripts/init-bottom | ||
install -m0755 -t $(DESTDIR)/etc/initramfs-tools/scripts/init-bottom initramfs/scripts/init-bottom/asahi | ||
install -m0644 -t $(DESTDIR)$(PREFIX)/share/asahi-scripts initramfs/modules | ||
|
||
install-fedora: install install-dracut | ||
|
||
install-ubuntu: install install-initramfs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably be |
||
|
||
uninstall: | ||
rm -f $(addprefix $(DESTDIR)$(BIN_DIR)/,$(SCRIPTS)) | ||
rm -rf $(DESTDIR)$(PREFIX)/share/asahi-scripts | ||
|
@@ -67,6 +78,11 @@ uninstall-mkinitcpio: | |
uninstall-dracut: | ||
rm -f $(DESTDIR)$(DRACUT_CONF_DIR)/10-asahi.conf | ||
|
||
uninstall-initramfs: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto here wrt |
||
rm -f $(DESTDIR)/etc/initramfs-tools/hooks/asahi | ||
rm -f $(DESTDIR)/etc/initramfs-tools/scripts/init-top/asahi | ||
rm -f $(DESTDIR)/etc/initramfs-tools/scripts/init-bottom/asahi | ||
|
||
uninstall-arch: uninstall-mkinitcpio | ||
rm -f $(addprefix $(DESTDIR)$(BIN_DIR)/,$(ARCH_SCRIPTS)) | ||
rm -f $(addprefix $(DESTDIR)$(PREFIX)/lib/systemd/system/,$(UNITS)) | ||
|
@@ -75,4 +91,6 @@ uninstall-arch: uninstall-mkinitcpio | |
|
||
uninstall-fedora: uninstall-dracut | ||
|
||
uninstall-ubuntu: uninstall-initramfs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably be |
||
|
||
.PHONY: clean install install-mkinitcpio install-dracut install-arch install-fedora uninstall uninstall-mkinitcpio uninstall-dracut uninstall-arch uninstall-fedora |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
# SPDX-License-Identifier: MIT | ||
|
||
PREREQ="" | ||
|
||
prereqs() | ||
{ | ||
echo "$PREREQ" | ||
} | ||
|
||
case $1 in | ||
prereqs) | ||
prereqs | ||
exit 0 | ||
;; | ||
esac | ||
|
||
# Hooks for loading asahi modules and firmware | ||
|
||
. /usr/share/initramfs-tools/hook-functions | ||
|
||
mkdir -p "${DESTDIR}/lib/firmware" | ||
mkdir -p "${DESTDIR}/usr/share/asahi-scripts" | ||
cp -r /usr/share/asahi-scripts/* "${DESTDIR}/usr/share/asahi-scripts" | ||
copy_exec /usr/bin/cpio | ||
|
||
add_modules_from_file /usr/share/asahi-scripts/modules |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# For NVMe & SMC | ||
apple-mailbox | ||
# For NVMe | ||
nvme_apple | ||
# For USB and HID | ||
pinctrl-apple-gpio | ||
# SMC core | ||
macsmc | ||
macsmc-rtkit | ||
# For USB | ||
i2c-apple | ||
tps6598x | ||
apple-dart | ||
dwc3 | ||
dwc3-of-simple | ||
nvmem-apple-efuses | ||
phy-apple-atc | ||
xhci-pci | ||
pcie-apple | ||
gpio_macsmc | ||
# For HID | ||
spi-apple | ||
spi-hid-apple | ||
spi-hid-apple-of | ||
# For RTC | ||
rtc-macsmc | ||
simple-mfd-spmi | ||
spmi-apple-controller | ||
nvmem_spmi_mfd | ||
# For MTP HID | ||
apple-dockchannel | ||
dockchannel-hid | ||
apple-rtkit-helper |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/sh | ||
# SPDX-License-Identifier: MIT | ||
|
||
PREREQ="" | ||
prereqs() | ||
{ | ||
echo "$PREREQ" | ||
} | ||
case $1 in | ||
# get pre-requisites | ||
prereqs) | ||
prereqs | ||
exit 0 | ||
;; | ||
esac | ||
|
||
. /scripts/functions | ||
|
||
mount -t tmpfs -o mode=0755 vendorfw "${rootmnt}"/lib/firmware/vendor | ||
cp -r /vendorfw/* /vendorfw/.vendorfw.manifest "${rootmnt}"/lib/firmware/vendor |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/sh | ||
# SPDX-License-Identifier: MIT | ||
|
||
PREREQ="udev" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this script run before udev? From https://github.com/AsahiLinux/docs/wiki/Open-OS-Ecosystem-on-Apple-Silicon-Macs#linux-specific:
|
||
prereqs() | ||
{ | ||
echo "$PREREQ" | ||
} | ||
case $1 in | ||
# get pre-requisites | ||
prereqs) | ||
prereqs | ||
exit 0 | ||
;; | ||
esac | ||
|
||
. /scripts/functions | ||
|
||
if [ -e /lib/firmware/vendor ]; then | ||
log_failure_msg "Vendor firmware was loaded by the bootloader" | ||
return 1 | ||
fi | ||
|
||
if [ ! -e /proc/device-tree/chosen/asahi,efi-system-partition ]; then | ||
log_failure_msg "Missing asahi,efi-system-partition variable, firmware will not be loaded!" | ||
return 1 | ||
fi | ||
|
||
log_success_msg "Load NVME modules" | ||
modprobe apple-mailbox | ||
modprobe nvme-apple | ||
|
||
for i in $(seq 0 50); do | ||
[ -e /sys/bus/platform/drivers/nvme-apple/*.nvme/nvme/nvme*/nvme*n1/ ] && break | ||
sleep 0.1 | ||
done | ||
|
||
if [ ! -e /sys/bus/platform/drivers/nvme-apple/*.nvme/nvme/nvme*/nvme*n1/ ]; then | ||
err "Timed out waiting for NVMe device" | ||
return 1 | ||
fi | ||
|
||
# If the above exists, hopefully the /dev device exists and this will work | ||
|
||
VENDORFW="/run/.system-efi/vendorfw/" | ||
|
||
( | ||
. /usr/share/asahi-scripts/functions.sh | ||
mount_sys_esp /run/.system-efi | ||
) | ||
|
||
if [ ! -e "$VENDORFW/firmware.cpio" ]; then | ||
log_failure_msg "Vendor firmware not available in ESP!" | ||
umount /run/.system-efi | ||
return 1 | ||
fi | ||
|
||
|
||
( cd /; cpio -i < "$VENDORFW/firmware.cpio" ) | ||
umount /run/.system-efi | ||
|
||
log_success_msg "Asahi: Vendor firmware unpacked successfully" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use
initramfstools
here instead ofinitramfs
? Otherwise it's confusing to people...