From nobody Mon Feb 9 16:17:09 2026 Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.49]) (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 DB61A326D76 for ; Fri, 14 Nov 2025 14:28:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763130489; cv=none; b=Xh8NeViIvecB89vvCWFmCruRqgSIAv8pbXpglg3Rr2AyScKMO9KWLlDbAUEgIsCix64BsCGkd7ToqNUpLkkYvSjcfRig6TB6cjaZcuclzJyeJ8CaGIHlFw3hPal6/awwx/tRvbbhD+YcOUlQ4MrY1DUoMC/jwDz1bCO1sEmAbDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763130489; c=relaxed/simple; bh=BGaCAKlcyk5xO8jgGliNm42nPEYthddki81jtkWbq08=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GX51VV53iyAXwX0YphWipYa5PT0d7r6b7AKdtsGy8H8DoTitQ/lGdTVdz3ZWFbOS1umQo70JBM9YHLjYU/o6wMYIZzHM7P05WxZ7OFfZAL6O7M7ra4zTC7tocl1b+OCBEdvQSte6tMFOGHsV3aDJkjrckC+7Py/aDI8/e+t5H68= 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=QbpsnYMr; arc=none smtp.client-ip=209.85.166.49 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="QbpsnYMr" Received: by mail-io1-f49.google.com with SMTP id ca18e2360f4ac-94861514a5cso168399539f.1 for ; Fri, 14 Nov 2025 06:28:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1763130487; x=1763735287; 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=t+WQ+WlElZR6b8foj+jTnRrBNTpepaWdsCyG6VTxCeY=; b=QbpsnYMrCwjh6HOQeMgyEx27+eIDeyJvKGCrwwKTbUclEcJ+yoNI+W+mGI2YyWY2aU rWzTflbpwZ5Bm3q+xJn0puhd4MoxXbZ16fwhdmCc8qrUmTLi+Ai5GR4HhxflV4Jn9Fw2 MujlnnEADq43M6fneR9qcQzHN5niXN9pAHg0w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763130487; x=1763735287; 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=t+WQ+WlElZR6b8foj+jTnRrBNTpepaWdsCyG6VTxCeY=; b=eGiiMzHjyq2PjzGOXiqMi0RIPl1voVw9Z0dVad0JdLjgxBsQixecCoBwhQ4wcApLQY bF4YXFi62NfLG3GNOrhZ4aO51BGgaB0Rf2bhqLb5LKpggx2AEkQEj79KqIQw2cF7ISU7 uABIoP0XkxK0euETL/e8ocfW6VpFPE/cLJjoWoTEkCXKef1Gu0mioU8fDJ0c+sEFaIfp SZxIGIuhsAhGKZNxgzhYMD1xKwobZvuFe5q0jw9l6sk6mg+S+QZfiVUVhduh/Nb6953O B6fSbeEmhEHGAzvCwJ7qqBII8ScnKMDybZP02u8cd6wOg+llKXjwNMpFIIV/SCW1tl47 r/nA== X-Forwarded-Encrypted: i=1; AJvYcCWnPorhZ1mqJIEU1QIzpLkty9V48Fzr/30hq8vxZFVjOogwYiA0tOp+kHAiP57v05ImcsWZk5nhFzwZVxA=@vger.kernel.org X-Gm-Message-State: AOJu0Yz8RuxIc1tVeS9dr9SWsrpi1SvvMoppcvJjDI0y7C3Jg4lep9Rl Be2Ml4AKVGdtirgS5IAlnc8iV/0avNmju5O7yMowSqUFEkup2VMoqjE2ef6iN8KpTQ== X-Gm-Gg: ASbGncsjTfrbYTFB0v+BxqOUfveiIMSp/CMSqPy17OK/OO5T5jevJ05awWdfhG3W6hm w25KAA/v6i7gCEef98DOmQNsUtrCPo8gGXOvXJr9EWs83/z/jxEx8M6ltydTyFi4WZ08G5N5edD rndFeGnPxnpdMb2bQ4HpBbq4T9sgwoT8p4QlG6e0j+ojJ7t3xcAi6tTK9Jb7ucTW5Q8pJxfu6Ln sctvT5H3sxjAt9PiaEn87pxyOKHtrhWU1NfkgfxvZxEpFYVixtVr6PIDwbRC00tMkLdzsXKcDrQ 7Qmp1PubYs4U77ZmGhTSmnxIiEWyjPQ9cnf+6GoziVMw32m1niRVrHAj/BThX1u5pIMWcQKGKqQ 7qX0iCuuJD3owpinP269FuZIv1k2giVDKJD763F8X4WBNaFRZq1K7ktCKX1fddYzWMylD0BA2rY esSgNMvgjP/qGEruo= X-Google-Smtp-Source: AGHT+IGHyVy5O73G/VZLCysyXwbrLp5vRyiOAKVWO/iDDKm1SSBWJajVWW6I/83NMUwWoVuzzbgYUQ== X-Received: by 2002:a92:c26c:0:b0:433:8161:872c with SMTP id e9e14a558f8ab-4348c88f748mr53671975ab.1.1763130487022; Fri, 14 Nov 2025 06:28:07 -0800 (PST) Received: from chromium.org ([73.34.74.121]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-434839cdb10sm27500205ab.32.2025.11.14.06.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Nov 2025 06:28:06 -0800 (PST) From: Simon Glass To: linux-arm-kernel@lists.infradead.org Cc: Nicolas Schier , Masahiro Yamada , Chen-Yu Tsai , Tom Rini , Ahmad Fatoum , =?UTF-8?q?J=20=2E=20Neusch=C3=A4fer?= , Simon Glass , Nicolas Schier , linux-kernel@vger.kernel.org Subject: [PATCH v5 3/8] scripts/make_fit: Move dtb processing into a function Date: Fri, 14 Nov 2025 07:27:29 -0700 Message-ID: <20251114142741.1919072-4-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251114142741.1919072-1-sjg@chromium.org> References: <20251114142741.1919072-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" Since build_fit() is getting quite long, move the dtb processing into a separate function. Signed-off-by: Simon Glass Reviewed-by: Nicolas Schier --- (no changes since v1) scripts/make_fit.py | 67 +++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/scripts/make_fit.py b/scripts/make_fit.py index 984371f505bc..1a74a9dcd85e 100755 --- a/scripts/make_fit.py +++ b/scripts/make_fit.py @@ -277,6 +277,47 @@ def process_dtb(fname, args): =20 return (model, compat, files) =20 + +def _process_dtbs(args, fsw, entries, fdts): + """Process all DTB files and add them to the FIT + + Args: + args: Program arguments + fsw: FIT writer object + entries: List to append entries to + fdts: Dictionary of processed DTBs + + Returns: + tuple: + Number of files processed + Total size of files processed + """ + seq =3D 0 + size =3D 0 + for fname in args.dtbs: + # Ignore non-DTB (*.dtb) files + if os.path.splitext(fname)[1] !=3D '.dtb': + continue + + try: + (model, compat, files) =3D process_dtb(fname, args) + except Exception as e: + sys.stderr.write(f'Error processing {fname}:\n') + raise e + + for fn in files: + if fn not in fdts: + seq +=3D 1 + size +=3D os.path.getsize(fn) + output_dtb(fsw, seq, fn, args.arch, args.compress) + fdts[fn] =3D seq + + files_seq =3D [fdts[fn] for fn in files] + entries.append([model, compat, files_seq]) + + return seq, size + + def build_fit(args): """Build the FIT from the provided files and arguments =20 @@ -289,7 +330,6 @@ def build_fit(args): int: Number of configurations generated size: Total uncompressed size of data """ - seq =3D 0 size =3D 0 fsw =3D libfdt.FdtSw() setup_fit(fsw, args.name) @@ -310,34 +350,15 @@ def build_fit(args): size +=3D len(data) write_ramdisk(fsw, data, args) =20 - for fname in args.dtbs: - # Ignore non-DTB (*.dtb) files - if os.path.splitext(fname)[1] !=3D '.dtb': - continue - - try: - (model, compat, files) =3D process_dtb(fname, args) - except Exception as e: - sys.stderr.write(f"Error processing {fname}:\n") - raise e - - for fn in files: - if fn not in fdts: - seq +=3D 1 - size +=3D os.path.getsize(fn) - output_dtb(fsw, seq, fn, args.arch, args.compress) - fdts[fn] =3D seq - - files_seq =3D [fdts[fn] for fn in files] - - entries.append([model, compat, files_seq]) + count, fdt_size =3D _process_dtbs(args, fsw, entries, fdts) + size +=3D fdt_size =20 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 + bool(args.ramdisk), size + return fdt.as_bytearray(), count + 1 + bool(args.ramdisk), size =20 =20 def run_make_fit(): --=20 2.43.0