Commit Graph

3058 Commits (d1df8b2df0b0667af62e412e678bbc8e19309698)

Author SHA1 Message Date
Daniele Lacamera d1df8b2df0 Fix initialization of string in otp_keystore tag (fix build error)
Emerged in newer gcc15, due to -Wunterminated-string-initialization
added to -Wall
2026-05-06 10:22:59 +02:00
Brett Nicholas 9a667f2a75 set TC3 ARCH_FLASH_OFFSET with ?= 2026-05-05 16:37:54 +02:00
Brett Nicholas dd8accdc87 increase size 2026-05-05 16:37:54 +02:00
Brett Nicholas 8f191b9f3a enable WOLFBOOT_IMG_HASH_ONESHOT for all AURIX configs 2026-05-05 16:37:54 +02:00
Brett Nicholas 24841a0eb8 support AURIX hw accel 2026-05-05 16:37:54 +02:00
Brett Nicholas 8ac4838b92 tc3: disable/capture bus errors for lifetime of bootloader 2026-05-05 16:37:54 +02:00
Brett Nicholas 149db43612 tc3: add echo test to test-app when wolfHSM is enabled 2026-05-05 16:37:54 +02:00
Brett Nicholas f5a8efeb25 tc3: fix for latest wolfHSM, remove devId from cryptoCtx as it no longer exists 2026-05-05 16:37:54 +02:00
Brett Nicholas 2ca5ae3894 add self-header to tricore config 2026-05-05 16:37:54 +02:00
Brett Nicholas e43e012e98 review feedback 2026-05-05 16:37:54 +02:00
Brett Nicholas dc2664a701 update unit tests to use new APIs 2026-05-05 16:37:54 +02:00
Brett Nicholas 627e0664a2 fix include order for unit tests 2026-05-05 16:37:54 +02:00
Brett Nicholas a2e9267529 Adds generic cryptocb support for PK, hash, and symmetric crypto 2026-05-05 16:37:54 +02:00
Thomas Cook 8d96afb7e2 Fix lms/xmss header includes. 2026-05-05 14:08:35 +02:00
David Garske 9ca1d435b9 Peer review fixes (copilot)
src/fdt.c, include/fdt.h
  - Propagate fdt_fixup_initrd error in fit_load_ramdisk so a /chosen
    patch failure no longer silently boots a kernel with no initrd.
  - Add fit_load_image_to(): decompress (or memcpy) directly to a
    caller-supplied destination buffer instead of going through the
    FIT-declared `load` address. fit_load_ramdisk now uses this when
    WOLFBOOT_LOAD_RAMDISK_ADDRESS is set, so the override is a real
    safety bound for compressed ramdisks (previously the gzip stream
    was still inflated to the FIT `load` and only memcpy'd afterward).
  - Refactor fit_load_image_ex into a shared inner helper.
  - Reword the WOLFBOOT_FIT_MAX_DECOMP comment: the cap is a sanity
    ceiling, not a per-destination memory-safety bound. Authenticity
    is provided by the outer wolfBoot signature; tighter bounds need
    fit_load_image_ex / _to with an explicit out_max / dst_max.
  - Add WOLFBOOT_FIT_MAX_RAMDISK (defaults to WOLFBOOT_FIT_MAX_DECOMP)
    so targets can pin a tighter ramdisk decompression bound.

src/update_ram.c, src/update_disk.c
  - Panic when fit_load_image() returns NULL for the kernel subimage
    instead of letting load_address=NULL propagate into do_boot().

tools/unit-tests/unit-gzip.c
  - Add deterministic stored / fixed-Huffman / dynamic-Huffman gzip
    fixtures so the inflater's BTYPE 00/01/10 paths are exercised
    independent of host gzip(1) heuristics.
  - Add FEXTRA / FNAME / FCOMMENT / FHCRC and combined-flag fixtures
    plus a truncated-FEXTRA negative case to cover the optional gzip
    header parser.

tools/unit-tests/unit-fit-gzip.c (new), tools/unit-tests/Makefile
  - New libcheck binary covering the FIT loader's compression
    branches: gzip success, gzip stream corruption, unknown
    compression, compression="none" baseline, and the no-load
    fail-closed path. Built twice from the same source - once with
    WOLFBOOT_GZIP for the success / runtime-failure paths, and once
    without it so the compile-time fail-closed branch is also tested.
2026-05-05 10:16:16 +02:00
David Garske d92053037c Fixes from peer review (Thank you Daniele and Marco) 2026-05-05 10:16:16 +02:00
David Garske 85fb32b1dd Fixes from peer review. Thank you Alex 2026-05-05 10:16:16 +02:00
David Garske afb9389c1d Peer review fixes 2026-05-05 10:16:16 +02:00
David Garske 5c29938ba3 docs: document FIT compressed and ramdisk paths for ZynqMP/Versal/PolarFire
PolarFire MPFS250, Versal VMK180, and ZynqMP "Booting PetaLinux"
walkthroughs now describe both options for handing PetaLinux off through
the FIT image:

  * Option A (default GZIP=1): set compression="gzip" in the .its,
    point data at Image.gz / linux.bin.gz, and let mkimage build the
    FIT directly. wolfBoot decompresses straight to the kernel load
    address at boot and verifies hash-1.
  * Option B (GZIP=0): keep the existing host-side gzip -cdvk /
    gunzip step and compression="none" in the .its.

ZynqMP also gains a "FIT ramdisk (initramfs)" subsection covering
RAMDISK=1, WOLFBOOT_LOAD_RAMDISK_ADDRESS, the commented-out opt-in
block in zynqmp_sdcard.config, gzip ramdisk support, and a sample ITS
layout with kernel + DTB + ramdisk subimages.
2026-05-05 10:16:16 +02:00
David Garske c643215c5e fit: gzip-compressed kernel + ramdisk (initramfs) support
Wires the new wolfBoot_gunzip inflater into the FIT image-loading path
and adds initramfs (ramdisk) extraction with DTB /chosen fixup so a
single signed FIT can carry kernel, DTB, and rootfs.

GZIP path
---------
* fit_load_image_ex(out_max) added; fit_load_image kept as a wrapper.
* When a subimage carries compression="gzip", inflate straight to the
  FIT-declared load address, then verify the FIT hash-1 subnode
  (sha256 / sha384 if available) for defense in depth on top of the
  outer wolfBoot signature. The compression property is now read
  unconditionally so a build without WOLFBOOT_GZIP can warn and fail
  closed instead of silently memcpy-ing compressed bytes as if they
  were raw.
* fit_verify_hash propagates wc_InitSha256 / wc_Sha256Update /
  wc_Sha256Final return codes (and the SHA-384 equivalents) - any
  non-zero return is treated as a verification failure so a misbehaving
  backend cannot silently degrade to a no-op.
* GZIP=1 is the new default in the FIT-using example configs (zynqmp,
  zynqmp_sdcard, polarfire_mpfs250, polarfire_mpfs250_qspi,
  versal_vmk180, versal_vmk180_sdcard); set GZIP=0 to opt out.

Ramdisk path
------------
* fit_find_images() gains a ramdisk out-arg and fdt_fixup_initrd()
  writes /chosen/linux,initrd-{start,end} as 64-bit big-endian cells.
* update_disk.c and update_ram.c load the FIT ramdisk node (under
  WOLFBOOT_FIT_RAMDISK) and patch the loaded DTB. Compressed (gzip)
  ramdisks reuse the same fit_load_image_ex() decompress path.
* RAMDISK=1 build switch defines WOLFBOOT_FIT_RAMDISK;
  WOLFBOOT_LOAD_RAMDISK_ADDRESS is plumbed through tools/config.mk ->
  Makefile sed -> include/target.h.in. Defaults to 0; when 0 the
  ramdisk stays at whatever fit_load_image returned.
* hal/zynq.c and hal/versal.c bump fdt_totalsize headroom from 512 to
  768 bytes to fit the new linux,initrd-{start,end} entries.
* config/examples/zynqmp_sdcard.config gains a commented-out opt-in
  block (RAMDISK=1, WOLFBOOT_LOAD_RAMDISK_ADDRESS=0x40000000, alt
  LINUX_BOOTARGS) so a single config file covers both rootfs-on-disk
  and FIT-bundled-initramfs flows.

Builds against the existing master configs are byte-identical when
GZIP=0 and RAMDISK is unset.
2026-05-05 10:16:16 +02:00
David Garske 090f0ef411 gzip: add clean-room RFC 1951/1952 inflater + libcheck tests
New src/gzip.c implements DEFLATE (RFC 1951) plus the gzip wrapper
(RFC 1952) from the RFC text only. Single-pass inflate, no allocations:
the output buffer doubles as the LZ77 sliding window, so back-references
read from out[out_pos - distance]. Canonical Huffman decode using
counts[] / symbols[] tables, ~10x smaller code than fast lookup tables
which matters in the bootloader. CRC32 + ISIZE verified against the
gzip trailer. Gated by WOLFBOOT_GZIP.

include/gzip.h carries the public entry point plus the RFC-canonical
constants (magic bytes, CM=DEFLATE, fixed Huffman boundaries, EOB
symbol, dynamic block field widths, run-length repeat metadata, CRC32
init/final-XOR, header/trailer sizes, alphabet sizes) so future
maintainers can cross-reference the RFC sections by name instead of
chasing literal numbers.

Tests in tools/unit-tests/unit-gzip.c round-trip 6 corpora through host
gzip(1) and back through wolfBoot_gunzip (empty, short text, all-zeros,
structured text, pseudo-random, ~2 MB kernel-sized). 9 negative cases
cover bad magic, bad CM, reserved FLG bits, truncated header,
truncated DEFLATE body, CRC32 mismatch, ISIZE mismatch, output overflow,
and NULL parameters. All 15 pass under libcheck.
2026-05-05 10:16:16 +02:00
David Garske 8c7b8640dd
Merge pull request #762 from danielinux/fenrir-fixes-2026-04-29
Fenrir fixes
2026-04-29 11:24:44 -07:00
Daniele Lacamera 971f0c67e1 Improve readability of changes in disk.c 2026-04-29 16:06:22 +02:00
David Garske e44e6b2a8d
Merge pull request #754 from danielinux/fix-renode-test
Migrate renode test to new container
2026-04-29 06:58:32 -07:00
Daniele Lacamera 1226776ff4 Modernize riscv build test 2026-04-29 13:24:07 +02:00
Daniele Lacamera 8c0b44c7fa Fixed size-all thresholds 2026-04-29 13:20:36 +02:00
Daniele Lacamera 8eb7fa6a18 Addressed copilot's comments 2026-04-29 13:15:52 +02:00
Daniele Lacamera 2a9aa60d40 Fixed test regressions 2026-04-29 13:12:45 +02:00
Daniele Lacamera 47e1f77fca Zero LMS key verify buffer
F/3309
2026-04-29 12:32:50 +02:00
Daniele Lacamera 05f5f5cbe3 Zeroize XMSS key readback buffer
F/3308
2026-04-29 12:31:21 +02:00
Daniele Lacamera a60461f18b Fix XMSS keygen param fallback
F/3306
2026-04-29 12:30:23 +02:00
Daniele Lacamera afa9641107 Add sector flag unit coverage
F/3305
2026-04-29 12:26:55 +02:00
Daniele Lacamera 47ef6b4e85 Add GPT single-sector partition test
F/3304
2026-04-29 12:24:41 +02:00
Daniele Lacamera c39522edb3 Add inverse delta version gate tests
F/3303
2026-04-29 12:23:03 +02:00
Daniele Lacamera cc6f52edb3 Add final sanity check after boot hook
F/3302
2026-04-29 12:20:41 +02:00
Daniele Lacamera 26cae311d2 Fix decrypted blob TLV parsing
F/3301
2026-04-29 12:18:04 +02:00
Daniele Lacamera 54b2ba34b7 Bound TPM name fallback copies
F/3300
2026-04-29 12:16:03 +02:00
Daniele Lacamera 98d1e7726f Abort QSPI writes after WE failure
F/3299
2026-04-29 12:13:40 +02:00
Daniele Lacamera 8eddbf3516 zeroize ARM TEE PS buffers on reuse
F/3047
2026-04-29 12:11:31 +02:00
Daniele Lacamera dfc7656071 Validate GPT partition array CRC
F/3045
2026-04-29 12:10:02 +02:00
Daniele Lacamera 6e8e20ceb6 Cap backward delta match length
F/3044
2026-04-29 11:34:23 +02:00
Daniele Lacamera 74c0d29c2d Add single-partition disk boot tests
F/3043
2026-04-29 11:32:24 +02:00
Daniele Lacamera 1e6dd16c6a Harden encrypted key comparisons
F/3042
2026-04-29 11:31:08 +02:00
Daniele Lacamera b6e6dc022e Harden local secret comparisons
F/3041
2026-04-29 11:29:56 +02:00
Daniele Lacamera bcd75b0a89 Fix multiboot debug header length guard
F/3040
2026-04-29 11:27:58 +02:00
Daniele Lacamera b0f1bf9bd1 Handle library image malloc failure
F/3038
2026-04-29 11:24:44 +02:00
Daniele Lacamera f86ffd8ffc Fix delta update cleanup on early errors
F/3298
2026-04-29 11:22:07 +02:00
Daniele Lacamera eaa6af2b66 Return UART flash read error on timeout
F/3039
2026-04-29 11:20:57 +02:00
Daniele Lacamera c0f6b12721 Addressed copilot's comments 2026-04-28 15:22:41 +02:00
Daniele Lacamera 42455508c0 Fix NRF52 UART DMA and Renode test infrastructure
hal/nrf52.c:
- Use static volatile buffer for UARTE DMA source instead of stack
  variable address. GCC 15.2 with -Os optimized away the store to the
  stack slot, causing the DMA to read zeros.
- Set UART0_ENABLE to 4 (UARTE mode) per NRF52840 datasheet.

tools/test-expect-version/test-expect-version.c:
- Replace deprecated termio.h and linux/serial.h with sys/ioctl.h
  for compatibility with newer glibc.

tools/renode/docker-test.sh:
- Remove unused RENODE_CHECKOUT env var.

tools/scripts/renode-test-update.sh:
- Add robust UART wait functions with timeouts and liveness checks.
- Log Renode output to /tmp/renode.log for diagnostics on failure.
- Use run_expect_version helper with configurable timeout.
2026-04-28 15:04:35 +02:00