Commit Graph

825 Commits (a79bace7729bc3eeffaef9aa606b5a829828dab8)

Author SHA1 Message Date
Daniele Lacamera a2706b98d5 mcxw: extend the erase length when rounding the start down
hal_flash_erase() rounded an unaligned address down to the sector boundary
but left len at the caller's value, so a request ending in a later sector
erased only the first one. Grow len by the same amount.

test_erase_zero_runtime_sector_falls_back covered a request that ends
0x10 into the second sector, so its one-erase expectation encoded the
under-erase; it now expects both.
2026-08-12 13:21:08 +02:00
Daniele Lacamera a69b3384d7 nrf52/nrf5340/stm32l0: fix the 32-bit fast path in hal_flash_write
F-6757 fixed the byte-wise path but left the fast path above it indexing
dst[i >> 2]/src[i >> 2] off the call-time base. The guard only proves that
"address + i" and "data + i" are word aligned, so when the destination and
source share a non-zero misalignment the byte path advances i to the next
word boundary and the fast path then copies the wrong word, through an
unaligned 32-bit access that faults on the Cortex-M0+ of stm32l0.

Index both pointers by i directly, and cover the case the existing tests
deliberately avoided.
2026-08-12 13:20:56 +02:00
Daniele Lacamera f7551256d0 F-6757: fix partial-word hal_flash_write on nrf52, nrf5340 and stm32l0
The byte-wise branch of hal_flash_write() derived the containing word from
the call-time "address" instead of the current position "address + i":

    int off = (address + i) - (((address + i) >> 2) << 2);
    dst = (uint32_t *)(address - off);
    val = dst[i >> 2];

so "dst[i >> 2]" addressed physical byte "address - off + (i & ~3)". Any
iteration with "i" not a multiple of 4 modified the wrong byte, and with
off != 0 it did so through a misaligned 32-bit flash access (a HardFault on
the Cortex-M0+ of stm32l0). A word-aligned 6-byte write, for instance, put
data[5] at "address + 4" and left "address + 5" erased.

Use the form already applied to hal/samr21.c and hal/same51.c: base the
word on "address + i - off", read it with a single aligned access, and fill
it byte by byte up to the next word boundary.

Add unit-flash-write-nrf52, covering the aligned-with-tail, mismatched
alignment and single-word cases against hal/nrf52.c.
2026-08-11 13:04:10 +02:00
Daniele Lacamera ab7b79cd16 F-7383: use one consistent sector size in mcxw hal_flash_erase
hal_flash_erase() in hal/mcxw.c rounded the start address down with the
runtime pflash_sector_size (queried from FLASH_GetProperty() in hal_init())
but stepped address and len by the compile-time WOLFBOOT_SECTOR_SIZE. When
the two differ, a larger WOLFBOOT_SECTOR_SIZE steps over hardware sectors
inside the requested range and leaves them unerased, while a smaller one
issues erase commands at non-sector-aligned addresses. A zero size reported
by the driver would also divide by zero.

Take a local sector_size, fall back to WOLFBOOT_SECTOR_SIZE when the driver
reports zero and use it for the alignment and both loop steps, as
hal/mcxn.c already does.

Add unit-flash-erase-mcxw, using the existing WOLFBOOT_UNIT_TEST_FLASH_ERASE
guard convention to compile hal_flash_erase() in isolation without the NXP
MCUXpresso SDK headers.
2026-08-11 12:52:20 +02:00
David Garske 2b3b7034a5 aarch64_efi: address PR818 review (measure cmdline, DTB GUID, size/page/desc fixes) 2026-08-10 21:03:50 +02:00
David Garske 4a16dce4f8 efi: authenticate the kernel command line via a signed HDR_CMDLINE manifest TLV 2026-08-10 21:03:50 +02:00
David Garske 9d50c1a6de aarch64_efi: fix open_kernel_image error return; expand kernel cmdline security docs 2026-08-10 21:03:50 +02:00
David Garske 811c9d049a aarch64_efi: measure kernel into firmware TPM via EFI_TCG2 2026-08-10 21:03:50 +02:00
David Garske 34941079e1 Add aarch64_efi target: wolfBoot as an AArch64 UEFI application 2026-08-10 21:03:50 +02:00
Marco Oliverio 0dfad2dbc1 hal: pic32cz: uart_deinit out from clock_restore block, nop asm volatile 2026-08-06 15:31:25 +02:00
Marco Oliverio 955b07cc0b mc: pic32cz: better state reset before boot 2026-08-06 15:31:25 +02:00
Aidan Garske db0801b9b4 Add wolfCOSE DICE attestation 2026-08-06 09:44:52 +02:00
David Garske 5f40400e57 PolarFire SoC: address PR review
- wolfBoot_fit_memcpy: return int so a failed PDMA copy propagates instead
  of being swallowed. The weak default (memcpy) returns 0; the MPFS250 PDMA
  override returns -1 if any chunk's mpfs_pdma_memcpy() fails. Callers now
  fail closed: fit_load_image_inner returns NULL (kernel load then panics
  via update_disk.c), the update_disk DTS copy panics, and hal_dts_fixup
  returns an error on a failed L2->DDR copy-back.
