[v4,4/5] misc: fw_loader: introduce FIP loader driver
Simon Glass
sjg at chromium.org
Thu Apr 2 01:25:52 CEST 2026
Hi Christian,
On 2026-03-31T07:53:19, Christian Marangi <ansuelsmth at gmail.com> wrote:
> misc: fw_loader: introduce FIP loader driver
> misc: fw_loader: introduce FIP loader driver
>
> Introduce a variant of the FS loader driver to extract images from FIP
> image. These image can contain additional binary used to init Network
> accellerator or PHY firmware blob.
>
> The way FIP handle image type is with the usage of UUID.
>
> This FIP loader driver implement a simple FIP image parser that check
> every entry for a matching UUID.
>
> Similar to FS loader, this driver also support both UBI and Block
> devices.
>
> Also an additional property is added to handle special case with eMMC
> that doesn't have a GPT partition and require a global offset to
> reference the FIP partition.
>
> An example usage of this driver is the following:
> [...]
> diff --git a/drivers/misc/fw_loader/fip_loader.c b/drivers/misc/fw_loader/fip_loader.c
> @@ -0,0 +1,547 @@
> +#define MIN(a, b) ((a) < (b) ? (a) : (b))
Please can you use the existing min() macro from linux/kernel.h rather
than defining your own?
> diff --git a/drivers/misc/fw_loader/fip_loader.c b/drivers/misc/fw_loader/fip_loader.c
> @@ -0,0 +1,547 @@
> +static int blk_parse_fip_firmware(struct firmware *firmwarep,
> + struct blk_desc *desc,
> + struct disk_partition *part_info,
> + unsigned int part_offset,
> + struct fip_toc_entry *dent)
> +{
> + unsigned int offset = part_info->start + part_offset;
> + struct fip_toc_header hdr;
> + struct fip_toc_entry ent;
> + struct uuid uuid;
> + unsigned int pos;
> + char *read_buf;
> + int ret;
> +
> + /* Allocate a Scratch Buffer for FIP parsing */
> + read_buf = malloc(desc->blksz);
> + if (!read_buf)
> + return -ENOMEM;
> +
> + pos = blk_read_fip_toc_header(desc, offset, read_buf, &hdr);
> + if (pos < 0) {
This check will never be true since pos is unsigned but
blk_read_fip_toc_header() returns int. Either change pos to int or use
a separate variable to capture the return value and check for errors
before assigning to pos.
> diff --git a/drivers/misc/fw_loader/fip_loader.c b/drivers/misc/fw_loader/fip_loader.c
> @@ -0,0 +1,547 @@
> +#include <fs_loader.h>
I suspect this include is not needed - the driver uses fw_loader.h
which is already pulled in via internal.h ?
> misc: fw_loader: introduce FIP loader driver
>
> These image can contain additional binary used to init Network
> accellerator or PHY firmware blob.
Typo: "accellerator" should be "accelerator".
Regards,
Simon
More information about the U-Boot
mailing list