Skip to content

Commit b3e2fb9

Browse files
dgarskedanielinux
authored andcommitted
NXP T1024 wolfBoot support:
* Added DDR4 w/ECC. * Added L2 and L2 CPC SRAM support * Added platform SRAM 160KB support * Added support for core timers (timebase) and platform clock. * Added IFC driver with erase/write * Added stage 1 loader to relocate wolfBoot to DDR * Added CPLD, QUICC, FMAN and MP drivers * Added eSPI driver for TPM. * Added hal_early_init instead of calling ddr_init directly. * Fixes for device tree (DTB) loading with update_ram and PPC boot. * Fixes for relocating CCSRBAR to upper. * Fixes for interrupt offsets.
1 parent bef9d8c commit b3e2fb9

28 files changed

+2581
-328
lines changed

.github/workflows/test-configs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ jobs:
7676
arch: ppc
7777
config-file: ./config/examples/nxp-p1021.config
7878

79+
nxp_t1024_test:
80+
uses: ./.github/workflows/test-build.yml
81+
with:
82+
arch: ppc
83+
config-file: ./config/examples/nxp-t1024.config
84+
7985
nxp_t2080_68ppc2_test:
8086
uses: ./.github/workflows/test-build.yml
8187
with:

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ endif
106106
ifeq ($(TARGET),nxp_p1021)
107107
MAIN_TARGET:=factory_wstage1.bin
108108
endif
109+
ifeq ($(TARGET),nxp_t1024)
110+
MAIN_TARGET:=factory_wstage1.bin
111+
endif
109112

110113
ASFLAGS:=$(CFLAGS)
111114
BOOTLOADER_PARTITION_SIZE?=$$(( $(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLASH_OFFSET)))

arch.mk

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,30 @@ ifeq ($(ARCH),ARM_BE)
412412
endif
413413
endif
414414

415+
ifeq ($(TARGET),nxp_t1024)
416+
# Power PC big endian
417+
ARCH_FLAGS=-mhard-float -mcpu=e5500
418+
CFLAGS+=$(ARCH_FLAGS) -DBIG_ENDIAN_ORDER
419+
CFLAGS+=-DMMU -DWOLFBOOT_DUALBOOT
420+
CFLAGS+=-pipe # use pipes instead of temp files
421+
CFLAGS+=-feliminate-unused-debug-types
422+
LDFLAGS+=$(ARCH_FLAGS)
423+
LDFLAGS+=-Wl,--hash-style=both # generate both sysv and gnu symbol hash table
424+
LDFLAGS+=-Wl,--as-needed # remove weak functions not used
425+
OBJS+=src/boot_ppc_mp.o # support for spin table
426+
UPDATE_OBJS:=src/update_ram.o
427+
ifeq ($(SPMATH),1)
428+
MATH_OBJS += ./lib/wolfssl/wolfcrypt/src/sp_c32.o
429+
else
430+
# Use the SP math all assembly accelerations
431+
CFLAGS+=-DWOLFSSL_SP_PPC
432+
endif
433+
SPI_TARGET=nxp
434+
endif
435+
415436
ifeq ($(TARGET),nxp_t2080)
416437
# Power PC big endian
417-
ARCH_FLAGS=-m32 -mhard-float -mcpu=e6500
438+
ARCH_FLAGS=-mhard-float -mcpu=e6500
418439
CFLAGS+=$(ARCH_FLAGS) -DBIG_ENDIAN_ORDER
419440
CFLAGS+=-DMMU -DWOLFBOOT_DUALBOOT
420441
CFLAGS+=-pipe # use pipes instead of temp files
@@ -440,8 +461,8 @@ ifeq ($(TARGET),nxp_p1021)
440461
CFLAGS+=-pipe # use pipes instead of temp files
441462
LDFLAGS+=$(ARCH_FLAGS)
442463
LDFLAGS+=-Wl,--as-needed # remove weak functions not used
464+
OBJS+=src/boot_ppc_mp.o # support for spin table
443465
UPDATE_OBJS:=src/update_ram.o
444-
UPDATE_OBJS+=src/boot_ppc_mp.o
445466

446467
# Use PPC stdlib for memcpy, etc.
447468
#CFLAGS+=-DWOLFBOOT_USE_STDLIBC

