Skip to content

Fix the SPL loading of a FIT image from NAND

Dario Binacchi u-boot 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 0 repliesNew
  2. v23 patches 0 repliesSuperseded
  3. v13 patches 0 repliesSuperseded

Changes in v3 from the cover letter

The previous versions were buggy for devices others than NAND. This because the 'adjust_offset' helper was properly set only for the NAND case but called even for devices like MMC, RAM, and so on, crashing the boot up by that devices. Continuing to use the adjust_offset helper would mean checking the helper before calling it and patching too many files to set it properly before calling the spl_load_simple_fit routine. For this reason, the adjust_offset helper has been removed from the spl_image_info structure and the offset fixed inside the read helper for the NAND device only. This solution fixes the problem for the NAND device without side effects for other types of devices.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4spl: fix format of function documentationinclude/spl.h+1 -12 replies
2/4spl: fit: fail fit loading in case of FDT appending errorcommon/spl/spl_fit.c+6 -32 replies
3/4spl: fit: nand: fix fit loading in case of bad blockscommon/spl/spl_nand.c drivers/mtd/nand/raw/nand_spl_loaders.c include/nand.h+33 -12 replies
4/4spl: fit: improve spl_nand_fit_read(...) readabilitycommon/spl/spl_nand.c+5 -52 replies

Reviews trailers per patch

3 of 4 patches have a Reviewed-by or Acked-by.

PatchMichael TrimarchiSimon Glass
1/4R-b
2/4R-b R-b
3/4R-b
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/4] Fix the SPL loading of a FIT image from NAND

Loading u-boot and its fdt from a NAND memory area with bad blocks led to the creation of these patches.

Next, the output generated by the script used to flash the NAND of the SOC that caused the issue.

....
** Rewriting /dev/mtd0 with /mnt/MLO
Erasing 128 Kibyte @ 0 -- 100 % complete
Writing data to block 0 at offset 0x0
** Rewriting /dev/mtd1 with /mnt/MLO
Erasing 128 Kibyte @ 0 -- 100 % complete
Writing data to block 0 at offset 0x0
** Rewriting /dev/mtd2 with /mnt/MLO
Erasing 128 Kibyte @ 0 -- 100 % complete
Writing data to block 0 at offset 0x0
** Rewriting /dev/mtd3 with /mnt/MLO
Erasing 128 Kibyte @ 0 -- 100 % complete
Writing data to block 0 at offset 0x0
** Rewriting /dev/mtd4 with /mnt/u-boot.itb
Skipping bad block at 00020000
Erasing 128 Kibyte @ e0000 -- 100 % complete
Bad block at 20000, 1 block(s) will be skipped
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
Writing data to block 2 at offset 0x40000
Writing data to block 3 at offset 0x60000
Writing data to block 4 at offset 0x80000
Writing data to block 5 at offset 0xa0000
** Rewriting /dev/mtd5 with /mnt/u-boot.itb
Erasing 128 Kibyte @ e0000 -- 100 % complete
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
Writing data to block 2 at offset 0x40000
Writing data to block 3 at offset 0x60000
Writing data to block 4 at offset 0x80000
...

- The bad block of the mtd4 partition at address 0x20000 is skipped during the writing of u-boot.itb.
- A redundant copy of u-boot.itb is written on mtd5 partition. In this partition there are no bad blocks.
- Every data written on mtd5 partition at address <addr> greater than or equal to 0x20000, has been written on partition mtd4 at address 0x40000 + <addr> - 0x20000. The current version of u-boot correctly manages bad blocks only if they are at addresses that follow the address from which to start reading data. If the starting address of the device tree, which can be taken from the itb header, is higher than the address of any bad block of the same partition, the address is no longer valid and it must be changed.

Changes in v3:
The previous versions were buggy for devices others than NAND. This because the 'adjust_offset' helper was properly set only for the NAND case but called even for devices like MMC, RAM, and so on, crashing the boot up by that devices. Continuing to use the adjust_offset helper would mean checking the helper before calling it and patching too many files to set it properly before calling the spl_load_simple_fit routine. For this reason, the adjust_offset helper has been removed from the spl_image_info structure and the offset fixed inside the read helper for the NAND device only. This solution fixes the problem for the NAND device without side effects for other types of devices.

Changes in v2:
- Replace CONFIG_IS_ENABLED(OF_EMBED) with IS_ENABLED(CONFIG_OF_EMBED))

Dario Binacchi (4):
spl: fix format of function documentation
spl: fit: fail fit loading in case of FDT appending error
spl: fit: nand: fix fit loading in case of bad blocks
spl: fit: improve spl_nand_fit_read(...) readability

 common/spl/spl_fit.c                    |  9 +++++---
 common/spl/spl_nand.c                   | 15 +++++++------
 drivers/mtd/nand/raw/nand_spl_loaders.c | 28 +++++++++++++++++++++++++
 include/nand.h                          |  1 +
 include/spl.h                           |  2 +-
 5 files changed, 45 insertions(+), 10 deletions(-)
Signature · 1 line
2.17.1