From nobody Tue Feb 10 01:59:12 2026 Received: from mail-ot1-f67.google.com (mail-ot1-f67.google.com [209.85.210.67]) (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 EBCD031E11C for ; Sat, 27 Dec 2025 14:22:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766845346; cv=none; b=NC+YcQMPZ179gHEvHdAa38dZ8gnM7YjnZqmvKL/kO/w4icBOrODIcrPL166RSjZVJwKzBkF4Y2lJwJgcTHBpOxuaBKWL6E/Xyjt4g+2IYWT9zxQUF4TavWKzsnoaMAjSvexZKMWL7/2rzIE5LzyTAZHvwfW75J29EsqCoKojczY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766845346; c=relaxed/simple; bh=OJ5gjSQWKx5C84AvdM6xqDc/SoTZsEG7agwwRllLSl4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=goBondBPQrtlRIU03rY3iEckjxVCSR/tMaasv0Mr+ixgHumJqehLwtuj6ObYW8b4LvPtc6IVwe/hJ+y988yBIreHIGGAtYdH70x2hILw4VBSxLTPujcorMMiVqlc00Uteanjs7WjBfOPzNFP/Hy2wLdEohybSqLtcWQz8RALe6I= 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=BsifQ6g0; arc=none smtp.client-ip=209.85.210.67 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="BsifQ6g0" Received: by mail-ot1-f67.google.com with SMTP id 46e09a7af769-7c6dbdaced8so6381087a34.1 for ; Sat, 27 Dec 2025 06:22:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1766845344; x=1767450144; 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=OQo1oqJAVo44ptfZ9oLDxIXzqeCSewp3mycJJep0ovk=; b=BsifQ6g0IlOoCvN7kkqClQU5VoPtuIC+dKTv6AESOqgZ+TxQdgcEswLqLbD5UskFOR Kl8hE8WWFkFR4L8i9Vua2xq0eW/sY9GKspsAsNcsw+fhWWq1l0eEnhtELIKQ5suygwb5 r+fNXJ3dsRAVrHIXeAf8fmviigYzx6gJIB9j0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766845344; x=1767450144; 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=OQo1oqJAVo44ptfZ9oLDxIXzqeCSewp3mycJJep0ovk=; b=HU0fODKkvuCPwmqWxGcvC/bM5uIMGq9xe05s/llY08beIcYNKNQuTBD8w8cFtm9mR8 PQXv/AjuspBB+0G9D0s7Yxgv3ndbvlbHfedwjQeapuljL7JxF70DgfUFtBvpo5FS740K r/ZkrOYJXKWvfXYuTR4tSGGhO32NZBKGATRtxwjMHEpOG0UXUncpB+iQ4Q3RFNYPIW3O OHbfJWoheIEXPwtbsb5dVSwz49GJsBNsBoJs4BdKyimWDjDEYgKCU3ZU9LEf3wVTy9Fo yI9K0Llt+ydBJgd2DYvELxjT82VyUZjDmbS8w+D2fv5PQ3m0X36RYDzii3VnU8VC1FSg Q0IA== X-Forwarded-Encrypted: i=1; AJvYcCU5jNnar7eDZ3rii+/2ZTW0Dl7zXC+64A/cbD4PiSGfk3+Aso5OaaC0Gm97VcKD7IPNQ6zXnsPEc+3qj/0=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/w2fiCYwU27x/NQ27Jq1cuI1Fk9VHoDvxhmGYrCaCl4owaamE 1JjoHas4mzxE8bioCct5IsHVdS+aMosy8d+g5Sb4M7Q7SUyNC0kz3dzIU6GfHdtBzQ== X-Gm-Gg: AY/fxX4TNdkjRHCAg9l+wL57/Y0SZhfaMnql5FjQQ0dAQvpVEaGoqbo17pBGJDRSFP0 gNJpcb0LnzC4L5g3Pxlj3Pf4xxOI/3XjlShHrZgq9UrOK61JU7RHX1QTiIoXZEAlTBRKvOf1vbL 9kdz+PUCQmqbw8fsj8TUSkDwAIg0lQQ83H6TCzrT6fYUZ0whah6estqCSSZAFeiIYcQkS7nrxw9 5ckrJSI8e7zHpAYhFCBAVv+VY+8Ll3CIEcAE0qmIGCDM0p/cKPnwIvA1wttRFKnZkSX4WKFM6+Y cVMkfpmd+26EyPsMDHwpjWX+22qhdtz/q/5Wf6lmHE3zXCVpdDoJ60x75/MlYX3wZU0i4jUdyzX Ej6+QoLJyWlJtg7vAImd3UvZiS18bFI98Ny+/68NP//jRlRrn22MbpL8sSVKZjSpHG3gUpnKd1K COUyo68rfS44bSMWA= X-Google-Smtp-Source: AGHT+IG/iPHYfwLVw3hTqVWk+/TFfy/39UQV5YqNYUp6ccKtSuEg3+Tg7hchdtSmxedRas5yzGbUtg== X-Received: by 2002:a05:6830:3894:b0:7c7:501f:4bce with SMTP id 46e09a7af769-7cc66a952d3mr11728229a34.25.1766845343827; Sat, 27 Dec 2025 06:22:23 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Dec 2025 06:22:20 -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 3/6] scripts/make_fit: Move dtb processing into a function Date: Sat, 27 Dec 2025 07:21:47 -0700 Message-ID: <20251227142200.2241198-4-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" Since build_fit() is getting quite long, move the dtb processing into a separate function. Change the double quotes in the write() call to single, to match the rest of the script. Signed-off-by: Simon Glass Reviewed-by: Nicolas Schier Reviewed-by: Ahmad Fatoum Reviewed-by: Chen-Yu Tsai --- (no changes since v7) Changes in v7: - Add a note about the " -> ' change 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 66cd73711506..7ddaf3c0d783 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