config/examples/nxp-t1024.config

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# NXP QorIQ T1024 (2 core)
2+
3+
ARCH=PPC
4+
TARGET=nxp_t1024
5+
SIGN?=ECC384
6+
HASH?=SHA384
7+
IMAGE_HEADER_SIZE?=512
8+
DEBUG?=0
9+
DEBUG_UART?=1
10+
VTOR?=1
11+
CORTEX_M0?=0
12+
NO_ASM?=0
13+
EXT_FLASH?=0
14+
SPI_FLASH?=0
15+
NO_XIP?=0
16+
UART_FLASH?=0
17+
ALLOW_DOWNGRADE?=0
18+
NVM_FLASH_WRITEONCE?=0
19+
WOLFBOOT_VERSION?=0
20+
NO_MPU?=0
21+
SPMATH?=0
22+
SPMATHALL?=1
23+
RAM_CODE?=0
24+
DUALBANK_SWAP?=0
25+
WOLFTPM?=0
26+
ELF?=1
27+
DEBUG_ELF=0
28+
29+
# NOR Base Address
30+
ARCH_FLASH_OFFSET?=0xEC000000
31+
32+
# Flash Sector Size
33+
WOLFBOOT_SECTOR_SIZE=0x10000
34+
35+
# wolfBoot start address
36+
WOLFBOOT_ORIGIN=0xEFF40000
37+
# wolfBoot partition size (custom)
38+
BOOTLOADER_PARTITION_SIZE=0xC0000
39+
40+
# Application Partition Size
41+
WOLFBOOT_PARTITION_SIZE?=0x01E00000
42+
# Location in Flash for Application Partition
43+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xEE000000
44+
# Load Partition to RAM Address
45+
WOLFBOOT_LOAD_ADDRESS?=0x70000000
46+
47+
# Location in Flash for Update Partition
48+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0xEC200000
49+
50+
# Location of temporary sector used during updates
51+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0xEC0F0000
52+
53+
# Stage 1 loader settings (16KB)
54+
WOLFBOOT_STAGE1_SIZE=0x4000
55+
# Location in Flash for stage 1 loader (XIP from boot ROM)
56+
WOLFBOOT_STAGE1_FLASH_ADDR=0xEFFFC000
57+
# Address in RAM to load wolfBoot (end of DDR at 2GB-1MB)
58+
WOLFBOOT_STAGE1_LOAD_ADDR=0x7FF00000
59+
60+
# DTS (Device Tree)
61+
WOLFBOOT_DTS_BOOT_ADDRESS?=0xEC020000
62+
WOLFBOOT_DTS_UPDATE_ADDRESS?=0xEC040000
63+
# DTS Load to RAM Address
64+
WOLFBOOT_LOAD_DTS_ADDRESS?=0x7F100000
65+
66+
# Load to RAM before hash and verify
67+
CFLAGS_EXTRA+=-DWOLFBOOT_USE_RAMBOOT

config/examples/nxp-t2080.config

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ ARCH_FLASH_OFFSET?=0xEFFF0000
3030
BOOTLOADER_PARTITION_SIZE=0x10000
3131

3232
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0xEFFD0000
33+
WOLFBOOT_LOAD_ADDRESS?=0x19000
3334
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0xEFFB0000
35+
36+
# Location of temporary sector used during updates
3437
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0xEFFA0000
35-
WOLFBOOT_LOAD_ADDRESS?=0x200000
36-
WOLFBOOT_LOAD_DTS_ADDRESS?=0x40000
38+
39+
# DTS (Device Tree)
40+
WOLFBOOT_DTS_BOOT_ADDRESS?=0xE8040000
41+
WOLFBOOT_DTS_UPDATE_ADDRESS?=0xE8050000
42+
WOLFBOOT_LOAD_DTS_ADDRESS?=0x200000

