Skip to contentSkip to conversation

mkimage: allow zynqmp to use a register initialization file

PATCH Superseded Erich E. Hoover 3 participants 12 messages Jun 3 – Jun 5 Arm/Zynq architecture

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw
---
 tools/zynqmpbif.c   | 16 ++++++++++++++--
 tools/zynqmpimage.c |  4 ++--
 tools/zynqmpimage.h |  2 ++
 3 files changed, 18 insertions(+), 4 deletions(-)
tools/zynqmpbif.c +14 -2
index 82ce0ac1a52..546b9e4fd9d 100644
@@ -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 },
@@ -279,7 +280,7 @@ static int bif_add_blob(const void *data, size_t len, size_t *offset)
 	return 0;
 }
 
-static int bif_init(void)
+static int bif_initialize(void)
 {
 	struct zynqmp_header header = { { 0 } };
 	int r;
@@ -316,6 +317,15 @@ static int bif_add_pmufw(struct bif_entry *bf, const char *data, size_t len)
 	return 0;
 }
 
+static int bif_init(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_init(bf);
 
 	r = bif_add_blob(data, len, &bf->offset);
 	if (r)
@@ -837,7 +849,7 @@ int zynqmpbif_copy_image(int outfd, struct image_tool_params *mparams)
 	uint32_t csum;
 	int bldr = -1;
 
-	bif_init();
+	bif_initialize();
 
 	/* Read .bif input file */
 	bif = read_full_file(mparams->datafile, NULL);
tools/zynqmpimage.c +2 -2
index 4db9877127e..eb79c0696cc 100644
@@ -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;
tools/zynqmpimage.h +2 -0
index 7c47dc0763b..867fc5294a3 100644
@@ -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)
Signature · 1 line
2.43.0
maintainer
#1 lore raw

please fill description here. Then I can look at changes below.

M

Quoted 90 lines · Erich E. Hoover
---
  tools/zynqmpbif.c   | 16 ++++++++++++++--
  tools/zynqmpimage.c |  4 ++--
  tools/zynqmpimage.h |  2 ++
  3 files changed, 18 insertions(+), 4 deletions(-)
tools/zynqmpbif.c +14 -2
index 82ce0ac1a52..546b9e4fd9d 100644
@@ -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 },
@@ -279,7 +280,7 @@ static int bif_add_blob(const void *data, size_t len, size_t *offset)
  	return 0;
  }
 
-static int bif_init(void)
+static int bif_initialize(void)
  {
  	struct zynqmp_header header = { { 0 } };
  	int r;
@@ -316,6 +317,15 @@ static int bif_add_pmufw(struct bif_entry *bf, const char *data, size_t len)
  	return 0;
  }
 
+static int bif_init(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_init(bf);
 
  	r = bif_add_blob(data, len, &bf->offset);
  	if (r)
@@ -837,7 +849,7 @@ int zynqmpbif_copy_image(int outfd, struct image_tool_params *mparams)
  	uint32_t csum;
  	int bldr = -1;
 
-	bif_init();
+	bif_initialize();
 
  	/* Read .bif input file */
  	bif = read_full_file(mparams->datafile, NULL);
tools/zynqmpimage.c +2 -2
index 4db9877127e..eb79c0696cc 100644
@@ -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;
tools/zynqmpimage.h +2 -0
index 7c47dc0763b..867fc5294a3 100644
@@ -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)
#2 lore raw

PATCH 1/1 mkimage: allow zynqmpbif to use a register initialization file

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 implements a binding to that existing support.

---
 tools/zynqmpbif.c   | 16 ++++++++++++++--
 tools/zynqmpimage.c |  4 ++--
 tools/zynqmpimage.h |  2 ++
 3 files changed, 18 insertions(+), 4 deletions(-)
tools/zynqmpbif.c +14 -2
index 82ce0ac1a52..546b9e4fd9d 100644
@@ -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 },
@@ -279,7 +280,7 @@ static int bif_add_blob(const void *data, size_t len, size_t *offset)
 	return 0;
 }
 
-static int bif_init(void)
+static int bif_initialize(void)
 {
 	struct zynqmp_header header = { { 0 } };
 	int r;
@@ -316,6 +317,15 @@ static int bif_add_pmufw(struct bif_entry *bf, const char *data, size_t len)
 	return 0;
 }
 
+static int bif_init(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_init(bf);
 
 	r = bif_add_blob(data, len, &bf->offset);
 	if (r)
@@ -837,7 +849,7 @@ int zynqmpbif_copy_image(int outfd, struct image_tool_params *mparams)
 	uint32_t csum;
 	int bldr = -1;
 
-	bif_init();
+	bif_initialize();
 
 	/* Read .bif input file */
 	bif = read_full_file(mparams->datafile, NULL);
tools/zynqmpimage.c +2 -2
index 4db9877127e..eb79c0696cc 100644
@@ -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;
tools/zynqmpimage.h +2 -0
index 7c47dc0763b..867fc5294a3 100644
@@ -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)
Signature · 1 line
2.43.0
maintainer
#3 lore raw

