Skip to content

spl: Use common function for loading/parsing images

Sean Anderson u-boot 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest26 patches 6 repliesIn review
  2. v625 patches 36 repliesSuperseded

Changes in v7 from the cover letter

- Disable FS_FAT for the zynq(mp) boards as well, as suggested by Michal
- Reword documentation for spl_load_info
- Split off setting bl_len to ARCH_DMA_MINALIGN from filename removal
- Remove Pali from CC

Patches in v7 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/26spl: blk_fs: Fix uninitialized return value when we can't get a blk_desccommon/spl/spl_blk_fs.c+1 -10 replies
2/26arm: Disable SPL_FS_FAT when it isn't usedconfigs/am335x_evm_spiboot_defconfig configs/am65x_evm_r5_usbdfu_defconfig configs/xilinx_zynqmp_mini_qspi_defconfig +3 more+9 -32 replies
3/26spl: Make SHOW_ERRORS depend on LIBCOMMONcommon/spl/Kconfig common/spl/spl.c+2 -20 replies
4/26spl: semihosting: Don't close fd before spl_load_simple_fitcommon/spl/spl_semihosting.c+8 -120 replies
5/26spl: Remove NULL assignments in spl_load_infoarch/arm/mach-sunxi/spl_spi_sunxi.c common/spl/spl_fat.c common/spl/spl_mmc.c +3 more+0 -120 replies
6/26spl: Remove dev from spl_load_infocommon/spl/spl_mmc.c common/spl/spl_spi.c drivers/usb/gadget/f_sdp.c +1 more+10 -120 replies
7/26spl: Take advantage of bl_len's power-of-twonesscommon/spl/spl_fit.c common/spl/spl_imx_container.c+5 -50 replies
8/26spl: Refactor spl_load_info->read to use units of bytesarch/arm/mach-imx/spl_imx_romapi.c common/spl/spl_fit.c common/spl/spl_imx_container.c +4 more+82 -931 reply
9/26spl: Set FAT bl_len to ARCH_DMA_MINALIGNcommon/spl/spl_blk_fs.c common/spl/spl_fat.c common/spl/spl_fit.c +1 more+9 -271 reply
10/26spl: Remove filename from spl_load_infoarch/arm/mach-sunxi/spl_spi_sunxi.c common/spl/spl_blk_fs.c common/spl/spl_fat.c +7 more+6 -181 reply
11/26spl: Only support bl_len when we have toarch/arm/mach-imx/spl_imx_romapi.c arch/arm/mach-sunxi/spl_spi_sunxi.c common/spl/Kconfig +18 more+78 -410 replies
12/26spl: nand: Remove spl_nand_legacy_readcommon/spl/spl_nand.c+13 -200 replies
13/26spl: legacy: Split off LZMA decompression into its own functioncommon/spl/spl_legacy.c include/spl.h+52 -340 replies
14/26test: spl: Support testing LEGACY_LZMA filesystem imagesinclude/test/spl.h test/image/spl_load.c test/image/spl_load_fs.c+25 -60 replies
15/26spl: Add generic spl_load functioncommon/spl/spl.c include/spl_load.h+145 -00 replies
16/26spl: Convert ext to use spl_loadcommon/spl/spl_ext.c include/spl_load.h test/image/spl_load_fs.c+25 -210 replies
17/26spl: Convert fat to spl_loadcommon/spl/spl_fat.c include/spl_load.h test/image/spl_load_fs.c+20 -400 replies
18/26spl: Convert mmc to spl_loadcommon/spl/Kconfig common/spl/spl_mmc.c include/spl_load.h +1 more+16 -850 replies
19/26spl: Convert nand to spl_loadcommon/spl/spl_nand.c include/spl_load.h test/image/spl_load_nand.c+19 -540 replies
20/26spl: Convert net to spl_loadcommon/spl/spl_net.c include/spl_load.h test/image/spl_load_net.c+8 -240 replies
21/26spl: Convert nor to spl_loadcommon/spl/spl_legacy.c common/spl/spl_nor.c include/spl_load.h +1 more+10 -940 replies
22/26spl: Convert NVMe to spl_loadcommon/spl/spl_blk_fs.c include/spl_load.h test/image/spl_load_fs.c+14 -550 replies
23/26spl: Convert semihosting to spl_loadcommon/spl/spl_semihosting.c include/spl_load.h+7 -460 replies
24/26spl: Convert spi to spl_loadcommon/spl/spl_spi.c include/spl_load.h test/image/spl_load_spi.c+15 -670 replies
25/26spl: spi: Consolidate spi_load_image_os into spl_spi_load_imagecommon/spl/spl_spi.c+14 -400 replies
26/26spl: fat: Add option to disable DMA alignmentcommon/spl/Kconfig common/spl/spl_blk_fs.c common/spl/spl_fat.c+24 -40 replies

