Skip to content
Merged
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
26 changes: 23 additions & 3 deletions .github/workflows/test-build-riscv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
submodules: true

- uses: actions/checkout@v4
if: ${{ inputs.arch == 'riscv' }}
with:
repository: sifive/freedom-e-sdk
path: freedom-e-sdk
Expand Down Expand Up @@ -79,13 +80,26 @@ jobs:
- name: Update repository
run: sudo apt-get update -o Acquire::Retries=3

- name: Download and install SiFive RISC-V toolchain
- name: Download and install RISC-V toolchains
if: ${{ inputs.arch == 'riscv' }}
run: |
# Download SiFive prebuilt toolchain with newlib
wget -q https://static.dev.sifive.com/dev-tools/freedom-tools/v2020.12/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz
tar xzf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz
echo "$GITHUB_WORKSPACE/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin" >> $GITHUB_PATH

# Download latest prebuilt RISC-V toolchains
#wget -q https://github.com/RISCV-Tools/riscv-gnu-toolchain/releases/latest/download/riscv32-elf-ubuntu-24.04-gcc.tar.xz
#tar -xf riscv32-elf-ubuntu-24.04-gcc.tar.xz
#echo "$GITHUB_WORKSPACE/riscv/bin" >> $GITHUB_PATH

- name: Download and install RISC-V toolchains
if: ${{ inputs.arch == 'riscv64' }}
run: |
wget -q https://github.com/RISCV-Tools/riscv-gnu-toolchain/releases/latest/download/riscv64-elf-ubuntu-24.04-gcc.tar.xz
tar -xf riscv64-elf-ubuntu-24.04-gcc.tar.xz
echo "$GITHUB_WORKSPACE/riscv/bin" >> $GITHUB_PATH

- name: make clean
run: |
make distclean
Expand All @@ -98,7 +112,13 @@ jobs:
run: |
make -C tools/keytools && make -C tools/bin-assemble

- name: Build wolfboot
- name: Build wolfboot (riscv32)
if: ${{ inputs.arch == 'riscv' }}
run: |
make FREEDOM_E_SDK=$GITHUB_WORKSPACE/freedom-e-sdk CROSS_COMPILE=riscv64-unknown-elf- ${{inputs.make-args}}
# using riscv64 for now since riscv32-unknown-elf- is missing "zicsr" extension
make CROSS_COMPILE=riscv64-unknown-elf- FREEDOM_E_SDK=$GITHUB_WORKSPACE/freedom-e-sdk ${{inputs.make-args}}

- name: Build wolfboot (riscv64))
if: ${{ inputs.arch == 'riscv64' }}
run: |
make CROSS_COMPILE=riscv64-unknown-elf- ${{inputs.make-args}}
12 changes: 12 additions & 0 deletions .github/workflows/test-configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
with:
arch: riscv
config-file: ./config/examples/hifive1.config
# Only building wolfBoot - not test app for now (cross compiler cannot find suitable multilib set for '-march=rv32imafdc_zicsr_zmmul_zaamo_zalrsc_zca_zcd_zcf'/'-mabi=ilp32d')
# Consider building cached RISCV64 toolchain for this target
make-args: wolfboot.bin

sama5d3_test:
uses: ./.github/workflows/test-build.yml
Expand Down Expand Up @@ -207,6 +210,15 @@ jobs:
arch: arm
config-file: ./config/examples/mcxw-tz.config

microchip_mpfs250_test:
uses: ./.github/workflows/test-build-riscv.yml
with:
arch: riscv64
config-file: ./config/examples/polarfire_mpfs250.config
# Only building wolfBoot - not test app for now (cross compiler cannot find suitable multilib set for '-march=rv64imafd_zicsr_zmmul_zaamo_zalrsc'/'-mabi=lp64d')
# Consider building cached RISCV64 toolchain for this target
make-args: wolfboot.bin

raspi3_test:
uses: ./.github/workflows/test-build.yml
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* wolfBoot is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* wolfBoot is distributed in the hope that it will be useful,
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ line-count-nrf52:
cloc --force-lang-def cloc_lang_def.txt src/boot_arm.c src/image.c src/libwolfboot.c src/loader.c src/update_flash.c hal/nrf52.c

