From nobody Tue Feb 10 01:59:07 2026 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0498931B807 for ; Sat, 27 Dec 2025 14:22:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766845342; cv=none; b=hpJSajC/omcgy26oniquyrlZWesYSZU8Z+UpjNN/UeOJBOHz5LXzfdppf67QEsRc9DZkFiw4vfD2GljlHSvtStnWUoq2jYJwD8rXe6ecIyZPPYLONNm2L4dKClOv+jzVWUgOlTZcaSbzFCcxtO3Y81RzG/V8usoKWFss7iBBgkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766845342; c=relaxed/simple; bh=JDHwg4UH314RvplNCRL91Oy7GIV8cCK8/8DcmuuMJd8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qPdbnY6dQEHEexA+JbgPDSnPR88DhgR3BFug4qV5UR1EKZ4Eqf9QbNdoh4gKMGiXmTKpp1il1UDrskeQXNWA89Q+Tm38SJaSqFTtmZTJJneW/z04XF+xiQbgvveQbEwZnBeS4I9BAexX9PkWNGbENsjc71STkKBgKFYvFTDPfMQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=N2vTFX3U; arc=none smtp.client-ip=209.85.210.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="N2vTFX3U" Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-7cac9225485so6274495a34.3 for ; Sat, 27 Dec 2025 06:22:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1766845340; x=1767450140; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uf5OzsvzLJF7JMEHMJOMsmKpYuDb1ZnOHsvKTOsoYw0=; b=N2vTFX3U6GEngaNMgNJYlPfoIKsY7ai6KUa4Jawf2gYD7vcCcOKsCZvfE48mkGyIZ3 UsPxVr5O69pDAmmJv95Q3ZuQsp6Z8vUQzv0yg3D8Nk5aVECv8N1Fcko9ZpuFysklpRJp rMkDjvHWtY0bYqsy6vXKjjElGL/ur43DhdUwQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766845340; x=1767450140; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=uf5OzsvzLJF7JMEHMJOMsmKpYuDb1ZnOHsvKTOsoYw0=; b=bhbCuhovfdJzYkHBk/wxvike9KFvpBKCI3y56JgwFj/IMT4XEbfp/+R3RsKPk56N6L J0AkUf11Ld/3KvYXXdScIK1nWUByhdG6lcdSDvXTpRQ9GD9HYCH5RYN3/Ff7bl9wYi45 tDI3gBd7TbSlz/xDuDOg18FbDKcR0LPnqJkiB8eNLOHoRi3Rr2ASnPAYXAEoCe5P5Hhg CgKr9pu6TA2X+R3McbpR1DuYDbIZDzHke1y/TegJd4Wnb90oUw5B83PqBU1vmz1AiYXd hYyEk/5G91vi6nwLOhBwWcHxI9/qWt5I/LLFw+p7Xo735idV3cWOOSeLpewk6FJbhtC/ HbKQ== X-Forwarded-Encrypted: i=1; AJvYcCXl9K8XKsDvBh7IwHcQfHvAGr94V40PZsAkRhng+fKTlUjYOvbQJZIC9S8Y+axrp9EMNGNmR927jaIwbR8=@vger.kernel.org X-Gm-Message-State: AOJu0YwxR8Zlg01uidFNOoms2uyUmQB+776eXxgGnZOe3zxH/BGvMlCt 3VEGSgUNr0XW+kSs0Dfm3bnNb8+dBApRGhArsgLfac6ZmdiSK09Lfol25W7j+5zVOA== X-Gm-Gg: AY/fxX66CrjQApsxUkdpM83/QzwPjQmR6Gi02ZOp9rHhQK/Nm+VLVpaVxu6stro2OBb h6xueVZpVxXGYC4ZXvyzLVnHkvKppZFqWRAMnSZFoQJVH714Jq8sEzpkf7bPLyutS7298+aKd4M gbec4nqPb3kbXafglH7qcKwT5+ZP+WzBm1ey3D16DQ24vH3opyxnkJW9kMiB57dnILKQs7MJxGn sC95DN89R/aXQVYQ1plwfZhh1kNzmVA/gQtevCfaKGePBSm+pC6sVG7siCzCWsWSQTCeEy81U81 veqcOz/517vOFA/VSa6RClSl1OpEIfbBk9WskaTeAxgm7gFejLs7zOHUu+N+oFZOFNJA6nvqLJ4 T+FsPAVSmzRXYNo0WnMuL/w9IUL6kSjX3pn+pQidn3Acs0rxr76tqOrzaV3svGdGBG8w+65x/xu /vr7Rw X-Google-Smtp-Source: AGHT+IFB9fWalUcUiO3rdGujfqPvSy2uyVV1y9oBi7yYhQ7EZmFI5catOG8/EQRfew7LrIG6+51fPQ== X-Received: by 2002:a05:6830:2b2b:b0:7c7:701:fb10 with SMTP id 46e09a7af769-7cc668ffd39mr16342194a34.7.1766845339868; Sat, 27 Dec 2025 06:22:19 -0800 (PST) Received: from chromium.org ([73.34.74.121]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7cc66727e11sm17352660a34.3.2025.12.27.06.22.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Dec 2025 06:22:18 -0800 (PST) From: Simon Glass To: linux-arm-kernel@lists.infradead.org Cc: Masahiro Yamada , Chen-Yu Tsai , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Nicolas Schier , =?UTF-8?q?J=20=2E=20Neusch=C3=A4fer?= , Ahmad Fatoum , Tom Rini , Simon Glass , Nicolas Schier , linux-kernel@vger.kernel.org Subject: [PATCH v8 2/6] scripts/make_fit: Support an initial ramdisk Date: Sat, 27 Dec 2025 07:21:46 -0700 Message-ID: <20251227142200.2241198-3-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251227142200.2241198-1-sjg@chromium.org> References: <20251227142200.2241198-1-sjg@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" FIT (Flat Image Tree) allows a ramdisk to be included in each configuration. Add support for this to the script. This feature is not available via 'make image.fit' since the ramdisk likely needs to be built separately anyway, e.g. using modules from the kernel build. Future work may provide support for doing that. Note that the uncompressed size is not correct when a ramdisk is used, since it is too expensive to decompress the ramdisk. Signed-off-by: Simon Glass Reviewed-by: Nicolas Schier Reviewed-by: Ahmad Fatoum --- (no changes since v6) Changes in v6: - Drop the load address for ramdisk, as it is not needed - Bring back the ramdisk 'compression' property, set to 'none' Changes in v5: - Fix 'use' typo Changes in v4: - Update the commit message Changes in v3: - Add a comment at the top of the file about the -r option - Count the ramdisk in the total files - Update the commit message Changes in v2: - Don't compress the ramdisk as it is already compressed scripts/make_fit.py | 52 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/scripts/make_fit.py b/scripts/make_fit.py index 0f5e7c4b8aed..66cd73711506 100755 --- a/scripts/make_fit.py +++ b/scripts/make_fit.py @@ -10,10 +10,14 @@ Usage: make_fit.py -A arm64 -n 'Linux-6.6' -O linux -o arch/arm64/boot/image.fit -k /tmp/kern/arch/arm64/boot/image.itk - @arch/arm64/boot/dts/dtbs-list -E -c gzip + -r /boot/initrd.img-6.14.0-27-generic @arch/arm64/boot/dts/dtbs-li= st + -E -c gzip =20 -Creates a FIT containing the supplied kernel and a set of devicetree files, -either specified individually or listed in a file (with an '@' prefix). +Creates a FIT containing the supplied kernel, an optional ramdisk, and a s= et of +devicetree files, either specified individually or listed in a file (with = an +'@' prefix). + +Use -r to specify an existing ramdisk/initrd file. =20 Use -E to generate an external FIT (where the data is placed after the FIT data structure). This allows parsing of the data without loading @@ -29,8 +33,6 @@ looks at the .cmd files produced by the kernel build. =20 The resulting FIT can be booted by bootloaders which support FIT, such as U-Boot, Linuxboot, Tianocore, etc. - -Note that this tool does not yet support adding a ramdisk / initrd. """ =20 import argparse @@ -81,6 +83,8 @@ def parse_args(): help=3D'Specifies the operating system') parser.add_argument('-k', '--kernel', type=3Dstr, required=3DTrue, help=3D'Specifies the (uncompressed) kernel input file (.itk)') + parser.add_argument('-r', '--ramdisk', type=3Dstr, + help=3D'Specifies the ramdisk/initrd input file') parser.add_argument('-v', '--verbose', action=3D'store_true', help=3D'Enable verbose output') parser.add_argument('dtbs', type=3Dstr, nargs=3D'*', @@ -133,7 +137,28 @@ def write_kernel(fsw, data, args): fsw.property_u32('entry', 0) =20 =20 -def finish_fit(fsw, entries): +def write_ramdisk(fsw, data, args): + """Write out the ramdisk image + + Writes a ramdisk node along with the required properties + + Args: + fsw (libfdt.FdtSw): Object to use for writing + data (bytes): Data to write (possibly compressed) + args (Namespace): Contains necessary strings: + arch: FIT architecture, e.g. 'arm64' + fit_os: Operating Systems, e.g. 'linux' + """ + with fsw.add_node('ramdisk'): + fsw.property_string('description', 'Ramdisk') + fsw.property_string('type', 'ramdisk') + fsw.property_string('arch', args.arch) + fsw.property_string('compression', 'none') + fsw.property_string('os', args.os) + fsw.property('data', data) + + +def finish_fit(fsw, entries, has_ramdisk=3DFalse): """Finish the FIT ready for use =20 Writes the /configurations node and subnodes @@ -143,6 +168,7 @@ def finish_fit(fsw, entries): entries (list of tuple): List of configurations: str: Description of model str: Compatible stringlist + has_ramdisk (bool): True if a ramdisk is included in the FIT """ fsw.end_node() seq =3D 0 @@ -154,6 +180,8 @@ def finish_fit(fsw, entries): fsw.property_string('description', model) fsw.property('fdt', bytes(''.join(f'fdt-{x}\x00' for x in = files), "ascii")) fsw.property_string('kernel', 'kernel') + if has_ramdisk: + fsw.property_string('ramdisk', 'ramdisk') fsw.end_node() =20 =20 @@ -274,6 +302,14 @@ def build_fit(args): size +=3D os.path.getsize(args.kernel) write_kernel(fsw, comp_data, args) =20 + # Handle the ramdisk if provided. Compression is not supported as it is + # already compressed. + if args.ramdisk: + with open(args.ramdisk, 'rb') as inf: + data =3D inf.read() + size +=3D len(data) + write_ramdisk(fsw, data, args) + for fname in args.dtbs: # Ignore non-DTB (*.dtb) files if os.path.splitext(fname)[1] !=3D '.dtb': @@ -296,12 +332,12 @@ def build_fit(args): =20 entries.append([model, compat, files_seq]) =20 - finish_fit(fsw, entries) + finish_fit(fsw, entries, bool(args.ramdisk)) =20 # Include the kernel itself in the returned file count fdt =3D fsw.as_fdt() fdt.pack() - return fdt.as_bytearray(), seq + 1, size + return fdt.as_bytearray(), seq + 1 + bool(args.ramdisk), size =20 =20 def run_make_fit(): --=20 2.43.0