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 23A22C4332F for ; Wed, 21 Dec 2022 23:44:24 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EECB185278; Thu, 22 Dec 2022 00:44:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="sb5IVUor"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BFEE585236; Thu, 22 Dec 2022 00:44:19 +0100 (CET) Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DF7A685242 for ; Thu, 22 Dec 2022 00:44:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x836.google.com with SMTP id j16so241852qtv.4 for ; Wed, 21 Dec 2022 15:44:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TNXyxGXfOxljU0YW4itdbqN5XUnHgbTUpPPayht880k=; b=sb5IVUoravf1ZNVMiyhmvAwEuI1Xj0/iwFpZpDIRFkdLgEH7mgC9DqvCDCgGywKEWX VPJJNZ+DsMI3BNuFRkYKQnQQhYGXu8Oh/CQ6h3A4pFIRhJxVpdFHk3qv+OxjYG9TUbUW 8Pvvg/kI39RQdZxj++qTY/ioXFDyAe4CF27X0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TNXyxGXfOxljU0YW4itdbqN5XUnHgbTUpPPayht880k=; b=54btPePxTwrmPeICctnR64Y1R6+Sd3HkQUrKRKMmg2QKg2ZocXRqaRJA2Oyq5j7f/f aLr0pzLk1NhcAjxQH4LClWi8zTfpMHIm/HkwWEuxyRX4o2t6GHLbHOu9COr0F2XW2zb2 6Jn8HFxsmsUdlqw0Cqy56G8mBtosAbWN5OYQWEPxIZ7dDJqgnMfrn2kkBOEygIupMU4y rVCxi7wrTLdCpBG35JGvat0kmCKpsDJjPMupyfXCROiCE5XEaTGiBdIq/uelUiReU183 NpR11oPUkJeavEWXmYYOABAL3sjUyaWcI6atQzgoKdStcJtgAZAGKqWjd0+A2QJxkOPt MRFg== X-Gm-Message-State: AFqh2kpRaaeCrb6NtSpm8sOPqLKQ6UV7Y6Pxed201F6NX27VIuGzI8O+ lehzNBhksWOUMZR3vDOdD8Qt4w== X-Google-Smtp-Source: AMrXdXt6iyhTEPJAhl1wqjHZQvgSfZ27luiKpsSXYa6M1xEpt3DxutA2Eza97ZwUUdwkqtgLRBncRQ== X-Received: by 2002:ac8:43d8:0:b0:3a9:82a1:fb02 with SMTP id w24-20020ac843d8000000b003a982a1fb02mr4860610qtn.16.1671666255615; Wed, 21 Dec 2022 15:44:15 -0800 (PST) Received: from bill-the-cat (2603-6081-7b00-6400-24f0-bc4b-7894-230e.res6.spectrum.com. [2603:6081:7b00:6400:24f0:bc4b:7894:230e]) by smtp.gmail.com with ESMTPSA id t1-20020ac865c1000000b003a4f22c6507sm9899806qto.48.2022.12.21.15.44.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Dec 2022 15:44:15 -0800 (PST) Date: Wed, 21 Dec 2022 18:44:12 -0500 From: Tom Rini To: Mark Kettenis 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 Subject: Re: [PATCH] lds: align u-boot-nodtb with 8 bytes boundary Message-ID: <20221221234412.GE3787616@bill-the-cat> References: <20221215115825.827111-1-eugen.hristev@microchip.com> <87edsx4qzy.fsf@bloch.sibelius.xs4all.nl> <20221221215637.GA3787616@bill-the-cat> <87len02xan.fsf@bloch.sibelius.xs4all.nl> <20221221230910.GC3787616@bill-the-cat> <87k02k2vku.fsf@bloch.sibelius.xs4all.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="MKa6wr/LzAsEyz8d" Content-Disposition: inline In-Reply-To: <87k02k2vku.fsf@bloch.sibelius.xs4all.nl> X-Clacks-Overhead: GNU Terry Pratchett 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 --MKa6wr/LzAsEyz8d Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 22, 2022 at 12:20:01AM +0100, Mark Kettenis wrote: > > Date: Wed, 21 Dec 2022 18:09:10 -0500 > > From: Tom Rini > >=20 > > On Wed, Dec 21, 2022 at 11:42:56PM +0100, Mark Kettenis wrote: > > > > Date: Wed, 21 Dec 2022 16:56:37 -0500 > > > > From: Tom Rini > > > >=20 > > > > 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 > > > > > >=20 > > > > > > Newer DTC require that the DTB start address is aligned at 8 by= tes. > > > > > > In the u-boot.bin case, the u-boot-nodtb.bin is concatenated wi= th the > > > > > > DTB, but there is no alignment/padding to the next 8byte aligne= d address. > > > > > > This causes the board to fail booting, because the FDT will cla= im > > > > > > 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 byt= es. > > > > > > The objcopy in the Makefile will create the u-boot-nodtb.bin an= d it has to > > > > > > be truncated to 8 bytes to correspond to the u-boot.map file wh= ich 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. > > > > > >=20 > > > > > > This patch is also a prerequisite to have the possibility to up= date the > > > > > > dtc inside u-boot to newer versions (1.6.1+) > > > > > >=20 > > > > > > Signed-off-by: Eugen Hristev > > > > > > --- > > > > > > Hi, > > > > > >=20 > > > > > > 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 den= x. > > > > > > I cannot guarantee that no other boards are affected, so this p= atch is a bit > > > > > > of an RFC. > > > > > > If the u-boot-nodtb.bin does not have the size equal with the c= orresponding > > > > > > one in u-boot.map, the binary_size_check will fail at build tim= e with > > > > > > something like this: > > > > > >=20 > > > > > > u-boot.map shows a binary size of 502684 > > > > > > but u-boot-nodtb.bin shows 502688 > > > > > >=20 > > > > > > Thanks, > > > > > > Eugen > > > > > >=20 > > > > > > 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(-) > > > > > >=20 > > > > > > diff --git a/Makefile b/Makefile > > > > > > index 9d84f96481..b4d387bcce 100644 > > > > > > --- a/Makefile > > > > > > +++ b/Makefile > > > > > > @@ -1317,6 +1317,8 @@ endif > > > > > > =20 > > > > > > u-boot-nodtb.bin: u-boot FORCE > > > > > > $(call if_changed,objcopy_uboot) > > > > > > +# Make sure the size is 8 byte-aligned. > > > > > > + @truncate -s %8 $@ > > > > >=20 > > > > > $ truncate > > > > > ksh: truncate: not found > > > > >=20 > > > > > 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 there= fore > > > > > its usage is unportable. > > > > >=20 > > > > > Please find a different solution. > > > >=20 > > > > 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 sa= y 512 > > > > bytes: > > > > dd if=3D/dev/urandom of=3Dtestfile bs=3D1 count=3D500 > > > > dd if=3D/dev/null of=3Dtestfile bs=3D1 count=3D512 > > > >=20 > > > > And then hexdump or whatever to see that the last 12 bytes are zero= =2E 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! > > >=20 > > > Hi Tom, > > >=20 > > > 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). > >=20 > > Ah, I typod that, sorry! I meant (and just re-checked): > > dd if=3D/dev/urandom of=3Dtestfile bs=3D1 count=3D500 > > dd if=3D/dev/null of=3Dtestfile bs=3D1 seek=3D512 > >=20 > > Which here does: > > $ dd if=3D/dev/urandom of=3Dtestfile bs=3D1 count=3D500 > > 500+0 records in > > 500+0 records out > > 500 bytes copied, 0.00641125 s, 78.0 kB/s > > $ dd if=3D/dev/null of=3Dtestfile bs=3D1 seek=3D512 > > 0+0 records in > > 0+0 records out > > 0 bytes copied, 0.000358246 s, 0.0 kB/s > > $ ls -l testfile > > -rw-rw-r-- 1 trini trini 512 Dec 21 18:07 testfile > > $ hexdump testfile | tail -n2 > > 00001f0 8cdd 300e 0000 0000 0000 0000 0000 0000 > > 0000200 >=20 > That works here as well. Great, thanks! --=20 Tom --MKa6wr/LzAsEyz8d Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmOjmkkACgkQFHw5/5Y0 tyxx+gv/TmHq80lIx544p7UV1Ak+bmTPyfANsvmnvvLLsJ8ovafwZCetxeOE8sUg HfDAKhm3ml/3cV0lw7gWy5pNDsXNanXO61+5LLOEUDbBXpTg4fMQtbaA4kJqIP/Z cYsxG1RyvoDL/JD+cAnAmh2ZuLn/LZ+q/0JCKX7FQiElYrJM18Uo3Pg8eRG4e1tx s0tXjE1i0BeGTdfeuGpdLoR0qGTilN48qy98/ZSZ7T69U3ZZjANj3teaa2Y0FP7r LXILCUdpVF+lROYmErODsQLbztTKdSX1jcWhG2y6MryPeVE2zbYKeDVt52hejCzn fMaMJgsBjz1X5UbE9A06zeMUZQp9l7JC2LlJS8GtiGuqQAreP703k1H+vWuWFyfp rZIUjfyJtvblAPBqtAIz3EQWLV9qe/etnEif1FhuzabRVHJ9wZmcmIZdfGU2L+Sl XPmvRYWNDYoZq7RcE0lvF1zq/Ky8PxirLpUzs4vYyKHNnp0b7CTyAjFvnptLrymw 36w0llAN =nJcX -----END PGP SIGNATURE----- --MKa6wr/LzAsEyz8d--