line-count-x86:
cloc --force-lang-def cloc_lang_def.txt src/boot_x86_fsp.c src/boot_x86_fsp_payload.c src/boot_x86_fsp_start.S src/image.c src/keystore.c src/libwolfboot.c src/loader.c src/string.c src/update_disk.c src/x86/ahci.c src/x86/ata.c src/x86/common.c src/x86/gpt.c src/x86/hob.c src/pci.c src/x86/tgl_fsp.c hal/x86_fsp_tgl.c hal/x86_uart.c
cloc --force-lang-def cloc_lang_def.txt src/boot_x86_fsp.c src/boot_x86_fsp_payload.c src/boot_x86_fsp_start.S src/image.c src/keystore.c src/libwolfboot.c src/loader.c src/string.c src/update_disk.c src/gpt.c src/x86/ahci.c src/x86/ata.c src/x86/common.c src/disk.c src/x86/hob.c src/pci.c src/x86/tgl_fsp.c hal/x86_fsp_tgl.c hal/x86_uart.c

stack-usage: wolfboot.bin
$(Q)echo $(STACK_USAGE) > .stack_usage
Expand Down
52 changes: 46 additions & 6 deletions arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,10 @@ endif
## RISCV
ifeq ($(ARCH),RISCV)
CROSS_COMPILE?=riscv32-unknown-elf-
CFLAGS+=-fno-builtin-printf -DUSE_M_TIME -g -march=rv32imac -mabi=ilp32 -mcmodel=medany -nostartfiles -DARCH_RISCV
LDFLAGS+=-march=rv32imac -mabi=ilp32 -mcmodel=medany
ARCH_FLAGS=-march=rv32imac -mabi=ilp32 -mcmodel=medany
CFLAGS+=-fno-builtin-printf -DUSE_M_TIME -g -nostartfiles -DARCH_RISCV
CFLAGS+=$(ARCH_FLAGS)
LDFLAGS+=$(ARCH_FLAGS)
MATH_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_c32.o

# Prune unused functions and data
Expand All @@ -557,6 +559,41 @@ ifeq ($(ARCH),RISCV)
ARCH_FLASH_OFFSET=0x20010000
endif

## RISCV64
ifeq ($(ARCH),RISCV64)
CROSS_COMPILE?=riscv64-unknown-elf-
CFLAGS+=-DMMU -DWOLFBOOT_DUALBOOT
CFLAGS+=-DWOLFBOOT_UPDATE_DISK -DMAX_DISKS=1
UPDATE_OBJS:=src/update_disk.o
OBJS += src/gpt.o
OBJS += src/disk.o
ARCH_FLAGS=-march=rv64imafd -mabi=lp64d -mcmodel=medany
CFLAGS+=-fno-builtin-printf -DUSE_M_TIME -g -nostartfiles -DARCH_RISCV64
CFLAGS+=$(ARCH_FLAGS)
LDFLAGS+=$(ARCH_FLAGS)

# Prune unused functions and data
CFLAGS +=-ffunction-sections -fdata-sections
LDFLAGS+=-Wl,--gc-sections

OBJS+=src/boot_riscv64_start.o src/boot_riscv64.o src/vector_riscv64.o

CFLAGS+=-DWOLFBOOT_FDT
OBJS+=src/fdt.o

ifeq ($(SPMATH),1)
MATH_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_c64.o
endif

ifneq ($(NO_ASM),1)
CFLAGS+=-DWOLFSSL_RISCV_ASM
MATH_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-sha256.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-sha512.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-sha3.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/riscv/riscv-64-aes.o
endif
endif

