Skip to content

Commit 09d1a14

Browse files
committed
Fixes for T2080 CW VPX3 TLB. Removes test workarounds and implements peer review feedback.
1 parent f976a58 commit 09d1a14

5 files changed

Lines changed: 119 additions & 91 deletions

File tree

.github/workflows/test-configs.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,11 @@ jobs:
207207

208208
nxp_t2080_test:
209209
uses: ./.github/workflows/test-build-powerpc.yml
210-
# T2080 RDB DDR register values are not yet populated (placeholders in
211-
# nxp_t2080.h), so CI must select a board with complete DDR config.
210+
with:
211+
arch: ppc
212+
config-file: ./config/examples/nxp-t2080.config
213+
214+
# Additional T2080 board-specific compile tests for alternate board macros.
212215
nxp_t2080_test_naii_68ppc2:
213216
uses: ./.github/workflows/test-build-powerpc.yml
214217
with:

config/examples/nxp-t2080.config

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# NXP T2080 wolfBoot Configuration
22
# Default board: T2080 RDB (66.66 MHz oscillator, DDR3L SODIMM)
33
#
4-
# Board selection: uncomment exactly one line to override the default.
5-
# Default (no define): T2080 RDB (66.66 MHz oscillator, DDR3L SODIMM)
6-
# BOARD_CW_VPX3152: CW VPX3-152 (66.667 MHz oscillator, DDR3L)
7-
# BOARD_NAII_68PPC2: NAII 68PPC2 (100 MHz oscillator, 8GB DDR3)
4+
# Board selection:
5+
# Default (no define): T2080 RDB (66.66 MHz oscillator, DDR3L SODIMM)
6+
# BOARD_NAII_68PPC2: NAII 68PPC2 (100 MHz oscillator, 8 GB DDR3)
7+
# BOARD_CW_VPX3152: CW VPX3-152 (66.667 MHz oscillator, 4 GB DDR3L)
88
#
9-
#CFLAGS_EXTRA+=-DBOARD_CW_VPX3152
9+
# For NAII 68PPC2, uncomment the line below (addresses are the same as RDB):
1010
#CFLAGS_EXTRA+=-DBOARD_NAII_68PPC2
11+
#
12+
# For CW VPX3-152 (256 MB NOR flash at 0xF0000000), uncomment the BOARD
13+
# define AND the address override block at the bottom of this file.
14+
#CFLAGS_EXTRA+=-DBOARD_CW_VPX3152
1115

1216
ARCH=PPC
1317
TARGET=nxp_t2080
@@ -35,50 +39,57 @@ DUALBANK_SWAP?=0
3539
WOLFTPM?=0
3640
OPTIMIZATION_LEVEL?=1
3741

38-
# NOR Base Address
39-
# T2080 RDB: 128MB flash at 0xE8000000, wolfBoot at top (0xEFFE0000)
40-
# CW VPX3-152: 256MB flash at 0xF0000000, wolfBoot at top (0xFFFE0000)
42+
# -----------------------------------------------------------------------------
43+
# Default addresses: T2080 RDB / NAII 68PPC2 (128 MB NOR flash @ 0xE8000000)
44+
# -----------------------------------------------------------------------------
45+
46+
# NOR Base Address: wolfBoot at top of flash
4147
ARCH_FLASH_OFFSET?=0xEFFE0000
42-
#ARCH_FLASH_OFFSET?=0xFFFE0000 # CW VPX3-152
4348

4449
# CPC SRAM address (must match L2SRAM_ADDR in nxp_ppc.h)
45-
# CW VPX3-152: relocated to 0xEE900000 to avoid 256MB flash TLB overlap
4650
L2SRAM_ADDR?=0xF8F00000
47-
#L2SRAM_ADDR?=0xEE900000 # CW VPX3-152
4851

4952
# Flash Sector Size
5053
WOLFBOOT_SECTOR_SIZE?=0x10000
5154

5255
# wolfBoot start address
5356
WOLFBOOT_ORIGIN?=0xEFFE0000
54-
#WOLFBOOT_ORIGIN?=0xFFFE0000 # CW VPX3-152
5557
# wolfBoot partition size (custom)
5658
BOOTLOADER_PARTITION_SIZE=0x20000
5759

