From nobody Sun Feb 8 13:45:39 2026 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (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 A70FE25F96D for ; Tue, 6 Jan 2026 16:28:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767716891; cv=none; b=OudOSAPKTgLb4wpgjVyg47HTJceiFtt9uOv7jLvrx3zNL1UzWaBLMLVVFV5NjppUFSsJtXe+NRDffYtzP0rXU3cTNzw3087k4gxhQSjTkZl53Tdjq3A4oHtL8XIFywggEN/v8WwbDma93guDgXJvoHOt5Uq7h1qDmQsk+kt/2KM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767716891; c=relaxed/simple; bh=JDHwg4UH314RvplNCRL91Oy7GIV8cCK8/8DcmuuMJd8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hYdvO2DPLMfGhf3lPL2NODESJDvnKwDwZeL+qQRoh/KSurD6dtZywewf6nk7QNdAoKa+HkfpI3OznCipVwUUz3KRnqSUuha2OTgNpz3DcXVYzksUB1uruLCYhBFobcoMbBi01OQfsyVprFDaqtpF5Or5Xwewkcj8zq93el8dvXY= 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=c+X4V6Xz; arc=none smtp.client-ip=209.85.210.47 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="c+X4V6Xz" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-7c6cc44ff62so901911a34.3 for ; Tue, 06 Jan 2026 08:28:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1767716888; x=1768321688; 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=c+X4V6Xz2PkadvEJx4RrelIDwO68UYc03/SA4OgDuexrtkVmxA0icwAvOl5J1Xi3MA XRW3UI9tM3ve6wuOCZ6UrUeLIrLWLlxF5vMEofFcuQSWqZlzMVE9kRJNlBt4r63kDCO5 tCct3ccuvcUbYUifdR/ej6m5I7pQ6mjBOyv48= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767716888; x=1768321688; 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=SL9k0u9kCoYgeO002vGQDbCssh++V/P+PJFjIlqSBhJ+jjbMfbdHc9MwkOL210Fxjy N3RGjffJ/wJJdRFzJigHCtdn2cTZMtGD1tHfQ+aZwIUN3ZHRV3WVFRvoyUYe2wDTNpdr Y4uYSV5dcWsb+EaySmXZKwwEhmCwP/RIspjaNAzA935ASQCYcKGV2oXUNeb3G6cIlCmM eqQ238fTxHRBbC7oeqns2R3jrQ3JPkhqKNxc/jPnuPlkIfvRC2l4kdrfGkJ4KV8O9U+n ctOl+CeTCM9p3Ju+5gJlcW1K/RbWR0G5z/cSrBp+vtdxvLWOlJj/WfTaFOSKwrKZZ6bV CkSQ== X-Forwarded-Encrypted: i=1; AJvYcCWzj2Koq+3gUI9I73eUSwCIlDrSuFU/e6emWi98wgLXeQEzcuCjmcQWjtW3Vb68o58YcjtVjsvZiolugxk=@vger.kernel.org X-Gm-Message-State: AOJu0YxVGbGws/3Xd0AlMmo/8CxRh1vg6aHAveMTqUcF03nJf9yDmc2Y Nlz6AJeTCNEFQNZocJiK/lirf+1KIWDZHfdSxShMKmk+JNnzfQLcb/E/ZnaGcyPBqQ== X-Gm-Gg: AY/fxX6/5/E0q03OrSH1ULLkaZQvQjWGiIdS2sL1REF+q3+8HDl8IAUcjuvf7boO0Pz A6BG81f5Nr04CH7bowzZvLzP2BPqH7s2GnH9ZK23RpojM9k7aGEyNC6yBekWvkW8gpXMnEwaKo2 QpDo0/cdhyzjCXCPofdQ6MPu3Jo5KbQP4O0B9mUNj9863XlQ9oM2MzhksMolGsnnnqWxFbVGlD0 8b06T7GqSHDZpu/Tt8kLm40KYrw/yNW5ETQMRltP4yrjQsncnbd/NnXNZFwgttTYXqkW+kr1vos snTiTX0Gpm2VnBE8EqSnDw7FxJkW2dvjC1Pygteec0ihDniuKhWRCDDNd3tlIRJe628NhoXOjse 59rkxDbpFvV8kkwPhrRFYohcE3g3fulO4C7/dSaFk8A1xkgxnxtpG5xbBIdKmuuvwJYyDLmUFqv DEgiI0SZ85w5A3cZw= X-Google-Smtp-Source: AGHT+IH/uW+Dz4DHkg+DggfheF7JxW/x4X1apiIF05eXk1K0Su+uOEmzpRUhIyE4LvK1n4GcV+KuyA== X-Received: by 2002:a05:6830:2b26:b0:7c7:59ce:d195 with SMTP id 46e09a7af769-7ce4669d7f8mr2356558a34.6.1767716888521; Tue, 06 Jan 2026 08:28:08 -0800 (PST) Received: from chromium.org ([73.34.74.121]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7ce478af8b2sm1630951a34.15.2026.01.06.08.28.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jan 2026 08:28:02 -0800 (PST) From: Simon Glass To: linux-arm-kernel@lists.infradead.org Cc: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , =?UTF-8?q?J=20=2E=20Neusch=C3=A4fer?= , Masahiro Yamada , Ahmad Fatoum , Nicolas Schier , Tom Rini , Chen-Yu Tsai , Simon Glass , Nicolas Schier , linux-kernel@vger.kernel.org Subject: [PATCH v9 2/6] scripts/make_fit: Support an initial ramdisk Date: Tue, 6 Jan 2026 09:27:32 -0700 Message-ID: <20260106162738.2605574-3-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260106162738.2605574-1-sjg@chromium.org> References: <20260106162738.2605574-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