From patchwork Wed Oct 16 15:46:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 835811 Delivered-To: patch@linaro.org Received: by 2002:a5d:6804:0:b0:37d:45d0:187 with SMTP id w4csp504853wru; Wed, 16 Oct 2024 08:47:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXl3YRBi4QrJ6MVq7M1I+pM91cbQQ1leT21mET3B4TQUe+AMGuBEaiO3h3HbIr8LvywSN5iag==@linaro.org X-Google-Smtp-Source: AGHT+IEBnVpiy2wu9ToVhz+V0lywmz/rPVvgDsA1G4XZqmLzeGNwqgIUiclAF3zuNLFIc86h36TO X-Received: by 2002:a6b:7a42:0:b0:82c:ec0f:a081 with SMTP id ca18e2360f4ac-83aadea1164mr569939f.4.1729093634858; Wed, 16 Oct 2024 08:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729093634; cv=none; d=google.com; s=arc-20240605; b=gZFX5OhqECh7kAi/sXH+10V6zkdMjuIsNpE4fpC3fdmlfH2eoiCqv0PEFw3jWcYBsz 3B3ttpZTa9bQc1UGzhjZ3bUI1IymIYaxIirGHTSXctOKNV7fYsjFAxZzUP/WEqoCE4O5 WeJ+MRpevLmPksOnmXsCcrdfGlraTho0qzVrxgqpNsGNjakjaAWnAlR6Rb1kb1+KtgwM qd7ksAJs11F51Q6+QEQAe3f2IiUxu+MrjjzN6iIUF5dGXIdL8hRJf/qfCWxO6KibDtwE V9JfNngssNDtBw/im6rgkl+aa+nHgDGIiQPPYBoHVL3a8+FlYw3wmApTnB1qV+h9xN/U jf/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=PMW3yg5/p4yI0H1hypV4NS4mBNeYrwpqtQgL+0Ly950=; fh=NEOAR4uguMrgWPhuh2zChp0mpOq28Pgd8ssVAjKWZpI=; b=I5zHtJPutSTNE5a6z+egY5HMlgzRx1ZtV3yGs4NJYpeN2Mm/rGBCfn+10Wh5+Sx1CR VbQA2eE6xOOUyf0cy1zygQS6qRcZiSGiFVghds9HjhEGkL1gKXWTOv4Xvz7GDPyYGetx 2qXCB5lkZI491S/c2VfSjhUID8mC30yWWI2zOeX9oIXFFupSVjxSRRKKz3HPe4mDR3ZZ g/eJ1DBmdG/BmrNlf4YqRRwtdxPX0j7YkR/rXJeL9Vnxqv7ZTGm0dMwauG9SCqOUP1BY xALtbcXUFK3lgqBEqnkUjkfJogVhgqtLrzgInQaPZ+2s06cRsAgHFd2JyfV1tLaiZJph CqyA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PhkZQGh5; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id ca18e2360f4ac-83a8b20fcc1si179491639f.17.2024.10.16.08.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 08:47:14 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PhkZQGh5; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 227E488D7E; Wed, 16 Oct 2024 17:47:05 +0200 (CEST) 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="PhkZQGh5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3736988C05; Wed, 16 Oct 2024 17:47:02 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) (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 43C1188D14 for ; Wed, 16 Oct 2024 17:47:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-37d538fe5f2so3981270f8f.2 for ; Wed, 16 Oct 2024 08:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729093620; x=1729698420; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=PMW3yg5/p4yI0H1hypV4NS4mBNeYrwpqtQgL+0Ly950=; b=PhkZQGh5F0SMy3WKHADdS9BxkgPhhR48ulzejIVRvMUxM1NqlEP/BIZvS9vqVhdT1W wG2ARljgpifOulm4yejySdUdWJ96MifiioIAaE8Q+RFVqpvxSMrhMRw6QTXIPBAOP00Y YON2+PJ8IP60ouMU1fJ8qsDwtCuG6LAX0HsgSLxHfY2MrkVPkwmspdX0mj5I71UMENM0 2l7tsySh7FxRGYDUyf/XKMccB6xNlw7LuA11E/6LV8PBmg2LBESm4DRGWC98FXq+2/nr qzcygYPxqUsvHdBO1PiiO5n5OeoL+vvDJrSHOstIARTDZ/YP4uDnSd+aIW8cK5wROSMc Mbqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729093620; x=1729698420; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PMW3yg5/p4yI0H1hypV4NS4mBNeYrwpqtQgL+0Ly950=; b=qV38rBwU057L/Z+4mmZb/402Oj6UN4PsH5BWYob69L2vimQxdn2y3ytvGZMHUkCZJP kEG7Tgc2RVOkiWEzM5Fzn3iNsp5aKFpiDm/fpn3dm3MtBoQXprw/hGhWBa9OWty3GEYa G4ZnY9GqbadGdDGxXOGn/aa3Met/93ejc6cMELy+uOEkjUGfigCzM9ubFoYhNFoQ3va/ Uq5ZLZpHFc983y9xrc14ZQmx030+82jAjSR/dx1qOUiaJsTuEJ7uMNe0JtAdIOxEK8LH wGs0fziLwM56o82mbJa2G5nOkUMT71Mbl7rSVl5qvF7JzkeZcgH1+Mn6BznuQ5Gom9E4 8QKw== X-Forwarded-Encrypted: i=1; AJvYcCVBEL1dykp9Y9cscIXp0AnCkKqd8FK2PZMoGEVbVnMVTZbKF07QfPrYNmkluaG1UnUZe2nWVm0=@lists.denx.de X-Gm-Message-State: AOJu0YyzHmsHSss6s/8HYWAAJ5yCwoXP2wiZhJn7Ts5Xo6Zs0iTsq+Lh D4oJV3vWbHSJRzWogfWntYaGhQboyi8zKOEei3M0Up3htvyxQl1VTmQ4BNg6Zoo= X-Received: by 2002:a5d:6e43:0:b0:37d:4d80:34ae with SMTP id ffacd0b85a97d-37d5519873emr13218544f8f.4.1729093619684; Wed, 16 Oct 2024 08:46:59 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4314a6fbb77sm37767315e9.14.2024.10.16.08.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 08:46:59 -0700 (PDT) From: Neil Armstrong Date: Wed, 16 Oct 2024 17:46:48 +0200 Subject: [PATCH 1/3] image: android: use ulong for kernel address MIME-Version: 1.0 Message-Id: <20241016-topic-fastboot-fixes-mkbootimg-v1-1-94fd9340722b@linaro.org> References: <20241016-topic-fastboot-fixes-mkbootimg-v1-0-94fd9340722b@linaro.org> In-Reply-To: <20241016-topic-fastboot-fixes-mkbootimg-v1-0-94fd9340722b@linaro.org> To: Tom Rini Cc: Mattijs Korpershoek , Guillaume La Roque , Caleb Connolly , u-boot-qcom@groups.io, u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1790; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=MwJtIiuhsW2BMluGpsaSc56K536Ikm+rTmqQvN50x28=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBnD9/wQTxZlfZj5BQHNIKBEgFYSL7K6Kr4NNGZAu9j /J8/y9iJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZw/f8AAKCRB33NvayMhJ0Q+WEA C7g4KTERIHDqa3Fhu6ZIk0ywKJJD0/igBeZK0y7HsblovM8cYYokkBBVLObfj06MFfxcQYrtzeXuoZ gdDG9opw1yFhPjhWUWkuzjUNHwg3jfPkdbNdE+YSqZOi/bfKughB2n+yf3N9zoUpxFk6Xau2WK1Dpg gY03+DFfdcZteyBqMKLDgWxGMmQGwDxAMA18C0kzNWU1Ed39fWjwTVB1a7EgetBgdpZkO5nk1e/MTA +dMmEMFHboI3VMH24Qr1b3kyDKUfS6r1Ki/2aJnAJRCPELVNOA01OfORFLF1iGUhbmG00tWWUWpa8o rYt2kHXk1TK8GlNmwr8MS+0W/A9dtIB8o5UA4ALH2ZFHsXKCwmifKftv6fqM9BP9QQYPYTBd+biPr1 pcFLTkNgEcJ7VvAwIa0sPDQlLuku72IsTJuvjuNqENB7+VEZSlcS/h0lQLkVNOZ6w2ySiPDAk1vbzl oKYFdktfV85HbQxOiDNGx0Pse58EmUhx8W3Alc6PqxcTSh2FnpnrkoWpjDAdF5X1SOeL5Po/0Gd9uf KDohSi8cyPd6CVq41kbsFFWhjBnjtKaQjIUj2aLOAz814oxEy+XNeXC+CUuZmgHoa4SkZs8PCG1uJ6 C3SNaP+UDTsIkBag+qkFYMBA6h+f5qgw8wWUCE04W4WQqgetFio5oHIf0l5w== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE 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.8 at phobos.denx.de X-Virus-Status: Clean When booting with platforms having > 4GiB of memory, the kernel physical address can be more than 32bits. Use ulong like all the other addresses, and fix the print to show the > 32bits address numbers. Signed-off-by: Neil Armstrong --- boot/image-android.c | 4 ++-- include/android_image.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/boot/image-android.c b/boot/image-android.c index e74dd498a30..bb5f4f84487 100644 --- a/boot/image-android.c +++ b/boot/image-android.c @@ -256,7 +256,7 @@ int android_image_get_kernel(const void *hdr, ulong *os_data, ulong *os_len) { struct andr_image_data img_data = {0}; - u32 kernel_addr; + ulong kernel_addr; const struct legacy_img_hdr *ihdr; if (!android_image_get_data(hdr, vendor_boot_img, &img_data)) @@ -275,7 +275,7 @@ int android_image_get_kernel(const void *hdr, if (strlen(andr_tmp_str)) printf("Android's image name: %s\n", andr_tmp_str); - printf("Kernel load addr 0x%08x size %u KiB\n", + printf("Kernel load addr 0x%08lx size %u KiB\n", kernel_addr, DIV_ROUND_UP(img_data.kernel_size, 1024)); int len = 0; diff --git a/include/android_image.h b/include/android_image.h index d503c980b23..96820709b42 100644 --- a/include/android_image.h +++ b/include/android_image.h @@ -348,7 +348,7 @@ struct andr_image_data { ulong bootconfig_addr; /* bootconfig image address */ ulong bootconfig_size; /* bootconfig image size */ - u32 kernel_addr; /* physical load addr */ + ulong kernel_addr; /* physical load addr */ ulong ramdisk_addr; /* physical load addr */ ulong ramdisk_ptr; /* ramdisk address */ ulong dtb_load_addr; /* physical load address for DTB image */ From patchwork Wed Oct 16 15:46:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 835812 Delivered-To: patch@linaro.org Received: by 2002:a5d:6804:0:b0:37d:45d0:187 with SMTP id w4csp504927wru; Wed, 16 Oct 2024 08:47:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUJXUeg6I/Kva2fIEASWglxA8oL7a1sUoIajG17NYiQQCLhRBPveeymNhO6Fvk+sOwcwmc0NQ==@linaro.org X-Google-Smtp-Source: AGHT+IGiWK7nmWUe0DZX9DC6yOvSJmQJ+r39wdkpKXll+YPkFr86+ttUlS+nBVUqXksfTmVycYib X-Received: by 2002:a05:6e02:1487:b0:39d:351a:d0a2 with SMTP id e9e14a558f8ab-3a3dc4f66d5mr49551785ab.25.1729093646451; Wed, 16 Oct 2024 08:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729093646; cv=none; d=google.com; s=arc-20240605; b=U/gj7w0bRJ87lE46cXcrcNpVSLD8bSSeX8g6Nv0mGCSQJezySuQPrDwuZOYzbk/cbM fUiAA5uIrLHFenRvmiBEWR/rfIFOjbT3SoXNlO5OjCllS5aWB8FV1Me0rPARKHMl0bgs Cg+3O+acaZOKzUA3hhAy1uaiEbAg30cB5oBdQ8ZwcfXq7G4rMRAg6DE6BkfOUU16Lxcm sHP0z9Y8jnbvxo05yVuhiowRuX8jLjhbiznpI4uKmBS8VMvCHOtPkt+EIrrd0sU0VXqV APp1F+z+nEavoR+iHZzso4XFoUcmmtV2nTspiBT0cSP7XRooR9CHtqi5lD0G3CJ+142A EH0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=GmI94IIHjO0NgEyeaiuqYocEyawHuuNMNsUoUYEXbPA=; fh=XnyVCgUTEOu1INKkCiW/Wpm2NwaoO0tTRP2KY+0mPAM=; b=MesLD7qQJNHm9f9JomOwX5nowNf5BD3vm8jMeyeeamCB6sieB0I1ZSypgA0xjVLmBL sFU2aXFNybKLshwU/dFvof+/tcAehBNp2IGEFZYBwvDjI349HQ+CFepdUCNsT6dj13eG AUIY8OJEm4lZWcjwpvb11iWZr1/XJ0aoWcTzVna4Ri+yl6a/7s1etY4FKc/1QK6o1zOC gp+GGP17TCugFE6NEVCqzyInWKPsekIUVWSKtRHRavFat5TesweipJdWDVH/dP41tvm3 zl0h4X6kdc6yQwBDBfIHTnBM+dXinjUAIb7cFV9eGFCjlTXOHo0KnxMyIHbEG8gPGP+h aUgQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bbGa4UvZ; 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; dara=neutral header.i=@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 e9e14a558f8ab-3a3d9c813b6si15279275ab.11.2024.10.16.08.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 08:47:26 -0700 (PDT) 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=bbGa4UvZ; 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; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 93EAA88CC5; Wed, 16 Oct 2024 17:47:07 +0200 (CEST) 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="bbGa4UvZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9C01C88D7E; Wed, 16 Oct 2024 17:47:04 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (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 9284188C05 for ; Wed, 16 Oct 2024 17:47:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-37d47eff9acso4056528f8f.3 for ; Wed, 16 Oct 2024 08:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729093622; x=1729698422; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=GmI94IIHjO0NgEyeaiuqYocEyawHuuNMNsUoUYEXbPA=; b=bbGa4UvZmk+jcsLPL/c8uF8DG2nS3m9g8TtChslTDXrlf4s4rsWgIDvbVanUCplzkg k7+5Y0cHJ385/IlWmJdABZuxBFBzh4gaHE+ifoBFzM7g0zZsh0aBYAGe9ULzCo6e3qnF +oAhQL/ld70T2txwe1dfhCghOlQUYvhYknLl9AnKKffDsCg/1yfz04KQdfphHJqyFg/j AK8AClVKjheFqci6iouWRSUgPjiG6Lr6X/ibvAvGmTYwBqeJ/c+uOPq8DMWi5pDJXISP ydCHgFbKRYBSMTEgJDusESkdp9wrJac/pSy2q+UgtsWADKDU2Ii2OPzK6qMW0KLS+ase 4iJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729093622; x=1729698422; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GmI94IIHjO0NgEyeaiuqYocEyawHuuNMNsUoUYEXbPA=; b=JahwRxUqQ0riil87oeCND2ztJ5EGr9fSJSaBfnXbYbk2wYadeSY1HYJfT5pkOR362j PzmWtEdQro9M+UsKBhrwyOpIZlVfx+FiX9sU1F9SQyxweeBNvxEjCS63r+Oi+2TGH5FT o2ds5Sq8qw0HUIWYjGwgrQ510YHLFXhvkX7qanXLtm/Mth1cqFO57BF1MhQ1N6p6caby fwL/GmlbpUdDB+VHS6HZUkytTj0f2v0y0d0Wn41x/Ljv6WWOA+fQajMGPtG7KdWf9AQl oC6DhG5RK8lMRpNxkQeBMZsDTxM/hvH2Wz/sexaaA2G/SujRTBEVcI6/7M8XBjd348eg JBHw== X-Forwarded-Encrypted: i=1; AJvYcCWOfTVevtAek4BqkuNY0a1ZKnYyviGOQEEtBAA2ruAapVD24Jk6QmLrNFd4477cjHN5n1Ix7IU=@lists.denx.de X-Gm-Message-State: AOJu0Yx7VMLi48tZNook3h/Y7t35w6LmCnmWGufKCESXlStOKNd9ZNRq cxp6dMH8Hp6RKuhCfosyc3LxzM54HlR6RAzrpn/qqnSiM3Q0Pjo343yBydxg7EA= X-Received: by 2002:adf:f70c:0:b0:37c:c842:a16e with SMTP id ffacd0b85a97d-37d5fe96419mr11955559f8f.5.1729093620521; Wed, 16 Oct 2024 08:47:00 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4314a6fbb77sm37767315e9.14.2024.10.16.08.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 08:47:00 -0700 (PDT) From: Neil Armstrong Date: Wed, 16 Oct 2024 17:46:49 +0200 Subject: [PATCH 2/3] boot: image-android: do not boot XIP when kernel is compressed MIME-Version: 1.0 Message-Id: <20241016-topic-fastboot-fixes-mkbootimg-v1-2-94fd9340722b@linaro.org> References: <20241016-topic-fastboot-fixes-mkbootimg-v1-0-94fd9340722b@linaro.org> In-Reply-To: <20241016-topic-fastboot-fixes-mkbootimg-v1-0-94fd9340722b@linaro.org> To: Tom Rini Cc: Mattijs Korpershoek , Guillaume La Roque , Caleb Connolly , u-boot-qcom@groups.io, u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2567; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=C2asPNVvCkaRMBf1k9LqeJ3IegU/Gwasa5aSQDtR3qc=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBnD9/xdcY2hFgWyE3UISPLsFVa/qOn3aJtFY4j6MyI woqkrHCJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZw/f8QAKCRB33NvayMhJ0QNaD/ 9Q6QGmwPn/1tzXJcyyQwr1NqXSwIICHnRx3AP4aWCxqGVdUK4KV2wLARaQKmlUP8WJp1QtE3yAgv/3 mHh78cOGDbz73XSTqHeEVt48JtsGPA2M7kWJlzEZ5p5Dj461ib57Mbf0/riwylPvJmRfouLukTwrLO X6pXUON3GQA8g+UUdtPDoBNNVgKI3RSLN+yc86iJgjmft0UIovcL/qR5+TwGsuYoQyPA1p/+v9bQTw LwSobhUZMXN5K0JU9wM5qkvPpi498s+5o2+ij1P85wzwL8ngXoKqYlRtjVYoElo//s9V59Vk5cjddl eWPf7BHG0Y8yPbtKqaI/qeo2Hq9cep5IKTaKYWR6Dmynb9g5VbsIWgugLJDjT7fViJ7csMceVs6aE8 TCzEmpE927/d/Sg0YWFG4Ctdz0MOjVGiQ5If8raiRgclDbRfXSNCfgnzlJMFxK3d2U2VDEa3hqD1T8 fsGGUkIHpazBKZP4tC7WcBSHKinqMjTNrrDlEYAzy1UxO7GFRHKkUhaAOQvnE3ruc8D+Sakp0B2AO3 3DVAESvwmdQzmrnCgjFdavFK3vzYEBCz+ma1LjFtUkd2qqec3feDJ92TiEwCy/B1J9SAAhgvgqFsza oSsiZ2IUhM3u70GnZXVeMRQrsYV6RKKOuf5pcbKgrl+Qk7USaTl5duBxd1Gw== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE 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.8 at phobos.denx.de X-Virus-Status: Clean When trying to boot an android boot image with a compressed kernel, if the kernel is used in-place because it was created with mkbootimg, the space will be too small to properly uncompress. Take in account the compressed state, and if compressed use the kernel_addr_r which should be big enough. Signed-off-by: Neil Armstrong --- boot/image-android.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/boot/image-android.c b/boot/image-android.c index bb5f4f84487..3adcc69a392 100644 --- a/boot/image-android.c +++ b/boot/image-android.c @@ -208,7 +208,8 @@ bool android_image_get_data(const void *boot_hdr, const void *vendor_boot_hdr, return true; } -static ulong android_image_get_kernel_addr(struct andr_image_data *img_data) +static ulong android_image_get_kernel_addr(struct andr_image_data *img_data, + ulong comp) { /* * All the Android tools that generate a boot.img use this @@ -221,8 +222,11 @@ static ulong android_image_get_kernel_addr(struct andr_image_data *img_data) * * Otherwise, we will return the actual value set by the user. */ - if (img_data->kernel_addr == ANDROID_IMAGE_DEFAULT_KERNEL_ADDR) - return img_data->kernel_ptr; + if (img_data->kernel_addr == ANDROID_IMAGE_DEFAULT_KERNEL_ADDR) { + if (comp == IH_COMP_NONE) + return img_data->kernel_ptr; + return env_get_ulong("kernel_addr_r", 16, 0); + } /* * abootimg creates images where all load addresses are 0 @@ -258,11 +262,14 @@ int android_image_get_kernel(const void *hdr, struct andr_image_data img_data = {0}; ulong kernel_addr; const struct legacy_img_hdr *ihdr; + ulong comp; if (!android_image_get_data(hdr, vendor_boot_img, &img_data)) return -EINVAL; - kernel_addr = android_image_get_kernel_addr(&img_data); + comp = android_image_get_kcomp(hdr, vendor_boot_img); + + kernel_addr = android_image_get_kernel_addr(&img_data, comp); ihdr = (const struct legacy_img_hdr *)img_data.kernel_ptr; /* @@ -359,11 +366,14 @@ ulong android_image_get_kload(const void *hdr, const void *vendor_boot_img) { struct andr_image_data img_data; + ulong comp; if (!android_image_get_data(hdr, vendor_boot_img, &img_data)) return -EINVAL; - return android_image_get_kernel_addr(&img_data); + comp = android_image_get_kcomp(hdr, vendor_boot_img); + + return android_image_get_kernel_addr(&img_data, comp); } ulong android_image_get_kcomp(const void *hdr, From patchwork Wed Oct 16 15:46:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 835813 Delivered-To: patch@linaro.org Received: by 2002:a5d:6804:0:b0:37d:45d0:187 with SMTP id w4csp504988wru; Wed, 16 Oct 2024 08:47:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWwSaYw3u1kFZSDOFUTjuogmNlOWafX+030lvU8yit1hSwHXGomD1styY3BkHp2vxalvbHhpw==@linaro.org X-Google-Smtp-Source: AGHT+IEZaPxepyz8L0blQehPNIApGDKYPV3PO9FdRhOIPi+5dTVjtR4HVp2vLoPSaKbSDkBf4aHS X-Received: by 2002:a05:6602:1614:b0:835:4cb5:4fa7 with SMTP id ca18e2360f4ac-83a946fad6cmr446955639f.12.1729093655947; Wed, 16 Oct 2024 08:47:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729093655; cv=none; d=google.com; s=arc-20240605; b=dJjotPhBr0DBPP03HvJFS52GiO03dKe8nUAe3YkfPCSR4Xfm4GUodjIb5FZVRsQH07 mrMRf3WOs73tFC/EJKvTmK1ujaIpaoNJ5P5d2ZwakXL9p/MpMpLCncsWYRmpv5tbDQ/A Ji9UIT9whFdBYVzaI/MeLCCDOSBpsNPjKcJQ5kibP3I1cIxx7QGAan70YeiSJngI9J99 zAlimmkTuVLMh9eUokNCKVq400QhamD9MbxAe5AKkPHDEbYnWYwlvvmnNb12VsLsSqC7 msjmz3g549ajKqiA236CwqlBjh7i/GUBXcJCARVU6BKjV4p142fJsq2QBJtzaAlCzcnj YThA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=nwo7viARzicMn+IrB8qzSCQQbI9c8PHhgymd0JXOgLY=; fh=VwhQiwN7ziOwf8An3ESCwTjyhuqw+y+Q0Bod/CA4Hcs=; b=UXrQb9EE9+DMIOqr2FUl6mAo+cx4ey2A3CRRsSJ8bJIY1LaSmKb/BPRvyKiTdr9p9O H2Iqaut5H5SfSIbl6fmoyV0Kts/p4OERW+StqQaMu9iKJIMgglros+7A/6kXS5bLOgWR qvBDIb7zFEMOz4OyyGcR9FRDrDmCqhvtLLANrtsJ9NawuGvk8OIBuqSl/4Mio2lejIKV QQhROBg85QtySW1bSm95nKPE9mUXvoRgiOoeN6javSNuJGObLLRu3Y1BBCraunpRurl6 dazKEAvZMOgaJgZKgGuZVmh2uJATkxcpnr0gI3zR6BpRvF7paLmjNeo2ZDjxylnDzUgt 20Mg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XfVIRp5Y; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id ca18e2360f4ac-83a8b25127fsi177412339f.68.2024.10.16.08.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 08:47:35 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XfVIRp5Y; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F14D588D97; Wed, 16 Oct 2024 17:47:07 +0200 (CEST) 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="XfVIRp5Y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3317A88D90; Wed, 16 Oct 2024 17:47:05 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) (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 329A088D56 for ; Wed, 16 Oct 2024 17:47:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4311ae6426aso47132825e9.2 for ; Wed, 16 Oct 2024 08:47:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729093623; x=1729698423; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=nwo7viARzicMn+IrB8qzSCQQbI9c8PHhgymd0JXOgLY=; b=XfVIRp5YJuUN3B8BXch+ied1bUcTAIMxZGXxwNf0BcDqE6SVQYX4B8w5d/wotdUrVm veGhcsXlcHmThvGIqaoapjHBAUIy3LIon56Er4nX+A+J+zR3xtk9k8/fEacZ4qqhh2IK C00F29pHuA0S2d8P4Ji4bjCY149gdwyNBn+GNdar08BmlmMcE0YLmMbxseyl4624bDmR xNmNRUHIJJbGg3kGVy8PhUCYj+FuqfDIBZeOKiGo3VdsQIZIaSyM6q14t6vCbLT0kIGU YpuRze96DWyF6xIj5cRdgS1AIk3RUOMtwVc0HOGoEphCMsKZTs+Wp8WM977eAMPI0IY2 /zSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729093623; x=1729698423; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nwo7viARzicMn+IrB8qzSCQQbI9c8PHhgymd0JXOgLY=; b=Gdhg96LZOEbyaq8xu0PkdLG4/rCoVqIOknkCbJiOgOKYrFoqA6F5HMwNTp3vx1L+Aq +fvyXVERIndJdSXTxxP72OnCS4nQcWPCTZmId/ArMZybouxOH9POPc07dzYUz+9XKhFz Ou5JJHEAR2ifVmd9iaNviZD+9ZnQKfmthTCB7p6UHQbQSrPsxo+k0sR+siASy5ZdThcC DaQ7+SHpbOWg2RAxIEgy1LSwqY/DTK9I+J/oIdpUs+VygLv96gEf/FK07Z666Wik5CKm Au3ULeMjUgfL1X7EnQ4UaySHm3JnjqggqKQZ0DPiEMZ2XXyQUfetHNpLtfm+Kx0+E0PG RD/Q== X-Forwarded-Encrypted: i=1; AJvYcCV7fmsIu2YAv/gaB2M8Z3grOsGG/sh+lnjl+rNPk5BQhgz+LxUR9oX1z2wXDaQO/yJC9rXJU4Y=@lists.denx.de X-Gm-Message-State: AOJu0YzG/agnDfQRSbaYAuWiYgWEAshdaBFe8i2clGh6vwq7nHufAM0e HsM0t59N9i85pNp998cf0zYiDbUxQWrgwa2wTLWoRHQTvmeNLh2Id9K53qhPVJg= X-Received: by 2002:a05:600c:2282:b0:431:4e25:fe42 with SMTP id 5b1f17b1804b1-4314e2601cfmr29977995e9.32.1729093622673; Wed, 16 Oct 2024 08:47:02 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4314a6fbb77sm37767315e9.14.2024.10.16.08.47.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 08:47:01 -0700 (PDT) From: Neil Armstrong Date: Wed, 16 Oct 2024 17:46:50 +0200 Subject: [PATCH 3/3] image: android: handle ramdisk default address MIME-Version: 1.0 Message-Id: <20241016-topic-fastboot-fixes-mkbootimg-v1-3-94fd9340722b@linaro.org> References: <20241016-topic-fastboot-fixes-mkbootimg-v1-0-94fd9340722b@linaro.org> In-Reply-To: <20241016-topic-fastboot-fixes-mkbootimg-v1-0-94fd9340722b@linaro.org> To: Tom Rini Cc: Mattijs Korpershoek , Guillaume La Roque , Caleb Connolly , u-boot-qcom@groups.io, u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3344; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=4jEtvjOceqPeMpdDY/AHbF4hP8lHsb0o/0CpEIS5dTU=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBnD9/x5GY+w/TI4MlIVDiF/g+w3NQbLXeG8jE9pMM1 1/Xa5+aJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZw/f8QAKCRB33NvayMhJ0VRfEA CGYL7vlpEenaqORALCWTfueXnkMhJtNvVIWdmV8WJ34S496EpTR1WrhgbksAxq2ncSRyV98/EjLvUd JtsQmWWtBLooILVSuy7euA58NCsGCMkYfhPNU+Yx0aM2k9TJ5QkyBkQVv4nyVOd0LBOB0h1hO+TmI+ IwjrQD1gSVaazICnQwdZTgvG2OTMiBc4TY192F3KR+2RBogzEsabBTMVhKnrX8dC0nRoYU5FOZRxF+ tpzSh3SAYBtO/aLj9aMmnTof/G3FV47dsESKivUJApqw/faOdAMsvP9kX+L96RVKVQTKNsZ7oeuwwB gUE9DOf4Udqb+pHjzWtA31m1+Ml//VmAi33THtpDalRKb1B6iAM4yTGSClN/3Y2AjqeeLuUeFPc0co qY6zage7fHGVoBZVWSMiynL3y/3Q9zfPe/piM3Nu+0kG1TQNa4HhvVrpKv2LoCVg4GTn2n7ynOmibe i9T3mMEOxADXOX8iQKkqmW7+eo/Hxny5aToBOfmA/GRSRAoPFe+KN9kv+32OiaRKEy6a2sSZo5187V PK/bb8JXNotWbHO4A/XOnS0rzEPByVtvwNFOYXJbgnktZAyzdK+nGgTIKoMGs3Y/xH3Yqx5zRQXu81 9El5W+sE8Nb83/89+lM2T8Lpd3OOc/Qdr60A6LTDeOd/64emHs6r+UER1rbg== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE 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.8 at phobos.denx.de X-Virus-Status: Clean The two tools that create android boot images, mkbootimg and the fastboot client, set the kernel address by default to 0x11008000. U-boot always honors this field, and will try to copy the ramdisk to whatever value is set in the header, which won't be mapped to the actual RAM on most platforms, resulting in the kernel obviously not booting. All the targets in U-Boot right now will download the android boot image to CONFIG_SYS_LOAD_ADDR, which means that it will already have been downloaded to some location that is suitable to use the ramdisk in-place for header version 0 to 2. For header version 3 and later, the ramdisk can't be used in-place to use ramdisk_addr_r in this case. Signed-off-by: Neil Armstrong --- boot/image-android.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/boot/image-android.c b/boot/image-android.c index 3adcc69a392..a261bb63999 100644 --- a/boot/image-android.c +++ b/boot/image-android.c @@ -14,6 +14,7 @@ #include #define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR 0x10008000 +#define ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR 0x11000000 static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1]; @@ -405,9 +406,24 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img, if (!img_data.ramdisk_size) return -ENOENT; - + /* + * Android tools can generate a boot.img with default load address + * or 0, even though it doesn't really make a lot of sense, and it + * might be valid on some platforms, we treat that address as + * the default value for this field, and try to pass ramdisk + * in place if possible. + */ if (img_data.header_version > 2) { - ramdisk_ptr = img_data.ramdisk_addr; + /* Ramdisk can't be used in-place, copy it to ramdisk_addr_r */ + if (img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR) { + ramdisk_ptr = env_get_ulong("ramdisk_addr_r", 16, 0); + if (!ramdisk_ptr) { + printf("Invalid ramdisk_addr_r to copy ramdisk into\n"); + return -EINVAL; + } + } else { + ramdisk_ptr = img_data.ramdisk_addr; + } memcpy((void *)(ramdisk_ptr), (void *)img_data.vendor_ramdisk_ptr, img_data.vendor_ramdisk_size); ramdisk_ptr += img_data.vendor_ramdisk_size; @@ -420,15 +436,21 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img, img_data.bootconfig_size); } } else { - ramdisk_ptr = img_data.ramdisk_addr; - memcpy((void *)(ramdisk_ptr), (void *)img_data.ramdisk_ptr, - img_data.ramdisk_size); + /* Ramdisk can be used in-place, use current ptr */ + if (img_data.ramdisk_addr == 0 || + img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR) { + ramdisk_ptr = img_data.ramdisk_ptr; + } else { + ramdisk_ptr = img_data.ramdisk_addr; + memcpy((void *)(ramdisk_ptr), (void *)img_data.ramdisk_ptr, + img_data.ramdisk_size); + } } printf("RAM disk load addr 0x%08lx size %u KiB\n", - img_data.ramdisk_addr, DIV_ROUND_UP(img_data.ramdisk_size, 1024)); + ramdisk_ptr, DIV_ROUND_UP(img_data.ramdisk_size, 1024)); - *rd_data = img_data.ramdisk_addr; + *rd_data = ramdisk_ptr; *rd_len = img_data.ramdisk_size; return 0;