Skip to content

Commit a90d60f

Browse files
committed
Port improvements
1 parent 26395b4 commit a90d60f

10 files changed

Lines changed: 100 additions & 119 deletions

File tree

.github/workflows/test-configs.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,6 @@ jobs:
182182
arch: ppc
183183
config-file: ./config/examples/nxp-t1024.config
184184

185-
nxp_t2080_68ppc2_test:
186-
uses: ./.github/workflows/test-build.yml
187-
with:
188-
arch: ppc
189-
config-file: ./config/examples/nxp-t2080-68ppc2.config
190-
191185
nxp_t2080_test:
192186
uses: ./.github/workflows/test-build.yml
193187
with:

arch.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,15 +627,15 @@ endif
627627
ifeq ($(ARCH),PPC)
628628
CROSS_COMPILE?=powerpc-linux-gnu-
629629
LDFLAGS+=-Wl,--build-id=none
630-
CFLAGS+=-DARCH_PPC -DFAST_MEMCPY
630+
CFLAGS+=-DARCH_PPC -DFAST_MEMCPY -ffreestanding -fno-tree-loop-distribute-patterns
631631

632632
ifeq ($(DEBUG_UART),0)
633633
CFLAGS+=-fno-builtin-printf
634634
endif
635635

636636
# Target-specific CPU flags
637637
ifeq ($(TARGET),nxp_t2080)
638-
CFLAGS+=-mcpu=e6500 -mno-altivec
638+
CFLAGS+=-mcpu=e6500 -mno-altivec -mbss-plt
639639
else ifeq ($(TARGET),nxp_t1024)
640640
CFLAGS+=-mcpu=e5500
641641
endif

config/examples/nxp-t2080-68ppc2.config

Lines changed: 0 additions & 55 deletions
This file was deleted.

config/examples/nxp-t2080.config

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
# NXP T2080 wolfBoot Configuration Template
2+
#
3+
# Stock (default): Compact layout, NOR base 0xEFFE0000
4+
# NAII 68PPC2 (alternate): Larger app partition, NOR base 0xE8000000
5+
# Uncomment the "# NAII 68PPC2:" lines and comment the stock lines to use.
6+
17
ARCH=PPC
28
TARGET=nxp_t2080
39
SIGN?=ECC384
410
HASH?=SHA384
11+
IMAGE_HEADER_SIZE?=512
512
DEBUG?=0
13+
DEBUG_SYMBOLS?=1
614
DEBUG_UART?=1
715
VTOR?=1
816
CORTEX_M0?=0
@@ -17,25 +25,43 @@ WOLFBOOT_VERSION?=0
1725
NO_MPU?=0
1826
SPMATH?=0
1927
SPMATHALL?=1
20-
RAM_CODE?=0
28+
RAM_CODE?=1
2129
DUALBANK_SWAP?=0
22-
PKA?=1
2330
WOLFTPM?=0
24-
WOLFBOOT_ORIGIN?=0xEFFE0000
25-
WOLFBOOT_PARTITION_SIZE?=0x20000
26-
WOLFBOOT_SECTOR_SIZE?=0x10000
2731

32+
# NOR Base Address
2833
ARCH_FLASH_OFFSET?=0xEFFE0000
34+
# NAII 68PPC2: ARCH_FLASH_OFFSET?=0xE8000000
35+
36+
# Flash Sector Size
37+
WOLFBOOT_SECTOR_SIZE?=0x10000
38+
39+
# wolfBoot start address
40+
WOLFBOOT_ORIGIN?=0xEFFE0000
41+
# NAII 68PPC2: WOLFBOOT_ORIGIN?=0xEFF40000
42+
# wolfBoot partition size (custom)
2943
BOOTLOADER_PARTITION_SIZE=0x20000
3044

45+
# Application Partition Size
46+
WOLFBOOT_PARTITION_SIZE?=0x20000
47+
# NAII 68PPC2: WOLFBOOT_PARTITION_SIZE?=0xA00000
48+
# Location in Flash for Application Partition
3149
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xEFFC0000
50+
# NAII 68PPC2: WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xE8080000
51+
# Load Partition to RAM Address
3252
WOLFBOOT_LOAD_ADDRESS?=0x19000
53+
54+
# Location in Flash for Update Partition
3355
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0xEFFA0000
56+
# NAII 68PPC2: WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0xE8A80000
3457

3558
# Location of temporary sector used during updates
3659
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0xEFF90000
60+
# NAII 68PPC2: WOLFBOOT_PARTITION_SWAP_ADDRESS?=0xE8060000
3761

3862
# DTS (Device Tree)
3963
WOLFBOOT_DTS_BOOT_ADDRESS?=0xE8040000
4064
WOLFBOOT_DTS_UPDATE_ADDRESS?=0xE8050000
65+
# DTS Load to RAM Address
4166
WOLFBOOT_LOAD_DTS_ADDRESS?=0x200000
67+
# NAII 68PPC2: WOLFBOOT_LOAD_DTS_ADDRESS?=0x40000

docs/Targets.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,9 +3061,8 @@ Flash factory_custom.bin to NOR base 0xEC00_0000
30613061

30623062
The NXP QorIQ T2080 is a PPC e6500 based processor (four cores). Support has been tested with the NAII 68PPC2.
30633063

3064-
Example configurations for this target are provided in:
3065-
* NXP T2080: [/config/examples/nxp-t2080.config](/config/examples/nxp-t2080.config).
3066-
* NAII 68PPC2: [/config/examples/nxp-t2080-68ppc2.config](/config/examples/nxp-t2080-68ppc2.config).
3064+
Example configuration: [/config/examples/nxp-t2080.config](/config/examples/nxp-t2080.config).
3065+
Stock layout is default; for NAII 68PPC2, uncomment the "# NAII 68PPC2:" lines and comment the stock lines.
30673066

30683067
### Design NXP T2080 PPC
30693068

@@ -3080,9 +3079,10 @@ RM 4.3.3 Boot Space Translation
30803079
By default wolfBoot will use `powerpc-linux-gnu-` cross-compiler prefix. These tools can be installed with the Debian package `gcc-powerpc-linux-gnu` (`sudo apt install gcc-powerpc-linux-gnu`).
30813080

30823081
The `make` creates a `factory.bin` image that can be programmed at `0xE8080000`
3082+
(For NAII 68PPC2, first edit `nxp-t2080.config` to uncomment the NAII 68PPC2 lines.)
30833083

