Skip to content

ZynqMP ZCU102 SD-card Linux boot: EL2 cleanup, DTS bootargs, SDHCI init#750

Open
dgarske wants to merge 1 commit intowolfSSL:masterfrom
dgarske:zynqmp_bb
Open

ZynqMP ZCU102 SD-card Linux boot: EL2 cleanup, DTS bootargs, SDHCI init#750
dgarske wants to merge 1 commit intowolfSSL:masterfrom
dgarske:zynqmp_bb

Conversation

@dgarske
Copy link
Copy Markdown
Contributor

@dgarske dgarske commented Apr 14, 2026

ZynqMP ZCU102 SD-card Linux boot: EL2 cleanup, DTS bootargs, SDHCI init

Add the pieces needed to boot Linux end-to-end from the ZCU102 SD card
with wolfBoot at EL2:

  • src/boot_aarch64_start.S: new el2_flush_and_disable_mmu helper that
    cleans D-cache to PoC, invalidates I-cache to PoU, and clears
    SCTLR_EL2.{M,C,I}, then returns. Satisfies the ARM64 Linux boot
    protocol and is also correct for any other payload that sets up its
    own translation (hypervisor, RTOS, later bootloader stage).
  • src/boot_aarch64.c: call el2_flush_and_disable_mmu from do_boot() on
    the EL2 direct-jump path before falling through to the br x4 block.
    Also pull in hal/zynq.h and hal/nxp_ls1028a.h so the EL_HYPERVISOR /
    BOOT_EL1 guards compile for those targets.
  • hal/zynq.c: implement hal_dts_fixup() — set /chosen/bootargs from
    LINUX_BOOTARGS (with a LINUX_BOOTARGS_ROOT default of /dev/mmcblk0p4)
    and grow DTB totalsize by 512 bytes to give fdt_setprop() headroom
    (matches hal/versal.c). Add hal_get_timer_us() via CNTPCT_EL0.
  • src/sdhci.c: add a 1 ms settling delay after sdhci_platform_init()
    and a CMD0 retry loop (up to 10 x 10 ms) so the ZCU102 Arasan
    controller reliably detects the card after the slot-type change +
    soft reset.
  • config/examples/zynqmp_sdcard.config: stay at EL2 by default (comment
    out BOOT_EL1), default rootfs to /dev/mmcblk0p4, turn DEBUG off.
  • hal/versal.c: correct the default LINUX_BOOTARGS_ROOT to
    /dev/mmcblk0p4 to match the shipped MBR layout.
  • docs/Targets.md: note the unconditional EL2 cleanup in the ZynqMP
    and Versal SD-card sections.

Behavior change: non-Linux AArch64 EL2 payloads now enter with MMU
off and caches clean instead of inheriting wolfBoot's tables. No
in-tree payload relies on the old state leakage.

@dgarske dgarske self-assigned this Apr 14, 2026
@dgarske dgarske requested review from Copilot and danielinux April 14, 2026 19:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Targets reliable SD-card Linux boot on Xilinx ZynqMP (ZCU102) by improving SDHCI init timing, adding timer support, patching DT bootargs at runtime, and ensuring ARM64 Linux entry requirements are met when booting from EL2.

Changes:

  • Add SDHCI delays/retries to avoid CMD0 cold-boot timeout on Arasan SDHCI.
  • Add ZynqMP timer + DTB /chosen/bootargs runtime fixup to match wolfBoot partitioning.
  • Add EL2 cache clean + MMU/I/D-cache disable path before jumping to Linux.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 11 comments.

File Description
src/sdhci.c Adds settle delays and CMD0 retry loop to stabilize SD card initialization timing.
src/boot_aarch64_start.S Introduces an EL2 cleanup/jump helper to satisfy Linux boot protocol cache/MMU requirements.
src/boot_aarch64.c Calls the EL2 cleanup/jump helper when booting from EL2.
hal/zynq.c Implements DTB bootargs fixup and adds a microsecond timer using the ARMv8 generic timer.

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

Comment thread src/sdhci.c
Comment thread src/sdhci.c
Comment thread src/sdhci.c
Comment thread src/sdhci.c Outdated
Comment thread src/boot_aarch64_start.S Outdated
Comment thread src/boot_aarch64.c
Comment thread src/boot_aarch64.c Outdated
Comment thread hal/zynq.c Outdated
Comment thread hal/zynq.c Outdated
Comment thread hal/zynq.c Outdated
Copy link
Copy Markdown

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #750

Scan targets checked: wolfboot-bugs, wolfboot-consttime, wolfboot-defaults, wolfboot-mutation, wolfboot-proptest, wolfboot-src, wolfboot-zeroize

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread src/sdhci.c
Copilot AI review requested due to automatic review settings April 15, 2026 18:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.


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

Comment thread src/boot_aarch64.c Outdated
Comment thread src/boot_aarch64_start.S
Comment thread hal/zynq.c
Comment thread hal/zynq.c
Comment thread hal/zynq.c
Copilot AI review requested due to automatic review settings April 15, 2026 18:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


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

Comment thread src/boot_aarch64.c Outdated
Comment thread hal/zynq.c
@dgarske dgarske changed the title Fixes for Xilinx ZynqMP ZCU102 SD card boot with Linux ZynqMP ZCU102 SD-card Linux boot: EL2 cleanup, DTS bootargs, SDHCI init Apr 15, 2026
Add the pieces needed to boot Linux end-to-end from the ZCU102 SD card
with wolfBoot at EL2:

* src/boot_aarch64_start.S: new el2_flush_and_disable_mmu helper that
  cleans D-cache to PoC, invalidates I-cache to PoU, and clears
  SCTLR_EL2.{M,C,I}, then returns. Satisfies the ARM64 Linux boot
  protocol and is also correct for any other payload that sets up its
  own translation (hypervisor, RTOS, later bootloader stage).
* src/boot_aarch64.c: call el2_flush_and_disable_mmu from do_boot() on
  the EL2 direct-jump path before falling through to the br x4 block.
  Also pull in hal/zynq.h and hal/nxp_ls1028a.h so the EL_HYPERVISOR /
  BOOT_EL1 guards compile for those targets.
* hal/zynq.c: implement hal_dts_fixup() — set /chosen/bootargs from
  LINUX_BOOTARGS (with a LINUX_BOOTARGS_ROOT default of /dev/mmcblk0p4)
  and grow DTB totalsize by 512 bytes to give fdt_setprop() headroom
  (matches hal/versal.c). Add hal_get_timer_us() via CNTPCT_EL0.
* src/sdhci.c: add a 1 ms settling delay after sdhci_platform_init()
  and a CMD0 retry loop (up to 10 x 10 ms) so the ZCU102 Arasan
  controller reliably detects the card after the slot-type change +
  soft reset.
* config/examples/zynqmp_sdcard.config: stay at EL2 by default (comment
  out BOOT_EL1), default rootfs to /dev/mmcblk0p4, turn DEBUG off.
* hal/versal.c: correct the default LINUX_BOOTARGS_ROOT to
  /dev/mmcblk0p4 to match the shipped MBR layout.
* docs/Targets.md: note the unconditional EL2 cleanup in the ZynqMP
  and Versal SD-card sections.

Behavior change: non-Linux AArch64 EL2 payloads now enter with MMU
off and caches clean instead of inheriting wolfBoot's tables. No
in-tree payload relies on the old state leakage.
@dgarske dgarske added the Later It won't be fixed in the upcoming release label Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Later It won't be fixed in the upcoming release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants