[U-Boot, v3, 1/1] misc: fs_loader: Add request_firmware_into_buf_via_script() for flexible firmware loading via U-Boot script

Lucien.Jheng lucienzx159 at gmail.com
Sat Aug 2 08:09:51 CEST 2025


Marek Vasut 於 2025/7/30 上午 02:07 寫道:
> On 7/29/25 4:51 PM, Lucien.Jheng wrote:
>
> [...]
>
>> +int request_firmware_into_buf_via_script(void **buf, size_t max_size,
>> +                                      const char *script_name)
>> +{
>
> [...]
>
>> +    *buf = (void *)memdup((void *)addr, size);
>> +    if (!*buf) {
>> +        log_err("Failed to allocate memory for firmware copy.\n");
>> +        return -ENOMEM;
>> +    }
> One more nitpick, do we want to memdup() the firmware here, or would 
> it be better if user passed an already pre-allocated buffer pointer 
> into this function and this function would only copy up to 'max_size' 
> bytes into that buffer ?
>
> This:
>
> int request_firmware_into_buf_via_script(void *buf, size_t max_size,
>                                          const char *script_name)
> ...
> memcpy(buf, addr, min(size, max_size));
> ...
>
> What do you think ?
>
> Also, I would really like if someone else voiced their opinion this 
> firmware loading mechanism.
Hi Marek

I agree with this assessment.

I think it's better to have the user pass an already pre-allocated 
buffer pointer into this function,

and I will modify this part accordingly.

Hi all

Since you all have extensive development experience with U-Boot,

I'm very hopeful that we can make the firmware loading a better user 
experience for developers.

Therefore, I would greatly appreciate any suggestions you have on how to 
improve the firmware loading mechanism.

Thank you in advance for your insights.



More information about the U-Boot mailing list