{"id":2175517,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2175517/?format=json","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.0/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20251218-bootconfig-v4-3-5bbbdb0be1dc@baylibre.com>","date":"2025-12-18T11:16:58","name":"[v4,3/5] boot: android: Add bootconfig support","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"a71e1af753a51b172a1b606adec4e0054ffbf958","submitter":{"id":76253,"url":"http://patchwork.ozlabs.org/api/1.0/people/76253/?format=json","name":"Guillaume La Roque","email":"glaroque@baylibre.com"},"delegate":{"id":117687,"url":"http://patchwork.ozlabs.org/api/1.0/users/117687/?format=json","username":"mkorpershoek","first_name":"Mattijs","last_name":"Korpershoek","email":"mkorpershoek@baylibre.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20251218-bootconfig-v4-3-5bbbdb0be1dc@baylibre.com/mbox/","series":[{"id":485825,"url":"http://patchwork.ozlabs.org/api/1.0/series/485825/?format=json","date":"2025-12-18T11:16:55","name":"android: add bootconfig support","version":4,"mbox":"http://patchwork.ozlabs.org/series/485825/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2175517/checks/","tags":{},"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=baylibre-com.20230601.gappssmtp.com\n header.i=@baylibre-com.20230601.gappssmtp.com header.a=rsa-sha256\n header.s=20230601 header.b=Srzte9aY;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)","phobos.denx.de;\n dmarc=none (p=none dis=none) header.from=baylibre.com","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=baylibre-com.20230601.gappssmtp.com\n header.i=@baylibre-com.20230601.gappssmtp.com header.b=\"Srzte9aY\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=none (p=none dis=none) header.from=baylibre.com","phobos.denx.de;\n spf=pass smtp.mailfrom=glaroque@baylibre.com"],"Received":["from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4dX7S64L9Hz1y2F\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 18 Dec 2025 22:17:42 +1100 (AEDT)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id AE0FF83D71;\n\tThu, 18 Dec 2025 12:17:15 +0100 (CET)","by phobos.denx.de (Postfix, from userid 109)\n id D6F0683DA8; Thu, 18 Dec 2025 12:17:12 +0100 (CET)","from mail-wm1-x336.google.com (mail-wm1-x336.google.com\n [IPv6:2a00:1450:4864:20::336])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 7E1D083C54\n for <u-boot@lists.denx.de>; Thu, 18 Dec 2025 12:17:10 +0100 (CET)","by mail-wm1-x336.google.com with SMTP id\n 5b1f17b1804b1-4779cc419b2so3482715e9.3\n for <u-boot@lists.denx.de>; Thu, 18 Dec 2025 03:17:10 -0800 (PST)","from [127.0.1.1] ([2a01:e0a:e50:3860:3734:1277:36b8:3f57])\n by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-47be273f147sm38070965e9.7.2025.12.18.03.17.09\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 18 Dec 2025 03:17:09 -0800 (PST)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham\n autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1766056630;\n x=1766661430;\n darn=lists.denx.de;\n h=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n :mime-version:subject:date:from:from:to:cc:subject:date:message-id\n :reply-to; bh=BiLBQtc68JLc4djYm1anPNIWN1eh6hnbQf51fNuoAVE=;\n b=Srzte9aYX2Mu4TBa5fVtPJgpzdnvX3lJSjFiLPHVKeAkILRTjASYp5/yIc0iLIIFp1\n gEHzO9ZvSeCYJwgB+/QTfmbbNzEzJ3Uny1x/ZcPzGvnOE/Lz2wsTP8lmskg0KJ9hvldk\n fMSt5XWxiIj05bRSzOM1s7M2wTzAb0nN3wCnwfFI5kCHJcYJ/CqwDG2ZrZZkFtacztnA\n 8MfeQ6ZbpD8jj3ulHvzyGgoPUfXpVZwI1JLQhDSwrjDCi7ePSbyTcsunoTnofAUamtH2\n qMQtYKoULaaVq4DxzgKeeg4GY1sQYzGYnOngnc6lIaqdKs8pXR41K5vOmimqII9IE+rU\n zP0w==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1766056630; x=1766661430;\n h=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to\n :cc:subject:date:message-id:reply-to;\n bh=BiLBQtc68JLc4djYm1anPNIWN1eh6hnbQf51fNuoAVE=;\n b=tKWwx/OkNhGwuC5PP9Lto+zEGY5Dkl4fA4L3s9i39SYBdn7F/4OKhLtiyFUPhokYHj\n oHoO7kvFm3W7DBqeyfmFn9hSoFnWJUUjV0hXGsYn+YyxilaFocflfnpuMKvp0AmLIr1r\n N7HTF1s6fyrJk09dkqF5UsDmguwJ7PjWcU0Ib1aLuPDBqUsJdpv06aNpsLwDBh/X4cJS\n toprFTepnYnilK2V7yNZO5+R4c/RUwpU/MuRcjskqbXhsfGAZVswMeTIEVG2kuJmZfqa\n Fn2SE2OlfUVpBocP3rdoRdP+GysAsZefcr+YVhbqFTXx+KCnxqj0GBfT+CqyG7yBR26f\n uxoA==","X-Forwarded-Encrypted":"i=1;\n AJvYcCU92OoeWu78RQ4WMANIM2sXnWHyZ/shozdJ/whDfE+XtVmVHEgIGONg9k70lBnSqtCkYjezBds=@lists.denx.de","X-Gm-Message-State":"AOJu0YzurPshKpWsvl7iRxvLWl0FQtiUYm9FEk2Drz0DmmFUugQUhVnL\n xCsmmYKPCRZScfrF+lfhvu1ZjYJeQs0fnlCh60G4G3NxNeyDLnmW8ug0OzSm6/YJv+0=","X-Gm-Gg":"AY/fxX4wL4hb8i1qAHGPtSpIiLR1ZHNgb7geWREcYU9xJ5g+xsiKSV7sm1cMAVkX63w\n XLRy9vIX2tFew5aUESXyKfusfeoocwJM3GwsWZeXga9TSVOwvG2W/uhBSSv7puGSCdnsLCOJrwo\n 9WHpvpZ1wP3EkI4ah/PI9kEHBHFAzmPMFyuKifjrzQ2IXSfJZjf9MMwE8UBcwbCz2sVYK+W7cdP\n u9QoUFsO0mPlwaBcICkINUtd48ttnkqOAIp0CPmGXWOk8cWvY7WtsIBMI5BLYWnr17SZbphiqPJ\n CgNvAw0yfNDESXAH7Cnsb1f7Hlg/xvuld/R9dDqB1CO8wTr8/Xb19cwTC4s4hkfiPvUboCH6enu\n aXGXQoao8m2G6o5491cKsMVvbCQPYmx4Nv31UBjCJkam9qhjKXmcGFhQCzc3av0zz75smhGTE4x\n yh0yfTj1zWJNKntA==","X-Google-Smtp-Source":"\n AGHT+IEZKuG46QUDa2aiwNOpIDkLxnlPR5RsnmyIIb4aP9K1LRhFR75ZZoyb7IJKNZAgZ44kTxCqUA==","X-Received":"by 2002:a05:600c:3146:b0:479:3a88:de5f with SMTP id\n 5b1f17b1804b1-47a8f9174f3mr194719265e9.36.1766056629912;\n Thu, 18 Dec 2025 03:17:09 -0800 (PST)","From":"\"Guillaume La Roque (TI.com)\" <glaroque@baylibre.com>","Date":"Thu, 18 Dec 2025 12:16:58 +0100","Subject":"[PATCH v4 3/5] boot: android: Add bootconfig support","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20251218-bootconfig-v4-3-5bbbdb0be1dc@baylibre.com>","References":"<20251218-bootconfig-v4-0-5bbbdb0be1dc@baylibre.com>","In-Reply-To":"<20251218-bootconfig-v4-0-5bbbdb0be1dc@baylibre.com>","To":"Tom Rini <trini@konsulko.com>,\n Mattijs Korpershoek <mkorpershoek@kernel.org>","Cc":"Julien Masson <jmasson@baylibre.com>,\n Guillaume La Roque <glaroque@baylibre.com>, u-boot@lists.denx.de,\n Simon Glass <sjg@chromium.org>, Nicolas Belin <nbelin@baylibre.com>,\n Neil Armstrong <neil.armstrong@linaro.org>,\n Andrew Goodbody <andrew.goodbody@linaro.org>,\n Aaron Kling <webgeek1234@gmail.com>, George Chan <gchan9527@gmail.com>,\n Sam Day <me@samcday.com>, Jerome Forissier <jerome.forissier@linaro.org>,\n Maxime Fournier <mfournier@baylibre.com>, Eddie Kovsky <ekovsky@redhat.com>,\n Casey Connolly <casey.connolly@linaro.org>,\n Guillaume Ranquet <ranquet.guillaume@gmail.com>","X-Mailer":"b4 0.14.3","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.8 at phobos.denx.de","X-Virus-Status":"Clean"},"content":"For android vendor boot image version 4 bootconfig is mandatory.[1]\n\nIn the android_image_get_ramdisk function, after copying both vendor and\nboot ramdisks, we extract all androidboot.* entries from the kernel\ncommand line. These entries are added to the bootconfig section.\nWe then update the sizes of the ramdisk and bootconfig.\nFinally, all androidboot.* entries are removed from the kernel command\nline.\n\n[1] https://source.android.com/docs/core/architecture/partitions/vendor-boot-partitions#bootloader-support\n\nReviewed-by: Simon Glass <sjg@chromium.org>\nSigned-off-by: Guillaume La Roque (TI.com) <glaroque@baylibre.com>\n---\n boot/image-android.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++----\n 1 file changed, 163 insertions(+), 11 deletions(-)","diff":"diff --git a/boot/image-android.c b/boot/image-android.c\nindex 48886f39e4c..76600aec863 100644\n--- a/boot/image-android.c\n+++ b/boot/image-android.c\n@@ -505,6 +505,166 @@ ulong android_image_get_kcomp(const void *hdr,\n \t\treturn image_decomp_type(p, sizeof(u32));\n }\n \n+/**\n+ * android_boot_append_bootconfig() - Append bootconfig parameters to ramdisk\n+ * @img_data: Pointer to Android image data\n+ * @params: Pointer to boot config parameters to append\n+ * @params_len: Length of boot config parameters\n+ * @ramdisk_dest: Destination address for the merged ramdisk\n+ *\n+ * This function copies the vendor ramdisk, boot ramdisk, and bootconfig to\n+ * the destination. It then appends the provided bootconfig parameters.\n+ *\n+ * Return: Bytes added to the bootconfig on success, negative on error.\n+ */\n+static long android_boot_append_bootconfig(const struct andr_image_data *img_data,\n+\t\t\t\t\t   char *params, long params_len,\n+\t\t\t\t\t   void *ramdisk_dest)\n+{\n+\tvoid *vendor_ramdisk_src;\n+\tvoid *boot_ramdisk_src;\n+\tvoid *bootconfig_src;\n+\tlong bytes_added = 0;\n+\n+\t/* Map sources */\n+\tvendor_ramdisk_src = map_sysmem(img_data->vendor_ramdisk_ptr,\n+\t\t\t\t\timg_data->vendor_ramdisk_size);\n+\tboot_ramdisk_src = map_sysmem(img_data->ramdisk_ptr,\n+\t\t\t\t      img_data->boot_ramdisk_size);\n+\n+\t/* Copy Vendor Ramdisk */\n+\tmemcpy(ramdisk_dest, vendor_ramdisk_src, img_data->vendor_ramdisk_size);\n+\n+\t/* Copy Boot Ramdisk */\n+\tmemcpy((char *)ramdisk_dest + img_data->vendor_ramdisk_size,\n+\t       boot_ramdisk_src, img_data->boot_ramdisk_size);\n+\n+\t/* Copy Bootconfig and Append Params */\n+\tif (img_data->bootconfig_size) {\n+\t\tbootconfig_src = map_sysmem(img_data->bootconfig_addr,\n+\t\t\t\t\t    img_data->bootconfig_size);\n+\t\tmemcpy((char *)ramdisk_dest + img_data->vendor_ramdisk_size +\n+\t\t       img_data->boot_ramdisk_size,\n+\t\t       bootconfig_src, img_data->bootconfig_size);\n+\t\tunmap_sysmem(bootconfig_src);\n+\n+\t\tif (params && params_len > 1) {\n+\t\t\tvoid *bootconfig_ptr = (char *)ramdisk_dest +\n+\t\t\t\t\t       img_data->vendor_ramdisk_size +\n+\t\t\t\t\t       img_data->boot_ramdisk_size;\n+\t\t\tbytes_added = add_bootconfig_parameters(params, params_len,\n+\t\t\t\t\t\t\t\t(ulong)bootconfig_ptr,\n+\t\t\t\t\t\t\t\timg_data->bootconfig_size);\n+\t\t}\n+\t}\n+\n+\tunmap_sysmem(boot_ramdisk_src);\n+\tunmap_sysmem(vendor_ramdisk_src);\n+\n+\tif (bytes_added < 0)\n+\t\treturn bytes_added;\n+\n+\treturn bytes_added;\n+}\n+\n+/**\n+ * android_image_set_bootconfig() - Extract androidboot.* args and append to bootconfig\n+ * @hdr: Pointer to boot image header\n+ * @vendor_boot_img: Pointer to vendor boot image header\n+ * @ramdisk_addr: Destination address for the merged ramdisk\n+ *\n+ * Return: Size of the bootconfig section (including new params) on success, negative on error.\n+ */\n+static long android_image_set_bootconfig(const void *hdr,\n+\t\t\t\t\t const void *vendor_boot_img,\n+\t\t\t\t\t ulong ramdisk_addr)\n+{\n+\tconst char *bootargs = env_get(\"bootargs\");\n+\tchar *params = NULL;\n+\tchar *new_bootargs = NULL;\n+\tlong params_len = 0; /* Renamed from androidboot_params_len */\n+\tstruct andr_image_data img_data;\n+\tlong ret;\n+\tsize_t len;\n+\tconst char *src;\n+\tchar *bc_dst;\n+\tchar *args_dst;\n+\tulong total_size;\n+\tvoid *ramdisk_dest;\n+\n+\tif (!android_image_get_data(hdr, vendor_boot_img, &img_data))\n+\t\treturn -EINVAL; /* Use errno */\n+\n+\t/* Extract androidboot.* parameters from bootargs */\n+\tif (bootargs && img_data.bootconfig_size) {\n+\t\tlen = strlen(bootargs);\n+\t\tsrc = bootargs;\n+\n+\t\tparams = malloc(len + 1);\n+\t\tnew_bootargs = malloc(len + 1);\n+\t\tif (!params || !new_bootargs) {\n+\t\t\tfree(params);\n+\t\t\tfree(new_bootargs);\n+\t\t\tprintf(\"Error: malloc failed\\n\");\n+\t\t\treturn -ENOMEM;\n+\t\t}\n+\n+\t\tbc_dst = params;\n+\t\targs_dst = new_bootargs;\n+\n+\t\t/* Extract androidboot.* and build new bootargs in one pass */\n+\t\twhile (*src) {\n+\t\t\t/* Skip leading spaces */\n+\t\t\twhile (*src == ' ')\n+\t\t\t\tsrc++;\n+\t\t\tif (!*src)\n+\t\t\t\tbreak;\n+\n+\t\t\t/* Check if this param starts with androidboot. */\n+\t\t\tif (strncmp(src, \"androidboot.\", 12) == 0) {\n+\t\t\t\t/* Copy to bootconfig (add newline if not first) */\n+\t\t\t\tif (bc_dst != params)\n+\t\t\t\t\t*bc_dst++ = '\\n';\n+\t\t\t\twhile (*src && *src != ' ')\n+\t\t\t\t\t*bc_dst++ = *src++;\n+\t\t\t} else {\n+\t\t\t\t/* Copy to new bootargs (add space if not first) */\n+\t\t\t\tif (args_dst != new_bootargs)\n+\t\t\t\t\t*args_dst++ = ' ';\n+\t\t\t\twhile (*src && *src != ' ')\n+\t\t\t\t\t*args_dst++ = *src++;\n+\t\t\t}\n+\t\t}\n+\n+\t\t*bc_dst++ = '\\n'; /* Final newline for bootconfig */\n+\t\t*bc_dst = '\\0';\n+\t\t*args_dst = '\\0';\n+\t\tparams_len = bc_dst - params;\n+\n+\t\t/* Update bootargs if we extracted any androidboot params */\n+\t\tif (params_len > 1)\n+\t\t\tenv_set(\"bootargs\", new_bootargs);\n+\t}\n+\n+\t/* Calculate total size for mapping */\n+\ttotal_size = img_data.ramdisk_size + img_data.bootconfig_size;\n+\tif (params_len > 1)\n+\t\ttotal_size += params_len + BOOTCONFIG_TRAILER_SIZE;\n+\n+\t/* Map Dest */\n+\tramdisk_dest = map_sysmem(ramdisk_addr, total_size);\n+\n+\t/* Copy data */\n+\tret = android_boot_append_bootconfig(&img_data, params, params_len,\n+\t\t\t\t\t     ramdisk_dest);\n+\n+\tunmap_sysmem(ramdisk_dest);\n+\tfree(params);\n+\tfree(new_bootargs);\n+\n+\treturn ret;\n+}\n+\n int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img,\n \t\t\t      ulong *rd_data, ulong *rd_len)\n {\n@@ -536,17 +696,9 @@ int android_image_get_ramdisk(const void *hdr, const void *vendor_boot_img,\n \t\t\tramdisk_ptr = img_data.ramdisk_addr;\n \t\t}\n \t\t*rd_data = ramdisk_ptr;\n-\t\tmemcpy((void *)(ramdisk_ptr), (void *)img_data.vendor_ramdisk_ptr,\n-\t\t       img_data.vendor_ramdisk_size);\n-\t\tramdisk_ptr += img_data.vendor_ramdisk_size;\n-\t\tmemcpy((void *)(ramdisk_ptr), (void *)img_data.ramdisk_ptr,\n-\t\t       img_data.boot_ramdisk_size);\n-\t\tramdisk_ptr += img_data.boot_ramdisk_size;\n-\t\tif (img_data.bootconfig_size) {\n-\t\t\tmemcpy((void *)\n-\t\t\t       (ramdisk_ptr), (void *)img_data.bootconfig_addr,\n-\t\t\t       img_data.bootconfig_size);\n-\t\t}\n+\t\tif (img_data.header_version > 3)\n+\t\t\timg_data.ramdisk_size +=\n+\t\t\t\tandroid_image_set_bootconfig(hdr, vendor_boot_img, ramdisk_ptr);\n \t} else {\n \t\t/* Ramdisk can be used in-place, use current ptr */\n \t\tif (img_data.ramdisk_addr == 0 ||\n","prefixes":["v4","3/5"]}