diff mbox series

boot/qoriq-ddr-phy-binary: new package

Message ID 20250318163228.9989-1-vjardin@free.fr
State Rejected
Headers show
Series boot/qoriq-ddr-phy-binary: new package | expand

Commit Message

Vincent Jardin March 18, 2025, 4:32 p.m. UTC
The DDR PHY on the NXP LX2160A SoC needs firmware. This is distributed
as prebuilt binaries by NXP through GitHub.
This firmware is linked and used by the ATF.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: Vincent Jardin <vjardin@free.fr>
---
 DEVELOPERS                                    |  3 +++
 boot/Config.in                                |  1 +
 .../arm-trusted-firmware.mk                   |  8 +++++++
 boot/qoriq-ddr-phy-binary/Config.in           |  9 ++++++++
 .../qoriq-ddr-phy-binary.hash                 |  3 +++
 .../qoriq-ddr-phy-binary.mk                   | 21 +++++++++++++++++++
 6 files changed, 45 insertions(+)
 create mode 100644 boot/qoriq-ddr-phy-binary/Config.in
 create mode 100644 boot/qoriq-ddr-phy-binary/qoriq-ddr-phy-binary.hash
 create mode 100644 boot/qoriq-ddr-phy-binary/qoriq-ddr-phy-binary.mk

Comments

Vincent Jardin March 18, 2025, 4:36 p.m. UTC | #1
Hi Vladimir,

On Tue, Mar 18, 2025 at 05:32:28PM +0100, Vincent Jardin wrote:
> The DDR PHY on the NXP LX2160A SoC needs firmware. This is distributed
> as prebuilt binaries by NXP through GitHub.
> This firmware is linked and used by the ATF.
> 
> Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
> Signed-off-by: Vincent Jardin <vjardin@free.fr>

Please, can you consider this move to boot/ ? It seems to be better
aligned with some other binary firmwares that are used to build the ATF
using Buildroot such as binaries-marvell/ for instance.

Best regards,
  Vincent
Vladimir Oltean March 26, 2025, 2:20 p.m. UTC | #2
Hi Vincent,

On Tue, Mar 18, 2025 at 05:36:28PM +0100, Vincent Jardin wrote:
> On Tue, Mar 18, 2025 at 05:32:28PM +0100, Vincent Jardin wrote:
> > This firmware is linked and used by the ATF.
> 
> Please, can you consider this move to boot/ ? It seems to be better
> aligned with some other binary firmwares that are used to build the ATF
> using Buildroot such as binaries-marvell/ for instance.

I didn't study the binaries-marvell case, but I can explain the
situation here.

You say "the [DDR PHY] firmware is linked by the ATF" and required to
build it, but that isn't really the case.

The documentation at https://docs.nxp.com/bundle/UG10143/page/topics/tf-a_features.html
says:

  How to compile DDR FIP image (only applicable for LX2160ARDB and LX2162AQDS)

  A pre-built FIP image is already provided in the release.
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  To regenerate the DDR fip image for LX2160ARDB, and LX2162AQDS, perform
  the following steps [ proceeds to show how to use fiptool ]:

In other words, running the commands below results in the exact same
fip_ddr binary as the atf would produce.

