[U-Boot, v2, 1/1] misc: fs_loader: Add request_firmware_into_buf_via_script() for flexible firmware loading via U-Boot script
Marek Vasut
marek.vasut at mailbox.org
Mon Jul 28 23:44:10 CEST 2025
On 7/28/25 8:08 PM, Frank Wunderlich wrote:
> Am 28. Juli 2025 18:34:01 MESZ schrieb "Lucien.Jheng" <lucienzx159 at gmail.com>:
>>
>> Marek Vasut 於 2025/7/27 下午 10:46 寫道:
>>> On 7/27/25 4:16 PM, Lucien.Jheng wrote:
>>>> This commit introduces a new API, request_firmware_into_buf_via_script(),
>>>> to the fs_loader framework.
>>>> This function allows firmware to be loaded into memory
>>>> using a user-defined U-Boot script,
>>>> providing greater flexibility for firmware loading scenarios that cannot be handled
>>>> by static file paths or device/partition selection alone.
>>>
>>> Please run some 'fmt -w 72' on the paragraph above.
>> Got it. Will modify for the next version.
>>> [...]
>>>
>>>> I've validated this API on the Banana Pi R3 Mini. Here are my test commands and logs:
>>>> 1. `env set en8811h_load_firmware 'env set fw_addr 0x46000000 && env set fw_size 0x24000 && load mmc 0:3 0x46000000 /boot/EthMD32.dm.bin && load mmc 0:3 0x46004000 /boot/EthMD32.DSP.bin
>>>
>>> The 'load' command sets $filesize variable AFTER the load completed. The $filesize variable contains the actual size of the loaded data. You will likely need to expand the script a bit:
>>>
>>> env set fw_addr 0x46000000 && env set fw_size 0x24000 && \
>>> mw.b ${fw_addr} 0 ${fw_size} && # Make sure the memory backing the
>>> # firmware is initialized to some valid
>>> # content.
>>> load mmc 0:3 0x46000000 /boot/EthMD32.dm.bin && \
>>> if test ${filesize} -lt 0x4000 ; then # Validate that the size of loaded
>>> # data is correct
>>> load mmc 0:3 0x46004000 /boot/EthMD32.DSP.bin
>>> # Validate loaded data size here again
>>> else
>>> env set fw_size 0 # Indicate failure
>>> exit 1
>>> fi
>> OK. I will expand the script you mention.
>>>
>>> [...]
>>>
>>> Looks pretty good otherwise I think , thanks !
>> Thank you for your great advice.
>
> Hi,
>
> Is it possible to trigger it from uboot console?
>
> E.g. setting these vars from there and then call the firmware load function and maybe network init?
For some devices (like PCIe and USB) it might be possible, since those
are initialized after 'pci enum' and 'usb start' . For devices which are
started early, set the script, saveenv , and reset. For some devices it
might be possible to experiment with this using CMD_BIND too.
More information about the U-Boot
mailing list