From nobody Tue Dec 2 02:30:06 2025 Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) (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 3C61D327C15 for ; Wed, 19 Nov 2025 18:14:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763576066; cv=none; b=F8o8k0CKGXGrrY6CAuN5wnVc3cMrWQ/4XfB2VnFRu5A84jzDs0fEy9yqjf7qCGv0vKLWB5q5dxBP4seRs1IauNVo7D2czaDBly4OPpsUUfmudPOsrYnnvtpnZy8QvngRF/MYnW+mSBhtJxc0wikcwVRkoU4tj10IKsvTl4Dvd/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763576066; c=relaxed/simple; bh=BGaCAKlcyk5xO8jgGliNm42nPEYthddki81jtkWbq08=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jcbjDeGa9hDnb32apyN+IctECY23cs9ZSlQwHC0zzNMtLM6PWEPnQ0cXKirXtFy2qUrta2D4EggX7JRfMTMRplDULHGAuLtU3ImDZlukUOtoTm8dF4J5IGmADUcj0JLrSQDK1Jdg6YFaU7PIoq02leSuu181syNGCpmbkd6EiQQ= 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=fOBqTwZD; arc=none smtp.client-ip=209.85.166.44 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="fOBqTwZD" Received: by mail-io1-f44.google.com with SMTP id ca18e2360f4ac-9491ba846b2so83648539f.2 for ; Wed, 19 Nov 2025 10:14:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1763576048; x=1764180848; 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=fOBqTwZDqBnDz/Vbs/qtBfpdCYGink4pV72SMpx0M0NrnziE32AVlonwfqA53WnnNn /Vbdwq5BfB10iXa1ur1dgE9gCinwVrEsQnvp+fHKIhND00nJhjGQnfge6iuAEZkqGCMb wR9KJ40YpR4a5eqJDuyQtNN07c2d3QzPetQrQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763576048; x=1764180848; 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=U+V40nrKwsWhTYy3XGozXFb6u5BPURYc/yzaaZhYL/pcxvMj5okKxs7rWBnRCUXgaY YpRxHAoFULxTlWd4K+fUI2CZJXWQRg8CX2Ly6Y75Yxa1qupw6Nl6s1qEtermqyykvtnO zdizWnHTgeNqne2Ogob+0/1pVX6237Q//PBNlY3HEtkFYMySdJ4n8gKL2LbOPLhQGUyD p07YLygOtrWDEhE2RoRHOxci2SjXBZXags0cfrWOKEAcTpaHOowxet6mzp14e9+bKz58 2fMqCMxl8WscUSmIAs7+rCA0cJMWihlEeDL0txdUDscQ8fVf8YymfJyCAlgg3oeSzmxp 6rog== X-Forwarded-Encrypted: i=1; AJvYcCWZP8HomWuyPLh7j7gJ+up8oPO181CGQtgUpV9h+XR3PZnutNFPDK/dn5dRUFVKF8QPPjjA4nTeIS1rFu0=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2d1IYuKDHAsmxH0VOD03MvHDSpwYiBpo/zTnpwvWQd1H0szLh aBmRXUSDuDP2J+g2pvfM5vk6ntzoiCUYyjxtjyvN7EArW8iudZAZLWHdG1lIFniKig== X-Gm-Gg: ASbGnctEjw58vkIsHQ6DQFaoodQ1ijL9HEcEYieWFhvCtlLbERPhzz+aP2b2ym9RA8S V+eoATG0w0cegLvMmhN32d7/y8hWfB1PXXL5Mx2tn4OFFDmS4QkqvPShbHZE6SEYIo73VIzkrH0 vrefvDn9r81HJ8ytMaeP9BThk/rjUr2BvznX5M2//NZ6UeXiO89z4GGWZwD2iS9w7uMa+gwY2ff HwzEsVujZ3sr0vCSOr1AEF00tJWusq7a4Fw4h2SHkMNa4icLobpFFZZkShxZZcO5j5GYDs7wPPM kqbExbxPWNVB/n2MaSFzo88oe6u3qGUZ5C6XOyz9ETUFr9b/CBnHf7JqR8no+B9bF7/O93cHU2c dz2SuddoRNY0eUdu+NEXNuefqDWVkBY7kxs6Jip6k23Cz6bpxvgfZLaAhjROfEGBMVc4yUy31vc b5o58b52GxWTL9hes= X-Google-Smtp-Source: AGHT+IEWVC1WUvwuvE7gE75ZizxaJkg7b27WdqYa4Fj1cP88bi/r3Jqe9CCCTezK2EVjIde2401KXw== X-Received: by 2002:a05:6602:4913:b0:938:9f22:ed34 with SMTP id ca18e2360f4ac-948e0d8eedamr1676190439f.16.1763576048598; Wed, 19 Nov 2025 10:14:08 -0800 (PST) Received: from chromium.org ([73.34.74.121]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-949385ae254sm4838639f.1.2025.11.19.10.14.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Nov 2025 10:14:07 -0800 (PST) From: Simon Glass To: linux-arm-kernel@lists.infradead.org Cc: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Masahiro Yamada , Tom Rini , Ahmad Fatoum , =?UTF-8?q?J=20=2E=20Neusch=C3=A4fer?= , Nicolas Schier , Chen-Yu Tsai , Simon Glass , Nicolas Schier , linux-kernel@vger.kernel.org Subject: [PATCH v6 3/8] scripts/make_fit: Move dtb processing into a function Date: Wed, 19 Nov 2025 11:13:24 -0700 Message-ID: <20251119181333.991099-4-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251119181333.991099-1-sjg@chromium.org> References: <20251119181333.991099-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 Reviewed-by: Ahmad Fatoum --- (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