[U-Boot, v3, 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
Tue Jul 29 20:07:35 CEST 2025


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.


More information about the U-Boot mailing list