- options.mk: gate -DSTACK_SIZE_PER_HART behind RISC-V arch (RISCV/RISCV64).
  The macro is only consumed by the RISC-V startup asm and the mpfs250-m.ld
  sed token, so it is no longer emitted for PPC/ARM/other targets. The
  unconditional default (?= 0) is kept because the linker sed always needs
  a value to substitute.
2026-08-03 12:27:22 +02:00
David Garske e718eed709 PolarFire SoC: LPDDR4 DDR init for MPFS250T Video Kit (M-Mode) 2026-08-03 12:27:22 +02:00
Mattia Moffa 6da07ffc3d Add support for ARM Compiler for Embedded on stm32u5 2026-07-31 16:00:14 +02:00
Mattia Moffa 6b8702dd63 Add uart driver for stm32u5 2026-07-31 16:00:14 +02:00
Mattia Moffa 357734d691 Fixes for old Maxim SDK 2026-07-31 14:33:56 +02:00
Mattia Moffa d750f46723 Fix issues found by Copilot 2026-07-31 14:33:56 +02:00
Mattia Moffa cadd3dfe1a Use bank-relative offsets instead of addresses in FLC registers 2026-07-31 14:33:56 +02:00
Mattia Moffa 60b9e87413 SHA256 acceleration for bootloader 2026-07-31 14:33:56 +02:00
Mattia Moffa f5f54c294e Implementation of test-app crypto test 2026-07-31 14:33:56 +02:00
Mattia Moffa bcda09e4ed Fix UART; support FTHR2 board 2026-07-31 14:33:56 +02:00
David Garske 9d9305eebb Support for MAX32666 2026-07-31 14:33:56 +02:00
David Garske d073ae4ddb watchdog: add generic feed hook and RX driver 2026-07-30 15:32:31 +02:00
David Garske eaa39be9e4 renesas-rx: fix build for GCC RX 8.3/14.2 2026-07-30 15:32:31 +02:00
David Garske d66d9b119f zynq: add optional ZynqMP PHY init over GEM MDIO 2026-07-30 15:26:01 +02:00
David Garske 87c34064d9 Add NXP LS1028A ENETC wolfIP support 2026-07-30 13:29:09 +02:00
David Garske 58887772cb Add NXP T10xx (T1024/T1040) wolfIP support + flash-write fix 2026-07-30 13:29:09 +02:00
David Garske ac5f532cf9 Add NXP T2080 (+ NAII 68PPC2) wolfIP support 2026-07-30 13:29:09 +02:00
Marco Oliverio 36b665bfcc pic32cz: add wolfHSM client target
Run wolfBoot on the PIC32CZ CA9x host core (Cortex-M7) as a wolfHSM client,
offloading the image digest (SHA-256) and the ECDSA P-256 signature check to
the wolfHSM server.
2026-07-29 18:07:45 +02:00
David Garske 1ceaef3eee zynqmp: wolfBoot ZynqMP FSBL with signed FIT Linux boot and EL3 security (eFuse/PUF/AES-CSU) 2026-07-22 11:56:40 +02:00
aidan garske 88c0f1fd55 6560 - Clear PFSWAP bit in pic32_fcw_pfswap_set read-modify-write 2026-07-21 19:33:40 +02:00
aidan garske f27d3eb2a9 6588 - Index LS1028A XSPI TX FIFO by word instead of by byte 2026-07-21 19:33:40 +02:00
David Garske a3e2bc89d2 Add wolfBoot HAL port for RealTek RTL8735B (AmebaPro2) 2026-07-16 10:16:25 +02:00
Daniele Lacamera 7baf9e65f7 stm32u5: fix erase bank selection when SWAP_BANK is active
On STM32U5 the BKER bit in FLASH_NSCR/SECCR always selects the
physical bank: the SWAP_BANK option only changes the address mapping
of the banks (RM0456 7.5.8, and confirmed on silicon). hal_flash_erase
derived BKER from the logical address only, so with SWAP_BANK active
every page erase landed in the bank opposite to the one mapped at the
target address.

