Skip to content

Commit 49fe8cd

Browse files
committed
Support for Microchip PolarFire SoC (MPFS250)
1 parent 5ea3de1 commit 49fe8cd

File tree

20 files changed

+2282
-2
lines changed

20 files changed

+2282
-2
lines changed

.github/workflows/test-configs.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ jobs:
184184
arch: arm
185185
config-file: ./config/examples/mcxw.config
186186

187+
# TODO: polarfire_mpfs250.config requires PolarFire SoC SDK
188+
#polarfire_mpfs250_test:
189+
# uses: ./.github/workflows/test-build-mcux-sdk.yml
190+
# with:
191+
# arch: riscv64
192+
# config-file: ./config/examples/polarfire_mpfs250.config
193+
187194
raspi3_test:
188195
uses: ./.github/workflows/test-build.yml
189196
with:

arch.mk

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,37 @@ ifeq ($(ARCH),RISCV)
557557
ARCH_FLASH_OFFSET=0x20010000
558558
endif
559559

560+
## RISCV64
561+
ifeq ($(ARCH),RISCV64)
562+
CROSS_COMPILE?=riscv64-unknown-elf-
563+
CFLAGS+=-DMMU -DWOLFBOOT_DUALBOOT
564+
UPDATE_OBJS:=src/update_ram.o
565+
ARCH_FLAGS=-march=rv64imafdc -mabi=lp64d -mcmodel=medany
566+
CFLAGS+=-fno-builtin-printf -DUSE_M_TIME -g -nostartfiles -DARCH_RISCV64
567+
CFLAGS+=$(ARCH_FLAGS)
568+
LDFLAGS+=$(ARCH_FLAGS)
569+
570+
# Prune unused functions and data
571+
CFLAGS +=-ffunction-sections -fdata-sections
572+
LDFLAGS+=-Wl,--gc-sections
573+
574+
OBJS+=src/boot_riscv64_start.o src/boot_riscv64.o src/vector_riscv64.o
575+
ARCH_FLASH_OFFSET=0x20220000
576+
577+
OBJS+=src/fdt.o
578+
579+
ifeq ($(SPMATH),1)
580+
MATH_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_c64.o
581+
endif
582+
583+
ifneq ($(NO_ASM),1)
584+
MATH_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-sha256.o \
585+
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-sha512.o \
586+
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-sha3.o \
587+
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-aes.o
588+
endif
589+
endif
590+
560591
# powerpc
561592
ifeq ($(ARCH),PPC)
562593
CROSS_COMPILE?=powerpc-linux-gnu-
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
ARCH?=RISCV64
2+
TARGET?=mpfs250
3+
SIGN?=ECC384
4+
HASH?=SHA384
5+
IMAGE_HEADER_SIZE=512
6+
WOLFBOOT_VERSION?=1
7+
ARMORED?=0
8+
DEBUG?=0
9+
DEBUG_SYMBOLS?=1
10+
DEBUG_UART?=1
11+
VTOR?=1
12+
EXT_FLASH?=1
13+
SPI_FLASH?=0
14+
NO_XIP?=1
15+
NVM_FLASH_WRITEONCE?=0
16+
UART_FLASH?=0
17+
V?=0
18+
NO_MPU?=1
19+
RAM_CODE?=0
20+
SPMATH?=1
21+
DUALBANK_SWAP?=0
22+
PKA?=0
23+
ENCRYPT=0
24+
WOLFTPM?=0
25+
26+
# Optionally allow downgrade to older valid version in update partition
27+
ALLOW_DOWNGRADE?=0
28+
29+
# Use assembly version of ECDSA and SHA
30+
NO_ASM?=0
31+
NO_ARM_ASM?=0
32+
33+
# Optional: Use smaller SHA512
34+
#CFLAGS_EXTRA+=-DUSE_SLOW_SHA512
35+
36+
# Flash sector size (4KB typical)
37+
WOLFBOOT_SECTOR_SIZE?=0x1000
38+
39+
# Load Partition to RAM Address
40+
WOLFBOOT_LOAD_ADDRESS?=0xA0000000
41+
42+
# Partition layout for PolarFire SoC MPFS250T
43+
# TODO: Update with actual flash layout based on your system design
44+
WOLFBOOT_PARTITION_SIZE?=0x10000
45+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x08080000
46+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x08090000
47+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x080FF000
48+
49+
# DTS (Device Tree)
50+
WOLFBOOT_LOAD_DTS_ADDRESS?=0x80000000
51+
WOLFBOOT_DTS_BOOT_ADDRESS?=0x20F00000
52+
WOLFBOOT_DTS_UPDATE_ADDRESS?=0x20F00000
53+
54+
#CFLAGS_EXTRA+=-DDEBUG_EXT_FLASH