# powerpc
ifeq ($(ARCH),PPC)
CROSS_COMPILE?=powerpc-linux-gnu-
Expand Down Expand Up @@ -815,7 +852,7 @@ ifeq ($(TARGET),nxp_t1024)
ARCH_FLAGS=-mhard-float -mcpu=e5500
CFLAGS+=$(ARCH_FLAGS)
BIG_ENDIAN=1
CFLAGS+=-DMMU -DWOLFBOOT_DUALBOOT
CFLAGS+=-DMMU -DWOLFBOOT_FDT -DWOLFBOOT_DUALBOOT
CFLAGS+=-pipe # use pipes instead of temp files
CFLAGS+=-feliminate-unused-debug-types
LDFLAGS+=$(ARCH_FLAGS)
Expand All @@ -836,7 +873,7 @@ ifeq ($(TARGET),nxp_t2080)
ARCH_FLAGS=-mhard-float -mcpu=e6500
CFLAGS+=$(ARCH_FLAGS)
BIG_ENDIAN=1
CFLAGS+=-DMMU -DWOLFBOOT_DUALBOOT
CFLAGS+=-DMMU -DWOLFBOOT_FDT -DWOLFBOOT_DUALBOOT
CFLAGS+=-pipe # use pipes instead of temp files
CFLAGS+=-feliminate-unused-debug-types
LDFLAGS+=$(ARCH_FLAGS)
Expand Down Expand Up @@ -1012,6 +1049,8 @@ ifeq ("${FSP}", "1")
LD_START_GROUP =
LD_END_GROUP =
LD := ld
# load to address in RAM after wolfBoot (aligned to 16 bytes)
CFLAGS+=-DWOLFBOOT_NO_LOAD_ADDRESS
ifeq ($(filter-out $(STAGE1),1),)
# building stage1
ifeq ($(FSP_TGL), 1)
Expand Down Expand Up @@ -1079,7 +1118,8 @@ ifeq ("${FSP}", "1")
CFLAGS+=-DWOLFBOOT_USE_PCI
OBJS += src/x86/ahci.o
OBJS += src/x86/ata.o
OBJS += src/x86/gpt.o
OBJS += src/gpt.o
OBJS += src/disk.o
OBJS += src/x86/mptable.o
OBJS += src/stage2_params.o
OBJS += src/x86/exceptions.o
Expand Down Expand Up @@ -1339,7 +1379,7 @@ BOOT_IMG?=test-app/image.bin

## Update mechanism
ifeq ($(ARCH),AARCH64)
CFLAGS+=-DMMU -DWOLFBOOT_DUALBOOT
CFLAGS+=-DMMU -DWOLFBOOT_FDT -DWOLFBOOT_DUALBOOT
OBJS+=src/fdt.o
UPDATE_OBJS:=src/update_ram.o
else
Expand Down
64 changes: 64 additions & 0 deletions config/examples/polarfire_mpfs250.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
ARCH?=RISCV64
TARGET?=mpfs250
SIGN?=ECC384
HASH?=SHA384
IMAGE_HEADER_SIZE=512
WOLFBOOT_VERSION?=1
ARMORED?=0
DEBUG?=0
DEBUG_SYMBOLS?=1
DEBUG_UART?=1
VTOR?=1
EXT_FLASH?=0
SPI_FLASH?=0
NO_XIP?=1
NVM_FLASH_WRITEONCE?=0
UART_FLASH?=0
V?=0
NO_MPU?=1
RAM_CODE?=0
SPMATH?=1
DUALBANK_SWAP?=0
PKA?=0
ENCRYPT=0
WOLFTPM?=0
ELF?=1
#DEBUG_ELF?=1

# Optionally allow downgrade to older valid version in update partition
ALLOW_DOWNGRADE?=0

# Use RISC-V assembly version of ECDSA and SHA
NO_ASM?=0
NO_ARM_ASM?=0
# Optional: Use smaller SHA512
#CFLAGS_EXTRA+=-DUSE_SLOW_SHA512

# DDR Address for wolfBoot to start from
WOLFBOOT_ORIGIN?=0x80000000

# Flash sector size (4KB typical)
WOLFBOOT_SECTOR_SIZE?=0x1000

# Load Partition to RAM Address
WOLFBOOT_LOAD_ADDRESS?=0x8E000000

# Partition layout for PolarFire SoC MPFS250T
# Using update_disk loader we just need to specify the partition number or A/B
WOLFBOOT_NO_PARTITIONS=1
CFLAGS_EXTRA+=-DBOOT_PART_A=1
CFLAGS_EXTRA+=-DBOOT_PART_B=2
# Speed up disk partition read (1MB chunks)
CFLAGS_EXTRA+=-DDISK_BLOCK_SIZE=0x100000

# DTS (Device Tree)
WOLFBOOT_LOAD_DTS_ADDRESS?=0x8A000000

# Optional EMMC_SD debugging logs
#CFLAGS_EXTRA+=-DDEBUG_MMC
# Optional disk debugging logs
#CFLAGS_EXTRA+=-DDEBUG_DISK

# Used by test-application for ELF
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x80200000
WOLFBOOT_PARTITION_SIZE=0x4000000
1 change: 0 additions & 1 deletion config/examples/raspi3-encrypted.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ WOLFBOOT_PARTITION_SWAP_ADDRESS=0xFFFFFFFF
WOLFBOOT_PARTITION_SIZE=0x1000000
WOLFBOOT_SECTOR_SIZE=0x400
EXT_FLASH=0
MMU=1
ENCRYPT=1
NO_XIP=1
ENCRYPT_WITH_AES256=1
Expand Down
Loading