In DUALBANK_SWAP mode this broke fallback recovery: when image
verification failed while running from bank 2, wolfBoot_erase_partition
(PART_UPDATE) erased the healthy image in the active bank instead of
the failing update, leaving the device unable to boot. The same
mismatch corrupted any erase issued while swapped, including staging a
new update from the application.

Invert BKER when both DBANK and SWAP_BANK are set, mirroring the
STM32H5 HAL which already handles this (RM0481 has the same physical
bank semantics). STM32L5 is not affected: RM0438 defines NSBKER as the
page number MSB, which follows the mapped address.

Verified on the m33mu emulator with hardware-faithful BKER/SWAP_BANK
modeling: full cycle (update to bank 2, swap, stage corrupt update,
verify failure) now erases the corrupt update and falls back to the
healthy image; before this fix the healthy image was erased and the
device bricked.
2026-07-09 12:09:14 +02:00
Daniele Lacamera d977baa60e hal/mcxw: fix truncated empty-word sentinel
empty_qword[0] was 0xFFFFFFF (7 nibbles), so a fully-erased 16-byte
word never compared equal and was always reprogrammed.
2026-07-02 17:01:22 +02:00
Daniele Lacamera aecf904978 hal: advance source index in aligned flash-write fast path
The bulk FLASH_Program path read data+w but never advanced w, so a
partial-word tail after an aligned run re-read the input from offset 0.
Affects kinetis, mcxa, mcxw. Pin with an mcxa bulk+tail test case.
2026-07-02 17:01:08 +02:00
Daniele Lacamera 102ddc38fd F-5964: fix stale in-word offset in hal_flash_write byte-wise path (samr21/same51)
In the else branch of hal_flash_write, off was computed once per call from
the original (call-time) "address" instead of the current position
"address + i". The word index dst_idx advanced with i, but the fill loop
kept starting at the stale off, so once destination address and source
buffer had different alignment mod 4, every word after the first was
filled at the wrong byte offset, dropping and misplacing data. Derive off
and dst from address + i so each word's offset tracks the current
position, mirroring the fix already applied to mcxa.c for the same bug
class (F-5963).
2026-07-02 15:57:54 +02:00
Daniele Lacamera 32e41f0f40 F-6399: fix imx_rt DCACHE invalidation to include down-alignment offset
hal_flash_write() and hal_flash_erase() aligned the invalidation start
address down to a 32-byte cache line but rounded the length up from
"len" alone, omitting the (address - aligned_address) offset. Whenever
(address % 32) + (len % 32) > 32, the invalidated range fell short of
address + len, leaving the last cache line stale after a write/erase.

