Skip to content

Commit 1014558

Browse files
committed
Attempt to fix RISC-V CI. Adding the MPFS test script.
1 parent 1c5534e commit 1014558

6 files changed

Lines changed: 1717 additions & 43 deletions

File tree

.gdbinit

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
file wolfboot.elf
22
tar rem:3333
3-
add-symbol-file ../hart-software-services/build/hss-l2scratch.elf
3+
add-symbol-file test-app/image.elf
44
set pagination off
55
foc c
66

7-
set $target_riscv=1
8-
set mem inaccessible-by-default off
9-
set architecture riscv:rv64

.github/workflows/test-configs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ jobs:
1919
with:
2020
arch: riscv
2121
config-file: ./config/examples/hifive1.config
22-
# 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')
23-
# Consider building cached RISCV64 toolchain for this target
22+
# Only building wolfBoot (test-app needs freedom-e-sdk multilib for ilp32d)
2423
make-args: wolfboot.bin
2524

2625
sama5d3_test:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ language.settings.xml
327327

328328
# PolarFire SoC Device Tree Binary
329329
hal/mpfs.dtb
330+
bootmode1/
330331

331332
# Emulator test: generated linker scripts
332333
test-app/emu-test-apps/*/target.ld

arch.mk

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -563,30 +563,24 @@ endif
563563
## RISCV (32-bit)
564564
ifeq ($(ARCH),RISCV)
565565
CROSS_COMPILE?=riscv32-unknown-elf-
566-
# Detect zicsr/zifencei support: GCC 12+ may require these extensions
567-
# explicitly. However, GCC 15 decomposes arch strings (m→zmmul,
568-
# a→zaamo+zalrsc, c→zca) which can break multilib lookup.
569-
# Verify with a link test, not just compile, to catch multilib mismatches.
566+
# GCC 12+ separated _zicsr (CSR instructions) and _zifencei (fence.i)
567+
# from the base "I" extension, requiring them to be listed explicitly in
568+
# the -march string. Detect with compile-only tests (-c).
569+
#
570+
# IMPORTANT: these extensions are added to CFLAGS only (compilation).
571+
# They must NOT appear in LDFLAGS because GCC 15 decomposes the ISA
572+
# string (m→zmmul, a→zaamo+zalrsc, c→zca) producing an expanded
573+
# -march that has no matching multilib, causing a fatal error at
574+
# link time. The base march is multilib-safe for all GCC versions.
570575
RISCV32_ZICSR := $(shell echo "void _start(void){}" | \
571576
$(CROSS_COMPILE)gcc -march=rv32imac_zicsr -mabi=ilp32 -c -x c - -o /dev/null 2>/dev/null && echo _zicsr)
572577
RISCV32_ZIFENCEI := $(shell echo "void _start(void){}" | \
573578
$(CROSS_COMPILE)gcc -march=rv32imac_zifencei -mabi=ilp32 -c -x c - -o /dev/null 2>/dev/null && echo _zifencei)
574-
ifneq ($(RISCV32_ZICSR)$(RISCV32_ZIFENCEI),)
575-
# Link test using 64-bit integer division to force libgcc resolution.
576-
# A trivial void _start(){} never references libgcc, hiding ABI
577-
# mismatches (e.g., GCC 15 falling back to double-float libgcc).
578-
RISCV32_EXT_LINK_OK := $(shell echo 'long long _d(long long a,long long b){return a/b;}void _start(void){_d(0,1);}' | \
579-
$(CROSS_COMPILE)gcc -march=rv32imac$(RISCV32_ZICSR)$(RISCV32_ZIFENCEI) \
580-
-mabi=ilp32 -nostartfiles -x c - -o /dev/null 2>/dev/null && echo ok)
581-
ifneq ($(RISCV32_EXT_LINK_OK),ok)
582-
RISCV32_ZICSR :=
583-
RISCV32_ZIFENCEI :=
584-
endif
585-
endif
586-
ARCH_FLAGS=-march=rv32imac$(RISCV32_ZICSR)$(RISCV32_ZIFENCEI) -mabi=ilp32 -mcmodel=medany
587579
CFLAGS+=-fno-builtin-printf -DUSE_M_TIME -g -nostartfiles -DARCH_RISCV
588-
CFLAGS+=$(ARCH_FLAGS)
589-
LDFLAGS+=$(ARCH_FLAGS)
580+
# Compilation: extended march so assembler accepts CSR/fence.i
581+
CFLAGS+=-march=rv32imac$(RISCV32_ZICSR)$(RISCV32_ZIFENCEI) -mabi=ilp32 -mcmodel=medany
582+
# Linking: base march (no extension suffixes) for multilib lookup
583+
LDFLAGS+=-march=rv32imac -mabi=ilp32 -mcmodel=medany
590584
MATH_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_c32.o
591585

592586
# Prune unused functions and data
@@ -632,30 +626,22 @@ ifeq ($(ARCH),RISCV64)
632626
UPDATE_OBJS?=src/update_ram.o
633627
endif
634628

635-
# Detect zicsr/zifencei support with link verification (see RV32 comment)
629+
# GCC 12+ extension detection (see RISCV 32-bit section above).
630+
# Extensions go in CFLAGS only; LDFLAGS uses the base march to avoid
631+
# GCC 15 multilib lookup failures from ISA string decomposition.
636632
RISCV64_ZICSR := $(shell echo "void _start(void){}" | \
637633
$(CROSS_COMPILE)gcc -march=rv64imafd_zicsr -mabi=lp64d -c -x c - -o /dev/null 2>/dev/null && echo _zicsr)
638634
RISCV64_ZIFENCEI := $(shell echo "void _start(void){}" | \
639635
$(CROSS_COMPILE)gcc -march=rv64imafd_zifencei -mabi=lp64d -c -x c - -o /dev/null 2>/dev/null && echo _zifencei)
640-
ifneq ($(RISCV64_ZICSR)$(RISCV64_ZIFENCEI),)
641-
# Link test using 128-bit integer division to force libgcc resolution.
642-
# A trivial void _start(){} never references libgcc, hiding multilib
643-
# mismatches (e.g., GCC 15 arch decomposition breaking multilib lookup).
644-
RISCV64_EXT_LINK_OK := $(shell echo '__int128 _d(__int128 a,__int128 b){return a/b;}void _start(void){_d(0,1);}' | \
645-
$(CROSS_COMPILE)gcc -march=rv64imafd$(RISCV64_ZICSR)$(RISCV64_ZIFENCEI) \
646-
-mabi=lp64d -nostartfiles -x c - -o /dev/null 2>/dev/null && echo ok)
647-
ifneq ($(RISCV64_EXT_LINK_OK),ok)
648-
RISCV64_ZICSR :=
649-
RISCV64_ZIFENCEI :=
650-
endif
651-
endif
652636

653637
ifeq ($(RISCV_MMODE),1)
654638
# E51 core: rv64imac (no FPU, no crypto extensions)
655-
ARCH_FLAGS=-march=rv64imac$(RISCV64_ZICSR)$(RISCV64_ZIFENCEI) -mabi=lp64 -mcmodel=medany
639+
CFLAGS+=-march=rv64imac$(RISCV64_ZICSR)$(RISCV64_ZIFENCEI) -mabi=lp64 -mcmodel=medany
640+
LDFLAGS+=-march=rv64imac -mabi=lp64 -mcmodel=medany
656641
else
657642
# U54 cores: rv64gc (with FPU)
658-
ARCH_FLAGS=-march=rv64imafd$(RISCV64_ZICSR)$(RISCV64_ZIFENCEI) -mabi=lp64d -mcmodel=medany
643+
CFLAGS+=-march=rv64imafd$(RISCV64_ZICSR)$(RISCV64_ZIFENCEI) -mabi=lp64d -mcmodel=medany
644+
LDFLAGS+=-march=rv64imafd -mabi=lp64d -mcmodel=medany
659645

660646
# FDT support for DDR S-mode (not needed for L2-LIM bare-metal boot)
661647
ifneq ($(MPFS_L2LIM),1)
@@ -664,8 +650,6 @@ ifeq ($(ARCH),RISCV64)
664650
endif
665651
endif
666652
CFLAGS+=-fno-builtin-printf -DUSE_M_TIME -g -nostartfiles -DARCH_RISCV -DARCH_RISCV64
667-
CFLAGS+=$(ARCH_FLAGS)
668-
LDFLAGS+=$(ARCH_FLAGS)
669653

670654
# Prune unused functions and data
671655
CFLAGS +=-ffunction-sections -fdata-sections

config/examples/polarfire_mpfs250_qspi.config

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ SPI_FLASH?=0
5050
# on MSS QSPI pins.
5151
CFLAGS_EXTRA+=-DMPFS_SC_SPI
5252

53-
5453
# Enable SD card temporarily (wolfBoot still loads from SD, apps from QSPI)
5554
# For pure QSPI boot, HSS would need to load wolfBoot from QSPI
5655
DISK_SDCARD?=0
@@ -101,3 +100,10 @@ CFLAGS_EXTRA+=-DWOLFBOOT_SHA_BLOCK_SIZE=4096
101100
# Optional QSPI flash test (erase/write/read on update partition)
102101
# Uncomment to run test during hal_init()
103102
#CFLAGS_EXTRA+=-DTEST_EXT_FLASH
103+
104+
# UART QSPI programmer (disabled by default)
105+
# When enabled, wolfBoot prompts on UART at startup to receive a signed firmware
106+
# image and write it to QSPI flash -- no Libero/JTAG tool required for updates.
107+
# Use: python3 tools/scripts/mpfs_qspi_prog.py <port> <image.bin> [qspi_offset]
108+
# Requires EXT_FLASH=1 (already set) and DEBUG_UART=1.
109+
UART_QSPI_PROGRAM?=0

0 commit comments

Comments
 (0)