5860
# Application Partition Size
5961
WOLFBOOT_PARTITION_SIZE?=0x100000
6062
# Location in Flash for Application Partition
6163
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xEFEE0000
62-
#WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xFFEE0000 # CW VPX3-152
6364
# Load Partition to RAM Address
6465
WOLFBOOT_LOAD_ADDRESS?=0x19000
6566

6667
# Location in Flash for Update Partition
6768
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0xEFDE0000
68-
#WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0xFFDE0000 # CW VPX3-152
6969

7070
# Location of temporary sector used during updates
7171
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0xEFDD0000
72-
#WOLFBOOT_PARTITION_SWAP_ADDRESS?=0xFFDD0000 # CW VPX3-152
7372

7473
# DTS (Device Tree)
7574
WOLFBOOT_DTS_BOOT_ADDRESS?=0xE8040000
76-
#WOLFBOOT_DTS_BOOT_ADDRESS?=0xF0040000 # CW VPX3-152
7775
WOLFBOOT_DTS_UPDATE_ADDRESS?=0xE8050000
78-
#WOLFBOOT_DTS_UPDATE_ADDRESS?=0xF0050000 # CW VPX3-152
7976
# DTS Load to RAM Address
8077
WOLFBOOT_LOAD_DTS_ADDRESS?=0x200000
8178

79+
# -----------------------------------------------------------------------------
80+
# CW VPX3-152 address overrides (256 MB NOR flash @ 0xF0000000)
81+
# Uncomment ALL lines below when building for VPX3-152.
82+
# Also uncomment CFLAGS_EXTRA+=-DBOARD_CW_VPX3152 at the top of this file.
83+
# -----------------------------------------------------------------------------
84+
#ARCH_FLASH_OFFSET=0xFFFE0000
85+
#L2SRAM_ADDR=0xEE900000
86+
#WOLFBOOT_ORIGIN=0xFFFE0000
87+
#WOLFBOOT_PARTITION_BOOT_ADDRESS=0xFFEE0000
88+
#WOLFBOOT_PARTITION_UPDATE_ADDRESS=0xFFDE0000
89+
#WOLFBOOT_PARTITION_SWAP_ADDRESS=0xFFDD0000
90+
#WOLFBOOT_DTS_BOOT_ADDRESS=0xF0040000
91+
#WOLFBOOT_DTS_UPDATE_ADDRESS=0xF0050000
92+
8293
# Flash erase/write/read test at update partition address
8394
#TEST_FLASH?=1
8495

docs/Targets.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,10 +4018,10 @@ variants are supported:
40184018
| Curtiss-Wright VPX3-152 | `BOARD_CW_VPX3152` | 66.667 MHz | 4 GB DDR3L | 256 MB @ `0xF0000000` |
40194019
| NAII 68PPC2 | `BOARD_NAII_68PPC2` | 100 MHz | 8 GB DDR3 | 128 MB @ `0xE8000000` |
40204020

