From nobody Wed Dec 17 00:12:45 2025 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (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 476B72C324C for ; Thu, 11 Dec 2025 14:03:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765461828; cv=none; b=kho1oOWzLr3j4PNOAL/c9jj0zR7U1HxFiFiQhHDvHo+6vVApVGeLP3t9MBDZsO3+ssyvoEnJeSBikpN/Vk1a5HkxNoar3/vOT3Ak0+htV6XZAWT0JTm3lo3xI7aBc8lTLW9da+u2RKxnmbmJJcUalesEnbeMyydr0KlD+XXRKpA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765461828; c=relaxed/simple; bh=UqfoVLVav09I0aw2CGKUg7qsVn5uYMmSpEa3teQI+zA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=llpQXHrAkP0aIbKqV620Vkl9JehG/swGrc/Lndzqt8wpS3SEOYKgjCs3n55SrA+BS2+FwEyRM6KJrZBK3OYH2Mx+CZo2W26M6e2/iFbz5OzhvD0halLtDfAJXx69rB7h+ZG0TJsT8hk1mznFlQSC7MkUNZRcm28Kz94tbrtBS64= 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=hRewFKgp; arc=none smtp.client-ip=209.85.167.176 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="hRewFKgp" Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-4557f0e5ed2so44093b6e.1 for ; Thu, 11 Dec 2025 06:03:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1765461826; x=1766066626; 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=NGboLX11faY20GW7EG69bVQ+HimuuG86Fz7KsZ0Cjec=; b=hRewFKgpfmHk48yrSe2H/oVfe9/kp+gzNAClf1u16EhurQlwqxG8wi7ZhC7KTkavMK mVjeWF2m2/mu1IQ7tyUklQlPd77lderGgmto2uqwCDGy7LVEN/UQG1gqil4lDBZGlrda 7ipRcjPKClks/6pIK7T3DGr8mh0+pzIWfd6sM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765461826; x=1766066626; 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=NGboLX11faY20GW7EG69bVQ+HimuuG86Fz7KsZ0Cjec=; b=n5EactsIk4yrKYkyekWn6HHIAVo6R+19Wtbo3flza2tExs2lm7iAXNo68NLH077dSx oX0SKKUDgdfGHt2U3030rFtF4VLjmVSdn7Vn4ZStqFMDPfzu3Gg6rUUhWqOL2KbhyPvt 07wvZZlFtPWDIJei4mOIF/77gNtpi5VooMW8FWtM5AECNHmeOsw5L2PuqVNhK0PNddy/ SX7AYGGgq7YPkfZzehpW43kmmA5/YVsEmtyziuApMBafREqduRAb1hk9dHDvoHytm5DI TmgNhziUMKFsm3GltacEltu8Pjtt1fBqzCt1QXMFqaBYqu1j4LjHuivcKvg62OI22uI/ W6hg== X-Forwarded-Encrypted: i=1; AJvYcCVfc9pjbM3VjEbNf3sOfdvr/mxZQvbTXuqFFE/7BbEZrlCCoAPyzns0Abp8/E6iNj6ej5NKN43EpiY74OM=@vger.kernel.org X-Gm-Message-State: AOJu0YySjTQ2KlayZr/JsRBQUnx6hMXVg5EyHtK9q6Dc1Z51cSFrrBeJ p+8NGMFmIGzJho49F/k5rh6WKblvIeJEhy7RiDS9NfhzIetMMrv9jMPyVqDapi4bPg== X-Gm-Gg: AY/fxX7ViY1YVlqTO61G0zPS/ZriH9zjgWxkYnquWwGjGYipFNqUi6vG79CoNrR3uEC 3HO/77QpwIPndJmjaTjkFZANYS/T4vTKYA6/HDr/vtlwFkt1YPlncCHl1CnHiiGHaSQV/M14EQS z5uTY8GttYW9/WfvIhHVNyNao9AV58+uJAUh3jfE1Z0CQqUSIlvg/BBkBYvSabXjS+pVFeWQ3PG 222zpDOh0irnLvzSo4dj8VXJa/XIKww39lLvmc4E1mi7wG3Ixy89e4b2Z8/1eF8RJ9Ox0q10ZWR geOEMgSlyvr4HdRz/E6OR/cKzytv+jFautvyzLmtZwgwuxA+II9XSVoI1542D7YDtJNaI81kaFo 47HHtEzNvfVIuotWYePNNy4HbZw6b3D0PIwn1EwpunlR8iP3Of33AfGlWL9J3v3us/0S1GAYtdy OPC3sEP+aHxdj3ugY= X-Google-Smtp-Source: AGHT+IFW4sXgXHRcnLBTV5SDzKKgVwFFYBppoyZ7iYax8w6vu6HYQtjGylKmpzENOm340PSo/tAJkg== X-Received: by 2002:a05:6808:222a:b0:450:89ee:922b with SMTP id 5614622812f47-4559bf3ef85mr1042177b6e.22.1765461826269; Thu, 11 Dec 2025 06:03:46 -0800 (PST) Received: from chromium.org ([73.34.74.121]) by smtp.gmail.com with ESMTPSA id 5614622812f47-45598d6e789sm1130030b6e.22.2025.12.11.06.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 06:03:44 -0800 (PST) From: Simon Glass To: linux-arm-kernel@lists.infradead.org Cc: Nicolas Schier , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , =?UTF-8?q?J=20=2E=20Neusch=C3=A4fer?= , Masahiro Yamada , Tom Rini , Ahmad Fatoum , Chen-Yu Tsai , Simon Glass , Nicolas Schier , linux-kernel@vger.kernel.org Subject: [PATCH v7 3/6] scripts/make_fit: Move dtb processing into a function Date: Thu, 11 Dec 2025 07:03:00 -0700 Message-ID: <20251211140309.1910613-4-sjg@chromium.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251211140309.1910613-1-sjg@chromium.org> References: <20251211140309.1910613-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 --- 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