Extract the range computation into hal_flash_cache_align_range()
(hal/imx_rt.h, dependency-free so it's unit-testable without the
NXP SDK) and include the down-alignment offset before rounding the
length up, so the invalidated range always covers [address, address+len).
2026-07-02 15:13:28 +02:00
Daniele Lacamera fea97c55f7 F-5963: fix over-advance of address/len in unaligned hal_flash_write (kinetis.c, mcxa.c, mcxw.c)
In the unaligned/partial-word path, address/len were advanced by the full
flash-word-relative loop index "i" (which starts at start_off), instead of
by the number of data bytes actually consumed (i - start_off). On a write
spanning more than one flash word this drops start_off bytes of input data
and misdirects the following word write. Mirrors the already-correct form
in hal/kinetis_kl26.c.
2026-07-02 14:47:38 +02:00
Alex Lanzano 76b023008b Add DEBUG_UART build test for stm32wba. Fix stm32wba clock init 2026-07-02 08:44:45 +02:00
Alex Lanzano 337dabf2f2 Implement port for STM32WBA. Bump wolfHAL lib to latest 2026-07-02 08:44:45 +02:00
Brett Nicholas b52dd5a1d0 make wolfHSM client ID parameterizable and settable via Makefiles 2026-06-16 22:03:28 -06:00
David Garske 61fd552526 Peer review fixes (thanks copilot and customer) 2026-06-15 06:13:28 +02:00
David Garske 8c059a8a01 Fixes to solve customer ELF loading 2026-06-15 06:13:28 +02:00
David Garske 413f6decae Peer review fixes (thanks Copilot) 2026-06-15 06:13:28 +02:00
David Garske 7cdfb4266a NXP T2080 / CW VPX3-152: VxWorks 7 64-bit boot support
Add wolfBoot support for booting VxWorks 7 SMP 64-bit (and signed ELF
images) on the NXP T2080 (e6500) / Curtiss-Wright VPX3-152.

Key fix: bring up the e6500 cluster L2 cache in the correct order -- set
L2PE (ECC) in its own polled write BEFORE enabling L2E, with L2FI|L2LFC --
matching CW U-Boot (SDK2.0). The previous bare-L2E init left the L2 ECC
array uninitialized for the kernel's 0x1E0000 set, machine-checking VxWorks
(MCSR[IF], L2ERRDET MBECC).

Also: ePAPR spin-table SMP bring-up of all four cores, ELF in-place loader
staging-overlap fix, DPAA/LIODN + QMan/BMan init, 64-bit OS handoff
(LAW/TLB/IVOR), and NAII 68PPC2 + CW VPX3-152 board configs.
2026-06-15 06:13:28 +02:00
Daniele Lacamera fe934ff277 Fix two regressions after the fenrir changes
In hal/va416x0.c, FRAM_Write now explicitly aborts the split SPI write transaction on command-phase failure before returning, instead of leaving the bus in the half-open state introduced
  by the early return. I also added a host-side regression test in tools/unit-tests/unit-va416x0-fram.c that injects a command-phase HAL_Spi_Transmit(..., false) failure and verifies a later
  write still reaches the closing ...true phase.

  In src/arm_tee_psa_ipc.c, I extracted the protected-storage dispatch path into a small helper so it can be tested directly without changing runtime behavior. The new test in tools/unit-
  tests/unit-arm-tee-psa-ipc.c covers the short-vector invalid-argument branches for SET, GET, GET_INFO, and REMOVE, plus a full success path across those operations. The unit harness
  additions are wired up in tools/unit-tests/Makefile and use a tiny local CMSE stub in tools/unit-tests/arm_cmse.h.
2026-06-11 19:54:52 +02:00
Daniele Lacamera 333055d092 F-3967: propagate HAL_Spi_Transmit errors in FRAM_Write and FRAM_Init
WREN and address-phase return codes were silently overwritten by
subsequent assignments; a failed WREN would let the write proceed
with the WEL bit unset, causing a silently dropped write while
returning hal_status_ok. Add early-return checks after each transmit
phase in FRAM_Write and guard the subsequent calls in FRAM_Init.
2026-06-11 19:05:49 +02:00
Daniele Lacamera 5cec6211d2 F-3735: fix EndingAddress uint32_t* arithmetic in x86_64_efi_do_boot
boot_addr is uint32_t*, so (boot_addr + *size) advanced *size * 4 bytes
instead of *size bytes, overstating the MEMMAP_DEVICE_PATH range by 4x
relative to the SourceSize passed to LoadImage. Cast to uint8_t* first
so the addition is byte-accurate and consistent with the SourceSize argument.

No unit test: compiling hal/x86_64_efi.c in a host test requires stubbing
the complete UEFI SDK type tree (EFI_FILE_IO_INTERFACE, EFI_LOADED_IMAGE,
EFI_GUID, CHAR16, LibFileInfo, FreePool, InitializeLib, …) throughout the
file — disproportionate scaffolding for a one-line arithmetic fix.
2026-06-11 18:43:02 +02:00