Skip to content

Commit 5a19f58

Browse files
committed
Progress testing
1 parent 1029bd3 commit 5a19f58

11 files changed

Lines changed: 780 additions & 57 deletions

File tree

config/examples/nxp-t1040.config

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,34 @@ WOLFTPM?=0
2626
ELF?=1
2727
DEBUG_ELF=0
2828

29-
# NOR Base Address (256MB NOR at 0xE8000000 - 0xF7FFFFFF)
29+
# NOR Base Address (128MB NOR at 0xE8000000 - 0xEFFFFFFF)
3030
ARCH_FLASH_OFFSET?=0xE8000000
3131

3232
# Flash Sector Size (128KB)
3333
WOLFBOOT_SECTOR_SIZE=0x20000
3434

35-
# wolfBoot start address
36-
WOLFBOOT_ORIGIN=0xF7F40000
35+
# wolfBoot start address (same as T1024 - NOR top is 0xEFFFFFFF)
36+
WOLFBOOT_ORIGIN=0xEFF40000
3737
# wolfBoot partition size (custom)
3838
BOOTLOADER_PARTITION_SIZE=0xC0000
3939

4040
# Application Partition Size (15MB)
4141
WOLFBOOT_PARTITION_SIZE?=0xF00000
4242
# Location in Flash for Application Partition
43-
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xF6000000
43+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xEE000000
4444
# Load Partition to RAM Address
4545
WOLFBOOT_LOAD_ADDRESS?=0x70000000
4646

4747
# Location in Flash for Update Partition
48-
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0xF6F00000
48+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0xEEF00000
4949

5050
# Location of temporary sector used during updates
5151
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0xE80F0000
5252

5353
# Stage 1 loader settings (16KB)
5454
WOLFBOOT_STAGE1_SIZE=0x4000
5555
# Location in Flash for stage 1 loader (XIP from boot ROM)
56-
WOLFBOOT_STAGE1_FLASH_ADDR=0xF7FFC000
56+
WOLFBOOT_STAGE1_FLASH_ADDR=0xEFFFC000
5757
# Address in RAM to load wolfBoot (end of DDR at 2GB-1MB for 32-bit addressing)
5858
WOLFBOOT_STAGE1_LOAD_ADDR=0x7FF00000
5959

docs/Targets.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3277,9 +3277,9 @@ Reset Configuration Word (RCW):
32773277
00000020: 00000000 00000000 00000000 00030810
32783278
00000030: 00000000 0342580f 00000000 00000000
32793279

3280-
Flash is NOR on IFC CS0 (0x0_E800_0000) 256MB.
3280+
Flash is NOR on IFC CS0 (0x0_E800_0000) 128MB (Micron JS28F00AM29EWHA, 16-bit, AMD CFI).
32813281

3282-
Default NOR Flash Memory Layout (256MB) (128KB block, 1K page)
3282+
Default NOR Flash Memory Layout (128MB) (128KB block, 1K page)
32833283

32843284
| Description | Address | Size |
32853285
| ----------------- | ---------- | -------------------- |
@@ -3289,13 +3289,13 @@ Default NOR Flash Memory Layout (256MB) (128KB block, 1K page)
32893289
| Free | 0xE8100000 | 0x00700000 ( 7 MB) |
32903290
| FDT (Primary) | 0xE8800000 | 0x00020000 (128 KB) |
32913291
| FDT (Update) | 0xE8820000 | 0x00020000 (128 KB) |
3292-
| Free | 0xE8840000 | 0x0D7C0000 (~200 MB) |
3293-
| Application (OS) | 0xF6000000 | 0x00F00000 ( 15 MB) |
3294-
| Update (OS) | 0xF6F00000 | 0x00F00000 ( 15 MB) |
3295-
| QUICC | 0xF7E00000 | 0x00100000 ( 1 MB) |
3296-
| DPAA (FMAN) | 0xF7F00000 | 0x00020000 (128 KB) |
3297-
| wolfBoot | 0xF7F40000 | 0x000BC000 (752 KB) |
3298-
| wolfBoot Stage 1 | 0xF7FFC000 | 0x00004000 ( 16 KB) |
3292+
| Free | 0xE8840000 | 0x057C0000 ( 87 MB) |
3293+
| Application (OS) | 0xEE000000 | 0x00F00000 ( 15 MB) |
3294+
| Update (OS) | 0xEEF00000 | 0x00F00000 ( 15 MB) |
3295+
| QUICC | 0xEFE00000 | 0x00100000 ( 1 MB) |
3296+
| DPAA (FMAN) | 0xEFF00000 | 0x00020000 (128 KB) |
3297+
| wolfBoot | 0xEFF40000 | 0x000BC000 (752 KB) |
3298+
| wolfBoot Stage 1 | 0xEFFFC000 | 0x00004000 ( 16 KB) |
32993299

