mbox series

[v2,0/6] RISC-V SPL: fix OpenSBI FULL FIT loading

Message ID 20260902-riscv-full-fit-support-v2-0-493e904a129e@maquefel.me
Headers show
Series RISC-V SPL: fix OpenSBI FULL FIT loading | expand

Message

Nikita Shubin Sept. 2, 2026, 6:31 a.m. UTC
Hi all,

This series improves CONFIG_SPL_LOAD_FIT_FULL support on RISC-V, primarily to enable loading OpenSBI as firmware and recording loadable images (e.g., U-Boot) into the FDT passed to the next boot stage. This aligns spl_load_fit_image() with the behaviour already present in spl_load_simple_fit().

Patch summary:

1/6: Allow IH_OS_OPENSBI in fit_image_load() so OpenSBI firmware can be loaded without error.

2/6: Enable spl_load_fit_image() for RAM boot when CONFIG_SPL_LOAD_FIT_FULL is selected.

3/6: Use map_sysmem() for FDT address handling to keep the code sandbox‑friendly.

4/6: Initialize spl_image_info in spl_test_load()/spl_test_load_fit_full().

5/6: Record loadables into spl_image->fdt_addr during FIT load, providing the entry addresses needed by subsequent stages (e.g., OpenSBI).

6/6: Add a unit test to verify that loadables are correctly recorded in the FDT.

Tested with provided sandbox test with a grafted FIT image containing OpenSBI (firmware), U‑Boot (loadable) and a DTB.

Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
---
Changes in v2:

Addressed all review comments from Simon Glass:

- Patch 2/6: common: spl: ram: Add LOAD_FIT_FULL support:
  - Reworded commit message to explain that FULL parser is needed for full image verification (CONFIG_SPL_FIT_FULL_CHECK)
  - Added fallback: if spl_load_fit_image() fails, try spl_load_simple_fit()
  - Mentioned fallback behavior in commit message
 
- Patch 4/6: test: spl: Zero spl_image_info:
  - New patch added to zero-initialize spl_image_info structures in tests

- Patch 5/6: spl: fit: Record loadables to spl_image->fdt_addr
  - Fixed typo: "lodable" → "loadable" (subject, commit message, code)
  - Replaced -1 with FDT_ERROR (from image.h) for missing entry point
  - Moved FDT size adjustment before loop: use fdt_shrink_to_minimum() once instead of fdt_increase_size() per iteration
  - Extracted duplicated code into helper function fit_record_loadable()
  - Replaced debug() with log_debug()
  - Removed backslashes from debug string concatenation
  - Added note about gd->fdt_blob limitation in commit message
 
- Patch 6/6: spl: fit: Add test to check loadables
  - Fixed typo: "lodables" → "loadables" (subject, commit message)
  - Removed unused variables (uname, str)
  - Added FDT size fix after fdt_finish() to prevent external data offset drift
  - Replaced #address-cells = 2 with ADDRESS_CELLS macro
  - Replaced fdt_property_u64() with fdt_property_addr() for entry/load properties
  - Extracted duplicated image node creation into helper append_fit_node()
  - Fixed assertion: ut_assert(noffset > 0) instead of ut_assert(noffset)

- Link to v1: https://patch.msgid.link/20260807-riscv-full-fit-support-v1-0-21a34f79c350@maquefel.me

---
Nikita Shubin (6):
      image: fit: allow IH_OS_OPENSBI in fit_image_load()
      common: spl: ram: Add LOAD_FIT_FULL support
      spl: fit: Use map_sysmem() with buffers for fdt address
      test: spl: Zero spl_image_info
      spl: fit: Record loadables to spl_image->fdt_addr
      spl: fit: Add test to check loadables

 boot/image-fit.c         |   1 +
 common/spl/spl_fit.c     |  66 ++++++++++++-----
 common/spl/spl_ram.c     |  19 +++--
 test/image/spl_load.c    | 184 +++++++++++++++++++++++++++++++++++++++++++++++
 test/image/spl_load_os.c |   4 +-
 5 files changed, 250 insertions(+), 24 deletions(-)
---
base-commit: cc8c034e78eba6b2a3845783889b80753bb1af1e
change-id: 20260731-riscv-full-fit-support-320d38f8311e

Best regards,

Comments

Nikita Shubin Sept. 29, 2026, 4:48 a.m. UTC | #1
Hi Simon !

A gentle ping on this series.

