summaryrefslogtreecommitdiff
path: root/scripts/make_fit.py
AgeCommit message (Collapse)AuthorFilesLines
12 daysscripts/make_fit.py: Drop explicit LZMA parallel compressionChen-Yu Tsai1-1/+1
Parallel compression for LZMA was added using the plzip tool. However plzip produces lzip format output, which is different from the raw LZMA format that the lzma tool produces. This causes depthcharge (the second stage bootloader on Chromebooks) to fail to load the payload. Drop the explicit LZMA parallel compression toolchain. If the lzma tool on the build machine is from xz-utils, then there's a chance parallel compression is already enabled. The xz-utils manpage says the following for the -T (threads) argument: Specify the number of worker threads to use. Setting threads to a special value 0 makes xz use up to as many threads as the processor(s) on the system support. The actual number of threads can be fewer than threads if the input file is not big enough for threading with the given settings or if using more threads would exceed the memory usage limit. [...] The default value for threads is 0. In xz 5.4.x and older the default is 1. Fixes: fcdcf22a34b0 ("scripts/make_fit: Support a few more parallel compressors") Signed-off-by: Chen-Yu Tsai <wenst@chromium.org> Reviewed-by: Simon Glass <simon.glass@canonical.com> Link: https://patch.msgid.link/20260212074308.2189032-1-wenst@chromium.org Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-02-04scripts/make_fit: Compress dtbs in parallelSimon Glass1-6/+50
When there are 1500 device tree files it takes quite a while to compress them. Do it in parallel. Signed-off-by: Simon Glass <sjg@chromium.org> Link: https://patch.msgid.link/20260106162738.2605574-7-sjg@chromium.org Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-02-04scripts/make_fit: Support a few more parallel compressorsSimon Glass1-3/+9
Add support for pbzip2, xz and plzip which can compress in parallel. This speeds up the ramdisk compression. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Nicolas Schier <nsc@kernel.org> Link: https://patch.msgid.link/20260106162738.2605574-6-sjg@chromium.org Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-02-04scripts/make_fit: Move dtb processing into a functionSimon Glass1-23/+44
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 <sjg@chromium.org> Reviewed-by: Nicolas Schier <nsc@kernel.org> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> Link: https://patch.msgid.link/20260106162738.2605574-4-sjg@chromium.org Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-02-04scripts/make_fit: Support an initial ramdiskSimon Glass1-8/+44
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 <sjg@chromium.org> Reviewed-by: Nicolas Schier <nsc@kernel.org> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://patch.msgid.link/20260106162738.2605574-3-sjg@chromium.org Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2026-02-04scripts/make_fit: Speed up operationSimon Glass1-2/+4
The kernel is likely at least 16MB so we may as well use that as a step size when reallocating space for the FIT in memory. Pack the FIT at the end, so there is no wasted space. This reduces the time to pack by an order of magnitude, or so. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Nicolas Schier <nsc@kernel.org> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Tested-by: Chen-Yu Tsai <wenst@chromium.org> Link: https://patch.msgid.link/20260106162738.2605574-2-sjg@chromium.org Signed-off-by: Nathan Chancellor <nathan@kernel.org>
2025-03-27scripts/make_fit: Print DT name before libfdt errorsJ. Neuschäfer1-1/+5
This makes it easier to pinpoint where the error happened. For example: FIT arch/powerpc/boot/image.fit Error processing arch/powerpc/boot/dts/microwatt.dtb: Traceback (most recent call last): File "/home/jn/dev/linux/linux-git/build-mpc83xx/../scripts/make_fit.py", line 335, in <module> sys.exit(run_make_fit()) ^^^^^^^^^^^^^^ File "/home/jn/dev/linux/linux-git/build-mpc83xx/../scripts/make_fit.py", line 309, in run_make_fit out_data, count, size = build_fit(args) ^^^^^^^^^^^^^^^ File "/home/jn/dev/linux/linux-git/build-mpc83xx/../scripts/make_fit.py", line 286, in build_fit raise e File "/home/jn/dev/linux/linux-git/build-mpc83xx/../scripts/make_fit.py", line 283, in build_fit (model, compat, files) = process_dtb(fname, args) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/jn/dev/linux/linux-git/build-mpc83xx/../scripts/make_fit.py", line 231, in process_dtb model = fdt.getprop(0, 'model').as_str() ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/libfdt.py", line 448, in getprop pdata = check_err_null(fdt_getprop(self._fdt, nodeoffset, prop_name), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/libfdt.py", line 153, in check_err_null raise FdtException(val) libfdt.FdtException: pylibfdt error -1: FDT_ERR_NOTFOUND Signed-off-by: J. Neuschäfer <j.ne@posteo.net> Link: https://lore.kernel.org/r/20250209-makefit-v1-1-bfe6151e8f0a@posteo.net Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
2024-07-15scripts/make_fit: Support decomposing DTBsChen-Yu Tsai1-22/+64
The kernel tree builds some "composite" DTBs, where the final DTB is the result of applying one or more DTB overlays on top of a base DTB with fdtoverlay. The FIT image specification already supports configurations having one base DTB and overlays applied on top. It is then up to the bootloader to apply said overlays and either use or pass on the final result. This allows the FIT image builder to reuse the same FDT images for multiple configurations, if such cases exist. The decomposition function depends on the kernel build system, reading back the .cmd files for the to-be-packaged DTB files to check for the fdtoverlay command being called. This will not work outside the kernel tree. The function is off by default to keep compatibility with possible existing users. To facilitate the decomposition and keep the code clean, the model and compatitble string extraction have been moved out of the output_dtb function. The FDT image description is replaced with the base file name of the included image. Signed-off-by: Chen-Yu Tsai <wenst@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2024-05-29scripts/make_fit: Drop fdt image entry compatible stringChen-Yu Tsai1-2/+1
According to the FIT image source file format document found in U-boot [1] and the split-out FIT image specification [2], under "'/images' node" -> "Conditionally mandatory property", the "compatible" property is described as "compatible method for loading image", i.e., not the compatible string embedded in the FDT or used for matching. Drop the compatible string from the fdt image entry node. While at it also fix up a typo in the document section of output_dtb. [1] U-boot source "doc/usage/fit/source_file_format.rst", or on the website: https://docs.u-boot.org/en/latest/usage/fit/source_file_format.html [2] https://github.com/open-source-firmware/flat-image-tree/blob/main/source/chapter2-source-file-format.rst Fixes: 7a23b027ec17 ("arm64: boot: Support Flat Image Tree") Signed-off-by: Chen-Yu Tsai <wenst@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
2024-04-12arm64: boot: Support Flat Image TreeSimon Glass1-0/+290
Add a script which produces a Flat Image Tree (FIT), a single file containing the built kernel and associated devicetree files. Compression defaults to gzip which gives a good balance of size and performance. The files compress from about 86MB to 24MB using this approach. The FIT can be used by bootloaders which support it, such as U-Boot and Linuxboot. It permits automatic selection of the correct devicetree, matching the compatible string of the running board with the closest compatible string in the FIT. There is no need for filenames or other workarounds. Add a 'make image.fit' build target for arm64, as well. The FIT can be examined using 'dumpimage -l'. This uses the 'dtbs-list' file but processes only .dtb files, ignoring the overlay .dtbo files. This features requires pylibfdt (use 'pip install libfdt'). It also requires compression utilities for the algorithm being used. Supported compression options are the same as the Image.xxx files. Use FIT_COMPRESSION to select an algorithm other than gzip. While FIT supports a ramdisk / initrd, no attempt is made to support this here, since it must be built separately from the Linux build. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Masahiro Yamada <masahiroy@kernel.org> Link: https://lore.kernel.org/r/20240329032836.141899-3-sjg@chromium.org Signed-off-by: Will Deacon <will@kernel.org>