From ac5f532cf9d490539fa280f608287cc79ca0e69f Mon Sep 17 00:00:00 2001 From: David Garske Date: Thu, 23 Jul 2026 12:50:44 -0700 Subject: [PATCH] Add NXP T2080 (+ NAII 68PPC2) wolfIP support --- config/examples/nxp-t2080.config | 49 +++++++++++++++++++++++-- docs/Targets.md | 12 ++++-- hal/nxp_t2080.c | 27 ++++++++++++-- test-app/app_nxp_t2080.c | 13 +++++-- tools/scripts/nxp_t2080/t2080_flash.cmm | 40 ++++++++++++-------- 5 files changed, 111 insertions(+), 30 deletions(-) diff --git a/config/examples/nxp-t2080.config b/config/examples/nxp-t2080.config index 39e11134..c3e32b0a 100644 --- a/config/examples/nxp-t2080.config +++ b/config/examples/nxp-t2080.config @@ -63,18 +63,22 @@ WOLFBOOT_ORIGIN?=0xEFFE0000 # wolfBoot partition size (custom) BOOTLOADER_PARTITION_SIZE=0x20000 +# The region [0xEFF00000, 0xEFFE0000) below wolfBoot is reserved for the FMan +# microcode (FMAN_FW_ADDR=0xEFF00000, the U-Boot-standard slot). The partitions +# below sit under it so a BOOT-partition erase/update never touches the ucode. + # Application Partition Size WOLFBOOT_PARTITION_SIZE?=0x100000 -# Location in Flash for Application Partition -WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xEFEE0000 +# Location in Flash for Application Partition (top = 0xEFF00000, below the ucode) +WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xEFE00000 # Load Partition to RAM Address WOLFBOOT_LOAD_ADDRESS?=0x19000 # Location in Flash for Update Partition -WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0xEFDE0000 +WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0xEFD00000 # Location of temporary sector used during updates -WOLFBOOT_PARTITION_SWAP_ADDRESS?=0xEFDD0000 +WOLFBOOT_PARTITION_SWAP_ADDRESS?=0xEFCF0000 # DTS (Device Tree) WOLFBOOT_DTS_BOOT_ADDRESS?=0xE8040000 @@ -124,3 +128,40 @@ WOLFBOOT_LOAD_DTS_ADDRESS?=0x200000 # wolfCrypt Test and Benchmark (requires larger partition size) #WOLFCRYPT_TEST?=1 #WOLFCRYPT_BENCHMARK?=1 + +# ----------------------------------------------------------------------------- +# wolfIP network test in the test-app (optional) +# ----------------------------------------------------------------------------- +# Compiles wolfIP + the NXP QorIQ FMan ethernet port (mEMAC/MDIO/SGMII, +# FM1@DTSEC1) into the test-app and runs a board-side network test. Build the +# app FLAT and 32-bit (ELF=0, OS_64BIT=0) at a low load address (the elf32 load +# path and 64-bit RTOS handoff are unused). wolfIP objects are built -fno-plt +# -D_FORTIFY_SOURCE=0 (no PLT/GOT runtime fixup). Point WOLFBOOT_LIB_WOLFIP at +# a wolfIP checkout (or add it as lib/wolfip). +#ENABLE_WOLFIP=1 +#WOLFBOOT_LIB_WOLFIP=../lib/wolfip +# Build FLAT + 32-bit at a low load address (as above; siblings t1040/t1024 too): +#ELF=0 +#OS_64BIT=0 +#WOLFBOOT_LOAD_ADDRESS=0x100000 +# Test mode (neither flag = acquire a DHCP lease and stop): +# WOLFBOOT_TEST_TFTP=1 RRQ a file from a host tftpd, report size+checksum +# (set CFLAGS_EXTRA TFTP_EXPECT_SIZE/TFTP_EXPECT_SUM to verify) +# WOLFIP_SPEED_TEST=1 TCP throughput server on port 9 (drive with nc/dd/pv) +#WOLFBOOT_TEST_TFTP=1 +#WOLFIP_SPEED_TEST=1 +# +# Per-board wolfIP ethernet wiring (defaults above are CW VPX3-152 / RDB = +# FM1@DTSEC1, SGMII, PHY probed at addr 0x2). Override per the board device +# tree if the wired port differs: +# +# NAII 68PPC2 (hardware-verified): PRIME port is FM1@DTSEC3 = RGMII, Marvell +# PHY at MDIO addr 0 (68ppc2.dts ethernet@e4000: "rgmii-id", ethernet-phy@0 +# reg <0>). The MDIO scan would otherwise grab DTSEC4's PHY at addr 1, so set +# the address explicitly: +#CFLAGS_EXTRA+=-DNXP_FMAN_MEMAC_IDX=3 +#CFLAGS_EXTRA+=-DNXP_FMAN_IF_SGMII=0 +#CFLAGS_EXTRA+=-DNXP_FMAN_PHY_ADDR=0 +# +# NAII NOR is dual-bank with only the top 128KB boot sector common to both +# banks; flash the ucode/app with the boot-bank select in its runtime state. diff --git a/docs/Targets.md b/docs/Targets.md index e41b99f4..20d42a4b 100644 --- a/docs/Targets.md +++ b/docs/Targets.md @@ -5998,6 +5998,10 @@ variants are supported: Example configuration: [/config/examples/nxp-t2080.config](/config/examples/nxp-t2080.config). See [Board Selection](#board-selection) below for per-board setup. +> **FMan microcode (DPAA/wolfIP):** with DPAA/FMan enabled, wolfBoot uploads the FMan microcode from NOR at `FMAN_FW_ADDR` (`hal/nxp_t2080.c`), board-gated: the T2080 RDB and NAII 68PPC2 (128 MB NOR at `0xE8000000`) use `0xEFF00000` -- the U-Boot-standard slot (`CONFIG_SYS_FMAN_FW_ADDR` in `T208xRDB.h`) -- and CW VPX3-152 (256 MB NOR) uses `0xFFE60000`. The wolfBoot partitions sit below this reserved firmware region so a BOOT-partition erase/update never overwrites the ucode. The address is bounds-checked against the NOR window, so a wrong value fails gracefully instead of machine-checking. Flash the matching `fsl_fman_ucode_*` blob at that address. +> +> wolfIP-on-FMan is hardware-verified on the CW VPX3-152 (FM1@DTSEC1, SGMII), the NAII 68PPC2 (FM1@DTSEC3, RGMII, PHY @ addr 0 -- see the example config's wolfIP block), and the T1040D4RDB (e5500; FM1@DTSEC4, RGMII, RTL8211 @ addr 4). NAII NOR is dual-bank with only the top 128 KB boot sector common to both banks, so flash the ucode/app with the boot-bank select in its runtime state. + ### Design NXP T2080 PPC The QorIQ requires a Reset Configuration Word (RCW) to define the boot parameters, which resides at the start of the flash (`0xE8000000` for 128 MB boards, `0xF0000000` for the 256 MB CW VPX3-152). @@ -6276,8 +6280,8 @@ Flash Layout (T2080 RDB / NAII 68PPC2, 128 MB flash): | Description | File | Address | | ----------- | ---- | ------- | | Reset Configuration Word (RCW) | _(board-specific)_ | `0xE8000000` | -| Frame Manager Microcode | `fsl_fman_ucode_t2080_r1.0.bin` | `0xE8020000` | -| Signed Application | `test-app/image_v1_signed.bin` | `0xE8080000` | +| Signed Application | `test-app/image_v1_signed.bin` | `0xEFE00000` | +| Frame Manager Microcode | `fsl_fman_ucode_t2080_r1.0.bin` | `0xEFF00000` | | wolfBoot | `wolfboot.bin` | `0xEFFE0000` | | Boot Entry Point (offset jump to init code) | | `0xEFFFFFFC` | @@ -6286,8 +6290,8 @@ Flash Layout (CW VPX3-152, 256 MB flash): | Description | File | Address | | ----------- | ---- | ------- | | Reset Configuration Word (RCW) | _(board-specific)_ | `0xF0000000` | -| Frame Manager Microcode | `fsl_fman_ucode_t2080_r1.0.bin` | `0xF0020000` | -| Signed Application | `test-app/image_v1_signed.bin` | `0xF0080000` | +| Frame Manager Microcode | `fsl_fman_ucode_t2080_r1.0.bin` | `0xFFE60000` | +| Signed Application | `test-app/image_v1_signed.bin` | `0xFF000000` | | wolfBoot | `wolfboot.bin` | `0xFFFE0000` | | Boot Entry Point (offset jump to init code) | | `0xFFFFFFFC` | diff --git a/hal/nxp_t2080.c b/hal/nxp_t2080.c index 7139a79f..19040fa2 100644 --- a/hal/nxp_t2080.c +++ b/hal/nxp_t2080.c @@ -579,11 +579,17 @@ static void hal_cpld_init(void) } #ifdef ENABLE_FMAN -/* FMAN microcode upload for T2080. - * Firmware is in NOR flash at FMAN_FW_ADDR (typically 0xFFE60000). - * Uses same QE firmware format as T1040. */ +/* FMan microcode NOR address (board-gated, same QE firmware format as T1040). + * T2080 RDB / NAII 68PPC2 (128MB NOR @ 0xE8000000): 0xEFF00000, the U-Boot- + * standard slot (CONFIG_SYS_FMAN_FW_ADDR in T208xRDB.h); the wolfBoot partitions + * sit below it. CW VPX3-152 (256MB NOR @ 0xF0000000): 0xFFE60000. A wrong address + * machine-checks when read in hal_fman_init(), so it is bounds-checked there. */ #ifndef FMAN_FW_ADDR +#ifdef BOARD_CW_VPX3152 #define FMAN_FW_ADDR 0xFFE60000UL +#else +#define FMAN_FW_ADDR 0xEFF00000UL +#endif #endif #define FMAN_BASE (CCSRBAR + 0x400000UL) #define FMAN_IRAM (FMAN_BASE + 0xC4000UL) @@ -643,9 +649,22 @@ static int hal_fman_init(void) const struct qe_header *hdr = &fw->header; unsigned int i; + /* Guard: FMAN_FW_ADDR must lie in the NOR window, else the magic read + * below machine-checks. Compare via offset-from-base (not base+size) so the + * bound does not overflow uintptr_t when a 256MB NOR sits at the top of the + * 32-bit space (CW VPX3-152: 0xF0000000 + 256MB wraps to 0); the first + * clause ensures addr >= base, so the subtraction is safe. */ + if ((uintptr_t)FMAN_FW_ADDR < (uintptr_t)FLASH_BASE_ADDR || + ((uintptr_t)FMAN_FW_ADDR - (uintptr_t)FLASH_BASE_ADDR) >= + (uintptr_t)FLASH_BANK_SIZE) { + wolfBoot_printf("FMAN: fw addr 0x%x outside NOR, skipping\n", + (unsigned)FMAN_FW_ADDR); + return -1; + } + /* Check firmware magic */ if (hdr->magic[0] != 'Q' || hdr->magic[1] != 'E' || hdr->magic[2] != 'F') { - wolfBoot_printf("FMAN: no firmware at 0x%x\n", FMAN_FW_ADDR); + wolfBoot_printf("FMAN: no firmware at 0x%x\n", (unsigned)FMAN_FW_ADDR); return -1; } diff --git a/test-app/app_nxp_t2080.c b/test-app/app_nxp_t2080.c index 7167cc70..fd2e1cd1 100644 --- a/test-app/app_nxp_t2080.c +++ b/test-app/app_nxp_t2080.c @@ -51,6 +51,10 @@ void __attribute__((naked, section(".text._app_entry"))) _app_entry(void) #include "../hal/nxp_ppc.h" +#ifdef ENABLE_WOLFIP +#include "wolfip_tftp_test.h" +#endif + /* wolfCrypt test/benchmark support */ #ifdef WOLFCRYPT_TEST #include @@ -139,9 +143,8 @@ static int print_info(void) void main(void) { - /* Zero BSS - required for bare-metal since there's no crt0 startup. - * Without this, static variables (gTestMemory, HEAP_HINT, etc.) - * contain DDR garbage, causing crashes in wc_LoadStaticMemory. */ + /* Zero BSS (no crt0 on bare metal): the wolfCrypt static-memory pools + * (gTestMemory/HEAP_HINT) must start zeroed or wc_LoadStaticMemory crashes. */ extern char _start_bss[], _end_bss[]; { char *p = _start_bss; @@ -177,6 +180,10 @@ void main(void) wolfCrypt_Cleanup(); #endif +#ifdef ENABLE_WOLFIP + wolfip_tftp_test_report(); +#endif + wolfBoot_printf("Test App: idle loop\r\n"); while(1) { /* Idle */ diff --git a/tools/scripts/nxp_t2080/t2080_flash.cmm b/tools/scripts/nxp_t2080/t2080_flash.cmm index 48146423..5a2c167d 100644 --- a/tools/scripts/nxp_t2080/t2080_flash.cmm +++ b/tools/scripts/nxp_t2080/t2080_flash.cmm @@ -199,12 +199,12 @@ IF &flashwolfboot ; -------------------------------------------------------------------------- PRINT "2. Programming FMAN microcode..." PRINT " Source: &basedir/t2080_fman.bin" - PRINT " Address: 0xE8020000 (128 KB)" - FLASH.UNLOCK 0xE8020000--0xE803FFFF - FLASH.ReProgram 0xE8020000--0xE803FFFF /Erase - Data.LOAD.binary &basedir/t2080_fman.bin 0xE8020000 + PRINT " Address: 0xEFF00000 (FMAN_FW_ADDR, one 64 KB sector, ~32 KB actual)" + FLASH.UNLOCK 0xEFF00000--0xEFF0FFFF + FLASH.ReProgram 0xEFF00000--0xEFF0FFFF /Erase + Data.LOAD.binary &basedir/t2080_fman.bin 0xEFF00000 FLASH.ReProgram.off - Data.LOAD.binary &basedir/t2080_fman.bin 0xE8020000 /Verify + Data.LOAD.binary &basedir/t2080_fman.bin 0xEFF00000 /Verify PRINT " FMAN microcode programmed and verified" PRINT "" @@ -227,12 +227,19 @@ IF &flashwolfboot ; -------------------------------------------------------------------------- PRINT "4. Programming test application..." PRINT " Source: &basedir/test-app/image_v1_signed.bin" - PRINT " Address: 0xEFEE0000 (WOLFBOOT_PARTITION_BOOT_ADDRESS, 1 MB)" - FLASH.UNLOCK 0xEFEE0000--0xEFFDFFFF - FLASH.ReProgram 0xEFEE0000--0xEFFDFFFF /Erase - Data.LOAD.binary &basedir/test-app/image_v1_signed.bin 0xEFEE0000 + ; Only erase/program sectors needed for the actual image size, not the + ; full 1 MB partition -- and never climb into the ucode sector above. + &appsize=OS.FILE.SIZE(&basedir/test-app/image_v1_signed.bin) + ; Round up to next 64 KB sector boundary (WOLFBOOT_SECTOR_SIZE=0x10000) + &append=0xEFE00000+((&appsize+0xFFFF)&~0xFFFF)-1 + &appsizekb=FORMAT.Decimal(0,&appsize>>10.) + PRINT " Address: 0xEFE00000 (WOLFBOOT_PARTITION_BOOT_ADDRESS, 1 MB)" + PRINT " Image size &appsizekb KB, erasing to &append" + FLASH.UNLOCK 0xEFE00000--&append + FLASH.ReProgram 0xEFE00000--&append /Erase + Data.LOAD.binary &basedir/test-app/image_v1_signed.bin 0xEFE00000 FLASH.ReProgram.off - Data.LOAD.binary &basedir/test-app/image_v1_signed.bin 0xEFEE0000 /Verify + Data.LOAD.binary &basedir/test-app/image_v1_signed.bin 0xEFE00000 /Verify PRINT " Test application programmed and verified" PRINT "" @@ -243,9 +250,9 @@ IF &flashwolfboot PRINT "" PRINT "Flash Layout:" PRINT " 0xE8000000: RCW (64 KB)" - PRINT " 0xE8020000: FMAN Microcode (128 KB)" - PRINT " 0xEFEE0000: Test Application (boot partition, 1 MB)" - PRINT " 0xEFFDFFFF: End of boot partition" + PRINT " 0xEFE00000: Test Application (boot partition, 1 MB)" + PRINT " 0xEFEFFFFF: End of boot partition" + PRINT " 0xEFF00000: FMAN Microcode (64 KB sector, ~32 KB actual)" PRINT " 0xEFFE0000: wolfBoot (128 KB)" PRINT "" @@ -254,11 +261,14 @@ IF &flashwolfboot PRINT "RCW at 0xE8000000 (should be AA 55 AA 55):" Data.dump 0xE8000000++0x3F /Long PRINT "" + PRINT "FMAN at 0xEFF00000 (should show QEF header):" + Data.dump 0xEFF00000++0x3F /Long + PRINT "" PRINT "wolfBoot at 0xEFFE0000:" Data.dump 0xEFFE0000++0x3F /Long PRINT "" - PRINT "Test app at 0xEFEE0000:" - Data.dump 0xEFEE0000++0x3F /Long + PRINT "Test app at 0xEFE00000:" + Data.dump 0xEFE00000++0x3F /Long PRINT "" GOTO flash_complete