{"id":2226026,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2226026/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20260422023131.2813748-1-sjg@chromium.org/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.2/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,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260422023131.2813748-1-sjg@chromium.org>","list_archive_url":null,"date":"2026-04-22T02:31:23","name":"fdtgrep: Add option to reserve free space in the output FDT","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"cf890d9bf35d76f3acd6db89d36ed7355143c71d","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/1.2/people/6170/?format=json","name":"Simon Glass","email":"sjg@chromium.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20260422023131.2813748-1-sjg@chromium.org/mbox/","series":[{"id":500914,"url":"http://patchwork.ozlabs.org/api/1.2/series/500914/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=500914","date":"2026-04-22T02:31:23","name":"fdtgrep: Add option to reserve free space in the output FDT","version":1,"mbox":"http://patchwork.ozlabs.org/series/500914/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2226026/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2226026/checks/","tags":{},"related":[],"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 (1024-bit key;\n unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256\n header.s=google header.b=L9al/XU3;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=85.214.62.61; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=chromium.org","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=chromium.org header.i=@chromium.org\n header.b=\"L9al/XU3\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=chromium.org","phobos.denx.de;\n spf=pass smtp.mailfrom=sjg@chromium.org"],"Received":["from phobos.denx.de (phobos.denx.de [85.214.62.61])\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 4g0jsd27wbz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 12:31:49 +1000 (AEST)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 571F883936;\n\tWed, 22 Apr 2026 04:31:44 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id ACA91840D8; Wed, 22 Apr 2026 04:31:42 +0200 (CEST)","from mail-qt1-x830.google.com (mail-qt1-x830.google.com\n [IPv6:2607:f8b0:4864:20::830])\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 7B95F8352B\n for <u-boot@lists.denx.de>; Wed, 22 Apr 2026 04:31:40 +0200 (CEST)","by mail-qt1-x830.google.com with SMTP id\n d75a77b69052e-50e63771d91so28776481cf.0\n for <u-boot@lists.denx.de>; Tue, 21 Apr 2026 19:31:40 -0700 (PDT)","from chromium.org ([174.51.25.52]) by smtp.gmail.com with ESMTPSA id\n d75a77b69052e-50e39495192sm126614081cf.27.2026.04.21.19.31.35\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 21 Apr 2026 19:31:37 -0700 (PDT)"],"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,DKIMWL_WL_HIGH,\n DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,\n 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=chromium.org; s=google; t=1776825099; x=1777429899; darn=lists.denx.de;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=72V43/6I50FrMbUfeORs6+trlQRH06niP+WrFi6EYgw=;\n b=L9al/XU38Zo+OmIQhTzNC/MgFdQ4NhAr6r8mEJhT56e+5zmbcfJdzj6mGNGI+l0VbK\n 5q/uwvvCRtGIgpo5aK7j+Z76XBJV8aJ6hK7BXuqfrN7UOnh05+nxeZ0r8YbrAbhuADpo\n z2jzHheF9XW5Y4Ys7QGCMkoKEQYYPyNWgkNpY=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776825099; x=1777429899;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=72V43/6I50FrMbUfeORs6+trlQRH06niP+WrFi6EYgw=;\n b=AgSkJ2iKP76/P06N0yBMKy9++LrtA1RElMyDtBI+F5eHLeSrAiJQBuEky4UQ0wUo12\n rfvR43BFA9E7lXlPcIOPWg3tXRU8RORemdmWmbhF48VI9Tzwt8il20fzfxTqW8B7Sy58\n 2Miu7ZRCPvKPVnprH62SLUNa5Xith3bW8Kwu+79axVp7PbmvIaecASEkrgzzm9djPB1I\n hKhyAsfAMDgrF8+/A8+SbZQo+kYIwSWsYuYPUk02hORYvOPdQOfutAJlpsLeBoq2ltmn\n 5bjMMu1GNvbYtnh+u7oL8rqsufuTS1D9EGPeQ6VVkN2o27GI9iIjKfN164l6axuoGwJQ\n oM3Q==","X-Gm-Message-State":"AOJu0Yye205KYIPnfOvHmzpzFnxq3FKmNSsfGjN8iMeesr7KTqpBdcjH\n SOOFCQ9vwGK9DRSIPVbejPOUep1+rEbyrWozOtcyLlFa7uPiLzwCpdfDB2Ula4zyUVmymHugiSR\n EIYaIpQ==","X-Gm-Gg":"AeBDievuYKt7HsL8WX+WVhsJMWlLunjJp4n6lwoY2U+YNRTTvmQjJRZT15wRZ53cPis\n X3q1prmJc8Kp1uX1hVUorPloMbcf7/kHBoI9uPKqmfuND9TAKabW1j14wAbAJVmjHGYesKjbupe\n uEh4UIY328douyr8EVi+xGnsXRqsuZYNh3XYUJCbvA8i/1KZIkb1ny6ZkLMG6/rKbTeqvru2C/L\n B/oNPILe5VHncHW/1cGdwzDoFi5aD+/aTJCoFYszwohpJRL3jhb2Wb6meYU/J4g3Oz/c/A8KFyo\n gjOBki6uHH3GjqnW+C8QPCs6lcoOUDsqB/zkI0wyZl3q00lMX0RiURiI2qqEL5p06fOJn1KIPgo\n Ha0X/7s21upHPU/SYfDEptNUPMdY7MRo/4KoKmNSDsribpAehbyOMPVqUPEvcMB0JrvZCcbTbpS\n GQOIrtHLQ9Db+7/bQVn/izc7V6mvKn","X-Received":"by 2002:a05:622a:1f99:b0:509:23ee:b9a5 with SMTP id\n d75a77b69052e-50e368372e2mr310893001cf.5.1776825098608;\n Tue, 21 Apr 2026 19:31:38 -0700 (PDT)","From":"Simon Glass <sjg@chromium.org>","To":"u-boot@lists.denx.de","Cc":"Simon Glass <sjg@chromium.org>, Marek Vasut <marek.vasut@mailbox.org>,\n Alper Nebi Yasak <alpernebiyasak@gmail.com>,\n Ilias Apalodimas <ilias.apalodimas@linaro.org>,\n Tom Rini <trini@konsulko.com>","Subject":"[PATCH] fdtgrep: Add option to reserve free space in the output FDT","Date":"Tue, 21 Apr 2026 20:31:23 -0600","Message-ID":"<20260422023131.2813748-1-sjg@chromium.org>","X-Mailer":"git-send-email 2.43.0","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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":"When producing a DTB from fdtgrep, there is no way to reserve extra\nspace so that more nodes/properties can be added at runtime without\ngrowing totalsize first.\n\nAdd a -B/--pad option that appends a caller-specified number of free\nbytes after the strings section and grows totalsize accordingly. The\npadding is applied after fdt_pack(), so it is not reclaimed when -r is\nused.\n\nSuggested-by: Marek Vasut <marek.vasut@mailbox.org>\nSigned-off-by: Simon Glass <sjg@chromium.org>\n---\n\n tools/binman/btool/fdtgrep.py |  3 ++-\n tools/fdtgrep.c               | 31 ++++++++++++++++++++++++++++++-\n 2 files changed, 32 insertions(+), 2 deletions(-)\n\n---\nbase-commit: 052988aa29bfd506d7ce207fbb3f5374a5dbecbb\nbranch: fdtgrep","diff":"diff --git a/tools/binman/btool/fdtgrep.py b/tools/binman/btool/fdtgrep.py\nindex 446b2f4144b..7b393241878 100644\n--- a/tools/binman/btool/fdtgrep.py\n+++ b/tools/binman/btool/fdtgrep.py\n@@ -16,9 +16,10 @@ Output formats are:\n \tdtb - device tree blob (sets -Hmt automatically)\n \tbin - device tree fragment (may not be a valid .dtb)\n \n-Options: -[haAc:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV]\n+Options: -[haAB:c:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTvhV]\n   -a, --show-address                 Display address\n   -A, --colour                       Show all nodes/tags, colour those that match\n+  -B, --pad <arg>                    Append free space to the output FDT, for later growth\n   -b, --include-node-with-prop <arg> Include contains containing property\n   -c, --include-compat <arg>         Compatible nodes to include in grep\n   -C, --exclude-compat <arg>         Compatible nodes to exclude in grep\ndiff --git a/tools/fdtgrep.c b/tools/fdtgrep.c\nindex b4c041070f5..83e3d0b9314 100644\n--- a/tools/fdtgrep.c\n+++ b/tools/fdtgrep.c\n@@ -64,6 +64,7 @@ struct display_info {\n \tint types_exc;\t\t/* Mask of types that we exclude (FDT_IS...) */\n \tint invert;\t\t/* Invert polarity of match */\n \tint props_up;\t\t/* Imply properties up to supernodes */\n+\tint pad;\t\t/* Free bytes to append after the strings section */\n \tstruct value_node *value_head;\t/* List of values to match */\n \tconst char *output_fname;\t/* Output filename */\n \tFILE *fout;\t\t/* File to write dts/dtb output */\n@@ -913,6 +914,27 @@ static int do_fdtgrep(struct display_info *disp, const char *filename)\n \t\t\tsize = fdt_totalsize(fdt);\n \t\t}\n \n+\t\tif (disp->pad) {\n+\t\t\tint new_size = fdt_totalsize(fdt) + disp->pad;\n+\t\t\tvoid *new_fdt = realloc(fdt, new_size);\n+\n+\t\t\tif (!new_fdt) {\n+\t\t\t\tfprintf(stderr, \"Out_of_memory\\n\");\n+\t\t\t\tret = -1;\n+\t\t\t\tgoto err;\n+\t\t\t}\n+\t\t\tfdt = new_fdt;\n+\t\t\tret = fdt_open_into(fdt, fdt, new_size);\n+\t\t\tif (ret < 0) {\n+\t\t\t\tfprintf(stderr,\n+\t\t\t\t\t\"Failed to expand FDT: %s\\n\",\n+\t\t\t\t\tfdt_strerror(ret));\n+\t\t\t\tgoto err;\n+\t\t\t}\n+\t\t\tmemset((char *)fdt + size, '\\0', new_size - size);\n+\t\t\tsize = new_size;\n+\t\t}\n+\n \t\tif ((size_t)size != fwrite(fdt, 1, size, disp->fout)) {\n \t\t\tfprintf(stderr, \"Write failure, %d bytes\\n\", size);\n \t\t\tfree(fdt);\n@@ -965,11 +987,12 @@ static const char usage_synopsis[] =\n \tcase '?': usage(\"unknown option\");\n \n static const char usage_short_opts[] =\n-\t\t\"haAc:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTuv\"\n+\t\t\"haAB:c:b:C:defg:G:HIlLmn:N:o:O:p:P:rRsStTuv\"\n \t\tUSAGE_COMMON_SHORT_OPTS;\n static const struct option usage_long_opts[] = {\n \t{\"show-address\",\tno_argument, NULL, 'a'},\n \t{\"colour\",\t\tno_argument, NULL, 'A'},\n+\t{\"pad\",\t\t\ta_argument, NULL, 'B'},\n \t{\"include-node-with-prop\", a_argument, NULL, 'b'},\n \t{\"include-compat\",\ta_argument, NULL, 'c'},\n \t{\"exclude-compat\",\ta_argument, NULL, 'C'},\n@@ -1002,6 +1025,7 @@ static const struct option usage_long_opts[] = {\n static const char * const usage_opts_help[] = {\n \t\"Display address\",\n \t\"Show all nodes/tags, colour those that match\",\n+\t\"Append free space to the output FDT, for later growth\",\n \t\"Include contains containing property\",\n \t\"Compatible nodes to include in grep\",\n \t\"Compatible nodes to exclude in grep\",\n@@ -1132,6 +1156,11 @@ static void scan_args(struct display_info *disp, int argc, char *argv[])\n \t\tcase 'A':\n \t\t\tdisp->all = 1;\n \t\t\tbreak;\n+\t\tcase 'B':\n+\t\t\tdisp->pad = atoi(optarg);\n+\t\t\tif (disp->pad < 0)\n+\t\t\t\tusage(\"Padding must be non-negative\");\n+\t\t\tbreak;\n \t\tcase 'b':\n \t\t\ttype = FDT_NODE_HAS_PROP;\n \t\t\tbreak;\n","prefixes":[]}