From patchwork Wed Feb 16 23:16:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 543046 Delivered-To: patch@linaro.org Received: by 2002:adf:df0e:0:0:0:0:0 with SMTP id y14csp1371312wrl; Wed, 16 Feb 2022 15:19:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJYQm6TFw4uao9gAldACND69UfTVQaHL87c2f3n/NMy5+KSDa7MhoKH8YhYRY9RDjS2YEG X-Received: by 2002:a50:c29a:0:b0:400:47b6:a928 with SMTP id o26-20020a50c29a000000b0040047b6a928mr84356edf.144.1645053546400; Wed, 16 Feb 2022 15:19:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645053546; cv=none; d=google.com; s=arc-20160816; b=i4lTRLxcwH2VnBy5it6MkGMjQ7OS2dbkRP9OALncIgFiJAJ1YuZ8sRlYK6/7dN4tbC Rl+KKO0jWiYvFs5CRd6OkdHJ4/i6vCk93xi9doy5gH7dZeXCJjJZ2IMIzjJcLkUJLeDL w2DQYepUCDijgMr0Ga8Qo49kj40/WjMkSxlz5b/864g4dDe6RWEK6vCT8QXpaahrNRsx tQMcQQzDFDdklnESQzBKjKd+wuea58WPzH5l3BYmPAC+EkSpWx16cgw/uzOGJHAkJbvP P8QnXYOswF8MTy5ABHfLtrvraR8cO3e6ro+UQ3u8/dJ1fmA4GDe7VDt47XD25o3oA3Cx ZWag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=sYk1Ya7G3aQj+8zQadktl9g0zpsGVzzODLpzrJ2EvIo=; b=YxMjRNl8vtZPbP3MXsMGRXvDK3o2+6LFV4hcUQpo4fZ8O+ZwPFCqosLxrcmfRi8Ztc DAH29+rWfO7zh7ZOHwISzWHnl/U+iD0Xzt/y3zv0m1F/j8lQXRSZlZu6dVecNcC3l6v4 cTHyz6LnHTcU3Kw5nwPFHN0OconFcFWsoCAYzF+c/GFkI7s5NhVM1osUep6JadbzPMHo H2HtZYPQxFlTEj4wzTP7kl3dS5LrecQ1a7q/Pba0xlI+SKF4vPTJ53YYz3tHDWmvB+WM HYuo/PSWmC5CaLF/8hp/DyOBQIyfr6pVqF8YzB/wfh6ZBA+y3BMVP19ShWEiF5j8KOYl YwOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oJsa8wBf; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id w7si3106160edd.402.2022.02.16.15.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 15:19:06 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oJsa8wBf; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 728E783A4F; Thu, 17 Feb 2022 00:18:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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; unprotected) header.d=linaro.org header.i=@linaro.org header.b="oJsa8wBf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 73CCC83A64; Thu, 17 Feb 2022 00:18:57 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) (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 0F2F3836C8 for ; Thu, 17 Feb 2022 00:18:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linus.walleij@linaro.org Received: by mail-lf1-x12d.google.com with SMTP id b9so6690798lfv.7 for ; Wed, 16 Feb 2022 15:18:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sYk1Ya7G3aQj+8zQadktl9g0zpsGVzzODLpzrJ2EvIo=; b=oJsa8wBfu9oIV+r0ax9wZtqrRSF8XB1ceoOPpEOnK5FNq6Akwj5RuwmyjnE3y81wji l3mCvucl+GVEEI2qF0a6mrJCMedUb3WA/xJYFQsfSSQBexeh1bbdKqeZ38A8WGJvLDZl jIJbOlYVmuB+Iy5Zuwb2pznRHvOsG2er3cYEYK9gQ6dfa0U6EO8Tp2SIlftqULNVGmI/ 0vgzK2E7hFSVmMRSFOWk/wzJv3zTzDqYf0eS3K/N17Tfdch0wF50b8ZSNkBm72GwDhFE iGqpNEyzHh7lgkfjf8YQ11uVSjHzebBe/cEKSw093mwg++VdF1Qiy9G7V6gykWXh1Mf0 CL6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sYk1Ya7G3aQj+8zQadktl9g0zpsGVzzODLpzrJ2EvIo=; b=Iy/CWgIIPEUXifMsHePyzQKLau/1t6zlYC/174FxXOYzZFGdXEJ51Hsb3EXN0yz0uL b0pGXQMaBW/cABnCAEF6lwOCavdAmsd8J1JOhsc0XlcbNX4mSbizQozW0UTujn0wxFwc vvJFC3ijYLbOTN2agtie+9ung//eHC7n0bm8isBA+bvvXYKPzIlMH1U5kc3de2oBgwxq xhgUeDrqnc3/cWdO1dSIur3NxPIU8dwJxX6y++S6nKyjO7t8t6nQ6n+k0sI7pCtSCiuy svDx/wfEGEDbN0dGF61U9uRZIysrYCfAMlP39wRVC00Z29yOKd+TbotsYeH/PWyqgfRI ty0w== X-Gm-Message-State: AOAM532ZZdyjW7BY3VaEIHXoGOi0eTy808FLdopK0F5LB6mUDhkIwSH9 EbvfAKimBC4Aj5npefAq0ueA573oR/Iy9E7b X-Received: by 2002:a05:6512:1329:b0:443:1593:4648 with SMTP id x41-20020a056512132900b0044315934648mr209292lfu.593.1645053533064; Wed, 16 Feb 2022 15:18:53 -0800 (PST) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id 18sm710657ljo.96.2022.02.16.15.18.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 15:18:52 -0800 (PST) From: Linus Walleij To: u-boot@lists.denx.de, Tom Rini Cc: Linus Walleij , Markuss Broks , Stephan Gerhold , Simon Glass , Sam Protsenko Subject: [PATCH] cmd: abootimg: Accept a DTB in second for index 0 Date: Thu, 17 Feb 2022 00:16:47 +0100 Message-Id: <20220216231647.1314798-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean If the user is using an old Android image (version < 2) there are no special DTB pointers. What systems do in this case is to use the "second" area for a DTB, and this is what bootm is falling back to when booting and abootimg, see image-fdt.c function boot_get_fdt(). So since I need this on some PostmarkeOS systems to modify DTBs on-the-fly, make the abootimg also recognize and fall back to using "second" if the Android image header is < 2. Cc: Markuss Broks Cc: Stephan Gerhold Cc: Simon Glass Cc: Sam Protsenko Signed-off-by: Linus Walleij --- cmd/abootimg.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/abootimg.c b/cmd/abootimg.c index f48a9dcb021d..fd4c102d909f 100644 --- a/cmd/abootimg.c +++ b/cmd/abootimg.c @@ -119,7 +119,19 @@ static int abootimg_get_dtb_by_index(int argc, char *const argv[]) if (!android_image_get_dtb_by_index(abootimg_addr(), num, &addr, &size)) { - return CMD_RET_FAILURE; + /* + * If we are asking for index 0 and have header v1 we fall back + * to getting the FDT from the "second" area. + */ + const struct andr_img_hdr *hdr = (const struct andr_img_hdr *)abootimg_addr(); + ulong tmp; + + if (num == 0 && !android_image_get_second(hdr, &addr, &tmp)) { + size = tmp; + printf("Using FDT in Android image second area for index 0\n"); + } else { + return CMD_RET_FAILURE; + } } if (argc == 1) {