Skip to content

relocate uImage payload to ih_load under RAMBOOT#833

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:uimage_ramboot_ihload
Open

relocate uImage payload to ih_load under RAMBOOT#833
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:uimage_ramboot_ihload

Conversation

@dgarske

@dgarske dgarske commented Jul 24, 2026

Copy link
Copy Markdown
Member

Under WOLFBOOT_USE_RAMBOOT, a WOLFBOOT_UBOOT_LEGACY (uImage) payload with a non-zero ih_load that differs from the RAMBOOT staging address boots corrupt: wolfBoot_start() rewrites the jump target (load_address = ih_load) but never copies the payload there, because the generic copy-to-RAM memcpy is compiled out under RAMBOOT -- so do_boot() jumps to memory that was never written. This is reachable on the shipped zynqmp/zynq7000/versal configs (all set EXT_FLASH+NO_XIP and enable WOLFBOOT_UBOOT_LEGACY), just not on today's raw-zImage test path; any mkimage-wrapped kernel with a real ih_load hits it. The fix relocates the staged payload from os_image.fw_base to ih_load via overlap-safe memmove when the two differ, mirroring the non-RAMBOOT path (the ih_load == 0 Linux/PPC path is untouched). Added a host regression test (tools/unit-tests/unit-update-ram-uboot.c) that drives the real wolfBoot_start() flow with -DWOLFBOOT_UBOOT_LEGACY and asserts the payload lands at ih_load across four cases (coincident / higher / lower-overlap / ih_load==0); verified it fails the relocation cases when the fix is reverted. No Zynq/Versal hardware locally -- validated via the host check harness.

Fixes #827

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a RAMBOOT-specific boot corruption when booting U-Boot legacy (uImage) payloads whose non-zero ih_load differs from the RAMBOOT staging location. Under WOLFBOOT_USE_RAMBOOT, wolfBoot_start() updates the jump target to ih_load but (prior to this change) did not relocate the already-staged payload there because the generic copy-to-RAM path is compiled out.

Changes:

  • Relocate the staged uImage payload to ih_load via overlap-safe memmove() under WOLFBOOT_USE_RAMBOOT when ih_load != 0 and differs from os_image.fw_base.
  • Add a host regression test that drives the real wolfBoot_start() flow under WOLFBOOT_USE_RAMBOOT + WOLFBOOT_UBOOT_LEGACY, covering coincident, higher, lower-overlap, and ih_load == 0 cases.
  • Wire the new unit test into the unit-test build/run Makefile.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/update_ram.c Adds RAMBOOT-only payload relocation to ih_load for uImage legacy boot to prevent jumping to unwritten memory.
tools/unit-tests/unit-update-ram-uboot.c New regression test exercising uImage ih_load relocation behavior under RAMBOOT across multiple address/overlap cases.
tools/unit-tests/Makefile Adds unit-update-ram-uboot to the test list and build rules with required defines and link objects.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dgarske dgarske assigned danielinux and wolfSSL-Bot and unassigned dgarske Jul 24, 2026
@dgarske
dgarske requested a review from danielinux July 24, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants