arm64: zynqmp: Support converting pm_cfg_obj.c
Subsystems (3)
PATCH 1/1 arm64: zynqmp: Support converting pm_cfg_obj.c
To use CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE, a developer must pull down the U-Boot source and run ./tools/zynqmp_pm_cfg_obj_convert.py to convert their pm_cfg_obj.c into U-Boot's PMU loader format, then feed that file back to U-Boot during build.
Instead, by doing the conversion in U-Boot during the build, we can simplify the developer's build system. And it ensures that if zynqmp_pm_cfg_obj_convert.py is updated, the pm_cfg_obj will stay in sync with U-Boot.
Add a config to set the file format, but leave the default as binary type for backwards compatibility.
---
arch/arm/mach-zynqmp/Kconfig | 20 ++++++++++++++++++++ board/xilinx/zynqmp/Makefile | 10 +++++++++- board/xilinx/zynqmp/pm_cfg_obj.S | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-)
arch/arm/mach-zynqmp/Kconfig +20 -0
@@ -65,6 +65,26 @@ config PMUFW_INIT_FILE Include external PMUFW (Platform Management Unit FirmWare) to a Xilinx bootable image (boot.bin). +choice + prompt "PMU firmware configuration format" + default ZYNQMP_SPL_PM_CFG_BIN + help + Format of the file given to ZYNQMP_SPL_PM_CFG_OBJ_FILE. + +config ZYNQMP_SPL_PM_CFG_BIN + bool "pm_cfg_obj.bin" + help + The pm_cfg_obj.c after being preprocessed to a binary blob. + +config ZYNQMP_SPL_PM_CFG_SRC + bool "pm_cfg_obj.c" + help + The source file output from the Xilinx tools. This file is + generated when building the Xilinx SDK BSP. For example at + ./psu_cortexa53_0/libsrc/xilpm_v2_4/src/pm_cfg_obj.c + +endchoice + config ZYNQMP_SPL_PM_CFG_OBJ_FILE string "PMU firmware configuration object to load at runtime by SPL" depends on SPL
board/xilinx/zynqmp/Makefile +9 -1
@@ -40,8 +40,16 @@ endif ifdef CONFIG_SPL_BUILD ifneq ($(CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE),"") +ZYNQMP_SPL_CFG_OBJ_FILE = $(shell cd $(srctree); readlink -f $(CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE)) FORCE +ifdef CONFIG_ZYNQMP_SPL_PM_CFG_BIN +board/xilinx/zynqmp/pm_cfg_obj.bin: $(ZYNQMP_SPL_CFG_OBJ_FILE) + cp $< $@ +else +board/xilinx/zynqmp/pm_cfg_obj.bin: $(ZYNQMP_SPL_CFG_OBJ_FILE) + $(srctree)/tools/zynqmp_pm_cfg_obj_convert.py $< $@ +endif obj-$(CONFIG_SPL_BUILD) += pm_cfg_obj.o -$(obj)/pm_cfg_obj.o: $(shell cd $(srctree); readlink -f $(CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE)) FORCE +$(obj)/pm_cfg_obj.o: board/xilinx/zynqmp/pm_cfg_obj.bin endif endif
board/xilinx/zynqmp/pm_cfg_obj.S +1 -1
@@ -9,7 +9,7 @@ zynqmp_pm_cfg_obj: .align 4 -.incbin CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE +.incbin "board/xilinx/zynqmp/pm_cfg_obj.bin" zynqmp_pm_cfg_obj_end:
Signature · 1 line
2.25.1
PATCH 1/1 arm64: zynqmp: Support converting pm_cfg_obj.c
Hi Brandon,
Quoted 9 lines · Brandon Maier
To use
CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE, a developer must pull down the U-Boot source and run./tools/zynqmp_pm_cfg_obj_convert.pyto convert theirpm_cfg_obj.cinto U-Boot's PMU loader format, then feed that file back to U-Boot during build.Instead, by doing the conversion in U-Boot during the build, we can simplify the developer's build system. And it ensures that if
zynqmp_pm_cfg_obj_convert.pyis updated, thepm_cfg_objwill stay in sync with U-Boot.
In the workflows I have used so far U-Boot tools are extracted in a different step w.r.t. U-Boot cross-compilation, so I never felt the need for this feature. But I understand this feature can be handy.
The code looks OK too.
Signature · 1 line
Luca
A message that is not in the archive (sent off-list or not yet received): CA+fik50_-6oRQTY0MdXacg=LHoKtjkBTQ+MYgK4VptDy5Njygg@mail.gmail.com
PATCH 1/1 arm64: zynqmp: Support converting pm_cfg_obj.c
Forwarding as I forgot to CC
---------- Forwarded message ---------
From: Brandon Maier <[email protected]>
Date: Tue, Jun 23, 2020 at 12:08 PM
Subject: Re: [PATCH] arm64: zynqmp: Support converting pm_cfg_obj.c
To: Luca Ceresoli <[email protected]>
Quoted 9 lines · Luca Ceresoli
Hi Brandon,
Quoted 5 lines · Brandon Maier
To use
CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE, a developer must pull down the U-Boot source and run./tools/zynqmp_pm_cfg_obj_convert.pyto convert theirpm_cfg_obj.cinto U-Boot's PMU loader format, then feed that file back to U-Boot during build.
Quoted 8 lines
Quoted 4 lines
Instead, by doing the conversion in U-Boot during the build, we can simplify the developer's build system. And it ensures that if
zynqmp_pm_cfg_obj_convert.pyis updated, thepm_cfg_objwill stay in sync with U-Boot.In the workflows I have used so far U-Boot tools are extracted in a different step w.r.t. U-Boot cross-compilation, so I never felt the need for this feature. But I understand this feature can be handy.
I'm trying to get it to work with Buildroot. Buildroot does have a package for uboot-tools, so I could use that to run it. I'd have to move the config and build commands into Buildroot's uboot package. Since the script belongs to U-Boot anyway, it seemed cleaner to integrate it directly into U-Boot so it could be used by other build systems too.
Quoted 7 lines
The code looks OK too.
Reviewed-by Luca Ceresoli <[email protected]>--
Luca
PATCH 1/1 arm64: zynqmp: Support converting pm_cfg_obj.c
In reply to a message not in the archiveHi Brandon,
Quoted 19 lines · Brandon Maier
Quoted 9 lines · Luca Ceresoli
Hi Brandon,
Quoted 5 lines · Brandon Maier
To use
CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE, a developer must pull down the U-Boot source and run./tools/zynqmp_pm_cfg_obj_convert.pyto convert theirpm_cfg_obj.cinto U-Boot's PMU loader format, then feed that file back to U-Boot during build.Quoted 8 lines
Quoted 4 lines
Instead, by doing the conversion in U-Boot during the build, we can simplify the developer's build system. And it ensures that if
zynqmp_pm_cfg_obj_convert.pyis updated, thepm_cfg_objwill stay in sync with U-Boot.In the workflows I have used so far U-Boot tools are extracted in a different step w.r.t. U-Boot cross-compilation, so I never felt the need for this feature. But I understand this feature can be handy.
Quoted 6 lines
I'm trying to get it to work with Buildroot. Buildroot does have a package for uboot-tools, so I could use that to run it. I'd have to move the config and build commands into Buildroot's uboot package. Since the script belongs to U-Boot anyway, it seemed cleaner to integrate it directly into U-Boot so it could be used by other build systems too.
I understand. But I also understand Michal's concern: the U-Boot makefiles are quite complex already, and this feature is a relatively minor improvement.
Probably having the conversion in Buildroot could be even simpler as you can support _only_ the C format there and do the conversion unconditionally. Only one workflow, no ifs, simpler code. Don't forget to Cc: me if you send a patch for that, I'll be glad to review it.
Signature · 1 line
Luca
PATCH 1/1 arm64: zynqmp: Support converting pm_cfg_obj.c
Hi,
Quoted 29 lines · Luca Ceresoli
Hi Brandon,
Quoted 19 lines · Brandon Maier
Quoted 9 lines · Luca Ceresoli
Hi Brandon,
Quoted 5 lines · Brandon Maier
To use
CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE, a developer must pull down the U-Boot source and run./tools/zynqmp_pm_cfg_obj_convert.pyto convert theirpm_cfg_obj.cinto U-Boot's PMU loader format, then feed that file back to U-Boot during build.Quoted 8 lines
Quoted 4 lines
Instead, by doing the conversion in U-Boot during the build, we can simplify the developer's build system. And it ensures that if
zynqmp_pm_cfg_obj_convert.pyis updated, thepm_cfg_objwill stay in sync with U-Boot.In the workflows I have used so far U-Boot tools are extracted in a different step w.r.t. U-Boot cross-compilation, so I never felt the need for this feature. But I understand this feature can be handy.
Quoted 6 lines
I'm trying to get it to work with Buildroot. Buildroot does have a package for uboot-tools, so I could use that to run it. I'd have to move the config and build commands into Buildroot's uboot package. Since the script belongs to U-Boot anyway, it seemed cleaner to integrate it directly into U-Boot so it could be used by other build systems too.
Quoted 8 lines
I understand. But I also understand Michal's concern: the U-Boot makefiles are quite complex already, and this feature is a relatively minor improvement.
Probably having the conversion in Buildroot could be even simpler as you can support _only_ the C format there and do the conversion unconditionally. Only one workflow, no ifs, simpler code. Don't forget to Cc: me if you send a patch for that, I'll be glad to review it.
I almost forgot: I wrote some notes on how this could be implemented in yocto a while back. The principles are pretty much the same so you might be interested in reading them:
https://www.yoctoproject.org/pipermail/meta-xilinx/2019-November/004578.html
Signature · 1 line
Luca
Quoted 24 lines · Luca Ceresoli
Hi,
Quoted 20 lines · Luca Ceresoli
Hi Brandon,
Quoted 8 lines · Brandon Maier
Quoted 1 line · Luca Ceresoli
I'm trying to get it to work with Buildroot. Buildroot does have a package for uboot-tools, so I could use that to run it. I'd have to move the config and build commands into Buildroot's uboot package. Since the script belongs to U-Boot anyway, it seemed cleaner to integrate it directly into U-Boot so it could be used by other build systems too.
I understand. But I also understand Michal's concern: the U-Boot makefiles are quite complex already, and this feature is a relatively minor improvement.
Probably having the conversion in Buildroot could be even simpler as you can support _only_ the C format there and do the conversion unconditionally. Only one workflow, no ifs, simpler code. Don't forget to Cc: me if you send a patch for that, I'll be glad to review it.
Either U-Boot or Buildroot is fine by me. If Yocto alreads does it in their U-Boot package then I can see that being a precedent for patching Buildroot. I'll drop this patch to U-Boot then.
Quoted 7 lines
I almost forgot: I wrote some notes on how this could be implemented in yocto a while back. The principles are pretty much the same so you might be interested in reading them:
Thanks!
Quoted 3 lines
--
Luca
Quoted 21 lines · Brandon Maier
Quoted 20 lines · Luca Ceresoli
Hi,
Quoted 16 lines · Luca Ceresoli
Hi Brandon,
Quoted 8 lines · Brandon Maier
Quoted 1 line · Luca Ceresoli
I'm trying to get it to work with Buildroot. Buildroot does have a package for uboot-tools, so I could use that to run it. I'd have to move the config and build commands into Buildroot's uboot package. Since the script belongs to U-Boot anyway, it seemed cleaner to integrate it directly into U-Boot so it could be used by other build systems too.
I understand. But I also understand Michal's concern: the U-Boot makefiles are quite complex already, and this feature is a relatively minor improvement.
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Probably having the conversion in Buildroot could be even simpler as you can support _only_ the C format there and do the conversion unconditionally. Only one workflow, no ifs, simpler code. Don't forget to Cc: me if you send a patch for that, I'll be glad to review it.
Either U-Boot or Buildroot is fine by me. If Yocto alreads does it in their U-Boot package then I can see that being a precedent for patching Buildroot. I'll drop this patch to U-Boot then.
I have never started to use Luca's python script because I use different methods how to get this fragment.
The first one was taking fsbl and simply extract pmu cfg fragment from it with using binutils. I have sent that script some time ago.
And the second method is simply take what Xilinx C file and link it with embeddedSW repository (just for headers) and build it by gcc.
A month ago I was experiment with this fragment and was trying to find out if we can have generic one which works on all platforms. As is visible this is fine for boot but not so good for live system.
The fragment itself by spec has feature for exchanging it at run time. I sent a patch to utilize it based on current code.
https://lists.denx.de/pipermail/u-boot/2020-June/416310.html
It means I would more prefer to go in a way that pmufw will be able to accept board/platform/configuration specific fragments and have just one in u-boot which in general enable everything by default.
But I don't have time to go to pmufw and fix it.
Thanks,
Michal
PATCH 1/1 arm64: zynqmp: Support converting pm_cfg_obj.c
In reply to Brandon MaierQuoted 5 lines · Brandon Maier
To use
CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE, a developer must pull down the U-Boot source and run./tools/zynqmp_pm_cfg_obj_convert.pyto convert theirpm_cfg_obj.cinto U-Boot's PMU loader format, then feed that file back to U-Boot during build.
Quoted 7 lines
Instead, by doing the conversion in U-Boot during the build, we can simplify the developer's build system. And it ensures that if
zynqmp_pm_cfg_obj_convert.pyis updated, thepm_cfg_objwill stay in sync with U-Boot.Add a config to set the file format, but leave the default as binary type for backwards compatibility.
Based on description I can't see the reason for it.
pmu config object should be aligned with pmu not with u-boot itself.
Also using this script is just one way how to get pmufw config object. I personally don't use it but I can't see any issue to be in u-boot project if others want to use it.
Thanks,
Michal
A message that is not in the archive (sent off-list or not yet received): CA+fik51z3vVQDs23Yu7i164vzCQfJz_4jOa_k4nsY58edDHYYw@mail.gmail.com
PATCH 1/1 arm64: zynqmp: Support converting pm_cfg_obj.c
Forgot to CC
---------- Forwarded message ---------
From: Brandon Maier <[email protected]>
Date: Tue, Jun 23, 2020 at 12:16 PM
Subject: Re: [PATCH] arm64: zynqmp: Support converting pm_cfg_obj.c
To: Michal Simek <[email protected]>
Quoted 7 lines · Michal Simek
Quoted 2 lines · Brandon Maier
Add a config to set the file format, but leave the default as binary type for backwards compatibility.
Based on description I can't see the reason for it.
pmu config object should be aligned with pmu not with u-boot itself.
What I mean is, for example if there is a bug in zynqmp_pm_cfg_obj_convert then the pm_cfg binary will automatically be updated the next time U-Boot is built. Compared to if the pm_cfg_obj.bin is stored separately and has to be independently updated for a bug. But it's a minor issue and not that important.
Quoted 5 lines
Also using this script is just one way how to get pmufw config object. I personally don't use it but I can't see any issue to be in u-boot project if others want to use it.
We've been trying to piece together the scripts to build pmu config from an HDF using Luca's blog posts and other source code. Out of curiosity, what are these other methods?
Quoted 3 lines
Thanks,
Michal