[vladimir@pc /opt] $ git clone https://github.com/nxp-qoriq/ddr-phy-binary.git qoriq-ddr-phy-binary
Cloning into 'qoriq-ddr-phy-binary'...
remote: Enumerating objects: 110, done.
remote: Counting objects: 100% (43/43), done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 110 (delta 25), reused 28 (delta 12), pack-reused 67 (from 1)
Receiving objects: 100% (110/110), 255.87 KiB | 602.00 KiB/s, done.
Resolving deltas: 100% (69/69), done.
[vladimir@pc /opt] $ cd qoriq-ddr-phy-binary
[vladimir@pc /opt/qoriq-ddr-phy-binary] $ /opt/qoriq-atf/tools/fiptool/fiptool info lx2160a/fip_ddr.bin
DDR UDIMM PHY IMEM 1d FW: offset=0x178, size=0x6BD0, cmdline="--ddr-immem-udimm-1d"
DDR UDIMM PHY IMEM 2d FW: offset=0x6D48, size=0x694C, cmdline="--ddr-immem-udimm-2d"
DDR UDIMM PHY DMEM 1d FW: offset=0xD694, size=0x6D0, cmdline="--ddr-dmmem-udimm-1d"
DDR UDIMM PHY DMEM 2d FW: offset=0xDD64, size=0x5BC, cmdline="--ddr-dmmem-udimm-2d"
DDR RDIMM PHY IMEM 1d FW: offset=0xE320, size=0x7050, cmdline="--ddr-immem-rdimm-1d"
DDR RDIMM PHY IMEM 2d FW: offset=0x15370, size=0x6D14, cmdline="--ddr-immem-rdimm-2d"
DDR RDIMM PHY DMEM 1d FW: offset=0x1C084, size=0x714, cmdline="--ddr-dmmem-rdimm-1d"
DDR RDIMM PHY DMEM 2d FW: offset=0x1C798, size=0x5FC, cmdline="--ddr-dmmem-rdimm-2d"
[vladimir@pc /opt/qoriq-ddr-phy-binary] $ /opt/qoriq-atf/tools/fiptool/fiptool create --ddr-immem-udimm-1d lx2160a/ddr4_pmu_train_imem.bin --ddr-immem-udimm-2d lx2160a/ddr4_2d_pmu_train_imem.bin --ddr-dmmem-udimm-1d lx2160a/ddr4_pmu_train_dmem.bin --ddr-dmmem-udimm-2d lx2160a/ddr4_2d_pmu_train_dmem.bin --ddr-immem-rdimm-1d lx2160a/ddr4_rdimm_pmu_train_imem.bin --ddr-immem-rdimm-2d lx2160a/ddr4_rdimm2d_pmu_train_imem.bin --ddr-dmmem-rdimm-1d lx2160a/ddr4_rdimm_pmu_train_dmem.bin --ddr-dmmem-rdimm-2d lx2160a/ddr4_rdimm2d_pmu_train_dmem.bin fip_ddr_new.bin
[vladimir@pc /opt/qoriq-ddr-phy-binary] $ diff fip_ddr_new.bin lx2160a/fip_ddr.bin
[vladimir@pc /opt/qoriq-ddr-phy-binary] $ echo $?
0