Thanks !

On Wed, 2026-09-02 at 09:31 +0300, Nikita Shubin wrote:
> Hi all,
> 
> This series improves CONFIG_SPL_LOAD_FIT_FULL support on RISC-V,
> primarily to enable loading OpenSBI as firmware and recording
> loadable images (e.g., U-Boot) into the FDT passed to the next boot
> stage. This aligns spl_load_fit_image() with the behaviour already
> present in spl_load_simple_fit().
> 
> Patch summary:
> 
> 1/6: Allow IH_OS_OPENSBI in fit_image_load() so OpenSBI firmware can
> be loaded without error.
> 
> 2/6: Enable spl_load_fit_image() for RAM boot when
> CONFIG_SPL_LOAD_FIT_FULL is selected.
> 
> 3/6: Use map_sysmem() for FDT address handling to keep the code
> sandbox‑friendly.
> 
> 4/6: Initialize spl_image_info in
> spl_test_load()/spl_test_load_fit_full().
> 
> 5/6: Record loadables into spl_image->fdt_addr during FIT load,
> providing the entry addresses needed by subsequent stages (e.g.,
> OpenSBI).
> 
> 6/6: Add a unit test to verify that loadables are correctly recorded
> in the FDT.
> 
> Tested with provided sandbox test with a grafted FIT image containing
> OpenSBI (firmware), U‑Boot (loadable) and a DTB.
> 
> Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
> ---
> Changes in v2:
> 
> Addressed all review comments from Simon Glass:
> 
> - Patch 2/6: common: spl: ram: Add LOAD_FIT_FULL support:
>   - Reworded commit message to explain that FULL parser is needed for
> full image verification (CONFIG_SPL_FIT_FULL_CHECK)
>   - Added fallback: if spl_load_fit_image() fails, try
> spl_load_simple_fit()
>   - Mentioned fallback behavior in commit message
>  
> - Patch 4/6: test: spl: Zero spl_image_info:
>   - New patch added to zero-initialize spl_image_info structures in
> tests
> 
> - Patch 5/6: spl: fit: Record loadables to spl_image->fdt_addr
>   - Fixed typo: "lodable" → "loadable" (subject, commit message,
> code)
>   - Replaced -1 with FDT_ERROR (from image.h) for missing entry point
>   - Moved FDT size adjustment before loop: use
> fdt_shrink_to_minimum() once instead of fdt_increase_size() per
> iteration
>   - Extracted duplicated code into helper function
> fit_record_loadable()
>   - Replaced debug() with log_debug()
>   - Removed backslashes from debug string concatenation
>   - Added note about gd->fdt_blob limitation in commit message
>  
> - Patch 6/6: spl: fit: Add test to check loadables
>   - Fixed typo: "lodables" → "loadables" (subject, commit message)
>   - Removed unused variables (uname, str)
>   - Added FDT size fix after fdt_finish() to prevent external data
> offset drift
>   - Replaced #address-cells = 2 with ADDRESS_CELLS macro
>   - Replaced fdt_property_u64() with fdt_property_addr() for
> entry/load properties
>   - Extracted duplicated image node creation into helper
> append_fit_node()
>   - Fixed assertion: ut_assert(noffset > 0) instead of
> ut_assert(noffset)
> 
> - Link to v1:
> https://patch.msgid.link/20260807-riscv-full-fit-support-v1-0-21a34f79c350@maquefel.me
> 
> ---
> Nikita Shubin (6):
>       image: fit: allow IH_OS_OPENSBI in fit_image_load()
>       common: spl: ram: Add LOAD_FIT_FULL support
>       spl: fit: Use map_sysmem() with buffers for fdt address
>       test: spl: Zero spl_image_info
>       spl: fit: Record loadables to spl_image->fdt_addr
>       spl: fit: Add test to check loadables
> 
>  boot/image-fit.c         |   1 +
>  common/spl/spl_fit.c     |  66 ++++++++++++-----
>  common/spl/spl_ram.c     |  19 +++--
>  test/image/spl_load.c    | 184
> +++++++++++++++++++++++++++++++++++++++++++++++
>  test/image/spl_load_os.c |   4 +-
>  5 files changed, 250 insertions(+), 24 deletions(-)
> ---
> base-commit: cc8c034e78eba6b2a3845783889b80753bb1af1e
> change-id: 20260731-riscv-full-fit-support-320d38f8311e
> 
> Best regards,