Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7BE52C4332F for ; Wed, 21 Dec 2022 22:43:05 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 849F285236; Wed, 21 Dec 2022 23:43:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=xs4all.nl Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=xs4all.nl header.i=@xs4all.nl header.b="WVuNEx2t"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A361F85282; Wed, 21 Dec 2022 23:43:00 +0100 (CET) Received: from ewsoutbound.kpnmail.nl (ewsoutbound.kpnmail.nl [195.121.94.170]) (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 2799C851D7 for ; Wed, 21 Dec 2022 23:42:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=xs4all.nl Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mark.kettenis@xs4all.nl X-KPN-MessageId: cdba79a7-8180-11ed-8e68-005056ab378f Received: from smtp.kpnmail.nl (unknown [10.31.155.40]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id cdba79a7-8180-11ed-8e68-005056ab378f; Wed, 21 Dec 2022 23:42:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=xs4all01; h=subject:to:from:message-id:date; bh=a8U+jJ/Dzylxh+2r/xFSoj6G4+ZFDKvO5PgqVt5AdVE=; b=WVuNEx2t7iRK1+Vn3LfTZnPfqnbhhQf8HyjETINRVSx3GMckJkfxhxL3dygzeh0x2XWYvcgMmJdV7 ZakGRRtnmBb+ukj0Ztd9DQQ2NY92iFyvTPy5kXdp2tVSSar0oTjHxa5e56Zy8VBS6iRBJ43/U1FoI2 TC9XgaAkY9Kbxx8pbjBg+sP7S2qapszW6A0Ccn7RqQtXKkRYZMJA0OZVh8EDfForH0yD36wvsNDWKM qzWgOj88CGDVN2KG0wbmNIKyO+5mRzCypyARh3J61A4KojVoplnWfbZKEg7AZMijK1gebXPUbdFv7B LiD9+S83KAFiwc5KscgdVnneOtV4lsQ== X-KPN-MID: 33|faPvHuvEIVgK3vlZfvr6a7A4yhGJpMLSDntrohb+Tr9AOXIHSz21l8zmKN44aKx ij+5GI4d/aMyqoHphdKS3Z4W8PR+ud1ViOOisBFC90k0= X-KPN-VerifiedSender: Yes X-CMASSUN: 33|mJECOJTY9aEXElUpsLAY0PAUCHD49rr/a+NYKbPxAbflf02DACV+EBh9S+CYQPg k9wjrMzpypURF18T96lDyvA== X-Originating-IP: 80.61.163.207 Received: from bloch.sibelius.xs4all.nl (80-61-163-207.fixed.kpn.net [80.61.163.207]) by smtp.xs4all.nl (Halon) with ESMTPSA id cfe6610c-8180-11ed-927c-005056ab7584; Wed, 21 Dec 2022 23:42:56 +0100 (CET) Date: Wed, 21 Dec 2022 23:42:56 +0100 Message-Id: <87len02xan.fsf@bloch.sibelius.xs4all.nl> From: Mark Kettenis To: Tom Rini Cc: eugen.hristev@microchip.com, u-boot@lists.denx.de, sjg@chromium.org, xypron.glpk@gmx.de, michal.simek@amd.com, daniel.schwierzeck@gmail.com, marex@denx.de, alpernebiyasak@gmail.com In-Reply-To: <20221221215637.GA3787616@bill-the-cat> (message from Tom Rini on Wed, 21 Dec 2022 16:56:37 -0500) Subject: Re: [PATCH] lds: align u-boot-nodtb with 8 bytes boundary References: <20221215115825.827111-1-eugen.hristev@microchip.com> <87edsx4qzy.fsf@bloch.sibelius.xs4all.nl> <20221221215637.GA3787616@bill-the-cat> 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 > Date: Wed, 21 Dec 2022 16:56:37 -0500 > From: Tom Rini > > On Sat, Dec 17, 2022 at 11:14:41PM +0100, Mark Kettenis wrote: > > > From: Eugen Hristev > > > Date: Thu, 15 Dec 2022 13:58:25 +0200 > > > > > > Newer DTC require that the DTB start address is aligned at 8 bytes. > > > In the u-boot.bin case, the u-boot-nodtb.bin is concatenated with the > > > DTB, but there is no alignment/padding to the next 8byte aligned address. > > > This causes the board to fail booting, because the FDT will claim > > > that the DTB inside u-boot.bin is not a valid DTB, it will fail with > > > -FDT_ERR_ALIGNMENT. > > > To solve this, have the u-boot binary `_end` aligned with 8 bytes. > > > The objcopy in the Makefile will create the u-boot-nodtb.bin and it has to > > > be truncated to 8 bytes to correspond to the u-boot.map file which will > > > have the `_end` aligned to 8 bytes. > > > The lds files which use devicetrees have been changed to align the `_end` > > > tag with 8 bytes. > > > > > > This patch is also a prerequisite to have the possibility to update the > > > dtc inside u-boot to newer versions (1.6.1+) > > > > > > Signed-off-by: Eugen Hristev > > > --- > > > Hi, > > > > > > I could not test all affected boards, it's an impossible task. > > > I tried this on at91 boards which I have, and ran the CI on denx. > > > I cannot guarantee that no other boards are affected, so this patch is a bit > > > of an RFC. > > > If the u-boot-nodtb.bin does not have the size equal with the corresponding > > > one in u-boot.map, the binary_size_check will fail at build time with > > > something like this: > > > > > > u-boot.map shows a binary size of 502684 > > > but u-boot-nodtb.bin shows 502688 > > > > > > Thanks, > > > Eugen > > > > > > Makefile | 2 ++ > > > arch/arm/cpu/armv8/u-boot.lds | 4 ++-- > > > arch/arm/cpu/u-boot-spl.lds | 1 + > > > arch/arm/cpu/u-boot.lds | 1 + > > > arch/arm/lib/elf_arm_efi.lds | 5 +++++ > > > arch/arm/mach-at91/arm926ejs/u-boot-spl.lds | 2 +- > > > arch/arm/mach-at91/armv7/u-boot-spl.lds | 2 +- > > > arch/arm/mach-zynq/u-boot-spl.lds | 2 +- > > > arch/mips/cpu/u-boot.lds | 2 +- > > > arch/sandbox/cpu/u-boot.lds | 6 ++++++ > > > arch/sh/cpu/u-boot.lds | 2 ++ > > > board/ti/am335x/u-boot.lds | 1 + > > > tools/binman/test/u_boot_binman_embed.lds | 2 +- > > > 13 files changed, 25 insertions(+), 7 deletions(-) > > > > > > diff --git a/Makefile b/Makefile > > > index 9d84f96481..b4d387bcce 100644 > > > --- a/Makefile > > > +++ b/Makefile > > > @@ -1317,6 +1317,8 @@ endif > > > > > > u-boot-nodtb.bin: u-boot FORCE > > > $(call if_changed,objcopy_uboot) > > > +# Make sure the size is 8 byte-aligned. > > > + @truncate -s %8 $@ > > > > $ truncate > > ksh: truncate: not found > > > > In other words: truncate(1) isn't a standard UNIX utility and not > > present on OpenBSD for example. It isn't part of POSIX and therefore > > its usage is unportable. > > > > Please find a different solution. > > Ah yes. Can this perhaps be done with dd? A bit of looking around > suggests that this might be a portable way to truncate a file to say 512 > bytes: > dd if=/dev/urandom of=testfile bs=1 count=500 > dd if=/dev/null of=testfile bs=1 count=512 > > And then hexdump or whatever to see that the last 12 bytes are zero. Can > you please test this on OpenBSD? We'll need some shell work to get > current byte size and make it 8-byte aligned, but that should be > portable at least. Thanks! Hi Tom, That results on a file with zero bytes on OpenBSD... but also on Linux. Did you intend to write something different? I can't immediately come up with a way to do this with dd(1). Cheers, Mark