Even at runtime, the DDR PHY firmware is not compiled into the ATF firmware.
Rather, if you look at qoriq-atf commit 34d483565078 ("nxp: fip-handler
for additional ddr-fip.bin"), you will see that ddr_fip_setup() reads
the FIP image from offset 8M ("#define PLAT_DDR_FIP_OFFSET 0x800000") of
whatever boot storage device ATF was compiled for (QSPI_BOOT, NOR_BOOT etc).
In other words, the fact that board/solidrun/lx2160acex7/genimage.cfg in
my previous submission had "offset = 8M" here:

+       partition ddr-phy {
+               in-partition-table = "no"
+               image = "fip_ddr.bin"
+               offset = 8M
+       }

is not a coincidence, but ATF's expectation of where to find the FIP
image for the DDR PHY firmware at runtime. The two are in principle
decoupled at build time, and tied together by this convention.

But, my understanding is that one might want to re-generate another
Firmware Image Package (FIP) with DDR PHY firmware only in the case
where you have a trusted boot flow, and you want to authenticate the
firmware image by signing it with your own keys (more in
docs/plat/nxp/nxp-ls-tbbr.rst). That isn't something I was intending to
support, but is not something that your proposed patch supports either.
I would also imagine that using ATF's build system is not the only
possible way to sign the firmware images, but truth be told, I don't
really know, I never explored this, and for my personal use I don't
need it.

What is your intention? Do you just want me to move this package to
"boot" because of a misunderstanding, or do you want to support signing
of the DDR PHY firmware using ATF's build system?
Vincent Jardin March 26, 2025, 11:46 p.m. UTC | #3
Hi Vladimir,

On Wed, Mar 26, 2025 at 04:20:45PM +0100, Vladimir Oltean wrote:
> You say "the [DDR PHY] firmware is linked by the ATF" and required to
> build it, but that isn't really the case.
> 
> The documentation at https://docs.nxp.com/bundle/UG10143/page/topics/tf-a_features.html
> says:
> 
>   How to compile DDR FIP image (only applicable for LX2160ARDB and LX2162AQDS)
> 
>   A pre-built FIP image is already provided in the release.
>   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   To regenerate the DDR fip image for LX2160ARDB, and LX2162AQDS, perform
>   the following steps [ proceeds to show how to use fiptool ]:

Thanks for the pointers on this documentation and the below handson.

> In other words, running the commands below results in the exact same
> fip_ddr binary as the atf would produce.
> 
> [vladimir@pc /opt] $ git clone https://github.com/nxp-qoriq/ddr-phy-binary.git qoriq-ddr-phy-binary
> Cloning into 'qoriq-ddr-phy-binary'...
> remote: Enumerating objects: 110, done.
> remote: Counting objects: 100% (43/43), done.
> remote: Compressing objects: 100% (31/31), done.
> remote: Total 110 (delta 25), reused 28 (delta 12), pack-reused 67 (from 1)
> Receiving objects: 100% (110/110), 255.87 KiB | 602.00 KiB/s, done.
> Resolving deltas: 100% (69/69), done.
> [vladimir@pc /opt] $ cd qoriq-ddr-phy-binary
> [vladimir@pc /opt/qoriq-ddr-phy-binary] $ /opt/qoriq-atf/tools/fiptool/fiptool info lx2160a/fip_ddr.bin
> DDR UDIMM PHY IMEM 1d FW: offset=0x178, size=0x6BD0, cmdline="--ddr-immem-udimm-1d"
> DDR UDIMM PHY IMEM 2d FW: offset=0x6D48, size=0x694C, cmdline="--ddr-immem-udimm-2d"
> DDR UDIMM PHY DMEM 1d FW: offset=0xD694, size=0x6D0, cmdline="--ddr-dmmem-udimm-1d"
> DDR UDIMM PHY DMEM 2d FW: offset=0xDD64, size=0x5BC, cmdline="--ddr-dmmem-udimm-2d"
> DDR RDIMM PHY IMEM 1d FW: offset=0xE320, size=0x7050, cmdline="--ddr-immem-rdimm-1d"
> DDR RDIMM PHY IMEM 2d FW: offset=0x15370, size=0x6D14, cmdline="--ddr-immem-rdimm-2d"
> DDR RDIMM PHY DMEM 1d FW: offset=0x1C084, size=0x714, cmdline="--ddr-dmmem-rdimm-1d"
> DDR RDIMM PHY DMEM 2d FW: offset=0x1C798, size=0x5FC, cmdline="--ddr-dmmem-rdimm-2d"
> [vladimir@pc /opt/qoriq-ddr-phy-binary] $ /opt/qoriq-atf/tools/fiptool/fiptool create --ddr-immem-udimm-1d lx2160a/ddr4_pmu_train_imem.bin --ddr-immem-udimm-2d lx2160a/ddr4_2d_pmu_train_imem.bin --ddr-dmmem-udimm-1d lx2160a/ddr4_pmu_train_dmem.bin --ddr-dmmem-udimm-2d lx2160a/ddr4_2d_pmu_train_dmem.bin --ddr-immem-rdimm-1d lx2160a/ddr4_rdimm_pmu_train_imem.bin --ddr-immem-rdimm-2d lx2160a/ddr4_rdimm2d_pmu_train_imem.bin --ddr-dmmem-rdimm-1d lx2160a/ddr4_rdimm_pmu_train_dmem.bin --ddr-dmmem-rdimm-2d lx2160a/ddr4_rdimm2d_pmu_train_dmem.bin fip_ddr_new.bin
> [vladimir@pc /opt/qoriq-ddr-phy-binary] $ diff fip_ddr_new.bin lx2160a/fip_ddr.bin
> [vladimir@pc /opt/qoriq-ddr-phy-binary] $ echo $?
> 0

Yes, I had identified the same and I it is a good ack't that we can
rebuild it.

> Even at runtime, the DDR PHY firmware is not compiled into the ATF firmware.

Yes, I did notice it when reading the scripts.

> But, my understanding is that one might want to re-generate another
> Firmware Image Package (FIP) with DDR PHY firmware only in the case
> where you have a trusted boot flow, and you want to authenticate the
> firmware image by signing it with your own keys (more in
> docs/plat/nxp/nxp-ls-tbbr.rst). That isn't something I was intending to
> support, but is not something that your proposed patch supports either.

Right, it'll be my intend. I did notice this capability and I was
intending to check it once I'll dig with the complete chain of trust.

> What is your intention? Do you just want me to move this package to
> "boot" because of a misunderstanding, or do you want to support signing
> of the DDR PHY firmware using ATF's build system?

Sorry if I was unclear:
  - the signature will be a support I'll check and I'd like to
    mainstream with Buildroot.
  - it seems for me it was better to align it into the boot/ folder
    since this blob is rather loaded soon by the LX2160 ; so I was
    inspired by the Marvell case.

I do not pretend to have enough expertise with Buildroot, but it seems
for me that boot/ is a better home for such package. Maybe a Buildroot
maintainer can help us to be proper aligned with the intends of the
Buildroot's design ?

Vladimir: what would the rational be to have it into package/ ? Are
there some other cases of boot-stage firmwares that are into package/ ?
Maybe the package/freescale-imx with its FIRMWARE_IMX_PREPARE_DDR_FW
could be a case. What's about the signature of the IMX firmwares ?

Best regards,
  Vincent
Vladimir Oltean March 27, 2025, 2:42 p.m. UTC | #4
On Thu, Mar 27, 2025 at 12:46:47AM +0100, Vincent Jardin wrote:
> Sorry if I was unclear:
>   - the signature will be a support I'll check and I'd like to
>     mainstream with Buildroot.
>   - it seems for me it was better to align it into the boot/ folder
>     since this blob is rather loaded soon by the LX2160 ; so I was
>     inspired by the Marvell case.
> 
> I do not pretend to have enough expertise with Buildroot, but it seems
> for me that boot/ is a better home for such package. Maybe a Buildroot
> maintainer can help us to be proper aligned with the intends of the
> Buildroot's design ?
> 
> Vladimir: what would the rational be to have it into package/ ? Are
> there some other cases of boot-stage firmwares that are into package/ ?
> Maybe the package/freescale-imx with its FIRMWARE_IMX_PREPARE_DDR_FW
> could be a case. What's about the signature of the IMX firmwares ?

I don't want to compare with package/freescale-imx. I think it's
sufficient to consider package/qoriq-rcw/ as something which is more
directly relevant here, because that is already used on Layerscape, and
ATF does have a build dependency on it. We do already have:

config BR2_TARGET_ARM_TRUSTED_FIRMWARE_RCW
	bool "Include NXP RCW in BL2"
	depends on BR2_PACKAGE_HOST_QORIQ_RCW
	help
	  Include the NXP RCW (Reset Control Word) in BL2. See
	  package/qoriq-rcw/ for more details. This is mostly useful
	  on NXP LayerScape platforms.

so a dependency from boot/ to package/ is not something entirely new
(though not required here, at least for now). Still, maybe it's best for
a Buildroot maintainer to share an expert opinion.
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 0c6d7532f8..5c6106c481 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -3362,6 +3362,9 @@  N:	Vivien Didelot <vivien.didelot@gmail.com>
 F:	board/technologic/ts5500/
 F:	configs/ts5500_defconfig
 
+N:	Vladimir Oltean <olteanv@gmail.com>
+F:	boot/qoriq-ddr-phy-binary/
+
 N:	Volkov Viacheslav <sv99@inbox.ru>
 F:	package/v4l2grab/
 F:	package/zbar/
diff --git a/boot/Config.in b/boot/Config.in
index f167346cdf..873dc8b977 100644
--- a/boot/Config.in
+++ b/boot/Config.in
@@ -12,6 +12,7 @@  source "boot/mv-ddr-marvell/Config.in"
 source "boot/mxs-bootlets/Config.in"
 source "boot/optee-os/Config.in"
 source "boot/opensbi/Config.in"
+source "boot/qoriq-ddr-phy-binary/Config.in"
 source "boot/s500-bootloader/Config.in"
 source "boot/shim/Config.in"
 source "boot/syslinux/Config.in"
diff --git a/boot/arm-trusted-firmware/arm-trusted-firmware.mk b/boot/arm-trusted-firmware/arm-trusted-firmware.mk
index dca16d3960..ad9ffbfe6c 100644
--- a/boot/arm-trusted-firmware/arm-trusted-firmware.mk
+++ b/boot/arm-trusted-firmware/arm-trusted-firmware.mk
@@ -160,6 +160,14 @@  ARM_TRUSTED_FIRMWARE_MAKE_TARGETS += pbl
 ARM_TRUSTED_FIRMWARE_MAKE_OPTS += RCW=$(BINARIES_DIR)/PBL.bin
 endif
 
+# Specific for lx2160a
+# same name than https://github.com/nxp-qoriq/ddr-phy-binary/blob/master/lx2160a/fip_ddr.bin
+ifeq ($(BR2_TARGET_QORIQ_DDR_PHY_BINARY),y)
+ARM_TRUSTED_FIRMWARE_MAKE_OPTS += DDR_FIP_NAME=fip_ddr.bin
+ARM_TRUSTED_FIRMWARE_DEPENDENCIES += qoriq-ddr-phy-binary
+ARM_TRUSTED_FIRMWARE_MAKE_OPTS += DDR_PHY_BIN_PATH=$(QORIQ_DDR_PHY_BINARY_DIR)/lx2160a
+endif
+
 ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL31),y)
 ARM_TRUSTED_FIRMWARE_MAKE_TARGETS += bl31
 endif
diff --git a/boot/qoriq-ddr-phy-binary/Config.in b/boot/qoriq-ddr-phy-binary/Config.in
new file mode 100644
index 0000000000..8b8c18186f
--- /dev/null
+++ b/boot/qoriq-ddr-phy-binary/Config.in
@@ -0,0 +1,9 @@ 
+config BR2_TARGET_QORIQ_DDR_PHY_BINARY
+	bool "qoriq-ddr-phy-binary"
+	depends on BR2_aarch64
+	help
+	  Firmware binary for DDR PHY of NXP LX2160A family of SoCs.
+	  This package downloads and installs such firmware, which
+	  is needed to build the ATF.
+
+	  https://github.com/nxp-qoriq/ddr-phy-binary
diff --git a/boot/qoriq-ddr-phy-binary/qoriq-ddr-phy-binary.hash b/boot/qoriq-ddr-phy-binary/qoriq-ddr-phy-binary.hash
new file mode 100644
index 0000000000..adc173221e
--- /dev/null
+++ b/boot/qoriq-ddr-phy-binary/qoriq-ddr-phy-binary.hash
@@ -0,0 +1,3 @@ 
+# Locally calculated
+sha256  b49cb34f941f7e534ec31d3d14d18d4e565e4875b690ecb0d7e2992b72c64dc7  qoriq-ddr-phy-binary-lf-6.6.36-2.1.0.tar.gz
+sha256  e7e5f4949f7ac9f9a5d4d68b8f835f3ddc93ad47b594a11de699d90b9175413f  NXP-Binary-EULA.txt
diff --git a/boot/qoriq-ddr-phy-binary/qoriq-ddr-phy-binary.mk b/boot/qoriq-ddr-phy-binary/qoriq-ddr-phy-binary.mk
new file mode 100644
index 0000000000..fefc71e646
--- /dev/null
+++ b/boot/qoriq-ddr-phy-binary/qoriq-ddr-phy-binary.mk
@@ -0,0 +1,21 @@ 
+################################################################################
+#
+# qoriq-ddr-phy-binary
+#
+################################################################################
+
+QORIQ_DDR_PHY_BINARY_VERSION = lf-6.6.36-2.1.0
+QORIQ_DDR_PHY_BINARY_SITE = $(call github,nxp-qoriq,ddr-phy-binary,$(QORIQ_DDR_PHY_BINARY_VERSION))
+
+QORIQ_DDR_PHY_BINARY_LICENSE = NXP Binary EULA
+QORIQ_DDR_PHY_BINARY_LICENSE_FILES = NXP-Binary-EULA.txt
+
+QORIQ_DDR_PHY_BINARY_INSTALL_IMAGES = YES
+
+# same name than arm-trusted-firmware
+#   DDR_FIP_NAME=fip_ddr.bin
+define QORIQ_DDR_PHY_BINARY_INSTALL_IMAGES_CMDS
+	$(INSTALL) -D $(@D)/lx2160a/fip_ddr.bin $(BINARIES_DIR)/fip_ddr.bin
+endef
+
+$(eval $(generic-package))