docs/Targets.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This README describes configuration of supported targets.
1212
* [Kontron VX3060-S2](#kontron-vx3060-s2)
1313
* [Microchip PIC32CK](#microchip-pic32ck)
1414
* [Microchip PIC32CZ](#microchip-pic32cz)
15+
* [Microchip PolarFire SoC](#microchip-polarfire-soc)
1516
* [Microchip SAMA5D3](#microchip-sama5d3)
1617
* [Microchip SAME51](#microchip-same51)
1718
* [Nordic nRF52840](#nordic-nrf52840)
@@ -778,6 +779,110 @@ add-symbol-file test-app/image.elf 0x20020100
778779
```
779780

780781

782+
## Microchip PolarFire SoC
783+
784+
The PolarFire SoC is a 64-bit RISC-V SoC featuring a five-core CPU cluster (1× E51 monitor core and 4× U54 application cores) and FPGA fabric. Tested with MPFS250.
785+
786+
### Features
787+
* RISC-V 64-bit architecture (rv64imac)
788+
* Five-core CPU: 1× E51 monitor + 4× U54 application cores
789+
* Integrated DDR3/4, LPDDR3/4 controller and PHY
790+
* PCIe Gen2, USB 2.0, and Gigabit Ethernet interfaces
791+
* Secure boot capabilities
792+
* Low power consumption
793+
* External flash support
794+
795+
### Building PolarFire SoC
796+
797+
All build settings come from .config file. For this platform use `TARGET=mpfs250` and `ARCH=RISCV64`.
798+
799+
See example configuration at `config/examples/polarfire_mpfs250.config`.
800+
801+
```sh
802+
cp config/examples/polarfire_mpfs250.config .config
803+
make wolfboot.elf
804+
```
805+
806+
To assemble this as a flashable image you need the 0x100 byte HART header added:
807+
808+
```sh
809+
git clone https://github.com/polarfire-soc/hart-software-services.git
810+
cd hart-software-services
811+
cd tools/hss-payload-generator
812+
make
813+
# install tool
814+
sudo cp hss-payload-generator /usr/local/bin/
815+
```
816+
817+
Use this command to assemble a bootable wolfboot image:
818+
819+
```sh
820+
hss-payload-generator -vvv -c ./hal/mpfs.yaml wolfboot.bin
821+
```
822+
823+
Any customizations to the Device Tree can be made in mpfs.dts and it can be recompiled using: `dtc -I dts -O dtb mpfs.dts -o mpfs.dtb`
824+
825+
826+
Example one-shot command:
827+
828+
```sh
829+
cp ./config/examples/polarfire_mpfs250.config .config && make clean && make wolfboot.elf && size wolfboot.elf && hss-payload-generator -vvv -c ./hal/mpfs.yaml wolfboot.bin && file wolfboot.bin && ls -la wolfboot.bin
830+
```
831+
832+
### Flashing PolarFire SoC
833+
834+
835+
The HSS MMC boot source looks for GPT with GUID "21686148-6449-6E6F-744E-656564454649" or sector "0" if no GPT found. That GUID is the default "BIOS" boot partition.
836+
837+
The resulting image from `hss-payload-generator` can be directly placed into GPT BIOS partition. The HSS tinyCLI supports the `USBDMSC` command to mount the eMMC or SD card as a USB device. You can then use "dd" to copy the boot image to the BOOT partition 2. Example:
838+
839+
```
840+
sudo dd if=wolfboot.bin of=/dev/sde2 bs=1024
841+
```
842+
843+
Flashing to eNVM:
844+
845+
The boot rom expects a 0x100 byte secure boot header added. It also requires the .ld is offset by 0x100 to leave room for this. The mpfsBootmodeProgrammer adds 0x100 of meta information for secure boot.
846+
847+
```sh
848+
$SC_INSTALL_DIR/eclipse/jre/bin/java -jar \
849+
$SC_INSTALL_DIR/extras/mpfs/mpfsBootmodeProgrammer.jar \
850+
--bootmode 1 --die MPFS250T --package FCVG484 --workdir $PWD wolfboot.elf
851+
```
852+
Note: wolfBoot does not support running from eNVM in machine mode yet.
853+
854+
### Debugging PolarFire Soc
855+
856+
Start GDB server:
857+
858+
```sh
859+
$SC_INSTALL_DIR/openocd/bin/openocd --command "set DEVICE MPFS" --file board/microsemi-riscv.cfg
860+
```
861+
862+
Start GDB Client: `riscv64-unknown-elf-gdb`
863+
864+
```
865+
file wolfboot.elf
866+
tar rem:3333
867+
add-symbol-file ../hart-software-services/build/hss-l2scratch.elf
868+
set pagination off
869+
foc c
870+
871+
set $target_riscv=1
872+
set mem inaccessible-by-default off
873+
set architecture riscv:rv64
874+
#load wolfboot.elf
875+
#thread apply 2 set $pc=_reset
876+
#thread apply all set $pc=_start
877+
```
878+
879+
### PolarFire TODO
880+
881+
1) Add support for full HSS replacement using wolfboot.
882+
2) Add support for eMMC and QSPI NOR flash
883+
884+
885+
781886
## STM32F7
782887

783888
The STM32-F76x and F77x offer dual-bank hardware-assisted swapping.

hal/mpfs.dtb

19.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)