33003300
QE: uploading microcode 'Microcode for T1040 r1.0' version 0.0.1
33013301

@@ -3336,11 +3336,11 @@ If getting errors with keystore then you can reset things using `make distclean`
33363336
./tools/bin-assemble/bin-assemble factory_custom.bin \
33373337
0xE8000000 RCW.bin \
33383338
0xE8020000 custom.dtb \
3339-
0xF6000000 custom_v1_signed.bin \
3340-
0xF7E00000 iram_Type_A_T1040_r1.0.bin \
3341-
0xF7F00000 fsl_fman_ucode_t1040.bin \
3342-
0xF7F40000 wolfboot.bin \
3343-
0xF7FFC000 stage1/loader_stage1.bin
3339+
0xEE000000 custom_v1_signed.bin \
3340+
0xEFE00000 iram_Type_A_T1040_r1.0.bin \
3341+
0xEFF00000 fsl_fman_ucode_t1040.bin \
3342+
0xEFF40000 wolfboot.bin \
3343+
0xEFFFC000 stage1/loader_stage1.bin
33443344
```
33453345

33463346
Flash factory_custom.bin to NOR base 0xE800_0000

hal/nxp_ppc.h

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@
9494
#endif
9595

9696
#define FLASH_BASE_ADDR 0xEC000000UL
97-
#define FLASH_BASE_PHYS_HIGH 0xFULL
97+
#ifndef BUILD_LOADER_STAGE1
98+
#define FLASH_BASE_PHYS_HIGH 0xFULL /* 36-bit: 0xF_EC000000 */
99+
#else
100+
#define FLASH_BASE_PHYS_HIGH 0x0ULL /* 32-bit stage1 */
101+
#endif
98102
#define FLASH_LAW_SIZE LAW_SIZE_64MB
99103
#define FLASH_TLB_PAGESZ BOOKE_PAGESZ_64M
100104

@@ -110,14 +114,23 @@
110114
#define CCSRBAR_DEF (0xFE000000) /* T1040RM 4.4.1 default base */
111115
#define CCSRBAR_SIZE BOOKE_PAGESZ_16M
112116

113-
#define INITIAL_SRAM_ADDR 0xFDFC0000
114-
#define INITIAL_SRAM_LAW_SZ LAW_SIZE_256KB
115-
#define INITIAL_SRAM_LAW_TRGT LAW_TRGT_PSRAM
116-
#define INITIAL_SRAM_BOOKE_SZ BOOKE_PAGESZ_256K
117-
118117
#define ENABLE_L1_CACHE
119118
#define ENABLE_INTERRUPTS
120119

120+
/* T1040 has a 256KB CPC (CoreNet Platform Cache), not PSRAM.
121+
* Use L1 locked dcache (16KB) as initial stack, same as T2080.
122+
* CPC SRAM is configured but not used for stack to avoid
123+
* cold power cycle reliability issues via CoreNet. */
124+
#define L1_CACHE_ADDR (0xFDFC0000UL)
125+
126+
#define L2SRAM_ADDR (0xFDFE0000UL) /* CPC as SRAM (256KB) */
127+
#define L2SRAM_SIZE (256UL * 1024UL)
128+
129+
#define INITIAL_SRAM_ADDR L2SRAM_ADDR
130+
#define INITIAL_SRAM_LAW_SZ LAW_SIZE_256KB
131+
#define INITIAL_SRAM_LAW_TRGT LAW_TRGT_DDR_1 /* CPC target per T1040RM */
132+
#define INITIAL_SRAM_BOOKE_SZ BOOKE_PAGESZ_256K
133+
121134
#ifdef BUILD_LOADER_STAGE1
122135
#define ENABLE_L2_CACHE
123136
#else
@@ -131,10 +144,15 @@
131144
#define DDR_SIZE (8192ULL * 1024ULL * 1024ULL) /* 8GB */
132145
#endif
133146

134-
/* 256MB NOR: 0xE8000000 - 0xF7FFFFFF */
147+
/* 128MB NOR: 0xE8000000 - 0xEFFFFFFF */
135148
#define FLASH_BASE_ADDR 0xE8000000UL
136-
#define FLASH_BASE_PHYS_HIGH 0xFULL
137-
#define FLASH_LAW_SIZE LAW_SIZE_256MB
149+
#ifndef BUILD_LOADER_STAGE1
150+
#define FLASH_BASE_PHYS_HIGH 0xFULL /* 36-bit: 0xF_E8000000 */
151+
#else
152+
#define FLASH_BASE_PHYS_HIGH 0x0ULL /* 32-bit stage1 */
153+
#endif
154+
#define FLASH_LAW_SIZE LAW_SIZE_128MB
155+
/* e5500 BookE has no 128M page size (64M->256M), use 256M TLB */
138156
#define FLASH_TLB_PAGESZ BOOKE_PAGESZ_256M
139157

140158
#define USE_LONG_JUMP

hal/nxp_t1040.ld

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ ENTRY( _reset )
44

55
MEMORY
66
{
7-
/* DDR4 - 8GB (offset by destination address and 4KB boot region) */
7+
/* DDR4 - 8GB physical (32-bit addressing limits window to <2GB) */
88
DRAM (rwx) : ORIGIN = @WOLFBOOT_STAGE1_LOAD_ADDR@,
99
LENGTH = 0x7FFFFFFF - 4K - @WOLFBOOT_STAGE1_LOAD_ADDR@
1010

11-
/* L1 SRAM - 16KB */
12-
L1RAM (rwx) : ORIGIN = 0xF8F80000, LENGTH = 0x4000
11+
/* L1 locked dcache - 16KB */
12+
L1RAM (rwx) : ORIGIN = 0xFDFC0000, LENGTH = 0x4000
1313

14-
/* Platform SRAM - 160KB */
15-
PSRAM (rwx) : ORIGIN = 0xFDFC0000, LENGTH = 0x28000
14+
/* CPC SRAM - 256KB */
15+
CPCSRAM (rwx) : ORIGIN = 0xFDFE0000, LENGTH = 0x40000
1616
}
1717

1818
SECTIONS
@@ -84,6 +84,6 @@ SECTIONS
8484
PROVIDE(_start_heap = _end);
8585
PROVIDE(_end_stack = ORIGIN(DRAM) + (LENGTH(DRAM)));
8686

87-
/* Platform SRAM heap/stack */
88-
/* PROVIDE(_start_heap = ORIGIN(PSRAM)); */
89-
/* PROVIDE(_end_stack = ORIGIN(PSRAM) + (LENGTH(PSRAM))); */
87+
/* CPC SRAM heap/stack (unused - wolfBoot runs from DDR) */
88+
/* PROVIDE(_start_heap = ORIGIN(CPCSRAM)); */
89+
/* PROVIDE(_end_stack = ORIGIN(CPCSRAM) + (LENGTH(CPCSRAM))); */

hal/nxp_t1040_stage1.ld

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,30 @@ OUTPUT_ARCH( "powerpc" )
22

33
ENTRY( _reset )
44

5-
/* Boot ROM out of reset mapped to 0xF7FFF000 */
5+
/* Boot ROM out of reset mapped to 0xEFFFF000 (top of 128MB NOR) */
66
BASE_ADDR = @WOLFBOOT_STAGE1_FLASH_ADDR@;
77

88
LOADER_STAGE1_SIZE = @WOLFBOOT_STAGE1_SIZE@;
99

1010
/* Boot initialization code */
11-
BOOTSTRAP_TLB = 0xF7FFF000;
11+
BOOTSTRAP_TLB = 0xEFFFF000;
1212

1313
/* Entry point where RCW directs code to execute from */
14-
BOOTSTRAP_ENTRY = 0xF7FFFFFC;
14+
BOOTSTRAP_ENTRY = 0xEFFFFFFC;
1515

1616
MEMORY
1717
{
1818
/* Boot Location */
1919
FLASH (rx) : ORIGIN = BASE_ADDR, LENGTH = LOADER_STAGE1_SIZE
2020

21-
/* L1 SRAM - 16KB */
22-
L1RAM (rwx) : ORIGIN = 0xF8F80000, LENGTH = 0x4000
21+
/* L1 locked dcache as initial stack - 16KB */
22+
L1RAM (rwx) : ORIGIN = 0xFDFC0000, LENGTH = 0x4000
2323

24-
/* Platform SRAM - 160KB */
25-
PSRAM (rwx) : ORIGIN = 0xFDFC0000, LENGTH = 0x28000
24+
/* CPC SRAM - 256KB (CoreNet Platform Cache configured as SRAM) */
25+
CPCSRAM (rwx) : ORIGIN = 0xFDFE0000, LENGTH = 0x40000
2626

27-
/* DDR - 8GB: Start at 16MB to avoid using 0x0 (NULL) addresses */
27+
/* DDR - 8GB physical, 32-bit addressing limits window to <2GB.
28+
* Start at 16MB to avoid using 0x0 (NULL) addresses */
2829
DRAM (rwx) : ORIGIN = 0x1000000, LENGTH = 0x7FFFFFFF - 0x1000000
2930
}
3031

@@ -105,6 +106,6 @@ SECTIONS
105106

106107
}
107108

108-
/* Platform SRAM heap/stack */
109-
PROVIDE(_start_heap = ORIGIN(PSRAM));
110-
PROVIDE(_end_stack = ORIGIN(PSRAM) + (LENGTH(PSRAM)));
109+
/* CPC SRAM heap, L1 locked dcache stack */
110+
PROVIDE(_start_heap = ORIGIN(CPCSRAM));
111+
PROVIDE(_end_stack = ORIGIN(L1RAM) + (LENGTH(L1RAM)));

hal/nxp_t10xx.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@
6565
#endif
6666

6767
#define USE_ERRATA_DDRA008378
68-
#define USE_ERRATA_DDRA008109
6968
#define USE_ERRATA_DDRA009663
7069
#define USE_ERRATA_DDRA009942
70+
#ifdef TARGET_nxp_t1024
71+
/* A-008109: T1024 rev 1.0 specific - DDR controller init failure */
72+
#define USE_ERRATA_DDRA008109
73+
#endif
7174

7275
/* Forward declarations */
7376
static void hal_flash_unlock_sector(uint32_t sector);
@@ -525,7 +528,7 @@ enum ifc_amask_sizes {
525528

526529
/* NOR Flash */
527530
#ifdef TARGET_nxp_t1040
528-
#define FLASH_BANK_SIZE (256*1024*1024) /* 256MB NOR */
531+
#define FLASH_BANK_SIZE (128*1024*1024) /* 128MB NOR */
529532
#else
530533
#define FLASH_BANK_SIZE (64*1024*1024) /* 64MB NOR */
531534
#endif
@@ -1304,7 +1307,7 @@ static void hal_flash_init(void)
13041307
IFC_CSPR_MSEL_NOR |
13051308
IFC_CSPR_V));
13061309
#ifdef TARGET_nxp_t1040
1307-
set32(IFC_AMASK(0), IFC_AMASK_256MB);
1310+
set32(IFC_AMASK(0), IFC_AMASK_128MB);
13081311
#else
13091312
set32(IFC_AMASK(0), IFC_AMASK_64MB);
13101313
#endif
@@ -1442,10 +1445,13 @@ static void hal_ddr_init(void)
14421445
set32(DDR_DEBUG_29, reg);
14431446
#endif
14441447

1445-
/* Wait for data initialization to complete */
1448+
/* Wait for data initialization to complete.
1449+
* Use simple delay loop instead of udelay() — timebase may not be
1450+
* running yet during early stage1 init (RCPM clock distribution). */
14461451
while (get32(DDR_SDRAM_CFG_2) & DDR_SDRAM_CFG_2_D_INIT) {
1447-
/* busy wait loop - throttle polling */
1448-
udelay(10000);
1452+
volatile int i;
1453+
for (i = 0; i < 1000; i++)
1454+
;
14491455
}
14501456

14511457
#ifdef USE_ERRATA_DDRA009663
@@ -1461,11 +1467,15 @@ void hal_early_init(void)
14611467
/* enable timebase on core 0 */
14621468
set32(RCPM_PCTBENR, (1 << 0));
14631469

1464-
/* invalidate the CPC before DDR gets enabled */
1470+
/* invalidate the CPC before DDR gets enabled.
1471+
* Skip for stage1: assembly already configured CPC as SRAM and the
1472+
* stack/heap reside there — re-invalidating would destroy them. */
1473+
#ifndef BUILD_LOADER_STAGE1
14651474
set32((volatile uint32_t*)(CPC_BASE + CPCCSR0),
14661475
(CPCCSR0_CPCFI | CPCCSR0_CPCLFC));
14671476
while (get32((volatile uint32_t*)(CPC_BASE + CPCCSR0)) &
14681477
(CPCCSR0_CPCFI | CPCCSR0_CPCLFC));
1478+
#endif
14691479

14701480
/* set DCSRCR space = 1G */
14711481
set32(DCFG_DCSR, (get32(DCFG_DCSR) | CORENET_DCSR_SZ_1G));

src/boot_ppc_start.S

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,15 @@ cpc_poll_invalidate:
597597
stw r0, CPCSRCR1(r1) /* SRAM high address = 0 */
598598
/* SRAM low address - use LOAD_ADDR32 on e6500 to avoid sign extension */
599599
LOAD_ADDR32(r0, L2SRAM_ADDR)
600-
/* Enable SRAM and set size (must match L2SRAM_SIZE = 1MB for P384) */
600+
/* Enable SRAM and set size.
601+
* e6500 (T2080): SRAMSZ_1024 = ways 8-15, 1MB
602+
* e5500 (T1040): SRAMSZ_256 = ways 0-7, 256KB
603+
* Both are (0x3 << 1) but interpreted differently per core. */
604+
#ifdef CORE_E6500
601605
ori r0, r0, (CPCSRCR0_SRAMSZ_1024 | CPCSRCR0_SRAMEN)
606+
#else
607+
ori r0, r0, (CPCSRCR0_SRAMSZ_256 | CPCSRCR0_SRAMEN)
608+
#endif
602609
stw r0, CPCSRCR0(r1)
603610
mbar
604611
isync

stage1/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ CFLAGS+=\
101101

102102
# For printf support (disable NO_PRINTF_UART) and increase WOLFBOOT_STAGE1_SIZE
103103
ifeq ($(ARCH),PPC)
104+
CFLAGS+=-g -gdwarf-4
104105
CFLAGS+=-DNO_PRINTF_UART -DWOLFBOOT_NO_PRINTF
105106
ifeq ($(NO_XIP),1)
106107
# Use PIC (Position Independent Code) for first stage loader

test-app/app_nxp_t1040.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static const char* hex_lut = "0123456789abcdef";
2828
void main(void)
2929
{
3030
int i = 0;
31-
int j = 0;
31+
volatile int j = 0;
3232
int k = 0;
3333
char snum[8];
3434

0 commit comments

Comments
 (0)