Re: [PATCH] scripts: Add script to extract built-in firmware blobs
From: Guilherme G. Piccoli
Date: Fri Jan 24 2025 - 07:31:32 EST
On 24/01/2025 03:38, Andrew Morton wrote:
> On Mon, 20 Jan 2025 16:04:26 -0300 "Guilherme G. Piccoli" <gpiccoli@xxxxxxxxxx> wrote:
>
>> Through the options CONFIG_EXTRA_FIRMWARE{_DIR} one is able to build
>> a kernel including firmware blobs in a built-in fashion. This is
>> usually the case of built-in drivers that require some blobs in
>> order to work properly, for example, like in non-initrd based systems.
>>
>> Add hereby a script to extract these blobs from a non-stripped vmlinux,
>> similar to the idea of "extract-ikconfig". The firmware loader interface
>> saves such built-in blobs as rodata entries, having a field for the FW
>> name as "_fw_<module_name>_<firmware_name>_bin"; the tool extracts files
>> named "<module_name>_<firmware_name>" for each rodata firmware entry
>> detected. It makes use of awk, bash, dd and readelf, pretty standard
>> tooling for Linux development.
>
> Please describe the use case(s) for this. ie, why are you suggesting
> this be added to Linux?
>
Hi Andrew, there is currently no tool to extract a firmware blob that is
built-in on vmlinux to the best of my knowledge. So if we have a kernel
image containing the blobs, and we want to rebuild the kernel with some
debug patches for example (and given that the image also has
IKCONFIG=y), we currently can't do that for the same versions for all
the firmware blobs, _unless_ we have exact commits of linux-firmware for
the specific versions for each firmware included.
With this tool, we can blindly extract the FWs and easily re-add them in
the new debug kernel build, allowing a more deterministic testing
without the burden of "hunting down" the proper version of each firmware
binary.
Makes sense to you?
Cheers,
Guilherme