Reviews trailers per patch

25 of 26 patches have a Reviewed-by or Acked-by.

PatchSimon GlassTom RiniMichal Simek
1/26R-b
2/26R-b R-b
3/26R-b R-b
4/26R-b
5/26R-b
6/26R-b
7/26R-b
8/26R-b
9/26R-b
10/26R-b
11/26R-b
12/26R-b
13/26R-b
14/26R-b
15/26R-b
16/26R-b
17/26R-b
18/26R-b
19/26R-b
20/26R-b
21/26R-b
22/26R-b
23/26
24/26R-b
25/26R-b
26/26R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v7 thread

Cover letter [PATCH v7 00/26] spl: Use common function for loading/parsing images

This series adds support for loading all image types (Legacy (with and without LZMA), FIT (with and without LOAD_FIT_FULL), and i.MX) to the MMC, SPI, NOR, NET, FAT, EXT, NVMe, and semihosting load methods. It does this by introducing a helper function which handles the minutiae of invoking the proper parsing function, and reading the rest of the image.

Hopefully, this will make it easier for load methods to support all image types that U-Boot supports, without having undocumented unsupported image types. I applied this to several loaders which were invoking spl_load_simple_fit and/or spl_parse_image_header, but I did not use it with others (e.g. DFU/RAM) which had complications in the mix.

This series is organized roughly into two parts. Patches up to "spl: Add generic spl_load function" are all setup or size-reduction oriented. Later patches generally convert various load functions to spl_load.

bloat-o-meter results (for CONFIG_SPL only) at [1]. Size growth has been the bigegst challenge to preparing this series. I have used every trick I can think of to reduce bloat. Some SAMA boards no longer fit, but I have a plan to fix them [2].

This is bar far the largest and most-difficult revision of this series to-date. There are probably still things which can reduce the size, but I have been working on this series for the better part of two months and I think it is a good idea to get some feedback. Because of the SAMA bloat, this series will not pass CI, so I expect to do a v7 before this is ready to apply. Feel free, however, to apply patches in the first half (especially the fixes).

This version of the series is better-tested than ever before, thanks to some new unit tests. However, things like the i.MX ROMAPI are untested. NAND should also be tested more-widely, for reasons listed in the commit message. I encourage you try this series out on your favorite board.

This series depends on [3]. (Almost passing) CI at [4].

[1] https://gist.github.com/Forty-Bot/5bfe88676dd3c2aec6ebc23abb08e06f
This includes some changes to am335x_evm_spiboot and am65x_evm_r5_usbdfu which have since been undone. This was ran for v6.
[2] https://lore.kernel.org/u-boot/[email protected]/
[3] https://lore.kernel.org/u-boot/[email protected]/
[4] https://source.denx.de/u-boot/custodians/u-boot-clk/-/pipelines/18447

    For v6.

Changes in v7:
- Disable FS_FAT for the zynq(mp) boards as well, as suggested by Michal
- Reword documentation for spl_load_info
- Split off setting bl_len to ARCH_DMA_MINALIGN from filename removal
- Remove Pali from CC

Changes in v6:
- Fix uninitialized return value when we can't get a blk_desc
- Disable SPL_FS_FAT when it isn't used
- Don't close fd before spl_load_simple_fit
- Remove NULL assignments in spl_load_info
- Remove dev from spl_load_info
- Take advantage of bl_len's power-of-twoness
- Refactor spl_load_info->read to use units of bytes
- Remove filename from spl_load_info
- Only support bl_len when we have to
- Remove spl_nand_legacy_read
- Split off LZMA decompression into its own function
- Support testing LEGACY_LZMA filesystem images
- Use pseudo-LTO for spl_load
- Align reads to bl_len
- Add SYS_MMCSD_RAW_MODE to help determine whether SPL_MMC loads anything directly.
- Convert nand to spl_load
- Fix LZMA support
- Fix load address
- Fix invalid return from spl_blk_load_image
- Fix soft reset after loading from SPI
- Explicitly initialize load_info members to reduce text size
- Rebase on u-boot/next
- Add option to disable DMA alignment for FAT