4021-
> **Note:** The T2080 RDB DDR register values are placeholder stubs (all zeros
4022-
> with TODO comments in `hal/nxp_t2080.h`). DDR initialization will not succeed
4023-
> until you populate them from a U-Boot register dump. The NAII 68PPC2 and
4024-
> CW VPX3-152 DDR configs are populated and tested.
4021+
> **Note:** The T2080 RDB DDR register values in `hal/nxp_t2080.h` are
4022+
> populated from a U-Boot register dump but have not been validated on
4023+
> hardware. The NAII 68PPC2 and CW VPX3-152 DDR configs are populated
4024+
> and tested.
40254025
40264026
Example configuration: [/config/examples/nxp-t2080.config](/config/examples/nxp-t2080.config).
40274027
See [Board Selection](#board-selection) below for per-board setup.
@@ -4359,11 +4359,27 @@ md.l 0xef008b28 2
43594359
md.l 0xef008e40 3; md.l 0xef008e58 1
43604360
```
43614361

4362-
**Automated test script:** `tools/scripts/nxp_t2080/cw_vpx3152_pabs_test.sh`
4362+
**Flashing wolfBoot via PABS U-Boot:**
43634363

4364-
Uses Pi4 GPIO control (GPIO 16 = PABS/JB1, GPIO 19 = Reset) and UART monitoring
4365-
to automate the full flash-and-verify cycle. See script for usage and options
4366-
including `--dump-ddr` mode.
4364+
The PABS U-Boot maps main NOR flash starting at `0x80000000`. To convert wolfBoot
4365+
flash addresses to PABS addresses, replace the `0xF` prefix with `0x8` (e.g.
4366+
`0xFFFE0000` becomes `0x8FFE0000`). After configuring the network, use:
4367+
4368+
```
4369+
# Flash wolfBoot (128 KB at top of flash)
4370+
tftp 0x1000000 wolfboot.bin
4371+
erase 0x8FFE0000 +0x20000
4372+
cp.b 0x1000000 0x8FFE0000 $filesize
4373+
cmp.b 0x1000000 0x8FFE0000 $filesize
4374+
4375+
# Flash signed application (1 MB boot partition)
4376+
tftp 0x1000000 image_v1_signed.bin
4377+
erase 0x8FEE0000 +0x100000
4378+
cp.b 0x1000000 0x8FEE0000 $filesize
4379+
cmp.b 0x1000000 0x8FEE0000 $filesize
4380+
```
4381+
4382+
Remove the JB1 jumper and power cycle to boot from main flash with wolfBoot.
43674383

43684384
### Debugging NXP T2080 PPC
43694385

hal/nxp_t2080.c

Lines changed: 29 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,8 @@
3131
/* #define DEBUG_FLASH */
3232

3333
#ifndef BUILD_LOADER_STAGE1
34-
#ifndef BOARD_CW_VPX3152
35-
/* CW VPX3-152: hal_mp_init() calls disable_tlb1(0) which invalidates the
36-
* 16 MB boot TLB Entry 0 (which contains wolfBoot code). Without a separate
37-
* flash TLB entry covering wolfBoot's code, the next instruction fetch
38-
* faults. NAII works because its 256 KB boot TLB doesn't cover wolfBoot
39-
* code (which is in flash TLB Entry 2 at 0xE8000000-0xEFFFFFFF).
40-
* For VPX3-152, secondary cores remain disabled. */
4134
#define ENABLE_MP /* multi-core support */
4235
#endif
43-
#endif
4436

4537
/* generic shared NXP QorIQ driver code */
4638
#include "nxp_ppc.c"
@@ -80,6 +72,12 @@ static void hal_mp_init(void);
8072
#define FLASH_UNLOCK_ADDR2 0x555
8173
#endif
8274

75+
/* FLASH_CMD_SECTOR: sector used for flash command sequences that don't target
76+
* a specific sector (reset, unlock, PPB entry/exit). AMD flash command decode
77+
* only looks at the low address bits, so sector 0 works for all boards with
78+
* a properly mapped full-flash TLB entry. */
79+
#define FLASH_CMD_SECTOR 0
80+
8381
/* Flash IO Helpers */
8482
#if FLASH_CFI_WIDTH == 16
8583
#define FLASH_IO8_WRITE(sec, n, val) *((volatile uint16_t*)(FLASH_BASE_ADDR + (FLASH_SECTOR_SIZE * (sec)) + ((n) * 2))) = (((val) << 8) | (val))
@@ -375,15 +373,9 @@ static void hal_reconfigure_cpc_as_cache(void)
375373

376374
/* Make flash TLB cacheable for XIP code performance.
377375
* Changes TLB Entry 2 (flash) from MAS2_I|MAS2_G to MAS2_M.
378-
* This enables L1 I-cache + L2 + CPC to cache flash instructions.
379-
*
380-
* For BOARD_CW_VPX3152: TLB1 Entry 2 is NOT used (256 MB flash TLB would
381-
* overlap with the 16 MB boot ROM TLB at the top of flash, causing e6500
382-
* multi-hit). The boot TLB covers wolfBoot + partitions cache-inhibited;
383-
* skip the caching update — flash runs uncached (slower but correct). */
376+
* This enables L1 I-cache + L2 + CPC to cache flash instructions. */
384377
static void hal_flash_enable_caching(void)
385378
{
386-
#ifndef BOARD_CW_VPX3152
387379
/* Rewrite flash TLB entry with cacheable attributes.
388380
* MAS2_M = memory coherent, enables caching */
389381
set_tlb(1, 2,
@@ -393,7 +385,6 @@ static void hal_flash_enable_caching(void)
393385

394386
/* Invalidate L1 I-cache so new TLB attributes take effect */
395387
invalidate_icache();
396-
#endif
397388

398389
#ifdef DEBUG_UART
399390
wolfBoot_printf("Flash: caching enabled (L1+L2+CPC)\n");
@@ -481,21 +472,17 @@ void hal_init(void)
481472
* returns a bus error (DSI). */
482473
static void RAMFUNCTION hal_flash_cache_disable(void)
483474
{
484-
#ifndef BOARD_CW_VPX3152
485475
set_tlb(1, 2, FLASH_BASE_ADDR, FLASH_BASE_ADDR, FLASH_BASE_PHYS_HIGH,
486476
MAS3_SX | MAS3_SW | MAS3_SR, MAS2_I | MAS2_G, 0, FLASH_TLB_PAGESZ, 1);
487-
#endif
488477
}
489478

490479
/* Restore flash TLB to cacheable mode after flash operation.
491480
* Flash must be back in read-array mode before calling (AMD_CMD_RESET sent).
492481
* Invalidate caches afterward so stale pre-erase data is not served. */
493482
static void RAMFUNCTION hal_flash_cache_enable(void)
494483
{
495-
#ifndef BOARD_CW_VPX3152
496484
set_tlb(1, 2, FLASH_BASE_ADDR, FLASH_BASE_ADDR, FLASH_BASE_PHYS_HIGH,
497485
MAS3_SX | MAS3_SW | MAS3_SR, MAS2_M, 0, FLASH_TLB_PAGESZ, 1);
498-
#endif
499486
invalidate_dcache();
500487
invalidate_icache();
501488
}
@@ -539,9 +526,9 @@ static int RAMFUNCTION hal_flash_ppb_unlock(uint32_t sector)
539526
uint32_t timeout;
540527

541528
/* Enter PPB ASO (Address Space Overlay) */
542-
FLASH_IO8_WRITE(0, FLASH_UNLOCK_ADDR1, AMD_CMD_UNLOCK_START);
543-
FLASH_IO8_WRITE(0, FLASH_UNLOCK_ADDR2, AMD_CMD_UNLOCK_ACK);
544-
FLASH_IO8_WRITE(0, FLASH_UNLOCK_ADDR1, AMD_CMD_SET_PPB_ENTRY);
529+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, FLASH_UNLOCK_ADDR1, AMD_CMD_UNLOCK_START);
530+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, FLASH_UNLOCK_ADDR2, AMD_CMD_UNLOCK_ACK);
531+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, FLASH_UNLOCK_ADDR1, AMD_CMD_SET_PPB_ENTRY);
545532

546533
/* Read PPB status for target sector: DQ0=0 means protected.
547534
* On 16-bit bus, must read both chip lanes to check both devices. */
@@ -553,16 +540,16 @@ static int RAMFUNCTION hal_flash_ppb_unlock(uint32_t sector)
553540
if ((ppb_status & 0x01) == 0x01) {
554541
#endif
555542
/* Both chips report unprotected — exit PPB mode and return */
556-
FLASH_IO8_WRITE(0, 0, AMD_CMD_SET_PPB_EXIT_BC1);
557-
FLASH_IO8_WRITE(0, 0, AMD_CMD_SET_PPB_EXIT_BC2);
543+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, 0, AMD_CMD_SET_PPB_EXIT_BC1);
544+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, 0, AMD_CMD_SET_PPB_EXIT_BC2);
558545
return 0;
559546
}
560547

561548
/* Exit PPB ASO before calling printf (flash must be in read-array
562549
* mode for I-cache misses to fetch valid instructions) */
563-
FLASH_IO8_WRITE(0, 0, AMD_CMD_SET_PPB_EXIT_BC1);
564-
FLASH_IO8_WRITE(0, 0, AMD_CMD_SET_PPB_EXIT_BC2);
565-
FLASH_IO8_WRITE(0, 0, AMD_CMD_RESET);
550+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, 0, AMD_CMD_SET_PPB_EXIT_BC1);
551+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, 0, AMD_CMD_SET_PPB_EXIT_BC2);
552+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, 0, AMD_CMD_RESET);
566553
udelay(50);
567554

568555
#ifdef DEBUG_FLASH
@@ -571,36 +558,36 @@ static int RAMFUNCTION hal_flash_ppb_unlock(uint32_t sector)
571558
#endif
572559

573560
/* Re-enter PPB ASO for erase */
574-
FLASH_IO8_WRITE(0, FLASH_UNLOCK_ADDR1, AMD_CMD_UNLOCK_START);
575-
FLASH_IO8_WRITE(0, FLASH_UNLOCK_ADDR2, AMD_CMD_UNLOCK_ACK);
576-
FLASH_IO8_WRITE(0, FLASH_UNLOCK_ADDR1, AMD_CMD_SET_PPB_ENTRY);
561+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, FLASH_UNLOCK_ADDR1, AMD_CMD_UNLOCK_START);
562+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, FLASH_UNLOCK_ADDR2, AMD_CMD_UNLOCK_ACK);
563+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, FLASH_UNLOCK_ADDR1, AMD_CMD_SET_PPB_ENTRY);
577564

578565
/* PPB Erase All (clears all sectors' PPBs) */
579-
FLASH_IO8_WRITE(0, 0, AMD_CMD_PPB_UNLOCK_BC1); /* 0x80 */
580-
FLASH_IO8_WRITE(0, 0, AMD_CMD_PPB_UNLOCK_BC2); /* 0x30 */
566+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, 0, AMD_CMD_PPB_UNLOCK_BC1); /* 0x80 */
567+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, 0, AMD_CMD_PPB_UNLOCK_BC2); /* 0x30 */
581568

582569
/* Wait for PPB erase completion — poll for toggle stop.
583570
* On 16-bit bus, read both chip lanes to ensure both complete. */
584571
timeout = 0;
585572
do {
586573
#if FLASH_CFI_WIDTH == 16
587-
read1 = FLASH_IO16_READ(0, 0);
588-
read2 = FLASH_IO16_READ(0, 0);
574+
read1 = FLASH_IO16_READ(FLASH_CMD_SECTOR, 0);
575+
read2 = FLASH_IO16_READ(FLASH_CMD_SECTOR, 0);
589576
#else
590-
read1 = FLASH_IO8_READ(0, 0);
591-
read2 = FLASH_IO8_READ(0, 0);
577+
read1 = FLASH_IO8_READ(FLASH_CMD_SECTOR, 0);
578+
read2 = FLASH_IO8_READ(FLASH_CMD_SECTOR, 0);
592579
#endif
593580
if (read1 == read2)
594581
break;
595582
udelay(10);
596583
} while (timeout++ < 100000); /* 1 second */
597584

598585
/* Exit PPB ASO */
599-
FLASH_IO8_WRITE(0, 0, AMD_CMD_SET_PPB_EXIT_BC1);
600-
FLASH_IO8_WRITE(0, 0, AMD_CMD_SET_PPB_EXIT_BC2);
586+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, 0, AMD_CMD_SET_PPB_EXIT_BC1);
587+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, 0, AMD_CMD_SET_PPB_EXIT_BC2);
601588

602589
/* Reset to read-array mode */
603-
FLASH_IO8_WRITE(0, 0, AMD_CMD_RESET);
590+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, 0, AMD_CMD_RESET);
604591
udelay(50);
605592

606593
if (timeout >= 100000) {
@@ -717,7 +704,7 @@ int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
717704

718705
/* Reset flash to read-array mode in case previous operation left it
719706
* in command mode (e.g. after a timeout or incomplete operation) */
720-
FLASH_IO8_WRITE(0, 0, AMD_CMD_RESET);
707+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, 0, AMD_CMD_RESET);
721708
udelay(50);
722709

723710
/* Program one word at a time using AMD single-word program (0xA0).
@@ -788,7 +775,7 @@ int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
788775

789776
/* Reset flash to read-array mode in case previous operation left it
790777
* in command mode (e.g. after a timeout or incomplete operation) */
791-
FLASH_IO8_WRITE(0, 0, AMD_CMD_RESET);
778+
FLASH_IO8_WRITE(FLASH_CMD_SECTOR, 0, AMD_CMD_RESET);
792779
udelay(50);
793780

794781
while (len > 0) {
@@ -1033,14 +1020,7 @@ void hal_prepare_boot(void)
10331020
#ifdef MMU
10341021
void* hal_get_dts_address(void)
10351022
{
1036-
#ifdef BOARD_CW_VPX3152
1037-
/* DTS is at 0xF0040000 which is below the 16 MB boot TLB
1038-
* (covers 0xFF000000-0xFFFFFFFF). Return NULL to skip DTS loading
1039-
* until a separate flash TLB is added for the DTS region. */
1040-
return NULL;
1041-
#else
10421023
return (void*)WOLFBOOT_DTS_BOOT_ADDRESS;
1043-
#endif
10441024
}
10451025

10461026
int hal_dts_fixup(void* dts_addr)

0 commit comments

Comments
 (0)