docs/Targets.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This README describes configuration of supported targets.
1111
* [NXP iMX-RT](#nxp-imx-rt)
1212
* [NXP Kinetis](#nxp-kinetis)
1313
* [NXP P1021 PPC](#nxp-qoriq-p1021-ppc)
14+
* [NXP T1024 PPC](#nxp-qoriq-t1024-ppc)
1415
* [NXP T2080 PPC](#nxp-qoriq-t2080-ppc)
1516
* [Qemu x86-64 UEFI](#qemu-x86-64-uefi)
1617
* [SiFive HiFive1 RISC-V](#sifive-hifive1-risc-v)
@@ -1245,6 +1246,92 @@ make factory_wstage1.bin
12451246
```
12461247

12471248

1249+
## NXP QorIQ T1024 PPC
1250+
1251+
The NXP QorIQ T1024 is a two core 64-bit PPC e5500 based processor at 1400MHz. Each core has 256KB L2 cache.
1252+
1253+
Board: T1024RDB
1254+
Board rev: 0x3031
1255+
CPLD ver: 0x42
1256+
1257+
T1024E, Version: 1.0, (0x8548_0010)
1258+
e5500, Version: 2.1, (0x8024_1021)
1259+
1260+
Reset Configuration Word (RCW):
1261+
00000000: 0810000e 00000000 00000000 00000000
1262+
00000010: 2d800003 40408812 fc027000 21000000
1263+
00000020: 00000000 00000000 60000000 00036800
1264+
00000030: 00000100 484a5808 00000000 00000006
1265+
1266+
Flash is NOR on IFC CS0 (0x0_EC00_0000) 64MB (default).
1267+
1268+
Default NOR Flash Memory Layout (64MB):
1269+
1270+
| Description | Address | Size |
1271+
| ----------------- | ---------- | ------------------- |
1272+
| RCW | 0xEC000000 | 0x00020000 (128 KB) |
1273+
| Primary (FDT) | 0xEC020000 | 0x00020000 (128 KB) |
1274+
| Update (FDT) | 0xEC040000 | 0x00020000 (128 KB) |
1275+
| Free | 0xEC060000 | 0x00090000 (576 KB) |
1276+
| Swap Sector | 0xEC0F0000 | 0x00010000 ( 64 KB) |
1277+
| Free | 0xEC100000 | 0x00100000 ( 1 MB) |
1278+
| Update (OS) | 0xEC200000 | 0x01E00000 ( 30 MB) |
1279+
| Application (OS) | 0xEE000000 | 0x01E00000 ( 30 MB) |
1280+
| QUICC | 0xEFE00000 | 0x00100000 ( 1 MB) |
1281+
| DPAA (FMAN) | 0xEFF00000 | 0x00020000 (128 KB) |
1282+
| wolfBoot | 0xEFF40000 | 0x000BC000 (752 KB) |
1283+
| wolfBoot Stage 1 | 0xEFFFC000 | 0x00004000 ( 16 KB) |
1284+
1285+
QE: uploading microcode 'Microcode for T1024 r1.0' version 0.0.1
1286+
1287+
DDR4 2GB
1288+
1289+
### Building wolfBoot for NXP T1024 PPC
1290+
1291+
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`).
1292+
1293+
The `make` creates a `factory_stage1.bin` image that can be programmed at `0xEC000000`
1294+
1295+
```
1296+
cp ./config/examples/nxp-t1024.config .config
1297+
make clean
1298+
make keytools
1299+
make
1300+
```
1301+
1302+
Or each `make` component can be manually built using:
1303+
1304+
```
1305+
make stage1
1306+
make wolfboot.elf
1307+
make test-app/image_v1_signed.bin
1308+
```
1309+
1310+
If getting errors with keystore then you can reset things using `make distclean`.
1311+
1312+
### Signing Custom application
1313+
1314+
```
1315+
./tools/keytools/sign --ecc384 --sha384 custom.elf wolfboot_signing_private_key.der 1
1316+
```
1317+
1318+
### Assembly of custom firmware image
1319+
1320+
```
1321+
./tools/bin-assemble/bin-assemble factory_custom.bin \
1322+
0xEC000000 RCW_CTS.bin \
1323+
0xEC020000 custom.dtb \
1324+
0xEE000000 custom_v1_signed.bin \
1325+
0xEFE00000 iram_Type_A_T1024_r1.0.bin \
1326+
0xEFF00000 fsl_fman_ucode_t1024_r1.0_108_4_5.bin \
1327+
0xEFF40000 wolfboot.bin \
1328+
0xEFFFC000 stage1/loader_stage1.bin
1329+
```
1330+
1331+
Flash factory_custom.bin to NOR base 0xEC00_0000
1332+
1333+
1334+
12481335
## NXP QorIQ T2080 PPC
12491336

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

hal/nxp_p1021.c

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ enum elbc_amask_sizes {
419419
#define DDR_SDRAM_MODE ((volatile uint32_t*)(DDR_BASE + 0x118)) /* DDR SDRAM mode configuration */
420420
#define DDR_SDRAM_MODE_2 ((volatile uint32_t*)(DDR_BASE + 0x11C)) /* DDR SDRAM mode configuration 2 */
421421
#define DDR_SDRAM_MD_CNTL ((volatile uint32_t*)(DDR_BASE + 0x120)) /* DDR SDRAM mode control */
422-
#define DDR_SDRAM_INTERVAL ((volatile uint32_t*)(DDR_BASE + 0x124)) /* DDR SDRAM interval configuration */
423422
#define DDR_SDRAM_CLK_CNTL ((volatile uint32_t*)(DDR_BASE + 0x130)) /* DDR SDRAM clock control */
424423

425424
#define DDR_SDRAM_CFG_MEM_EN 0x80000000 /* SDRAM interface logic is enabled */
@@ -482,7 +481,6 @@ enum elbc_amask_sizes {
482481
#define ESPI_CSMODE_CSAFT(x) (((x) & 0xF) << 8) /* CS assertion time in bits after frame end */
483482
#define ESPI_CSMODE_CSCG(x) (((x) & 0xF) << 3) /* Clock gaps between transmitted frames according to this size */
484483

485-
486484
#ifdef ENABLE_ELBC
487485

488486
static volatile uint8_t* flash_buf;
@@ -492,33 +490,31 @@ static uint32_t flash_idx;
492490
int ext_flash_read(uintptr_t address, uint8_t *data, int len);
493491
#endif
494492

493+
/* generic share NXP QorIQ driver code */
494+
#include "nxp_ppc.c"
495+
495496

496497
/* local functions */
498+
#ifdef ENABLE_BUS_CLK_CALC
497499
static uint32_t hal_get_bus_clk(void)
498500
{
501+
/* compute bus clock (system input 66MHz * ratio) */
499502
uint32_t bus_clk;
500-
#ifdef ENABLE_BUS_CLK_CALC
501-
/* compute bus clock (system input 66MHz * ratio */
502503
uint32_t plat_ratio = get32(GUTS_PORPLLSR);
503504
/* mask and shift by 1 to get platform ratio */
504505
plat_ratio = ((plat_ratio & 0x3E) >> 1);
505506
bus_clk = SYS_CLK * plat_ratio;
506507
return bus_clk;
508+
}
507509
#else
508-
return (uint32_t)(SYS_CLK * 6); /* can also be 8 */
510+
#define hal_get_bus_clk() (uint32_t)(SYS_CLK * 6)
509511
#endif
510-
}
511512

512-
#if defined(ENABLE_ESPI) || defined(ENABLE_DDR)
513-
#ifdef BUILD_LOADER_STAGE1
514-
static
515-
#endif
516-
void udelay(unsigned long delay_us)
513+
#define DELAY_US (hal_get_bus_clk() / 1000000)
514+
static void udelay(uint32_t delay_us)
517515
{
518-
delay_us *= (hal_get_bus_clk() / 1000000);
519-
wait_ticks(delay_us);
516+
wait_ticks(delay_us * DELAY_US);
520517
}
521-
#endif
522518

523519
/* ---- eSPI Driver ---- */
524520
#ifdef ENABLE_ESPI
@@ -903,7 +899,7 @@ static int hal_flash_init(void)
903899
return ret;
904900
}
905901

906-
void hal_ddr_init(void)
902+
static void hal_ddr_init(void)
907903
{
908904
#ifdef ENABLE_DDR
909905
uint32_t reg;
@@ -968,6 +964,12 @@ void hal_ddr_init(void)
968964
#endif /* ENABLE_DDR */
969965
}
970966

967+
void hal_early_init(void)
968+
{
969+
hal_ddr_init();
970+
}
971+
972+
971973
#ifdef ENABLE_PCIE
972974
#define CONFIG_SYS_PCIE1_MEM_PHYS 0xc0000000
973975
#define CONFIG_SYS_PCIE1_IO_PHYS 0xffc20000
@@ -987,18 +989,18 @@ static int hal_pcie_init(void)
987989
set_law(3, CONFIG_SYS_PCIE2_IO_PHYS, LAW_TRGT_PCIE2, LAW_SIZE_64KB),
988990

989991
/* Map TLB for PCIe */
990-
set_tlb(1, 2, CONFIG_SYS_PCIE2_MEM_VIRT, CONFIG_SYS_PCIE2_MEM_PHYS,
992+
set_tlb(1, 2, CONFIG_SYS_PCIE2_MEM_VIRT, CONFIG_SYS_PCIE2_MEM_PHYS, 0,
991993
MAS3_SX | MAS3_SW | MAS3_SR, MAS2_I | MAS2_G, 0, BOOKE_PAGESZ_256M, 1);
992994
set_tlb(1, 3, (CONFIG_SYS_PCIE2_MEM_VIRT + 0x10000000),
993-
(CONFIG_SYS_PCIE2_MEM_PHYS + 0x10000000),
995+
(CONFIG_SYS_PCIE2_MEM_PHYS + 0x10000000), 0,
994996
MAS3_SX | MAS3_SW | MAS3_SR, MAS2_I | MAS2_G, 0, BOOKE_PAGESZ_256M, 1);
995-
set_tlb(1, 4, CONFIG_SYS_PCIE1_MEM_VIRT, CONFIG_SYS_PCIE1_MEM_PHYS,
997+
set_tlb(1, 4, CONFIG_SYS_PCIE1_MEM_VIRT, CONFIG_SYS_PCIE1_MEM_PHYS, 0,
996998
MAS3_SX | MAS3_SW | MAS3_SR, MAS2_I | MAS2_G, 0, BOOKE_PAGESZ_256M, 1);
997999
set_tlb(1, 5, (CONFIG_SYS_PCIE1_MEM_VIRT + 0x10000000),
998-
(CONFIG_SYS_PCIE1_MEM_PHYS + 0x10000000),
1000+
(CONFIG_SYS_PCIE1_MEM_PHYS + 0x10000000), 0,
9991001
MAS3_SX | MAS3_SW | MAS3_SR, MAS2_I | MAS2_G, 0, BOOKE_PAGESZ_256M, 1);
10001002

1001-
set_tlb(1, 6, CONFIG_SYS_PCIE2_IO_VIRT, CONFIG_SYS_PCIE2_IO_PHYS,
1003+
set_tlb(1, 6, CONFIG_SYS_PCIE2_IO_VIRT, CONFIG_SYS_PCIE2_IO_PHYS, 0,
10021004
MAS3_SX | MAS3_SW | MAS3_SR, MAS2_I | MAS2_G, 0, BOOKE_PAGESZ_256K, 1);
10031005
return 0;
10041006
}
@@ -1011,7 +1013,7 @@ static int hal_cpld_init(void)
10111013
/* Setup Local Access Window (LAW) for CPLD/BCSR */
10121014
set_law(5, BCSR_BASE, LAW_TRGT_ELBC, LAW_SIZE_256KB);
10131015
/* Setup TLB MMU (Translation Lookaside Buffer) for CPLD/BCSR */
1014-
set_tlb(1, 8, BCSR_BASE, BCSR_BASE, MAS3_SX | MAS3_SW | MAS3_SR,
1016+
set_tlb(1, 8, BCSR_BASE, BCSR_BASE, 0, MAS3_SX | MAS3_SW | MAS3_SR,
10151017
MAS2_I | MAS2_G, 0, BOOKE_PAGESZ_256K, 1);
10161018

10171019
/* setup eLBC for CPLD (CS1), 8-bit */
@@ -1504,7 +1506,7 @@ static void hal_mp_init(void)
15041506

15051507
/* map reset page to bootpg so we can copy code there */
15061508
disable_tlb1(i_tlb);
1507-
set_tlb(1, i_tlb, BOOT_ROM_ADDR, bootpg, /* tlb, epn, rpn */
1509+
set_tlb(1, i_tlb, BOOT_ROM_ADDR, bootpg, 0, /* tlb, epn, rpn */
15081510
MAS3_SX | MAS3_SW | MAS3_SR, MAS2_I, /* perms, wimge */
15091511
0, BOOKE_PAGESZ_4K, 1); /* ts, esel, tsize, iprot */
15101512

hal/nxp_ppc.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* nxp_ppc.c
2+
*
3+
* Copyright (C) 2023 wolfSSL Inc.
4+
*
5+
* This file is part of wolfBoot.
6+
*
7+
* wolfBoot is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* wolfBoot is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20+
*/
21+
22+
/* This file gets directly included from nxp_ targets.
23+
* This file contains shared driver code for all NXP QorIQ platforms */

0 commit comments

Comments
 (0)