Changes in v5:
- Make SHOW_ERRORS depend on LIBCOMMON
- Load the header in spl_load as well
- Don't bother trying to DMA-align the buffer, since we can't really fix it.
- Convert NVMe to spl_load

Changes in v4:
- Fix format specifiers in debug prints
- Reword/fix some of the doc comments for spl_load
- Rebase on u-boot/master

Changes in v3:
- Fix using ffs instead of fls
- Fix using not initializing bl_len when info->filename was NULL
- Fix failing on success

Changes in v2:
- Use reverse-xmas-tree style for locals in spl_simple_read. This is not complete, since overhead depends on bl_mask.
- Convert semihosting as well
- Consolidate spi_load_image_os into spl_spi_load_image

Sean Anderson (26):
spl: blk_fs: Fix uninitialized return value when we can't get a
blk_desc
arm: Disable SPL_FS_FAT when it isn't used
spl: Make SHOW_ERRORS depend on LIBCOMMON
spl: semihosting: Don't close fd before spl_load_simple_fit
spl: Remove NULL assignments in spl_load_info
spl: Remove dev from spl_load_info
spl: Take advantage of bl_len's power-of-twoness
spl: Refactor spl_load_info->read to use units of bytes
spl: Set FAT bl_len to ARCH_DMA_MINALIGN
spl: Remove filename from spl_load_info
spl: Only support bl_len when we have to
spl: nand: Remove spl_nand_legacy_read
spl: legacy: Split off LZMA decompression into its own function
test: spl: Support testing LEGACY_LZMA filesystem images
spl: Add generic spl_load function
spl: Convert ext to use spl_load
spl: Convert fat to spl_load
spl: Convert mmc to spl_load
spl: Convert nand to spl_load
spl: Convert net to spl_load
spl: Convert nor to spl_load
spl: Convert NVMe to spl_load
spl: Convert semihosting to spl_load
spl: Convert spi to spl_load
spl: spi: Consolidate spi_load_image_os into spl_spi_load_image
spl: fat: Add option to disable DMA alignment

 arch/arm/mach-imx/spl_imx_romapi.c        |  24 ++--
 arch/arm/mach-sunxi/spl_spi_sunxi.c       |   5 +-
 common/spl/Kconfig                        |  37 +++++-
 common/spl/spl.c                          |  13 +-
 common/spl/spl_blk_fs.c                   |  73 +++--------
 common/spl/spl_ext.c                      |  36 +++---
 common/spl/spl_fat.c                      |  62 ++++------
 common/spl/spl_fit.c                      |  74 ++++-------
 common/spl/spl_imx_container.c            |  55 ++++-----
 common/spl/spl_legacy.c                   | 110 ++++-------------
 common/spl/spl_mmc.c                      | 101 ++-------------
 common/spl/spl_nand.c                     | 104 ++++------------
 common/spl/spl_net.c                      |  29 +----
 common/spl/spl_nor.c                      |  42 ++-----
 common/spl/spl_ram.c                      |   2 +-
 common/spl/spl_semihosting.c              |  65 ++--------
 common/spl/spl_spi.c                      | 130 ++++---------------
 common/spl/spl_ymodem.c                   |   4 +-
 configs/am335x_evm_spiboot_defconfig      |   2 +-
 configs/am65x_evm_r5_usbdfu_defconfig     |   1 -
 configs/xilinx_zynqmp_mini_qspi_defconfig |   3 +-
 configs/zynq_cse_nand_defconfig           |   2 +
 configs/zynq_cse_nor_defconfig            |   2 +
 configs/zynq_cse_qspi_defconfig           |   2 +
 drivers/usb/gadget/f_sdp.c                |  10 +-
 include/spl.h                             |  62 ++++++++--
 include/spl_load.h                        | 144 ++++++++++++++++++++++
 include/test/spl.h                        |   4 +
 test/image/Kconfig                        |   1 +
 test/image/spl_load.c                     |  13 +-
 test/image/spl_load_fs.c                  |  32 +++--
 test/image/spl_load_nand.c                |   2 +
 test/image/spl_load_net.c                 |   2 +
 test/image/spl_load_nor.c                 |   2 +
 test/image/spl_load_os.c                  |  16 ++-
 test/image/spl_load_spi.c                 |   1 +
 36 files changed, 534 insertions(+), 733 deletions(-)
 create mode 100644 include/spl_load.h
Signature · 1 line
2.37.1