Skip to content

Commit d007c9a

Browse files
dgarskedanielinux
authored andcommitted
Initial support for NXP LS1028A. Booting into OCRAM app. Updates to ARMv8 startup.
1 parent 34bb4f6 commit d007c9a

17 files changed

+2803
-41
lines changed

arch.mk

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,23 @@ ifeq ($(ARCH),AARCH64)
7272
MATH_OBJS += ./lib/wolfssl/wolfcrypt/src/sp_c32.o
7373
MATH_OBJS += ./lib/wolfssl/wolfcrypt/src/sp_arm64.o
7474
endif
75+
76+
ifeq ($(TARGET),nxp_ls1028a)
77+
ARCH_FLAGS=-mcpu=cortex-a72+crypto -mstrict-align -march=armv8-a+crypto -mtune=cortex-a72
78+
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A72 -DTARGET_LS1028A -DWOLFSSL_ARMASM -DWC_HASH_DATA_ALIGNMENT=8
79+
#LDFLAGS+=-Wl,--as-needed -D"__WOLFBOOT"
80+
CFLAGS +=-ffunction-sections -fdata-sections
81+
LDFLAGS+=-Wl,--gc-sections
82+
83+
WOLFCRYPT_OBJS += lib/wolfssl/wolfcrypt/src/port/arm/armv8-sha256.o \
84+
lib/wolfssl/wolfcrypt/src/port/arm/armv8-aes.o
85+
86+
ifeq ($(DEBUG_UART),0)
87+
CFLAGS+=-fno-builtin-printf
88+
endif
89+
90+
SPI_TARGET=nxp
91+
endif
7592
endif
7693

7794
## ARM Cortex-M
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
ARCH=AARCH64
2+
TARGET=nxp_ls1028a
3+
SIGN?=ECC256
4+
HASH?=SHA256
5+
DEBUG?=1
6+
DEBUG_UART?=1
7+
VTOR?=0
8+
CORTEX_M0?=0
9+
NO_ASM?=0
10+
EXT_FLASH?=1
11+
SPI_FLASH?=0
12+
## Force app to be copied into ram
13+
NO_XIP?=1
14+
UART_FLASH?=0
15+
ALLOW_DOWNGRADE?=0
16+
NVM_FLASH_WRITEONCE?=0
17+
WOLFBOOT_VERSION?=0
18+
V?=0
19+
NO_MPU?=0
20+
SPMATH?=1
21+
RAM_CODE?=0
22+
DUALBANK_SWAP?=0
23+
PKA?=0
24+
25+
WOLFTPM=1
26+
27+
MEASURED_BOOT?=0
28+
MEASURED_PCR_A?=3
29+
30+
WOLFBOOT_TPM_KEYSTORE?=1
31+
WOLFBOOT_TPM_KEYSTORE_NV_INDEX?=25166336
32+
WOLFBOOT_TPM_POLICY_NV_INDEX?=25166337
33+
WOLFBOOT_TPM_PCR_INDEX?=16
34+
35+
# NOR Base Address
36+
ARCH_FLASH_OFFSET?=0x20000000
37+
38+
# Flash Sector Size (128 KB)
39+
WOLFBOOT_SECTOR_SIZE=0x20000
40+
41+
# wolfBoot start address
42+
WOLFBOOT_ORIGIN=0x20020000
43+
44+
# wolfBoot partition size
45+
BOOTLOADER_PARTITION_SIZE=0x20000
46+
47+
# Application Partition size
48+
WOLFBOOT_PARTITION_SIZE?=0x20000
49+
50+
# Location in Flash for Application Partition
51+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x20040000
52+
53+
# Load Partition to RAM Address
54+
WOLFBOOT_LOAD_ADDRESS?=0x18020100
55+
56+
# Location in Flash for Update Partition
57+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x20060000
58+
59+
# Location of temporary sector used during updates
60+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x20080000
61+
62+
# DTS (Device Tree)
63+
WOLFBOOT_LOAD_DTS_ADDRESS?=0x80000000
64+
WOLFBOOT_DTS_BOOT_ADDRESS?=0x20F00000
65+
WOLFBOOT_DTS_UPDATE_ADDRESS?=0x20F00000

