pax_global_header00006660000000000000000000000064145402721030014510gustar00rootroot0000000000000052 comment=5126bf6ac925d4f54440b4c3d066100757bbe3b8 AsahiLinux-asahi-scripts-e9fd4f6/000077500000000000000000000000001454027210300170365ustar00rootroot00000000000000AsahiLinux-asahi-scripts-e9fd4f6/.editorconfig000066400000000000000000000002611454027210300215120ustar00rootroot00000000000000root = true # Defaults [*] indent_style = space indent_size = 4 tab_width = 4 charset = utf-8 insert_final_newline = true trim_trailing_whitespace = true max_line_length = 100 AsahiLinux-asahi-scripts-e9fd4f6/.gitignore000066400000000000000000000000061454027210300210220ustar00rootroot00000000000000build AsahiLinux-asahi-scripts-e9fd4f6/LICENSE000066400000000000000000000020641454027210300200450ustar00rootroot00000000000000MIT License Copyright The Asahi Linux Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. AsahiLinux-asahi-scripts-e9fd4f6/Makefile000066400000000000000000000064551454027210300205100ustar00rootroot00000000000000PREFIX=/usr/local SYS_PREFIX=$(PREFIX) CONFIG_DIR=/etc/default BIN_DIR=$(PREFIX)/bin SCRIPTS=asahi-diagnose asahi-fwupdate update-m1n1 ARCH_SCRIPTS=update-grub first-boot UNITS=first-boot.service MULTI_USER_WANTS=first-boot.service DRACUT_CONF_DIR=$(PREFIX)/lib/dracut/dracut.conf.d DRACUT_MODULES_DIR=$(PREFIX)/lib/dracut/modules.d BUILD_SCRIPTS=$(addprefix build/,$(SCRIPTS)) BUILD_ARCH_SCRIPTS=$(addprefix build/,$(ARCH_SCRIPTS)) all: $(BUILD_SCRIPTS) $(BUILD_ARCH_SCRIPTS) build/%: % @[ ! -e build ] && mkdir -p build || true sed -e s,/etc/default,$(CONFIG_DIR),g "$<" > "$@" chmod +x "$@" clean: rm -rf build install: all install -d $(DESTDIR)$(BIN_DIR)/ install -m0755 -t $(DESTDIR)$(BIN_DIR)/ $(BUILD_SCRIPTS) install -dD $(DESTDIR)/etc install -m0644 -t $(DESTDIR)/etc etc/m1n1.conf install -dD $(DESTDIR)$(PREFIX)/share/asahi-scripts install -m0644 -t $(DESTDIR)$(PREFIX)/share/asahi-scripts functions.sh install -dD $(DESTDIR)/$(SYS_PREFIX)/lib/firmware/vendor install-mkinitcpio: install install -dD $(DESTDIR)$(PREFIX)/lib/initcpio/install install -m0644 -t $(DESTDIR)$(PREFIX)/lib/initcpio/install initcpio/install/asahi install -dD $(DESTDIR)$(PREFIX)/lib/initcpio/hooks install -m0644 -t $(DESTDIR)$(PREFIX)/lib/initcpio/hooks initcpio/hooks/asahi install-dracut: install install -dD $(DESTDIR)$(DRACUT_CONF_DIR) install -m0644 -t $(DESTDIR)$(DRACUT_CONF_DIR) dracut/dracut.conf.d/10-asahi.conf install -dD $(DESTDIR)$(DRACUT_MODULES_DIR)/99asahi-firmware install -m0755 -t $(DESTDIR)$(DRACUT_MODULES_DIR)/99asahi-firmware dracut/modules.d/99asahi-firmware/install-asahi-firmware.sh install -m0755 -t $(DESTDIR)$(DRACUT_MODULES_DIR)/99asahi-firmware dracut/modules.d/99asahi-firmware/load-asahi-firmware.sh install -m0755 -t $(DESTDIR)$(DRACUT_MODULES_DIR)/99asahi-firmware dracut/modules.d/99asahi-firmware/module-setup.sh install-arch: install install-mkinitcpio install -m0755 -t $(DESTDIR)$(BIN_DIR)/ $(BUILD_ARCH_SCRIPTS) install -dD $(DESTDIR)$(PREFIX)/lib/systemd/system install -dD $(DESTDIR)$(PREFIX)/lib/systemd/system/{multi-user,sysinit}.target.wants install -m0644 -t $(DESTDIR)$(PREFIX)/lib/systemd/system $(addprefix systemd/,$(UNITS)) ln -sf $(addprefix $(PREFIX)/lib/systemd/system/,$(MULTI_USER_WANTS)) \ $(DESTDIR)$(PREFIX)/lib/systemd/system/multi-user.target.wants/ install -dD $(DESTDIR)$(PREFIX)/share/libalpm/hooks install -m0644 -t $(DESTDIR)$(PREFIX)/share/libalpm/hooks libalpm/hooks/95-m1n1-install.hook install-fedora: install install-dracut uninstall: rm -f $(addprefix $(DESTDIR)$(BIN_DIR)/,$(SCRIPTS)) rm -rf $(DESTDIR)$(PREFIX)/share/asahi-scripts uninstall-mkinitcpio: rm -f $(DESTDIR)$(PREFIX)/lib/initcpio/install/asahi rm -f $(DESTDIR)$(PREFIX)/lib/initcpio/hooks/asahi uninstall-dracut: rm -f $(DESTDIR)$(DRACUT_CONF_DIR)/10-asahi.conf uninstall-arch: uninstall-mkinitcpio rm -f $(addprefix $(DESTDIR)$(BIN_DIR)/,$(ARCH_SCRIPTS)) rm -f $(addprefix $(DESTDIR)$(PREFIX)/lib/systemd/system/,$(UNITS)) rm -f $(addprefix $(DESTDIR)$(PREFIX)/lib/systemd/system/multi-user.target.wants/,$(MULTI_USER_WANTS)) rm -f $(DESTDIR)$(PREFIX)/share/libalpm/hooks/95-m1n1-install.hook uninstall-fedora: uninstall-dracut .PHONY: clean install install-mkinitcpio install-dracut install-arch install-fedora uninstall uninstall-mkinitcpio uninstall-dracut uninstall-arch uninstall-fedora AsahiLinux-asahi-scripts-e9fd4f6/asahi-diagnose000077500000000000000000000234111454027210300216410ustar00rootroot00000000000000#!/bin/sh log() { echo "$@" } dt() { p=/proc/device-tree/"$1" if [ ! -e "$p" ]; then echo "(missing)" else cat "$p" | tr "\0" " " | sed -e 's/ $//g'; echo fi } banner() { cat < /dev/null \ && echo "yes" \ || echo "no" } pro_audio=$(check_proaudio) # Check for Configs in /etc/ (installed before mid 2023) check_audio_oldconfs() { [ -e /etc/pipewire/pipewire.conf.d/*asahi* ] \ || [ -e /etc/wireplumber/policy.lua.d/99-asahi-policy.lua ] \ && echo "yes" \ || echo "no" } old_conf=$(check_audio_oldconfs) # Check for the racy 99-asahi* build (installed before ~Oct 2023) check_audio_oldbuild() { [ -e /usr/share/wireplumber/policy.lua.d/99-asahi-policy.lua ] \ && echo "yes" \ || echo "no" } racy_build=$(check_audio_oldbuild) # Check if snd-soc-macaudio.please_blow_up_my_speakers was requested check_audio_macaudio() { grep "0" /sys/module/snd_soc_macaudio/parameters/please_blow_up_my_speakers > /dev/null \ && echo "no" \ || echo "yes" } bad_macaudio_params=$(check_audio_macaudio) # Check that snd-soc-tas2764.apple_quirks=0x3f is being applied check_audio_tas2764() { [ -e /sys/module/snd_soc_tas2764/ ] && ( grep "63" /sys/module/snd_soc_tas2764/parameters/apple_quirks > /dev/null \ && echo "yes" \ || echo "no" ) || echo "N/A" } tas2764_quirks=$(check_audio_tas2764) audio_config() { cat </dev/null | sort -u) \`\`\` EOF } module_parameters() { echo "## Module parameters" for mod in asahi hid_apple hid_magicmouse; do [ ! -e /sys/module/$mod/parameters/ ] && continue echo " $mod" for param in /sys/module/$mod/parameters/*; do echo " $(basename "$param")=$(cat "$param" | tr -d '\0')" done echo done echo } logfile() { f="$1" lines="$2" [ -e "$1" ] || return echo "## Log file: \`$f\`" echo '```' if [ -z "$lines" ]; then cat "$f" else tail -n "$lines" "$f" fi echo '```' echo } environment() { echo "## Environment" set | grep -E 'MESA|AGX|ASAHI|XDG_SESSION_TYPE|DISPLAY|TERM|LANG|LOCALE|LC_' | sed 's/^/ /' echo } diagnose() { f="$1" >$f log "Collecting system diagnostic information..." log ( exec >"$f" 2>&1 banner device_info firmware_versions boot_config system_info audio_config environment getfile /proc/mounts "Mounts" package_versions cmd lsblk "Block devices" cmd lspci "PCI devices" getfile /proc/bus/input/devices "Input devices" cmd lsmod "Loaded modules" module_parameters cmd 'journalctl -b 0 -tkernel' "Kernel log" cmd 'journalctl -b -1 -tkernel' "Kernel log (last boot)" logfile /var/log/Xorg.0.log logfile /var/log/pacman.log 500 ) log "Saved diagnostic information to $f" if [ "$macaudio_profile" != "HiFi" ]; then echo echo "Pipewire macaudio profile is \"${macaudio_profile}\"." echo "Headphones and speakers will not work. Select the \"Default\" or \"HiFi\" profile." fi if [ "$pro_audio" == "yes" ] || \ [ "$old_conf" == "yes" ] || \ [ "$racy_build" == "yes" ] || \ [ "$bad_macaudio_params" == "yes" ] || \ [ "$tas2764_quirks" == "no" ]; then echo echo "!! IMPORTANT !!" echo "Your audio configuration is in an invalid state. It is likely that you tried to" echo "enable speakers early, despite numerous and very explicit warnings not to do so." echo "Potential reason(s) you are seeing this message: " ( [ "$pro_audio" == "yes" ] && echo " - The Pro Audio profile is/was enabled for the internal speakers." [ "$old_conf" == "yes" ] && echo " - You have files in /etc/ from a prerelease version of asahi-audio." [ "$racy_build" == "yes" ] && echo " - You have files in /usr/share/ from a prerelease version of asahi-audio." [ "$bad_macaudio_params" == "yes" ] && echo " - You have tried to manually circumvent our kernel-level safety controls." [ "$tas2764_quirks" == "no" ] && echo " - Required speaker codec settings are not being applied." ) echo "Please go to https://github.com/AsahiLinux/docs/wiki/Undoing-early-speaker-support-hacks for fixes." echo "Do NOT file audio-related bugs until you have tried ALL fixes suggested at the page above." echo "Your bugs will be ignored and you will not be assisted." fi plat="$(cat /proc/device-tree/compatible | sed -re 's/.*apple,(t....).*/\1/g')" ver="$(tr -d '\0' /dev/null 2>&1; then echo echo "** WARNING! **" echo "The asahi-platform-metapackage package is not installed, you may be missing" echo "required platform dependencies. See https://discussion.fedoraproject.org/t/95301" echo "for how to fix it." fi fi } if [ -z "$1" ]; then diagnose "$HOME/asahi-diagnose-$(date +%Y%m%d-%H%M%S).txt" elif [ "$1" = "-" ]; then diagnose /dev/stdout else diagnose "$1" fi AsahiLinux-asahi-scripts-e9fd4f6/asahi-fwupdate000077500000000000000000000021131454027210300216630ustar00rootroot00000000000000#!/bin/sh # SPDX-License-Identifier: MIT set -eu unset PYTHON [ -e /etc/default/asahi-fwupdate ] && . /etc/default/asahi-fwupdate : "${ASAHIFW:=}" : "${VENDORFW:=}" : "${VENDORFWTMP:=/run/.vendorfw-tmp}" : "${PYTHON:=/usr/bin/python3}" if [ -e "$(dirname "$0")"/functions.sh ]; then . "$(dirname "$0")"/functions.sh else . /usr/share/asahi-scripts/functions.sh fi umount=false if [ -z "$ASAHIFW" ] && [ -z "$VENDORFW" ]; then mount_sys_esp /run/.system-efi ASAHIFW="/run/.system-efi/asahi/" VENDORFW="/run/.system-efi/vendorfw" umount=true fi if [ ! -e "${ASAHIFW}/all_firmware.tar.gz" ]; then echo "No firmware tarball found, skipping extraction" exit 0 fi if [ ! -d "$VENDORFW" ]; then mkdir -p "$VENDORFW" fi if [ ! -d "$VENDORFWTMP" ]; then mkdir -p "$VENDORFWTMP" fi echo "Upgrading vendor firmware package" asahi-fwextract "$ASAHIFW" "$VENDORFWTMP" rm -rf "$VENDORFW".new mv "${VENDORFWTMP}" "$VENDORFW".new rm -rf "$VENDORFW" mv "$VENDORFW".new "$VENDORFW" rm -rf "$VENDORFWTMP" echo "Firmware upgraded" $umount && umount /run/.system-efi true AsahiLinux-asahi-scripts-e9fd4f6/dracut/000077500000000000000000000000001454027210300203205ustar00rootroot00000000000000AsahiLinux-asahi-scripts-e9fd4f6/dracut/dracut.conf.d/000077500000000000000000000000001454027210300227505ustar00rootroot00000000000000AsahiLinux-asahi-scripts-e9fd4f6/dracut/dracut.conf.d/10-asahi.conf000066400000000000000000000015611454027210300251250ustar00rootroot00000000000000# Modules necessary for using Linux on Apple Silicon Macs # For NVMe & SMC add_drivers+=" apple-mailbox " # For NVMe add_drivers+=" nvme_apple " # For USB and HID add_drivers+=" pinctrl-apple-gpio " # SMC core add_drivers+=" macsmc macsmc-rtkit " # For USB add_drivers+=" i2c-apple tps6598x apple-dart dwc3 dwc3-of-simple nvmem-apple-efuses phy-apple-atc xhci-plat-hcd xhci-pci pcie-apple gpio_macsmc " # For HID add_drivers+=" spi-apple spi-hid-apple spi-hid-apple-of " # For RTC add_drivers+=" rtc-macsmc simple-mfd-spmi spmi-apple-controller nvmem_spmi_mfd " # For MTP HID add_drivers+=" apple-dockchannel dockchannel-hid apple-rtkit-helper " # dwc3 instantiates xHCI asynchronously. To make things like init=/bin/sh work where udev is no longer running, force load this one. force_drivers+=" xhci-plat-hcd " # For Apple firmware add_dracutmodules+=" asahi-firmware " AsahiLinux-asahi-scripts-e9fd4f6/dracut/modules.d/000077500000000000000000000000001454027210300222125ustar00rootroot00000000000000AsahiLinux-asahi-scripts-e9fd4f6/dracut/modules.d/99asahi-firmware/000077500000000000000000000000001454027210300252735ustar00rootroot00000000000000AsahiLinux-asahi-scripts-e9fd4f6/dracut/modules.d/99asahi-firmware/install-asahi-firmware.sh000077500000000000000000000006771454027210300322070ustar00rootroot00000000000000#!/bin/sh # SPDX-License-Identifier: MIT type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh info ":: Asahi: Installing vendor firmware to root filesystem..." if [ ! -d /sysroot/lib/firmware/vendor ]; then warn ":: Asahi: Vendor firmware directory missing on the root filesystem!" return 1 fi mount -t tmpfs -o mode=0755 vendorfw /sysroot/lib/firmware/vendor cp -pr /vendorfw/* /vendorfw/.vendorfw.manifest /sysroot/lib/firmware/vendor AsahiLinux-asahi-scripts-e9fd4f6/dracut/modules.d/99asahi-firmware/load-asahi-firmware.sh000077500000000000000000000024251454027210300314510ustar00rootroot00000000000000#!/bin/sh # SPDX-License-Identifier: MIT type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh if [ -e /vendorfw ]; then info ":: Asahi: Vendor firmware was loaded by the bootloader" return 0 fi if [ ! -e /proc/device-tree/chosen/asahi,efi-system-partition ]; then info ":: Asahi: Missing asahi,efi-system-partition variable, firmware will not be loaded!" return 0 fi info ":: Asahi: Triggering early load of 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 warn ":: Asahi: Timed out waiting for NVMe device" return 1 fi # If the above exists, hopefully the /dev device exists and this will work info ":: Asahi: Unpacking vendor firmware into initramfs..." VENDORFW="/run/.system-efi/vendorfw/" ( . /usr/share/asahi-scripts/functions.sh mount_sys_esp /run/.system-efi ) if [ ! -e "$VENDORFW/firmware.cpio" ]; then warn ":: Asahi: Vendor firmware not found in ESP." umount /run/.system-efi return 1 fi ( cd /; cpio --quiet -i < "$VENDORFW/firmware.cpio" ) info ":: Asahi firmware unpacked successfully" umount /run/.system-efi AsahiLinux-asahi-scripts-e9fd4f6/dracut/modules.d/99asahi-firmware/module-setup.sh000077500000000000000000000015711454027210300302610ustar00rootroot00000000000000#!/bin/sh # SPDX-License-Identifier: MIT # called by dracut check() { if [ -n "$hostonly" ] && [ ! -e /proc/device-tree/chosen/asahi,efi-system-partition ]; then return 0 elif [ -z "$hostonly" ]; then return 0 else return 255 fi } # called by dracut depends() { echo fs-lib return 0 } # called by dracut installkernel() { instmods apple-mailbox nvme-apple vfat } # called by dracut install() { inst_dir "/lib/firmware" ln_r "/vendorfw" "/lib/firmware/vendor" asahiscriptsdir="/usr/share/asahi-scripts" inst_dir $asahiscriptsdir $DRACUT_CP -R -L -t "${initdir}/${asahiscriptsdir}" "${dracutsysrootdir}${asahiscriptsdir}"/* inst_multiple cpio cut dirname modprobe mount seq sleep umount inst_hook pre-udev 10 "${moddir}/load-asahi-firmware.sh" inst_hook cleanup 99 "${moddir}/install-asahi-firmware.sh" } AsahiLinux-asahi-scripts-e9fd4f6/etc/000077500000000000000000000000001454027210300176115ustar00rootroot00000000000000AsahiLinux-asahi-scripts-e9fd4f6/etc/m1n1.conf000066400000000000000000000012771454027210300212430ustar00rootroot00000000000000# This configuration file specifies options for the m1n1 bootloader. # # Be careful when editing this file, as incorrect settings can cause your system to fail to boot. # # Display configuration (Mac Mini / Mac Studio only) # Force re-configuration of the display to defaults in m1n1 stage 2 # This is redundant unless your m1n1 stage 1 is buggy or ancient #display=auto # Configure the boot display to the default 4K mode #display=3840x2160 # Configure the boot display to 4K at 60Hz (or closest available) #display=3840x2160@60 # Configure the boot display to 4K at 59.97Hz (or closest available) #display=3840x2160@59.94 # Add an arbitrary property to /chosen in the device tree #chosen.foo=bar AsahiLinux-asahi-scripts-e9fd4f6/first-boot000077500000000000000000000024511454027210300210560ustar00rootroot00000000000000#!/bin/sh # SPDX-License-Identifier: MIT set -e root_dev=$(findmnt -n -o SOURCE /) efi_dev=$(findmnt -n -o SOURCE /boot/efi) if [ -e "$root_dev" ]; then echo "Randomizing root filesystem UUID..." tune2fs -U random "$root_dev" root_uuid="$(blkid -c /dev/null "$root_dev" -o export | grep '^UUID=')" echo "Root filesystem: $root_uuid" echo fi if [ -e "$efi_dev" ] && \ blkid "$efi_dev" | grep -q 'TYPE="vfat"'; then echo "Randomizing EFI system partition UUID..." # Ugly... why isn't there a command to do this? ssize="$(blockdev --getss "$efi_dev")" dd bs=1 seek=67 count=4 conv=notrunc if=/dev/urandom of="$efi_dev" dd bs=1 skip=67 seek=$((67+6*$ssize)) count=4 conv=notrunc if="$efi_dev" of="$efi_dev" efi_uuid="$(blkid -c /dev/null "$efi_dev" -o export | grep '^UUID=')" echo "EFI partition: $efi_uuid" echo fi if [ ! -z "$root_uuid" ] && [ ! -z "$efi_uuid" ]; then echo "Regenerating /etc/fstab..." tee /etc/fstab <&2 } warn() { echo "$@" 1>&2 } mount_sys_esp() { set -e mountpoint="$1" mkdir -p "$mountpoint" while grep -q "$mountpoint" /proc/mounts; do umount "$mountpoint" done esp_uuid="$(cat /proc/device-tree/chosen/asahi,efi-system-partition 2>/dev/null | sed 's/\x00//')" if [ -e /boot/efi/.builder ] || [ -e /boot/.builder ] || [ -z "$esp_uuid" ]; then if [ -e "/boot/efi/m1n1" ]; then bootmnt="/boot/efi" elif [ -e "/boot/m1n1" ]; then bootmnt="/boot" else warn "ESP not found and cannot determine ESP PARTUUID." warn "Make sure that your m1n1 has the right asahi,efi-system-partition configuration," warn "or that your ESP is mounted at /boot/efi or /boot." return 1 fi mount --bind "$bootmnt" "$mountpoint" warn "System ESP not identified in device tree, using $bootmnt" else mount "PARTUUID=$esp_uuid" "$mountpoint" fi dev="$(grep "$mountpoint" /proc/mounts | cut -d" " -f1)" info "Mounted System ESP $dev at $mountpoint" } mount_boot_esp() { set -e mountpoint="$1" mkdir -p "$mountpoint" while grep -q "$mountpoint" /proc/mounts; do umount "$mountpoint" done if [ -e "/boot/efi/efi/boot" ]; then mount --bind "/boot/efi" "$mountpoint" elif [ -e "/boot/efi/boot" ]; then mount --bind "/boot" "$mountpoint" else esp_uuid="$(cat /proc/device-tree/chosen/asahi,efi-system-partition | sed 's/\x00//')" if [ -z "$esp_uuid" ]; then echo "Boot ESP not found and cannot determine ESP PARTUUID." echo "Make sure your ESP is mounted at /boot/efi or /boot," echo "or that your m1n1 has the right asahi,efi-system-partition configuration." return 1 fi mount "PARTUUID=$esp_uuid" "$mountpoint" fi info "Mounted Boot ESP at $mountpoint" } AsahiLinux-asahi-scripts-e9fd4f6/initcpio/000077500000000000000000000000001454027210300206545ustar00rootroot00000000000000AsahiLinux-asahi-scripts-e9fd4f6/initcpio/hooks/000077500000000000000000000000001454027210300217775ustar00rootroot00000000000000AsahiLinux-asahi-scripts-e9fd4f6/initcpio/hooks/asahi000066400000000000000000000033241454027210300230110ustar00rootroot00000000000000#!/usr/bin/ash # SPDX-License-Identifier: MIT run_earlyhook() { if [ -e /vendorfw ]; then msg ":: Asahi: Vendor firmware was loaded by the bootloader" return 0 fi if [ ! -e /proc/device-tree/chosen/asahi,efi-system-partition ]; then msg ":: Asahi: Missing asahi,efi-system-partition variable, firmware will not be loaded!" return 1 fi msg ":: Asahi: Triggering early load of NVMe modules..." modprobe apple-mailbox modprobe nvme-apple modprobe xhci-plat-hcd 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 msg ":: Asahi: Unpacking vendor firmware into initramfs..." VENDORFW="/run/.system-efi/vendorfw/" ( . /usr/share/asahi-scripts/functions.sh mount_sys_esp /run/.system-efi ) if [ ! -e "$VENDORFW/firmware.cpio" ]; then msg ":: Asahi: Vendor firmware not available in ESP!" umount /run/.system-efi return 1 fi ( cd /; cpio -i < "$VENDORFW/firmware.cpio" ) umount /run/.system-efi msg ":: Asahi: Vendor firmware unpacked successfully" } run_latehook() { [ -e /vendorfw ] || return msg ":: Asahi: Copying vendor firmware to tmpfs under root filesystem..." mkdir -p /new_root/lib/firmware/vendor mount -t tmpfs -o mode=0755 vendorfw /new_root/lib/firmware/vendor cp -r /vendorfw/* /vendorfw/.vendorfw.manifest /new_root/lib/firmware/vendor } AsahiLinux-asahi-scripts-e9fd4f6/initcpio/install/000077500000000000000000000000001454027210300223225ustar00rootroot00000000000000AsahiLinux-asahi-scripts-e9fd4f6/initcpio/install/asahi000066400000000000000000000022141454027210300233310ustar00rootroot00000000000000#!/bin/bash # SPDX-License-Identifier: MIT build() { local filter # For NVMe & SMC add_module apple-mailbox? # For NVMe add_module nvme-apple? # For USB and HID add_module pinctrl-apple-gpio? # SMC core map add_module macsmc? macsmc-rtkit? # For USB map add_module i2c-apple? tps6598x? apple-dart? dwc3? dwc3-of-simple? \ nvmem-apple-efuses? phy-apple-atc? xhci-plat-hcd? xhci-pci? pcie-apple? gpio_macsmc? # For HID map add_module spi-apple? spi-hid-apple? spi-hid-apple-of? # For RTC map add_module rtc-macsmc? simple-mfd-spmi? spmi-apple-controller? \ nvmem_spmi_mfd? # For MTP HID map add_module apple-dockchannel? dockchannel-hid? apple-rtkit-helper? # Hook dependencies add_full_dir /usr/share/asahi-scripts # Firmware update script add_runscript add_dir /lib/firmware add_symlink /lib/firmware/vendor /vendorfw } help() { cat < /tmp/grub-core.cfg </dev/null cp -r /usr/share/grub/themes "$GRUB_DIR" cp -r /usr/lib/grub/arm64-efi "$GRUB_DIR" rm -f "$GRUB_DIR"/arm64-efi/*.module mkdir -p "$GRUB_DIR"/{fonts,locale} cp /usr/share/grub/unicode.pf2 "$GRUB_DIR"/fonts for i in /usr/share/locale/*/LC_MESSAGES/grub.mo; do lc="$(echo "$i" | cut -d/ -f5)" cp "$i" "$GRUB_DIR"/locale/"$lc".mo done [[ $MODULES != *$fs* ]] && MODULES="$MODULES $fs" echo "Core image modules: $MODULES" echo "Generating GRUB image..." grub-mkimage \ --directory '/usr/lib/grub/arm64-efi' \ -c /tmp/grub-core.cfg \ --prefix "$part/boot/grub" \ --output "$GRUB_DIR"/arm64-efi/core.efi \ --format arm64-efi \ --compression auto \ $MODULES cp "$GRUB_DIR"/arm64-efi/core.efi "$TARGET" grub-mkconfig -o "$CONFIG" $umount && umount "$EFI_PART" true AsahiLinux-asahi-scripts-e9fd4f6/update-m1n1000077500000000000000000000025561454027210300210300ustar00rootroot00000000000000#!/bin/sh # SPDX-License-Identifier: MIT set -e [ -e /etc/default/update-m1n1 ] && . /etc/default/update-m1n1 [ -n "$M1N1_UPDATE_DISABLED" ] && exit 0 if [ -e "$(dirname "$0")"/functions.sh ]; then . "$(dirname "$0")"/functions.sh else . /usr/share/asahi-scripts/functions.sh fi : ${SOURCE:="/usr/lib/asahi-boot/"} : ${M1N1:="$SOURCE/m1n1.bin"} : ${U_BOOT:="$SOURCE/u-boot-nodtb.bin"} : ${TARGET:="$1"} : ${DTBS:=$(/bin/ls -d /lib/modules/*-ARCH | sort -rV | head -1)/dtbs/*.dtb} : ${CONFIG:=/etc/m1n1.conf} umount=false m1n1config=/run/m1n1.conf >"$m1n1config" if [ -e "$CONFIG" ]; then info "Reading m1n1 config from $CONFIG:" while read line; do case "$line" in "") ;; \#*) ;; chosen.*=*|display=*) echo "$line" >> "$m1n1config" info " Option: $line" ;; *) warn " Ignoring unknown option: $line" ;; esac done <$CONFIG fi if [ -z "$TARGET" ]; then mount_sys_esp /run/.system-efi TARGET="/run/.system-efi/m1n1/boot.bin" umount=true fi cat "$M1N1" $DTBS >"${TARGET}.new" gzip -c "$U_BOOT" >>"${TARGET}.new" cat "$m1n1config" >>"${TARGET}.new" [ -e "$TARGET" ] && mv -f "$TARGET" "${TARGET}.old" mv -f "${TARGET}.new" "$TARGET" echo "m1n1 updated at ${TARGET}" $umount && umount /run/.system-efi true