Skip to content

Instantly share code, notes, and snippets.

@e8johan
Created December 11, 2022 14:51
Show Gist options
  • Save e8johan/93172e19c302983fe9dec0c1e5ee0d27 to your computer and use it in GitHub Desktop.
Save e8johan/93172e19c302983fe9dec0c1e5ee0d27 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# intel-sof-firmware initramfs-tools hoook script
# Copyright(C) 2022 Johan Thelin <hello@e8johan.se>
# Released under the GPL v2 or later license
#
# Builds a cpio image containing the intel-sof-signed firmware files needed for
# the Dell XPS13 Plus (9320) and installs it to the early initramfs.
#
# Requires intel-sof-signed to be installed
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
. /usr/share/initramfs-tools/hook-functions
# Create temporary working space
EFW=$(mktemp -d "${TMPDIR:-/var/tmp}/mkinitramfs-EFW_XXXXXXXXXX") || {
echo "E: intel-sof-firmware: cannot create temporary directory" >&2
exit 1
}
# Populate file system tree with firmware files
EFWCD="${EFW}/d/usr/lib/firmware/intel"
mkdir -p "${EFWCD}/sof"
cp /usr/lib/firmware/intel/sof/sof-adl.ri "${EFWCD}/sof/"
mkdir -p "${EFWCD}/sof-tplg"
cp /usr/lib/firmware/intel/sof-tplg/sof-adl-rt1316-l12-rt714-l0.tplg "${EFWCD}/sof-tplg/"
# Create cpio image
EFWF="${EFS}/early-initramfs.cpio"
cd "${EFW}/d" ; find . -print0 | LC_ALL=C sort -z | cpio --null --reproducible -R 0:0 -H newc -o --quiet > "${EFWF}"
# Prepend cpio image to initramfs
prepend_earlyinitramfs "${EFWF}" || {
[ -d "${EFW}" ] && rm -rf "${EFW}"
echo "E: intel-sof-firmware: failed to create of prepend the early initramfs to the initramfs" >&2
exit 0
}
# Clean up
[ -d "${EFW}" ] && rm -rf "${EFW}"
@valessiobrito
Copy link

L41: s/EFS/EFW/ ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment