All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v2-RESEND 2/6] arm-trusted-firmware: generate atf-uboot.ub for ZynqMP booting
Date: Mon, 9 Apr 2018 23:08:05 +0200	[thread overview]
Message-ID: <20180409230805.66ab7dc5@windsurf> (raw)
In-Reply-To: <1523032461-3295-3-git-send-email-luca@lucaceresoli.net>

Hello,

On Fri,  6 Apr 2018 18:34:17 +0200, Luca Ceresoli wrote:
> U-Boot SPL for the Xilinx ZynqMP SoCs needs ATF in this format to load
> it.
> 
> Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
> 
> Changes v1 -> v2: none.
> ---
>  boot/arm-trusted-firmware/Config.in               |  9 +++++++++
>  boot/arm-trusted-firmware/arm-trusted-firmware.mk | 21 +++++++++++++++++++++
>  2 files changed, 30 insertions(+)
> 
> diff --git a/boot/arm-trusted-firmware/Config.in b/boot/arm-trusted-firmware/Config.in
> index 7aef87cb746c..dca9958423b9 100644
> --- a/boot/arm-trusted-firmware/Config.in
> +++ b/boot/arm-trusted-firmware/Config.in
> @@ -71,6 +71,15 @@ config BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL31
>  	  typically used on platforms where another bootloader (e.g
>  	  U-Boot) encapsulates ATF BL31.
>  
> +config BR2_TARGET_ARM_TRUSTED_FIRMWARE_ZYNQMP_UB_MKIMAGE
> +	bool "Generate a U-Boot image (for Xilinx ZynqMP U-Boot)"
> +	depends on BR2_cortex_a53
> +	select BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL31
> +	help
> +	  Uses mkimage from uboot-tools to encapsulate bl31.bin into
> +	  a U-Boot image named atf-uboot.ub. This is needed by the
> +	  Xilinx version of U-Boot SPL to load ATF on the ZynqMP SoC.

In fact this doesn't look like very Xilinx-specific. It just
encapsulates the bl31 image in a U-Boot image format. This could
potentially be used by other platforms as well.

So, perhaps we could make this:

config BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL31_UBOOT
	bool "Build BL31 U-Boot image"
	select BR2_TARGET_ARM_TRUSTED_FIRMWARE_BL31
	help
	  This option will generate a bl31.bin that is encapsulates
	  into a U-Boot image named atf-uboot.ub. This is for example
	  used by the Xilinx version of U-Boot SPL to load ATF on the
	  ZynqMP SoC.

> +ifeq ($(BR2_TARGET_ARM_TRUSTED_FIRMWARE_ZYNQMP_UB_MKIMAGE),y)
> +define ARM_TRUSTED_FIRMWARE_ZYNQMP_UB_MKIMAGE
> +# Get the entry point address from the elf.
> +	BASE_ADDR=$$($(TARGET_READELF) -h $(ARM_TRUSTED_FIRMWARE_IMG_DIR)/bl31/bl31.elf | \
> +	             grep -E -m 1 -i "entry point.*?0x" | \
> +	             sed -r 's/.*?(0x.*?)/\1/g') && \

Meh, what a mess to get the entry point address :-/ Could this be
simplified with:

$(TARGET_READELF) -h $(ARM_TRUSTED_FIRMWARE_IMG_DIR)/bl31/bl31.elf | sed '/^  Entry point address: *\(.*\)/!d; s//\1/'

(Thanks Yann!)

> +	$(HOST_DIR)/bin/mkimage \
> +		-A arm64 -O arm-trusted-firmware -C none \
> +		-a $${BASE_ADDR} -e $${BASE_ADDR} \
> +		-d $(ARM_TRUSTED_FIRMWARE_IMG_DIR)/bl31.bin \
> +		$(ARM_TRUSTED_FIRMWARE_IMG_DIR)/atf-uboot.ub
> +endef
> +define ARM_TRUSTED_FIRMWARE_ZYNQMP_UB_INSTALL
> +	install $(ARM_TRUSTED_FIRMWARE_IMG_DIR)/atf-uboot.ub $(BINARIES_DIR)

Should be:

	$(INSTALL) -m 0644 -D $(ARM_TRUSTED_FIRMWARE_IMG_DIR)/atf-uboot.ub $(BINARIES_DIR)/atf-uboot.ub

> +endef
> +ARM_TRUSTED_FIRMWARE_MAKE_OPTS += RESET_TO_BL31=1
> +ARM_TRUSTED_FIRMWARE_DEPENDENCIES += host-uboot-tools
> +ARM_TRUSTED_FIRMWARE_POST_BUILD_HOOKS += ARM_TRUSTED_FIRMWARE_ZYNQMP_UB_MKIMAGE
> +ARM_TRUSTED_FIRMWARE_POST_INSTALL_IMAGES_HOOKS += ARM_TRUSTED_FIRMWARE_ZYNQMP_UB_INSTALL

Rather than hooks, just use directly
ARM_TRUSTED_FIRMWARE_ZYNQMP_UB_MKIMAGE and
ARM_TRUSTED_FIRMWARE_ZYNQMP_UB_INSTALL in the BUILD_CMDS and
INSTALL_IMAGES_CMDS. Of course, remove the ZYNQMP part of the variable
names if you agree with my proposal above.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2018-04-09 21:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06 16:34 [Buildroot] [PATCH v2-RESEND 0/6] Add Xilinx ZynqMP and ZCU106 board support Luca Ceresoli
2018-04-06 16:34 ` [Buildroot] [PATCH v2-RESEND 1/6] arm-trusted-firmware: simplify release dir path Luca Ceresoli
2018-04-06 16:34 ` [Buildroot] [PATCH v2-RESEND 2/6] arm-trusted-firmware: generate atf-uboot.ub for ZynqMP booting Luca Ceresoli
2018-04-09 21:08   ` Thomas Petazzoni [this message]
2018-04-11 21:12     ` Luca Ceresoli
2018-04-06 16:34 ` [Buildroot] [PATCH v2-RESEND 3/6] zynqmp-pmufw-binaries: new package Luca Ceresoli
2018-04-09 21:13   ` Thomas Petazzoni
2018-04-11 21:03     ` Luca Ceresoli
2018-04-12  9:09       ` Thomas Petazzoni
2018-05-03 16:26         ` Luca Ceresoli
2018-04-06 16:34 ` [Buildroot] [PATCH v2-RESEND 4/6] uboot: zynqmp: generate SPL image with PMUFW binary Luca Ceresoli
2018-04-09 21:26   ` Thomas Petazzoni
2018-04-06 16:34 ` [Buildroot] [PATCH v2-RESEND 5/6] uboot: zynqmp: allow to use custom psu_init files Luca Ceresoli
2018-04-06 16:34 ` [Buildroot] [PATCH v2-RESEND 6/6] configs: add Xilinx ZCU106 board (ZynqMP SoC) Luca Ceresoli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180409230805.66ab7dc5@windsurf \
    --to=thomas.petazzoni@bootlin.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.