config/examples/nxp-ls1028a.config

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
ARCH=AARCH64
2+
TARGET=nxp_ls1028a
3+
SIGN?=ECC256
4+
HASH?=SHA256
5+
DEBUG?=1
6+
DEBUG_UART?=1
7+
VTOR?=0
8+
CORTEX_M0?=0
9+
NO_ASM?=0
10+
EXT_FLASH?=1
11+
SPI_FLASH?=0
12+
## Force app to be copied into ram
13+
NO_XIP?=1
14+
UART_FLASH?=0
15+
ALLOW_DOWNGRADE?=0
16+
NVM_FLASH_WRITEONCE?=0
17+
WOLFBOOT_VERSION?=0
18+
V?=0
19+
NO_MPU?=0
20+
SPMATH?=1
21+
RAM_CODE?=0
22+
DUALBANK_SWAP?=0
23+
PKA?=0
24+
25+
# NOR Base Address
26+
ARCH_FLASH_OFFSET?=0x20000000
27+
28+
# Flash Sector Size (128 KB)
29+
WOLFBOOT_SECTOR_SIZE=0x20000
30+
31+
# wolfBoot start address
32+
WOLFBOOT_ORIGIN=0x20020000
33+
34+
# wolfBoot partition size
35+
BOOTLOADER_PARTITION_SIZE=0x20000
36+
37+
# Application Partition size
38+
WOLFBOOT_PARTITION_SIZE?=0x20000
39+
40+
# Location in Flash for Application Partition
41+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x20040000
42+
43+
# Load Partition to RAM Address
44+
WOLFBOOT_LOAD_ADDRESS?=0x18020100
45+
46+
# Location in Flash for Update Partition
47+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x20060000
48+
49+
# Location of temporary sector used during updates
50+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x20080000
51+
52+
# DTS (Device Tree)
53+
WOLFBOOT_LOAD_DTS_ADDRESS?=0x80000000
54+
WOLFBOOT_DTS_BOOT_ADDRESS?=0x20F00000
55+
WOLFBOOT_DTS_UPDATE_ADDRESS?=0x20F00000

docs/Targets.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ This README describes configuration of supported targets.
1616
* [NXP iMX-RT](#nxp-imx-rt)
1717
* [NXP Kinetis](#nxp-kinetis)
1818
* [NXP LPC54xxx](#nxp-lpc54xxx)
19+
* [NXP LS1028A](#nxp-ls1028a)
1920
* [NXP MCXA153](#nxp-mcxa153)
2021
* [NXP P1021 PPC](#nxp-qoriq-p1021-ppc)
2122
* [NXP T1024 PPC](#nxp-qoriq-t1024-ppc)
@@ -1073,6 +1074,97 @@ arm-none-eabi-gdb wolfboot.elf -ex "target remote localhost:3333"
10731074
```
10741075

10751076

1077+
## NXP LS1028A
1078+
1079+
The LS1028A is a AARCH64 armv8-a Cortex-A72 processor. Support has been tested with the NXP LS1028ARDB.
1080+
1081+
Example configurations for this target are provided in:
1082+
* NXP LS1028A: [/config/examples/nxp-ls1028a.config](/config/examples/nxp-ls1028a.config).
1083+
* NXP LS1028A with TPM: [/config/examples/nxp-ls1028a-tpm.config](/config/examples/nxp-ls1028a-tpm.config).
1084+
1085+
### Building wolfBoot for NXP LS1028A
1086+
1087+
1. Download `aarch64-none-elf-` toolchain.
1088+
1089+
2. Copy the example `nxp-ls1028a.cofig` file to root directory and rename to `.config`
1090+
1091+
3. Build keytools and wolfboot
1092+
1093+
```
1094+
cp ./config/examples/nxp-ls1028a.config .config
1095+
make distclean
1096+
make keytools
1097+
make
1098+
```
1099+
1100+
This should output 3 binary files, `wolfboot.bin`, `image_v1_signed.bin` and `factory.bin`
1101+
- `wolfboot.bin` is the wolfboot binary
1102+
- `image_v1_signed.bin` is the signed application image and by default is `test-app/app_nxp_ls1028a`
1103+
- `factory.bin` is the two binaries merged together
1104+
1105+
1106+
### Hardware Setup LS1028ARDB
1107+
1108+
DIP Switch Configuraiton for XSPI_NOR_BOOT:
1109+
```
1110+
SW2 : 0xF8 = 11111000 SW3 : 0x70 = 01110000 SW5 : 0x20 = 00100000
1111+
Where '1' = UP/ON
1112+
```
1113+
1114+
UART Configuraiton:
1115+
```
1116+
Baud Rate: 115200
1117+
Data Bits: 8
1118+
Parity: None
1119+
Stop Bits: 1
1120+
Flow Control: None
1121+
Specify device type - PC16552D
1122+
Configured for UART1 DB9 Connector
1123+
```
1124+
1125+
### Programming NXP LS1028A
1126+
1127+
Programming requires three components:
1128+
1. RCW binary - Distribured by NXP at `https://github.com/nxp-qoriq/qoriq-rcw-bin` or can be generated using `https://github.com/nxp-qoriq/rcw/tree/master/ls1028ardb/R_SQPP_0x85bb` (tested with `rcw_1300.bin`)
1129+
2. woflBoot
1130+
3. Application - Test app found in `test-app/app_nxp_ls1028a.c`
1131+
1132+
Once you have all components, you can use a lauterbach or CW to flash NOR flash. You must flash RCW, wolfboot and singed_image. `factory.bin` can be used which is wolfboot and the signed image merged. You will need to build a signed image for every update to the application code, which can be done by using keytools in `tools/keytools/sign` see `docs/Signing.md` for more details
1133+
and to sign a custom image.
1134+
1135+
```
1136+
Usage: tools/keytools/sign [options] image key version
1137+
```
1138+
1139+
#### Lauterbach Flashing and Debugging
1140+
1141+
1. Launch lauterbach and open the demo script `debug_wolfboot.cmm`.
1142+
2. Open any desired debug windows.
1143+
3. Hit the play button on the demo script.
1144+
4. It should pop up with a code window and at the reset startpoint. (May requrie a reset or power cycle)
1145+
1146+
```
1147+
./t32/bin/macosx64/t32marm-qt
1148+
1149+
Open Script > debug_wolfboot.cmm
1150+
```
1151+
1152+
You can modify the Lauterbach NOR flash demo or use `debug_wolfboot.cmm` script, just make sure the flash offset for
1153+
the RCW is `0x0` and the address offset for wolboot is `0x1000`.
1154+
1155+
#### Other Tools
1156+
1157+
1. Make sure the memory addresses are alinged with the `.config` file.
1158+
2. Note the important NOR flash addresses in the defualt config are as follows.
1159+
3. RCW location is offset `0x0` or `0x20000000` memory mapped.
1160+
4. Wolfboot location is offset `0x1000` or `0x20001000` where wolfboot starts.
1161+
5. Application location is offset `0x20000` or `0x20020000` where application code goes.
1162+
6. Update location is offset `0x40000` or `0x20040000` where the new or updated applciaiton goes.
1163+
7. Load Location is `0x18020100` which is OCRAM or where the applciaiton code is loaded if using RAM loading from
1164+
8. DTS Location is
1165+
9. Update memory locations as neeeded.
1166+
1167+
10761168
## Cortex-A53 / Raspberry PI 3 (experimental)
10771169

10781170
Tested using `https://github.com/raspberrypi/linux` on Ubuntu 20

docs/measured_boot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ To enable measured boot add `MEASURED_BOOT=1` setting in your wolfBoot config.
3939

4040
It is also necessary to select the PCR (index) where the measurement will be stored.
4141

42-
Selection is made using the `MEASURED_BOOT_PCR_A=[index]` setting. Add this
42+
Selection is made using the `MEASURED_PCR_A=[index]` setting. Add this
4343
setting in your wolfBoot config and replace `[index]` with a number between
4444
0 and 23. Below you will find guidelines for selecting a PCR index.
4545

hal/nxp_ls1028a-ocram.ld

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
2+
OUTPUT_ARCH(aarch64)
3+
ENTRY(_vector_table)
4+
5+
MEMORY
6+
{
7+
/*The flash address range on LS1028A RDB is 0x20000000 - 0x23FFFFFF.*/
8+
FLASH (rx) : ORIGIN = @WOLFBOOT_ORIGIN@, LENGTH = @BOOTLOADER_PARTITION_SIZE@
9+
10+
/* DDR4 - 2GB */
11+
DRAM (rwx) : ORIGIN = 0x80001000 , LENGTH = 0xBFFFFFFF
12+
13+
/* OCRAM 128K for startup RAM */
14+
OCRAM (rwx) : ORIGIN = 0x18000000, LENGTH = 128K
15+
}
16+
17+
SECTIONS
18+
{
19+
PROVIDE (_DDR_ADDRESS = 0x80001000);
20+
PROVIDE (_OCRAM_ADDRESS = 0x18000000);
21+
PROVIDE (_FLASH_ADDRESS = @WOLFBOOT_ORIGIN@);
22+
PROVIDE (_CORE_NUMBER = 0);
23+
PROVIDE (_MEMORY_SIZE = LENGTH(OCRAM));
24+
PROVIDE (_FLASH_SIZE = LENGTH(FLASH));
25+
PROVIDE (STACK_SIZE = 20K);
26+
27+
.boot :
28+
{
29+
PROVIDE(_vector_table = .);
30+
._vector_table = .;
31+
. = ALIGN(0x800);
32+
KEEP(*(.vector_table))
33+
KEEP(*(.boot*))
34+
} > OCRAM
35+
36+
37+
/* Read-only sections, merged into text segment: */
38+
.interp : { *(.interp) }
39+
.note.gnu.build-id : { *(.note.gnu.build-id) }
40+
.hash : { *(.hash) }
41+
.gnu.hash : { *(.gnu.hash) }
42+
.dynsym : { *(.dynsym) }
43+
.dynstr : { *(.dynstr) }
44+
.gnu.version : { *(.gnu.version) }
45+
.gnu.version_d : { *(.gnu.version_d) }
46+
.gnu.version_r : { *(.gnu.version_r) }
47+
.rela.init : { *(.rela.init) }
48+
.rela.fini : { *(.rela.fini) }
49+
.rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
50+
.rela.data.rel.ro : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
51+
.rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
52+
.rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
53+
.rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
54+
.rela.ctors : { *(.rela.ctors) }
55+
.rela.dtors : { *(.rela.dtors) }
56+
.rela.got : { *(.rela.got) }
57+
.rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
58+
59+
.text :
60+
{
61+
_start_text = .;
62+
*(.text*)
63+
*(.note.*)
64+
. = ALIGN(8);
65+
_end_text = .;
66+
} > OCRAM
67+
68+
.rodata :
69+
{
70+
_rodata_start = .;
71+
*(.rodata)
72+
*(.rodata.*)
73+
. = ALIGN(8);
74+
_rodata_end = .;
75+
} > OCRAM
76+
77+
PROVIDE(_stored_data = .);
78+
79+
.data :
80+
{
81+
_start_data = .;
82+
KEEP(*(.data .data.* .gnu.linkonce.d.*))
83+
. = ALIGN(8);
84+
KEEP(*(.ramcode))
85+
. = ALIGN(8);
86+
_end_data = .;
87+
} > OCRAM
88+
89+
.bss :
90+
{
91+
_start_bss = .;
92+
__bss_start__ = .;
93+
*(.dynbss)
94+
*(.bss .bss.* .gnu.linkonce.b.*)
95+
*(COMMON)
96+
. = ALIGN(8);
97+
_end_bss = .;
98+
__bss_end__ = .;
99+
_end = .;
100+
} > OCRAM
101+
102+
. = ALIGN(16);
103+
.stack :
104+
{
105+
_start_stack = .;
106+
. = . + STACK_SIZE;
107+
_end_stack = .;
108+
} > OCRAM
109+
110+
PROVIDE(_stack_base = .);
111+
}

0 commit comments

Comments
 (0)