Re: [PATCH] mkimage: allow zynqmpbif to use a register initialization file

Quoted 5 lines · Erich E. Hoover

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 implements a binding to that existing support.

Quoted 7 lines
---
  tools/zynqmpbif.c   | 16 ++++++++++++++--
  tools/zynqmpimage.c |  4 ++--
  tools/zynqmpimage.h |  2 ++
  3 files changed, 18 insertions(+), 4 deletions(-)

As discussed in that separate thread please send v2 with extended commit message as was asked by Sean.

Thanks,
Michal

#5 lore raw
Quoted 1 line · Sean Anderson

Please add a commit message.

My apologies to everyone. The checkpatch.pl script caught that and, since I changed the title a little, I accidentally uploaded the wrong version.

Quoted 1 line

And isn't this already possible with -R ?

Yes, sort of, if you are using "zynqmpimage" instead of "zynqmpbif" then you can add the register initialization with -R. The patch 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

We are using this feature, in combination with other zynqmpbif options, like so:
===

image : {
        [init] fsbl.int
        [bootloader] fsbl.elf
        [pmufw_image] pmufw.elf
        [destination_cpu=none] fsbl.tcl
        [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
}
===

Best,
Erich

#6 lore raw
Quoted 10 lines · Erich E. Hoover
Quoted 1 line · Sean Anderson

Please add a commit message.

My apologies to everyone. The checkpatch.pl script caught that and, since I changed the title a little, I accidentally uploaded the wrong version.

Quoted 1 line

And isn't this already possible with -R ?

Yes, sort of, if you are using "zynqmpimage" instead of "zynqmpbif"

I've never seen the point of BIFs; I've been able to do everything I want with zynqmpimage.

But this info would be good to put in the commit message.

Quoted 20 lines

then you can add the register initialization with -R. The patch 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

We are using this feature, in combination with other zynqmpbif options, like so:
===

image : {
         [init] fsbl.int
         [bootloader] fsbl.elf
         [pmufw_image] pmufw.elf
         [destination_cpu=none] fsbl.tcl
         [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
}
===

Best,
Erich

#7 lore raw
Quoted 6 lines · Sean Anderson
Quoted 2 lines · Erich E. Hoover

...
Yes, sort of, if you are using "zynqmpimage" instead of "zynqmpbif"

I've never seen the point of BIFs; I've been able to do everything I want with zynqmpimage.

My understanding is that "zynqmpimage" only works if you have one "partition", so if you're passing the ATF or other partition data I think that you have to use "zynqmpbif".

Quoted 1 line

But this info would be good to put in the commit message.

How's this sound?:
===
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 implements a binding to that existing support.
===
( https://lists.denx.de/pipermail/u-boot/2026-June/620814.html ) Please accept my apologies again for messing that up the first time around.

Quoted 1 line
Quoted 1 line

...

#8 lore raw
Quoted 5 lines · Erich E. Hoover
Quoted 4 lines · Sean Anderson
Quoted 2 lines · Erich E. Hoover

...
Yes, sort of, if you are using "zynqmpimage" instead of "zynqmpbif"

Quoted 7 lines
Quoted 2 lines

I've never seen the point of BIFs; I've been able to do everything I want with zynqmpimage.

My understanding is that "zynqmpimage" only works if you have one "partition", so if you're passing the ATF or other partition data I think that you have to use "zynqmpbif".

I used ATF, but this was with SPL. So the boot process went something like

Boot ROM loads zynqmpimage
- PMU firmware to PMU RAM
- U-Boot SPL to OCRAM

U-Boot SPL loads FIT
- ATF to OCRAM
- U-Boot/DTB to DDR
- Bitstream to PL

And ATF was configured to jump to DDR after initializing.

I guess if you are using FSBL that doesn't work, but IMO FSBL is yet another incompatible bootloader to maintain. I'd rather have a shared codebase (SPL/U-Boot).

Quoted 11 lines
Quoted 1 line

But this info would be good to put in the commit message.

How's this sound?:
===
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 implements a binding to that existing support.
===
( https://lists.denx.de/pipermail/u-boot/2026-June/620814.html ) Please accept my apologies again for messing that up the first time around.

Actually, I liked how you explained it in your previous email

If you are using "zynqmpimage" instead of "zynqmpbif" then you can add the register initialization with -R. This patch 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

We are using this feature, in combination with other zynqmpbif options, like so:
===

image : {
        [init] fsbl.int
        [bootloader] fsbl.elf
        [pmufw_image] pmufw.elf
        [destination_cpu=none] fsbl.tcl
        [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
}
===

#9 lore raw
Quoted 25 lines · Sean Anderson
Quoted 5 lines · Erich E. Hoover
Quoted 4 lines · Sean Anderson
Quoted 2 lines · Erich E. Hoover

...
Yes, sort of, if you are using "zynqmpimage" instead of "zynqmpbif"

Quoted 7 lines
Quoted 2 lines

I've never seen the point of BIFs; I've been able to do everything I want with zynqmpimage.

My understanding is that "zynqmpimage" only works if you have one "partition", so if you're passing the ATF or other partition data I think that you have to use "zynqmpbif".

I used ATF, but this was with SPL. So the boot process went something like

Boot ROM loads zynqmpimage
- PMU firmware to PMU RAM
- U-Boot SPL to OCRAM

U-Boot SPL loads FIT
- ATF to OCRAM
- U-Boot/DTB to DDR
- Bitstream to PL

Quoted 5 lines

And ATF was configured to jump to DDR after initializing.

I guess if you are using FSBL that doesn't work, but IMO FSBL is yet another incompatible bootloader to maintain. I'd rather have a shared codebase (SPL/U-Boot).

The other advantage of this is that the FIT is loaded with SPL (which can use a faster bus than the boot ROM, although I think FSBL does this too) and the images (especially the bitstream) can be compressed. Even something like LZO is very effective at compressing the bitstream and sped up the boot by several seconds.

Quoted 32 lines
Quoted 11 lines
Quoted 1 line

But this info would be good to put in the commit message.

How's this sound?:
===
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 implements a binding to that existing support.
===
( https://lists.denx.de/pipermail/u-boot/2026-June/620814.html ) Please accept my apologies again for messing that up the first time around.

Actually, I liked how you explained it in your previous email

If you are using "zynqmpimage" instead of "zynqmpbif" then you can add the register initialization with -R. This patch 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

We are using this feature, in combination with other zynqmpbif options, like so:
===
image : {
        [init] fsbl.int
        [bootloader] fsbl.elf
        [pmufw_image] pmufw.elf
        [destination_cpu=none] fsbl.tcl
        [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
}
===

#10 lore raw
Quoted 14 lines · Sean Anderson
Quoted 13 lines · Sean Anderson

...

I used ATF, but this was with SPL. So the boot process went something like

Boot ROM loads zynqmpimage
- PMU firmware to PMU RAM
- U-Boot SPL to OCRAM

U-Boot SPL loads FIT
- ATF to OCRAM
- U-Boot/DTB to DDR
- Bitstream to PL

Quoted 5 lines
Quoted 5 lines

And ATF was configured to jump to DDR after initializing.

I guess if you are using FSBL that doesn't work, but IMO FSBL is yet another incompatible bootloader to maintain. I'd rather have a shared codebase (SPL/U-Boot).

We currently have thirteen ZynqMP systems that all have different pin configurations, so we have a unified FSBL that uses the JTAG psu_init.tcl (and a small register initialization file) to initialize the part. I'm not aware of a clean way to do something similar in the SPL/U-Boot approach, without having a bunch of different u-boot builds, but I'm open to other suggestions.

Quoted 6 lines

The other advantage of this is that the FIT is loaded with SPL (which can use a faster bus than the boot ROM, although I think FSBL does this too) and the images (especially the bitstream) can be compressed. Even something like LZO is very effective at compressing the bitstream and sped up the boot by several seconds.
...

We no longer include the bitstream in the boot.bin, so the time to load the boot.bin is not something that is a major concern for us. We're mostly trying to manage the complexity of having a bunch of differently-configured ZynqMP systems.

Best,
Erich

maintainer
#11 lore raw
In reply to Sean Anderson
Quoted 51 lines · Sean Anderson
Quoted 5 lines · Erich E. Hoover
Quoted 4 lines · Sean Anderson
Quoted 2 lines · Erich E. Hoover

...
Yes, sort of, if you are using "zynqmpimage" instead of "zynqmpbif"

Quoted 7 lines
Quoted 2 lines

I've never seen the point of BIFs; I've been able to do everything I want with zynqmpimage.

My understanding is that "zynqmpimage" only works if you have one "partition", so if you're passing the ATF or other partition data I think that you have to use "zynqmpbif".

I used ATF, but this was with SPL. So the boot process went something like

Boot ROM loads zynqmpimage
- PMU firmware to PMU RAM
- U-Boot SPL to OCRAM

U-Boot SPL loads FIT
- ATF to OCRAM
- U-Boot/DTB to DDR
- Bitstream to PL

And ATF was configured to jump to DDR after initializing.

I guess if you are using FSBL that doesn't work, but IMO FSBL is yet another incompatible bootloader to maintain. I'd rather have a shared codebase (SPL/U-Boot).

Quoted 11 lines
Quoted 1 line

But this info would be good to put in the commit message.

How's this sound?:
===
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 implements a binding to that existing support.
===
( https://lists.denx.de/pipermail/u-boot/2026-June/620814.html ) Please accept my apologies again for messing that up the first time around.

Actually, I liked how you explained it in your previous email

If you are using "zynqmpimage" instead of "zynqmpbif" then you can add the register initialization with -R. This patch 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

Quoted 12 lines

We are using this feature, in combination with other zynqmpbif options, like so:
===
image : {
        [init] fsbl.int
        [bootloader] fsbl.elf
        [pmufw_image] pmufw.elf
        [destination_cpu=none] fsbl.tcl
        [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
}
===

I am reading it as request for v2 with updated commit message. That's why please send v2 with it.

Thanks,
Michal