bc50dd0279
Many devices need proprietary firmware blobs. So far those blobs were packaged and installed from the repository but this approach has many drawbacks: - The rootfs can only be used on a single device model. - If a model has multiple variants that have diferent secire-boot key, each must have it's own firmware blobs. This makes maintaining packaged firmware very hard and outweights the benefits of having a repeatable installation in most cases. Instead we can load blobs dynamically from preexisting firmware partitions that usually have same structure and contain the blobs we are interested in. The proposed scripts place symlinks to the blobs in a special dir that then given to the kernel. Blobs from firmware/postmarketos (or another dir that was set as extra path prior the script execution) will take priority which allows to override some blobs (e.g. for deviecs with no secure-boot)
31 lines
574 B
Bash
31 lines
574 B
Bash
#!/bin/sh
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
#
|
|
# Some devices have their modem firmware packaged as .gz blobs.
|
|
# Those needs to be unpacked as Kernel can't handle .gz packed
|
|
# firmware at this time.
|
|
#
|
|
|
|
BASEDIR="/lib/firmware/msm-firmware-loader/target"
|
|
|
|
for blob in "$BASEDIR"/*.gz
|
|
do
|
|
if ! [ -e "$blob" ]
|
|
then
|
|
exit
|
|
else
|
|
break
|
|
fi
|
|
done
|
|
|
|
UNPACKDIR="$(mktemp -td "unpacked_fw.XXXXXX")"
|
|
|
|
for blob in "$BASEDIR"/*.gz
|
|
do
|
|
blob_name="$(basename "${blob%.gz}")"
|
|
gzip -d < "$blob" > "$UNPACKDIR/$blob_name"
|
|
rm "$blob"
|
|
ln -s "$UNPACKDIR/$blob_name" "$BASEDIR/$blob_name"
|
|
done
|
|
|