]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mkimage: allow zynqmpbif to use a register initialization file
authorErich E. Hoover <erich.e.hoover@gmail.com>
Fri, 12 Jun 2026 15:04:54 +0000 (09:04 -0600)
committerMichal Simek <michal.simek@amd.com>
Wed, 8 Jul 2026 06:55:51 +0000 (08:55 +0200)
The ZynqMP Boot Image Format allows specifying the register
initialization file with the "[init]" attribute.  Since this
feature is already supported by the "zynqmpimage" backend, this
commit leverages that existing capability to add support for the
"[init]" attribute in the zynqmpbif backend:
https://docs.amd.com/r/en-US/ug1283-bootgen-user-guide/init

This currently uses the same register initialization file format as
zynqmpimage (ASCII text hex values with each line composed of a pair
of register address and value), for example:
===
0xff003248 0x12345678
===
It is not, yet, compatible with the format used by bootgen:
https://docs.amd.com/r/en-US/ug1283-bootgen-user-guide/Initialization-Pairs-and-INT-File-Attribute

Use this feature, with other zynqmpbif options, like so:
===
image : {
     [init] reginit.int
     [bootloader] fsbl.elf
     [pmufw_image] pmufw.elf
     [destination_cpu=a53-0, exception_level=el-3] bl31.elf
     [destination_cpu=a53-0, exception_level=el-2, load=0x08000000,
startup=0x08000000] u-boot.bin
}
===

Signed-off-by: Erich E. Hoover <erich.e.hoover@gmail.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/20260612150454.2194375-1-erich.e.hoover@gmail.com
tools/zynqmpbif.c
tools/zynqmpimage.c
tools/zynqmpimage.h

index 82ce0ac1a5200b17ad8c21fbe64ac5816b62b950..50d76b03476913481b3c65d3ee959c51436987d4 100644 (file)
@@ -191,6 +191,7 @@ static char *parse_partition_owner(char *line, struct bif_entry *bf)
 }
 
 static const struct bif_flags bif_flags[] = {
+       { "init", BIF_FLAG_INIT },
        { "fsbl_config", BIF_FLAG_FSBL_CONFIG },
        { "trustzone", BIF_FLAG_TZ },
        { "pmufw_image", BIF_FLAG_PMUFW_IMAGE },
@@ -316,6 +317,15 @@ static int bif_add_pmufw(struct bif_entry *bf, const char *data, size_t len)
        return 0;
 }
 
+static int bif_add_reginit(struct bif_entry *init)
+{
+       /* User can pass in text file with init list */
+       if (strlen(init->filename))
+               zynqmpimage_parse_initparams(bif_output.header, init->filename);
+
+       return 0;
+}
+
 static int bif_add_part(struct bif_entry *bf, const char *data, size_t len)
 {
        size_t parthdr_offset = 0;
@@ -340,6 +350,8 @@ static int bif_add_part(struct bif_entry *bf, const char *data, size_t len)
 
        if (bf->flags & (1ULL << BIF_FLAG_PMUFW_IMAGE))
                return bif_add_pmufw(bf, data, len);
+       else if (bf->flags & (1ULL << BIF_FLAG_INIT))
+               return bif_add_reginit(bf);
 
        r = bif_add_blob(data, len, &bf->offset);
        if (r)
index 4db9877127e74bcca75f711e2df50ef385993ed2..eb79c0696cc2c9f316bf1bd22a95f774b575f289 100644 (file)
@@ -400,8 +400,8 @@ static void zynqmpimage_pmufw(struct zynqmp_header *zynqhdr,
        fclose(fpmu);
 }
 
-static void zynqmpimage_parse_initparams(struct zynqmp_header *zynqhdr,
-       const char *filename)
+void zynqmpimage_parse_initparams(struct zynqmp_header *zynqhdr,
+                                 const char *filename)
 {
        FILE *fp;
        struct zynqmp_reginit reginit;
index 7c47dc0763bc77ea7f85482a56407d1851eca431..867fc5294a37dcdf40457a0cac9f2eb6bf738652 100644 (file)
@@ -142,6 +142,8 @@ struct zynqmp_header {
 
 void zynqmpimage_default_header(struct zynqmp_header *ptr);
 void zynqmpimage_print_header(const void *ptr, struct image_tool_params *params);
+void zynqmpimage_parse_initparams(struct zynqmp_header *zynqhdr,
+                                 const char *filename);
 
 static inline struct image_header_table *
 zynqmp_get_iht(const struct zynqmp_header *zynqhdr)