From patchwork Mon Jul 25 17:29:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Drudis Ferran X-Patchwork-Id: 1660458 X-Patchwork-Delegate: ykai007@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Ls6WC58RFz9sGH for ; Tue, 26 Jul 2022 03:30:14 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 562E88422F; Mon, 25 Jul 2022 19:30:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=tinet.cat Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id C31F584223; Mon, 25 Jul 2022 19:30:00 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mx1.tinet.cat (mx1.dipta.cat [195.76.233.59]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B7D6E84223 for ; Mon, 25 Jul 2022 19:29:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=tinet.cat Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xdrudis@tinet.cat X-ASG-Debug-ID: 1658770195-12aaf241471c4240001-4l7tJC Received: from smtp01.tinet.cat (smtp.tinet.org [195.77.216.131]) by mx1.tinet.cat with ESMTP id EPRmkx4Ab28EYEDX; Mon, 25 Jul 2022 19:29:55 +0200 (CEST) X-Barracuda-Envelope-From: xdrudis@tinet.cat X-Barracuda-Effective-Source-IP: smtp.tinet.org[195.77.216.131] X-Barracuda-Apparent-Source-IP: 195.77.216.131 Received: from begut (99.red-79-152-185.dynamicip.rima-tde.net [79.152.185.99]) by smtp01.tinet.cat (Postfix) with ESMTPSA id 3054E605E0C3; Mon, 25 Jul 2022 19:29:55 +0200 (CEST) Date: Mon, 25 Jul 2022 19:29:53 +0200 From: Xavier Drudis Ferran To: Quentin Schulz Cc: Xavier Drudis Ferran , Quentin Schulz , kever.yang@rock-chips.com, andy.yan@rock-chips.com, hl@rock-chips.com, chenjh@rock-chips.com, manivannan.sadhasivam@linaro.org, nick@khadas.com, jbx6244@gmail.com, deepakdas.linux@gmail.com, linux@alxd.me, u-boot@lists.denx.de Subject: Replace make-fit-atf.py with binman. Was: migrate u-boot-rockchip.bin to binman and generate an image for SPI Message-ID: <20220725172953.GD2029@begut> X-ASG-Orig-Subj: Replace make-fit-atf.py with binman. Was: migrate u-boot-rockchip.bin to binman and generate an image for SPI MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Barracuda-Connect: smtp.tinet.org[195.77.216.131] X-Barracuda-Start-Time: 1658770195 X-Barracuda-URL: https://webmail.tinet.cat:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 9832 X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: SPAM GLOBAL 1.0000 1.0000 4.3430 X-Barracuda-Spam-Score: 4.34 X-Barracuda-Spam-Status: No, SCORE=4.34 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=6.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.99624 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean El Mon, Jul 25, 2022 at 06:39:31PM +0200, Quentin Schulz deia: > > Don't really want to hijack the thread with something slightly unrelated but > posting this here for posterity: > > is what I have currently done and the outcome of this is: > > > U-Boot TPL 2022.07-00811-gf6815f93eb-dirty (Jul 25 2022 - 18:24:06) > Channel 0: DDR3, 666MHz > BW=32 Col=10 Bk=8 CS0 Row=15 CS=1 Die BW=16 Size=1024MB > Channel 1: DDR3, 666MHz > BW=32 Col=10 Bk=8 CS0 Row=15 CS=1 Die BW=16 Size=1024MB > 256B stride > Trying to boot from BOOTROM > Returning to boot ROM... > > U-Boot SPL 2022.07-00811-gf6815f93eb-dirty (Jul 25 2022 - 18:24:06 +0200) > Trying to boot from MMC2 > alloc space exhausted > FIT buffer of 1018880 bytes > Could not get FIT buffer of 1018880 bytes > check CONFIG_SYS_SPL_MALLOC_SIZE Yeah, happened to me too before I did it external. > No valid device tree binary found at 00000000002c0e88 > initcall sequence 0000000000286bd0 failed at call 0000000000279604 (err=-1) > ### ERROR ### Please RESET the board ### > > The new u-boot-rockchip.bin is only about 2KB bigger. The name and addresses > are correctly returned by mkimage -l when comparing the current > implementation and with the patch above applied. Mmmm.... It looks very similar to what I got to boot. I fixed alignment, just that, and my names are slightly different. But I think it's either you have it external or syou increase space for buffers. I copy here the rockchip-u-boot.dtsi file and then 2 patches on top of yours. // SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2019 Jagan Teki */ #include / { binman: binman { multiple-images; }; }; #ifdef CONFIG_SPL &binman { #ifndef CONFIG_USE_SPL_FIT_GENERATOR itb: itb { filename = "u-boot.itb"; fit { filename = "u-boot.itb"; description = "U-Boot FIT"; fit,fdt-list = "of-list"; fit,external-offset=<0>; images { uboot { description = "U-Boot (64-bit)"; type = "standalone"; os = "U-Boot"; arch = "arm64"; compression = "none"; load = ; u-boot-nodtb { }; }; #ifdef CONFIG_SPL_ATF @atf_SEQ { fit,operation = "split-elf"; description = "ARM Trusted Firmware"; type = "firmware"; arch = "arm64"; os = "arm-trusted-firmware"; compression = "none"; fit,load; fit,entry; fit,data; atf-bl31 { }; }; #endif #ifdef CONFIG_TEE @tee_SEQ { fit,operation = "split-elf"; description = "TEE"; type = "tee"; arch = "arm64"; os = "tee"; compression = "none"; fit,load; fit,entry; fit,data; tee-os { }; }; #endif @fdt_SEQ { description = "NAME.dtb"; type = "flat_dt"; compression = "none"; }; }; configurations { default = "@config_DEFAULT-SEQ"; @config_SEQ { description = "NAME.dtb"; fdt = "fdt_SEQ"; firmware = "atf_1"; loadables = "uboot","atf_2","atf_3"; }; }; }; }; #endif simple-bin { filename = "u-boot-rockchip.bin"; pad-byte = <0xff>; mkimage { args = "-n", CONFIG_SYS_SOC, "-T", "rksd"; #ifndef CONFIG_TPL u-boot-spl { }; }; #else u-boot-tpl { }; }; u-boot-spl { }; #endif #ifdef CONFIG_ARM64 #ifdef CONFIG_USE_SPL_FIT_GENERATOR blob { filename = "u-boot.itb"; #else collection { content = <&/binman/itb>; #endif #else u-boot-img { #endif offset = <((CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR - 64) * 512)>; }; }; #ifdef CONFIG_ROCKCHIP_SPI_IMAGE simple-bin-spi { filename = "u-boot-rockchip-spi.bin"; pad-byte = <0xff>; mkimage { args = "-n", CONFIG_SYS_SOC, "-T", "rkspi"; #ifdef CONFIG_TPL multiple-data-files; u-boot-tpl { }; #endif u-boot-spl { }; }; #ifdef CONFIG_ARM64 #ifdef CONFIG_USE_SPL_FIT_GENERATOR blob { filename = "u-boot.itb"; #else collection { content = <&/binman/itb>; #endif #else u-boot-img { #endif /* Sync with u-boot,spl-payload-offset if present */ offset = ; }; }; #endif }; #endif From 0f9cf7452a62268ec5978c80f46bf9323a269630 Mon Sep 17 00:00:00 2001 From: Xavier Drudis Ferran Date: Mon, 25 Jul 2022 17:35:27 +0200 Subject: [PATCH] Align the fit images that binman produces to 8 bytes. In commit 570c4636808 ("Makefile: Align fit-dtb.blob and u-boot.itb by 64bits") Michal Simek claims that according to the device tree spec, some things should be aligned to 4 bytes and some to 8, so passes -B 8 to mkimage. Do the same when using binman so that we can try to replace make_fit_atf.py . Should this be optional? I haven't found any uses of split-elf that I might be breaking, and Marek said it's from dt spec, so it should be always required. So I'm hard coding it until the need for being optional arises. --- tools/binman/btool/mkimage.py | 4 +++- tools/binman/etype/fit.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/binman/btool/mkimage.py b/tools/binman/btool/mkimage.py index c85bfe053c..d614d72d62 100644 --- a/tools/binman/btool/mkimage.py +++ b/tools/binman/btool/mkimage.py @@ -22,7 +22,7 @@ class Bintoolmkimage(bintool.Bintool): # pylint: disable=R0913 def run(self, reset_timestamp=False, output_fname=None, external=False, - pad=None, version=False): + pad=None, version=False, align=None): """Run mkimage Args: @@ -36,6 +36,8 @@ class Bintoolmkimage(bintool.Bintool): version: True to get the mkimage version """ args = [] + if align: + args += ['-B', f'{align:x}'] if external: args.append('-E') if pad: diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py index 12306623af..7b99b83fa3 100644 --- a/tools/binman/etype/fit.py +++ b/tools/binman/etype/fit.py @@ -420,6 +420,7 @@ class Entry_fit(Entry_section): ext_offset = self._fit_props.get('fit,external-offset') if ext_offset is not None: args = { + 'align': 8, 'external': True, 'pad': fdt_util.fdt32_to_cpu(ext_offset.value) } -- 2.20.1 From 9fc65a2eb55f742dd805ed96e3d2028b20078a03 Mon Sep 17 00:00:00 2001 From: Xavier Drudis Ferran Date: Mon, 25 Jul 2022 18:01:24 +0200 Subject: [PATCH] Replace make_fit_atf.py with binman. This boots my Rock Pi 4B, but likely needs more generalisation to cover more boards and configurations. --- Makefile | 3 -- arch/arm/dts/rockchip-u-boot.dtsi | 70 ++++++++++++++++++++++++++++++ configs/rock-pi-4-rk3399_defconfig | 1 + 3 files changed, 71 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 279aeacee3..ad739ef357 100644 --- a/Makefile +++ b/Makefile @@ -997,9 +997,6 @@ endif ifeq ($(CONFIG_ARCH_ROCKCHIP)$(CONFIG_SPL),yy) # Binman image dependencies -ifeq ($(CONFIG_ARM64),y) -INPUTS-y += u-boot.itb -endif else INPUTS-y += u-boot.img endif diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi index 4c26caa92a..5a613650f5 100644 --- a/arch/arm/dts/rockchip-u-boot.dtsi +++ b/arch/arm/dts/rockchip-u-boot.dtsi @@ -13,6 +13,75 @@ #ifdef CONFIG_SPL &binman { + itb { + filename = "u-boot.itb"; + fit { + filename = "u-boot.itb"; + description = "U-Boot FIT"; + fit,fdt-list = "of-list"; + fit,external-offset=<0>; + + images { + uboot { + description = "U-Boot (64-bit)"; + type = "standalone"; + os = "U-Boot"; + arch = "arm64"; + compression = "none"; + load = ; + u-boot-nodtb { + }; + }; +#ifdef CONFIG_SPL_ATF + @atf_SEQ { + fit,operation = "split-elf"; + description = "ARM Trusted Firmware"; + type = "firmware"; + arch = "arm64"; + os = "arm-trusted-firmware"; + compression = "none"; + fit,load; + fit,entry; + fit,data; + + atf-bl31 { + }; + }; +#endif +#ifdef CONFIG_TEE + @tee_SEQ { + fit,operation = "split-elf"; + description = "TEE"; + type = "tee"; + arch = "arm64"; + os = "tee"; + compression = "none"; + fit,load; + fit,entry; + fit,data; + + tee-os { + }; + }; +#endif + @fdt_SEQ { + description = "NAME.dtb"; + type = "flat_dt"; + compression = "none"; + }; + }; + configurations { + default = "@config_DEFAULT-SEQ"; + + @config_SEQ { + description = "NAME.dtb"; + fdt = "fdt_SEQ"; + firmware = "atf_1"; + loadables = "uboot","atf_2","atf_3"; + }; + }; + }; + }; simple-bin { filename = "u-boot-rockchip.bin"; pad-byte = <0xff>; @@ -62,6 +131,7 @@ #ifdef CONFIG_ARM64 blob { filename = "u-boot.itb"; + #else u-boot-img { #endif diff --git a/configs/rock-pi-4-rk3399_defconfig b/configs/rock-pi-4-rk3399_defconfig index f12cf24cb4..1c07114528 100644 --- a/configs/rock-pi-4-rk3399_defconfig +++ b/configs/rock-pi-4-rk3399_defconfig @@ -22,6 +22,7 @@ CONFIG_DEBUG_UART=y CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x3000000 CONFIG_TPL_SYS_MALLOC_F_LEN=0x4000 +# CONFIG_USE_SPL_FIT_GENERATOR is not set CONFIG_SYS_LOADADDR_ALIGN_DOWN_BITS=16 CONFIG_BOOTSTAGE=y CONFIG_SPL_BOOTSTAGE=y