From mboxrd@z Thu Jan 1 00:00:00 1970 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 AC58CC38142 for ; Wed, 1 Feb 2023 08:42:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1550685C2A; Wed, 1 Feb 2023 09:42:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com 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=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="7KVX3HqV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B3F7785C2A; Wed, 1 Feb 2023 09:42:46 +0100 (CET) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) (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 B4CF985C1B for ; Wed, 1 Feb 2023 09:42:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mkorpershoek@baylibre.com Received: by mail-wr1-x42b.google.com with SMTP id q5so16575063wrv.0 for ; Wed, 01 Feb 2023 00:42:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=FT7J4u8ZMaO7jsWQVJ0pxUj4eh3q8lNR5yxeKPl1GIw=; b=7KVX3HqV0ZPx8yKW+ZuG+9X92J13RQ8IIE4p9Kvy6FL1AYvGupwORmEzh3lvFvnEsS dIm1XKLpGeKmHPDzjpiQOaguOCsPoO58JrdErEycAF3Rv4xuutfkajv9XSIQ6t3mx160 tBDFjfK060t0k6P4TnQ6M36a3HO70YhSBz4OKyr7F2oBzXtpsT2glvbJyLI0r62O5jTn 4JkvreSgecgu6cGHLqm0QHy2qnvbiFDIx3/ZstKrgJtp+cXsxoojyOoTC3n8ir6/Nugb H8aFdeO1k9RxjraHlc1VJqGnkjrCiBKjpAs+k7xTqUOFs5thi8wRS/GF9Q4yPU5axJgp oP8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FT7J4u8ZMaO7jsWQVJ0pxUj4eh3q8lNR5yxeKPl1GIw=; b=rSekTFqV0Ex9ZpVvO3IYboJPGcE0seJ96YWZADXl5aa40I9852sxE7Py3MazkYbnNu Drkt55Y7IH+DO2Ha5OGo2hJ/kHe+sMa4YAQ9a0xD/XLB6ftk+m3dONuyQoSas6hCQxj2 cXE4H8fnyj+dPYF66PbcfYuyy2L6wT83pK//AQwvvpKpbUfcCuBhJ+6mVFB3P1w9O0tM jGMqbGIuWGoGTD6uSutMemiBIRHXr0SMAyNF1E4wccE7BrRYPxqyqkf6yHco5Osdkaao WC7KxvAx1wN+0y18lQvMFWlI5Ke/HT62flnWVRvb53+y1TrEA4unllY0tkJDYO4lcGAw OGlg== X-Gm-Message-State: AO0yUKWNggsQSB3mxRll6PHIg8fuBdyJH0lNlXYgEAZjVxiTnXepjccm 4x2UVffAJzfswHW1sx4td9CnqQ== X-Google-Smtp-Source: AK7set8tT50hbXMkTVzaYpMga5j6pyk9sNtigGi7WGU7qUuL11+5N7RF6ql9yEx1fryybtVHj40+7Q== X-Received: by 2002:a05:6000:8e:b0:2bf:bb48:ddaf with SMTP id m14-20020a056000008e00b002bfbb48ddafmr1529006wrx.7.1675240963285; Wed, 01 Feb 2023 00:42:43 -0800 (PST) Received: from localhost ([82.66.159.240]) by smtp.gmail.com with ESMTPSA id y8-20020adfdf08000000b002bfb31bda06sm17903396wrl.76.2023.02.01.00.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 00:42:42 -0800 (PST) From: Mattijs Korpershoek To: Simon Glass , Safae Ouajih Cc: u-boot@lists.denx.de, sean.anderson@seco.com, r.stratiienko@gmail.com, glaroque@baylibre.com, khilman@baylibre.com Subject: Re: [PATCH v2 13/17] android: boot: update android_image_get_dtb_img_addr to support v3,v4 In-Reply-To: References: <20230126160506.1026643-1-souajih@baylibre.com> <20230126160506.1026643-14-souajih@baylibre.com> Date: Wed, 01 Feb 2023 09:42:41 +0100 Message-ID: <87k011ixoe.fsf@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain 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 On Thu, Jan 26, 2023 at 17:55, Simon Glass wrote: > Hi Safae, > > On Thu, 26 Jan 2023 at 09:05, Safae Ouajih wrote: >> >> This adds support for boot image version 3 and 4 >> in android_image_get_dtb_img_addr(). Since the dtb >> is now included in vendor_boot image instead of >> boot image, the dtb address should be extracted from >> vendor_boot image when a v3 or v4 is used. >> >> Signed-off-by: Safae Ouajih >> --- >> boot/image-android.c | 47 +++++++++++++++++++++++++++++++------------- >> 1 file changed, 33 insertions(+), 14 deletions(-) >> > > Reviewed-by: Simon Glass Reviewed-by: Mattijs Korpershoek > > nits below > >> diff --git a/boot/image-android.c b/boot/image-android.c >> index cb4fc22b00..edeeaaaee0 100644 >> --- a/boot/image-android.c >> +++ b/boot/image-android.c >> @@ -459,6 +459,7 @@ exit: >> static bool android_image_get_dtb_img_addr(ulong hdr_addr, ulong vhdr_addr, ulong *addr) >> { >> const struct andr_boot_img_hdr_v0 *hdr; >> + const struct andr_vendor_img_hdr *v_hdr; >> ulong dtb_img_addr; >> bool ret = true; >> >> @@ -475,22 +476,40 @@ static bool android_image_get_dtb_img_addr(ulong hdr_addr, ulong vhdr_addr, ulon >> goto exit; >> } >> >> - if (hdr->dtb_size == 0) { >> - printf("Error: dtb_size is 0\n"); >> - ret = false; >> - goto exit; >> + if (hdr->header_version == 2) { >> + if (hdr->dtb_size == 0) { > > if (!hdr->dtb_size) > >> + printf("Error: dtb_size is 0\n"); >> + ret = false; >> + goto exit; >> + } >> + /* Calculate the address of DTB area in boot image */ >> + dtb_img_addr = hdr_addr; >> + dtb_img_addr += hdr->page_size; >> + dtb_img_addr += ALIGN(hdr->kernel_size, hdr->page_size); >> + dtb_img_addr += ALIGN(hdr->ramdisk_size, hdr->page_size); >> + dtb_img_addr += ALIGN(hdr->second_size, hdr->page_size); >> + dtb_img_addr += ALIGN(hdr->recovery_dtbo_size, hdr->page_size); >> + >> + *addr = dtb_img_addr; >> } >> >> - /* Calculate the address of DTB area in boot image */ >> - dtb_img_addr = hdr_addr; >> - dtb_img_addr += hdr->page_size; >> - dtb_img_addr += ALIGN(hdr->kernel_size, hdr->page_size); >> - dtb_img_addr += ALIGN(hdr->ramdisk_size, hdr->page_size); >> - dtb_img_addr += ALIGN(hdr->second_size, hdr->page_size); >> - dtb_img_addr += ALIGN(hdr->recovery_dtbo_size, hdr->page_size); >> - >> - *addr = dtb_img_addr; >> - >> + if (hdr->header_version > 2) { >> + v_hdr = map_sysmem(vhdr_addr, sizeof(*v_hdr)); >> + if (v_hdr->dtb_size == 0) { > > same here > >> + printf("Error: dtb_size is 0\n"); >> + ret = false; >> + unmap_sysmem(v_hdr); >> + goto exit; >> + } >> + /* Calculate the address of DTB area in boot image */ >> + dtb_img_addr = vhdr_addr; >> + dtb_img_addr += v_hdr->page_size; >> + if (v_hdr->vendor_ramdisk_size) >> + dtb_img_addr += ALIGN(v_hdr->vendor_ramdisk_size, v_hdr->page_size); >> + *addr = dtb_img_addr; >> + unmap_sysmem(v_hdr); >> + goto exit; >> + } >> exit: >> unmap_sysmem(hdr); >> return ret; >> -- >> 2.34.1 >> > > Regards, > Simon