Last active
September 2, 2024 13:00
-
-
Save daniel-thompson/5475864aee6262200fee7b474202f0c3 to your computer and use it in GitHub Desktop.
Suggested content for /etc/initramfs-tools/hooks/devicetree-firmware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh -e | |
| # Copyright (C) Linaro Ltd, 2024 | |
| # SPDX-License-Identifier: GPL-2.0-or-later | |
| # Add firmware whose names are dictated by the devicetree. Such firmware cannot | |
| # be described in a MODULE_FIRMWARE() meaning modinfo based discovery tools are | |
| # insufficient to handle these cases. | |
| # No prereq | |
| if [ "$1" = "prereqs" ]; then exit 0; fi | |
| . /usr/share/initramfs-tools/hook-functions | |
| # Only run if this system is booted with a devicetree | |
| if [ ! -d /sys/firmware/devicetree ]; then exit 0; fi | |
| # Scan for appropriately named devicetree nodes and add any firmware | |
| # we discover this way to the initramfs. Sadly we cannot tell the difference | |
| # between boot-critical firmware and any other so we have to be over-zealous. | |
| # However the impact on initramfs size should be acceptable because we only | |
| # scan the devicetree of the booted system. | |
| for node in $(find /sys/firmware/devicetree -name firmware-name); do | |
| firmware="$(cat "${node}")" | |
| if ! add_firmware "${firmware}"; then | |
| echo "W: Possible missing firmware /lib/firmware/${firmware} found in devicetree" >&2 | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment