All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lucien.Jheng" <lucienzx159@gmail.com>
To: Marek Vasut <marek.vasut@mailbox.org>,
	u-boot@lists.denx.de, marek.vasut+renesas@mailbox.org,
	tien.fong.chee@altera.com, trini@konsulko.com, sjg@chromium.org,
	xypron.glpk@gmx.de, seanga2@gmail.com, daniel@makrotopia.org
Cc: lucien.jheng@airoha.com, frank-w@public-files.de
Subject: Re: [U-Boot, v6, 1/1] misc: fs_loader: Add request_firmware_into_buf_via_script() for flexible firmware loading via U-Boot script
Date: Mon, 18 Aug 2025 23:57:54 +0800	[thread overview]
Message-ID: <6bfb72dd-7488-4534-8e4c-1e67196976d2@gmail.com> (raw)
In-Reply-To: <5cb388f9-d488-4091-9556-c0063f637aed@mailbox.org>


Marek Vasut 於 2025/8/18 上午 07:00 寫道:
> On 8/17/25 5:02 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.
>>
>> Key features:
>> - The API runs a specified U-Boot script (by name), which is responsible
>>    for loading the firmware into memory by any means (e.g., load from 
>> MMC, USB, network, etc.).
>> - The script must set two environment variables: 'fw_addr'
>>    (the memory address where the firmware is loaded) and
>>    'fw_size' (the size of the firmware in bytes).
>> - The function validates these variables, copies the firmware into a 
>> newly
>>    allocated buffer (using memdup), and returns the pointer
>>    via the provided double pointer argument.
>> - The maximum allowed firmware size is checked to prevent buffer 
>> overflows.
>> - The environment variables are cleared after use to avoid stale data.
>> - Detailed error messages are provided for all failure conditions to 
>> aid debugging.
>>
>> Usage example:
>> 1. Define a U-Boot script in the environment that loads the firmware
>>     and sets the required variables:
>>     => env set my_fw_script 'load mmc 0:1 ${loadaddr} firmware.bin &&
>>     env set fw_addr ${loadaddr} && env set fw_size ${filesize}'
>>
>> 2. In your code, call the new API:
>>     void *fw_buf = NULL;
>>     int ret = request_firmware_into_buf_via_script(&fw_buf, 
>> 0x46000000, "my_fw_script");
>>     if (ret < 0)
>>         return ret;
>>
>> This approach allows board integrators and users to customize the 
>> firmware
>> loading process without modifying the source code,
>> simply by changing the script in the U-Boot environment.
>>
>> Signed-off-by: Lucien.Jheng <lucienzx159@gmail.com>
>
> Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
>
> Thank you for all this hard work.

Hi Marek

Thank you for your detailed review and suggestions.



  reply	other threads:[~2025-08-18 17:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-17 15:02 [U-Boot, v6, 1/1] misc: fs_loader: Add request_firmware_into_buf_via_script() for flexible firmware loading via U-Boot script Lucien.Jheng
2025-08-17 23:00 ` Marek Vasut
2025-08-18 15:57   ` Lucien.Jheng [this message]
2025-08-27 14:41 ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6bfb72dd-7488-4534-8e4c-1e67196976d2@gmail.com \
    --to=lucienzx159@gmail.com \
    --cc=daniel@makrotopia.org \
    --cc=frank-w@public-files.de \
    --cc=lucien.jheng@airoha.com \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=marek.vasut@mailbox.org \
    --cc=seanga2@gmail.com \
    --cc=sjg@chromium.org \
    --cc=tien.fong.chee@altera.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.