30843084
```
3085-
cp ./config/examples/nxp-t2080-68ppc2.config .config
3085+
cp ./config/examples/nxp-t2080.config .config
30863086
make clean
30873087
make keytools
30883088
make

hal/nxp_ppc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133

134134
#define ENABLE_DDR
135135
#ifndef DDR_SIZE
136-
#define DDR_SIZE (8192UL * 1024UL * 1024UL)
136+
#define DDR_SIZE (8192ULL * 1024ULL * 1024ULL)
137137
#endif
138138

139139
#define FLASH_BASE_ADDR 0xE8000000UL

hal/nxp_t2080.c

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -200,38 +200,24 @@ static int hal_flash_getid(void)
200200
static void hal_flash_init(void)
201201
{
202202
#ifdef ENABLE_IFC
203-
/* IFC - NOR Flash */
204-
/* LAW is also set in boot_ppc_start.S:flash_law */
205-
set_law(1, FLASH_BASE_PHYS_HIGH, FLASH_BASE_ADDR, LAW_TRGT_IFC, LAW_SIZE_128MB, 1);
206-
207-
/* NOR IFC Flash Timing Parameters */
208-
set32(IFC_FTIM0(0), (IFC_FTIM0_NOR_TACSE(4) |
209-
IFC_FTIM0_NOR_TEADC(5) |
210-
IFC_FTIM0_NOR_TEAHC(5)));
211-
set32(IFC_FTIM1(0), (IFC_FTIM1_NOR_TACO(53) |
212-
IFC_FTIM1_NOR_TRAD(26) |
213-
IFC_FTIM1_NOR_TSEQ(19)));
214-
set32(IFC_FTIM2(0), (IFC_FTIM2_NOR_TCS(4) |
215-
IFC_FTIM2_NOR_TCH(4) |
216-
IFC_FTIM2_NOR_TWPH(14) |
217-
IFC_FTIM2_NOR_TWP(28)));
218-
set32(IFC_FTIM3(0), 0);
219-
/* NOR IFC Definitions (CS0) */
220-
set32(IFC_CSPR_EXT(0), FLASH_BASE_PHYS_HIGH);
221-
set32(IFC_CSPR(0), (IFC_CSPR_PHYS_ADDR(FLASH_BASE_ADDR) |
222-
#if FLASH_CFI_WIDTH == 16
223-
IFC_CSPR_PORT_SIZE_16 |
224-
#else
225-
IFC_CSPR_PORT_SIZE_8 |
226-
#endif
227-
IFC_CSPR_MSEL_NOR |
228-
IFC_CSPR_V));
229-
set32(IFC_AMASK(0), IFC_AMASK_128MB);
230-
set32(IFC_CSOR(0), 0x0000000C); /* TRHZ (80 clocks for read enable high) */
203+
/* IFC CS0 - NOR Flash
204+
* Do NOT reprogram IFC CS0 (CSPR, AMASK, CSOR, FTIM) while executing
205+
* from flash (XIP) with cache-inhibited TLB (MAS2_I|MAS2_G). The boot
206+
* ROM already configured CS0 correctly. Reprogramming CSPR while XIP
207+
* can cause instruction fetch failures because there is no cache to
208+
* serve fetches during the chip-select decode transition.
209+
*
210+
* U-Boot avoids this by using MAS2_W|MAS2_G (write-through, cached)
211+
* during XIP, only switching to MAS2_I|MAS2_G after relocating to RAM.
212+
*
213+
* The LAW is also already set in boot_ppc_start.S:flash_law.
214+
*/
231215

232-
#ifndef BUILD_LOADER_STAGE1
233-
hal_flash_getid();
234-
#endif
216+
/* Note: hal_flash_getid() is disabled because AMD Autoselect mode
217+
* affects the entire flash bank. Since wolfBoot runs XIP from the same
218+
* bank (CS0), entering Autoselect mode crashes instruction fetch.
219+
* Flash write/erase operations will need RAMFUNCTION support.
220+
* TODO: Implement RAMFUNCTION for flash operations on T2080. */
235221
#endif /* ENABLE_IFC */
236222
}
237223

@@ -578,7 +564,7 @@ void hal_flash_lock(void)
578564
/* from boot_ppc_mp.S */
579565
extern uint32_t _secondary_start_page;
580566
extern uint32_t _second_half_boot_page;
581-
extern uint32_t _spin_table;
567+
extern uint32_t _spin_table[];
582568
extern uint32_t _spin_table_addr;
583569
extern uint32_t _bootpg_addr;
584570

@@ -593,7 +579,7 @@ static void hal_mp_up(uint32_t bootpg)
593579
active_cores = (1 << whoami); /* current running cores */
594580

595581
wolfBoot_printf("MP: Starting cores (boot page %p, spin table %p)\n",
596-
bootpg, (uint32_t)&_spin_table);
582+
bootpg, (uint32_t)_spin_table);
597583

598584
/* Set the boot page translation register */
599585
set32(LCC_BSTRH, 0);
@@ -614,7 +600,7 @@ static void hal_mp_up(uint32_t bootpg)
614600
while (timeout) {
615601
for (i = 0; i < CPU_NUMCORES; i++) {
616602
uint32_t* entry = (uint32_t*)(
617-
(uint8_t*)&_spin_table + (i * ENTRY_SIZE) + ENTRY_ADDR_LOWER);
603+
(uint8_t*)_spin_table + (i * ENTRY_SIZE) + ENTRY_ADDR_LOWER);
618604
if (*entry) {
619605
active_cores |= (1 << i);
620606
}
@@ -651,14 +637,17 @@ static void hal_mp_init(void)
651637
const volatile uint32_t *s;
652638
volatile uint32_t *d;
653639

654-
/* Assign virtual boot page at end of DDR */
655-
bootpg = DDR_ADDRESS + DDR_SIZE - BOOT_ROM_SIZE;
640+
/* Assign virtual boot page at end of LAW-mapped DDR region.
641+
* DDR LAW maps 2GB (LAW_SIZE_2GB) starting at DDR_ADDRESS.
642+
* DDR_SIZE may exceed 32-bit range (e.g. 8GB), so use the LAW-mapped
643+
* size to ensure bootpg fits in 32 bits and is accessible. */
644+
bootpg = DDR_ADDRESS + 0x80000000UL - BOOT_ROM_SIZE;
656645

657646
/* Store the boot page address for use by additional CPU cores */
658647
_bootpg_addr = (uint32_t)&_second_half_boot_page;
659648

660649
/* Store location of spin table for other cores */
661-
_spin_table_addr = (uint32_t)&_spin_table;
650+
_spin_table_addr = (uint32_t)_spin_table;
662651

663652
/* Flush bootpg before copying to invalidate any stale cache lines */
664653
flush_cache(bootpg, BOOT_ROM_SIZE);
@@ -748,7 +737,7 @@ int hal_dts_fixup(void* dts_addr)
748737
#ifdef ENABLE_MP
749738
/* calculate location of spin table for core */
750739
core_spin_table = (uint64_t)((uintptr_t)(
751-
(uint8_t*)&_spin_table + (core * ENTRY_SIZE)));
740+
(uint8_t*)_spin_table + (core * ENTRY_SIZE)));
752741

753742
fdt_fixup_str(fdt, off, "cpu", "status", (core == 0) ? "okay" : "disabled");
754743
fdt_fixup_val64(fdt, off, "cpu", "cpu-release-addr", core_spin_table);

hal/nxp_t2080.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ SECTIONS
6363
{
6464
_start_data = .;
6565
KEEP(*(.data*))
66+
*(.got*)
67+
*(.got2*)
68+
*(.plt*)
69+
*(.dynamic)
6670
. = ALIGN(4);
6771
KEEP(*(.ramcode))
6872
. = ALIGN(4);

include/wolfboot/wolfboot.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ extern "C" {
4747
# if defined(__WOLFBOOT) && defined(RAM_CODE)
4848
# if defined(ARCH_ARM)
4949
# define RAMFUNCTION __attribute__((used,section(".ramcode"),long_call))
50+
# elif defined(ARCH_PPC)
51+
# define RAMFUNCTION __attribute__((used,section(".ramcode"),longcall))
5052
# else
5153
# define RAMFUNCTION __attribute__((used,section(".ramcode")))
5254
# endif

src/boot_ppc.c

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,25 +113,46 @@ int WEAKFUNCTION hal_dts_fixup(void* dts_addr)
113113
}
114114
#endif
115115

116+
/* forward declaration */
117+
#ifndef BUILD_LOADER_STAGE1
118+
void flush_cache(uint32_t start_addr, uint32_t size);
119+
#endif
120+
116121
void boot_entry_C(void)
117122
{
118-
register unsigned int *dst, *src, *end;
123+
volatile unsigned int *dst;
124+
volatile const unsigned int *src;
125+
volatile unsigned int *end;
119126

120127
hal_early_init();
121128

122-
/* Copy the .data section from flash to RAM */
123-
src = (unsigned int*)&_stored_data;
124-
dst = (unsigned int*)&_start_data;
125-
end = (unsigned int*)&_end_data;
129+
/* Copy the .data section from flash to RAM.
130+
* Use volatile to prevent the compiler from transforming this loop
131+
* into a memcpy() call — memcpy is RAMFUNCTION in .data and hasn't
132+
* been copied to DDR yet at this point. */
133+
src = (volatile const unsigned int*)&_stored_data;
134+
dst = (volatile unsigned int*)&_start_data;
135+
end = (volatile unsigned int*)&_end_data;
126136
while (dst < end) {
127137
*dst = *src;
128138
dst++;
129139
src++;
130140
}
131141

132-
/* Initialize the BSS section to 0 */
133-
dst = (unsigned int*)&__bss_start__;
134-
end = (unsigned int*)&__bss_end__;
142+
#ifndef BUILD_LOADER_STAGE1
143+
/* Flush D-cache and invalidate I-cache for .data region.
144+
* The .ramcode section (RAMFUNCTION code like memcpy) is within .data
145+
* and was just copied to DDR through D-cache. Without this flush, the
146+
* I-cache will fetch stale/uninitialized DDR content when calling
147+
* RAMFUNCTION code, causing instruction fetch failures.
148+
* PowerPC I/D caches are not coherent — explicit dcbst+icbi required. */
149+
flush_cache((uint32_t)&_start_data,
150+
(uint32_t)&_end_data - (uint32_t)&_start_data);
151+
#endif
152+
153+
/* Initialize the BSS section to 0 (volatile prevents memset transform) */
154+
dst = (volatile unsigned int*)&__bss_start__;
155+
end = (volatile unsigned int*)&__bss_end__;
135156
while (dst < end) {
136157
*dst = 0U;
137158
dst++;

0 commit comments

Comments
 (0)