Skip to content

Add wolfBoot FIT support for loading bitstream#786

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

Add wolfBoot FIT support for loading bitstream#786
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:fit_fpga_bitstream

Conversation

@dgarske
Copy link
Copy Markdown
Member

@dgarske dgarske commented May 29, 2026

Features

  • Load and program an FPGA bitstream from an fpga sub-image in a signed FIT, using the standard U-Boot convention: sub-image type = "fpga", configuration fpga = "<node>" reference, and a compatible string selecting the load method (partial in the string selects partial reconfiguration, otherwise full). Programmed before the kernel/DTB load so PL-dependent clocks/peripherals come up first.
  • New hal_fpga_load() HAL abstraction with a weak default (returns not-implemented) and per-target implementations.
    • ZynqMP (TARGET=zynq): full bitstream via the PMU firmware PM_FPGA_LOAD EEMI call (xilfpga / CSU DMA / PCAP).
    • Zynq-7000 (TARGET=zynq7000): full bitstream via a new DevC/PCAP DMA driver (UG585 ch.6) with bounded poll-loop timeouts.
    • Versal (TARGET=versal): documented not-implemented stub (PL config is a PLM Load-PDI IPI).
  • fit_load_fpga() stages the bitstream to a configurable DDR address (WOLFBOOT_LOAD_FPGA_ADDRESS), decompressing gzip bitstreams (the typical mkimage output, which has no load property) bounded by WOLFBOOT_FIT_MAX_FPGA and validated by the gzip CRC32 + ISIZE.
  • Generic per-board FIT configuration selection: FIT_CONFIG_SELECT=1 plus a weak hal_fit_config_name() hook lets an integrator boot a non-default configuration (e.g. conf-<board>); the default returns NULL (use the FIT default). No board-detection (GPIO/CHIPID) logic is shipped upstream.
  • New build flags: FPGA_BITSTREAM, FPGA_NONFATAL (failed PL load warns and continues instead of panicking), WOLFBOOT_LOAD_FPGA_ADDRESS, FIT_CONFIG_SELECT. All opt-in; default builds are unchanged.
  • fit_find_images() extended to discover the fpga node (config fpga property and type == "fpga" fallback); new fit_get_compatible() helper.
  • New unit-fit-fpga unit test covering fpga discovery and compatible parsing; docs and .its template updated.

Fixes

  • ZynqMP PM_FPGA_LOAD size is passed in bytes (not 32-bit words), matching stock Xilinx U-Boot and the PMU firmware xilfpga, which divides by the word length internally.
  • Decompress gzip fpga sub-images that have no load property to the staging address, instead of failing closed.
  • Place the weak hal_fpga_load() / hal_fit_config_name() defaults in hal/hal.c (linked into every target) rather than a region of libwolfboot.c that is compiled out for the Xilinx targets, fixing an undefined-reference link error.

@dgarske dgarske self-assigned this May 29, 2026
Copilot AI review requested due to automatic review settings June 1, 2026 20:21
@dgarske dgarske force-pushed the fit_fpga_bitstream branch from 134b701 to a5d0255 Compare June 1, 2026 20:21
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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 20 out of 20 changed files in this pull request and generated 2 comments.

Comment thread src/fdt.c
Comment thread hal/zynq7000.c Outdated
@dgarske dgarske force-pushed the fit_fpga_bitstream branch from a5d0255 to ab6b3b4 Compare June 1, 2026 22:25
@dgarske dgarske marked this pull request as ready for review June 1, 2026 22:25
@dgarske dgarske requested a review from Copilot June 1, 2026 22:28
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 20 out of 20 changed files in this pull request and generated 4 comments.

Comment thread src/fdt.c
Comment on lines +1240 to +1245
/* Select full vs partial reconfiguration from the U-Boot-style
* "compatible" string (e.g. "...fpga-partial"). Default is full. */
comp = fit_get_compatible(fdt, fpga_node);
if (fit_str_contains(comp, "partial")) {
flags = HAL_FPGA_PARTIAL;
}
Comment thread hal/zynq7000.c
Comment on lines +972 to +979
/* 8. Wait for the PL to report configuration complete. */
t0 = hal_get_timer_us();
while (!(Z7_DEVC_INT_STS & Z7_DEVC_INT_PCFG_DONE)) {
if (hal_get_timer_us() - t0 > Z7_FPGA_TIMEOUT_US) {
wolfBoot_printf("Z7 FPGA: timeout waiting PCFG_DONE\n");
return -1;
}
}
Comment thread hal/zynq.c
Comment on lines +1753 to +1757
/* Confirm the PL reports configured (PCAP status). */
memset(ret_payload, 0, sizeof(ret_payload));
pmu_request(PM_FPGA_GET_STATUS, 0, 0, 0, 0, ret_payload);
wolfBoot_printf("FPGA status: 0x%x\n", ret_payload[1]);

Comment thread tools/unit-tests/Makefile
Comment on lines +342 to +345
# FIT fpga-subimage discovery (fit_find_images / fit_get_compatible).
unit-fit-fpga: ../../include/target.h unit-fit-fpga.c
gcc -o $@ unit-fit-fpga.c $(CFLAGS) -DWOLFBOOT_FDT \
-ffunction-sections -fdata-sections $(LDFLAGS) -Wl,--gc-sections
@dgarske dgarske force-pushed the fit_fpga_bitstream branch from ab6b3b4 to fcc8bc3 Compare June 1, 2026 22:56
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.

2 participants