Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for LS1028A. Booting into OCRAM app. #306

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,22 @@ ifeq ($(TARGET),nxp_p1021)
SPI_TARGET=nxp
endif

ifeq ($(TARGET),nxp_ls1028a)
ARCH_FLAGS=-mcpu=cortex-a72+crypto -mstrict-align -march=armv8-a+crypto -mtune=cortex-a72
CFLAGS+=$(ARCH_FLAGS) -DCPU_A72 -DTARGET_LS1028A #-DWOLFSSL_ARMASM -DWOLFSSL_NO_HASH_RAW
LDFLAGS+=-Wl,--as-needed -D"__WOLFBOOT"
CFLAGS +=-ffunction-sections -fdata-sections
CFLAGS +=-Ihal/mmu/
LDFLAGS+=-Wl,--gc-sections

#WOLFCRYPT_OBJS += lib/wolfssl/wolfcrypt/src/port/arm/armv8-sha256.o

ifeq ($(DEBUG_UART),0)
CFLAGS+=-fno-builtin-printf
endif
SPI_TARGET=nxp
endif

ifeq ($(TARGET),ti_hercules)
# HALCoGen Source and Include?
CORTEX_R5=1
Expand Down
65 changes: 65 additions & 0 deletions config/examples/nxp-ls1028a.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
ARCH=AARCH64
TARGET=nxp_ls1028a
SIGN?=ECC256
HASH?=SHA256
DEBUG?=1
DEBUG_UART?=1
VTOR?=0
CORTEX_M0?=0
NO_ASM?=0
EXT_FLASH?=1
SPI_FLASH?=0
## Force app to be copied into ram
NO_XIP?=1
UART_FLASH?=0
ALLOW_DOWNGRADE?=0
NVM_FLASH_WRITEONCE?=0
WOLFBOOT_VERSION?=0
V?=0
NO_MPU?=0
SPMATH?=1
RAM_CODE?=0
DUALBANK_SWAP?=0
PKA?=0

WOLFTPM?=1

MEASURED_BOOT?=0
MEASURED_PCR_A?=3

WOLFBOOT_TPM_KEYSTORE?=1
WOLFBOOT_TPM_KEYSTORE_NV_INDEX?=25166336
WOLFBOOT_TPM_POLICY_NV_INDEX?=25166337
WOLFBOOT_TPM_PCR_INDEX?=16

# NOR Base Address
ARCH_FLASH_OFFSET?=0x20000000

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

# wolfBoot start address
WOLFBOOT_ORIGIN=0x20020000

# wolfBoot partition size
BOOTLOADER_PARTITION_SIZE=0x20000

# Application Partition size
WOLFBOOT_PARTITION_SIZE?=0x20000

# Location in Flash for Application Partition
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x20040000

# Load Partition to RAM Address
WOLFBOOT_LOAD_ADDRESS?=0x18020100

# Location in Flash for Update Partition
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x20060000

# Location of temporary sector used during updates
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x20080000

# DTS (Device Tree)
WOLFBOOT_LOAD_DTS_ADDRESS?=0x80000000
WOLFBOOT_DTS_BOOT_ADDRESS?=0x20F00000
WOLFBOOT_DTS_UPDATE_ADDRESS?=0x20F00000
90 changes: 90 additions & 0 deletions docs/Targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This README describes configuration of supported targets.
* [NXP P1021 PPC](#nxp-p1021-ppc)
* [NXP T2080 PPC](#nxp-t2080-ppc)
* [Qemu x86-64 UEFI](#qemu-x86-64-uefi)
* [NXP LS1028A](#nxp-ls1028a)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move up one line to sort with other NXP targets.

* [SiFive HiFive1 RISC-V](#sifive-hifive1-risc-v)
* [STM32F4](#stm32f4)
* [STM32F7](#stm32f7)
Expand Down Expand Up @@ -1528,3 +1529,92 @@ make test-sim-internal-flash-with-update
# it should print 2
./wolfboot.elf success get_version
```

## NXP LS1028A

The LS1028A is a AARCH64 armv8-a Cortex-A72 processor. Support has been tested with the NXP LS1028ARDB.

Example configurations for this target are provided in:
* NXP LS1028A: [/config/examples/nxp-ls1028a.config](/config/examples/nxp-ls1028a.config).

### Building wolfBoot for NXP LS1028A

1. Download `aarch64-none-elf-` toolchain.

2. Copy the example `nxp_ls1028a.cofig` file to root directory and rename to `.config`

3. Build keytools and wolfboot

```
cp ./config/examples/nxp-ls1028a.config .config
make distclean
make keytools
make
```

This should output 3 binary files, `wolfboot.bin`, `image_v1_signed.bin` and `factory.bin`
- `wolfboot.bin` is the wolfboot binary
- `image_v1_signed.bin` is the signed application image and by default is `test-app/app_nxp_ls1028a`
- `factory.bin` is the two binaries merged together


### Hardware Setup LS1028ARDB
DIP Switch Configuraiton for XSPI_NOR_BOOT:
```
SW2 : 0xF8 = 11111000 SW3 : 0x70 = 01110000 SW5 : 0x20 = 00100000
Where '1' = UP/ON
```

UART Configuraiton:
```
Baud Rate: 115200
Data Bits: 8
Parity: None
Stop Bits: 1
Flow Control: None
Specify device type - PC16552D
Configured for UART1 DB9 Connector
```

### Programming NXP LS1028A

Programming requires three components:
1. RCW binary - Distribured by NXP at `https://source.codeaurora.org/external/qoriq/qoriq-components/rcw` or can be generated (tested on `rcw_1300.bin`)
2. Woflboot
3. Applicaiton - Test app found in `/test-app/app_nxp_ls1028a.c`

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
and to sign a custom image.

```
Usage: tools/keytools/sign [options] image key version
```

## Lauterbach Flashing and Debugging

1. Launch lauterbach and open the demo script `debug_wolfboot.cmm`.
2. Open any desired debug windows.
3. Hit the play button on the demo script.
4. It should pop up with a code window and at the reset startpoint. (May requrie a reset or power cycle)

```
./t32/bin/macosx64/t32marm-qt

Open Script > debug_wolfboot.cmm
```

You can modify the Lauterbach NOR flash demo or use `debug_wolfboot.cmm` script, just make sure the flash offset for
the RCW is `0x0` and the address offset for wolboot is `0x1000`.


## Other Tools

1. Make sure the memory addresses are alinged with the `.config` file.
2. Note the important NOR flash addresses in the defualt config are as follows.
3. RCW location is offset `0x0` or `0x20000000` memory mapped.
4. Wolfboot location is offset `0x1000` or `0x20001000` where wolfboot starts.
5. Application location is offset `0x20000` or `0x20020000` where application code goes.
6. Update location is offset `0x40000` or `0x20040000` where the new or updated applciaiton goes.
7. Load Location is `0x18020100` which is OCRAM or where the applciaiton code is loaded if using RAM loading from
8. DTS Location is
9. Update memory locations as neeeded.
2 changes: 1 addition & 1 deletion docs/measured_boot.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ To enable measured boot add `MEASURED_BOOT=1` setting in your wolfBoot config.

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

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

Expand Down
Loading
Loading