Skip to content

Commit e154972

Browse files
committed
Fix issues with CI RISC-V build
1 parent 9b3b7e5 commit e154972

2 files changed

Lines changed: 26 additions & 19 deletions

File tree

.github/workflows/test-build-riscv.yml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,30 @@ jobs:
8080
- name: Update repository
8181
run: sudo apt-get update -o Acquire::Retries=3
8282

83-
- name: Download and install RISC-V toolchains
83+
# ============================================================
84+
# Prebuilt RISC-V toolchains from riscv-collab
85+
# https://github.com/riscv-collab/riscv-gnu-toolchain/releases
86+
# Extracts to: riscv/bin/riscv{32,64}-unknown-elf-*
87+
# ============================================================
88+
- name: Download and install RISC-V toolchain (riscv32)
8489
if: ${{ inputs.arch == 'riscv' }}
8590
run: |
86-
# Download SiFive prebuilt toolchain with newlib
87-
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
88-
tar xzf riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz
89-
echo "$GITHUB_WORKSPACE/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin" >> $GITHUB_PATH
90-
91-
# Download latest prebuilt RISC-V toolchains
92-
#wget -q https://github.com/RISCV-Tools/riscv-gnu-toolchain/releases/latest/download/riscv32-elf-ubuntu-24.04-gcc.tar.xz
93-
#tar -xf riscv32-elf-ubuntu-24.04-gcc.tar.xz
94-
#echo "$GITHUB_WORKSPACE/riscv/bin" >> $GITHUB_PATH
91+
wget -q https://github.com/riscv-collab/riscv-gnu-toolchain/releases/latest/download/riscv32-elf-ubuntu-24.04-gcc.tar.xz
92+
tar -xf riscv32-elf-ubuntu-24.04-gcc.tar.xz
93+
echo "$GITHUB_WORKSPACE/riscv/bin" >> $GITHUB_PATH
94+
$GITHUB_WORKSPACE/riscv/bin/riscv32-unknown-elf-gcc --version
9595
96-
- name: Download and install RISC-V toolchains
96+
- name: Download and install RISC-V toolchain (riscv64)
9797
if: ${{ inputs.arch == 'riscv64' }}
9898
run: |
99-
wget -q https://github.com/RISCV-Tools/riscv-gnu-toolchain/releases/latest/download/riscv64-elf-ubuntu-24.04-gcc.tar.xz
99+
wget -q https://github.com/riscv-collab/riscv-gnu-toolchain/releases/latest/download/riscv64-elf-ubuntu-24.04-gcc.tar.xz
100100
tar -xf riscv64-elf-ubuntu-24.04-gcc.tar.xz
101101
echo "$GITHUB_WORKSPACE/riscv/bin" >> $GITHUB_PATH
102+
$GITHUB_WORKSPACE/riscv/bin/riscv64-unknown-elf-gcc --version
102103
104+
# ============================================================
105+
# Build wolfboot
106+
# ============================================================
103107
- name: make clean
104108
run: |
105109
make distclean
@@ -115,10 +119,9 @@ jobs:
115119
- name: Build wolfboot (riscv32)
116120
if: ${{ inputs.arch == 'riscv' }}
117121
run: |
118-
# using riscv64 for now since riscv32-unknown-elf- is missing "zicsr" extension
119-
make CROSS_COMPILE=riscv64-unknown-elf- FREEDOM_E_SDK=$GITHUB_WORKSPACE/freedom-e-sdk ${{inputs.make-args}}
122+
make CROSS_COMPILE=riscv32-unknown-elf- FREEDOM_E_SDK=$GITHUB_WORKSPACE/freedom-e-sdk ${{inputs.make-args}}
120123
121-
- name: Build wolfboot (riscv64))
124+
- name: Build wolfboot (riscv64)
122125
if: ${{ inputs.arch == 'riscv64' }}
123126
run: |
124127
make CROSS_COMPILE=riscv64-unknown-elf- ${{inputs.make-args}}

arch.mk

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,10 @@ endif
564564
ifeq ($(ARCH),RISCV)
565565
CROSS_COMPILE?=riscv32-unknown-elf-
566566
# GCC 12+ requires explicit zicsr/zifencei extensions
567-
RISCV32_ZICSR := $(shell echo "" | $(CC) -march=rv32imac_zicsr -x c -c - -o /dev/null 2>/dev/null && echo _zicsr)
568-
RISCV32_ZIFENCEI := $(shell echo "" | $(CC) -march=rv32imac_zifencei -x c -c - -o /dev/null 2>/dev/null && echo _zifencei)
567+
# Note: use $(CROSS_COMPILE)gcc directly because CC is not yet defined
568+
# at this point in the Makefile (it's set later in the USE_GCC block).
569+
RISCV32_ZICSR := $(shell echo "" | $(CROSS_COMPILE)gcc -march=rv32imac_zicsr -x c -c - -o /dev/null 2>/dev/null && echo _zicsr)
570+
RISCV32_ZIFENCEI := $(shell echo "" | $(CROSS_COMPILE)gcc -march=rv32imac_zifencei -x c -c - -o /dev/null 2>/dev/null && echo _zifencei)
569571
ARCH_FLAGS=-march=rv32imac$(RISCV32_ZICSR)$(RISCV32_ZIFENCEI) -mabi=ilp32 -mcmodel=medany
570572
CFLAGS+=-fno-builtin-printf -DUSE_M_TIME -g -nostartfiles -DARCH_RISCV
571573
CFLAGS+=$(ARCH_FLAGS)
@@ -610,8 +612,10 @@ ifeq ($(ARCH),RISCV64)
610612

611613
# GCC 12+ / binutils 2.38+ split CSR and fence.i instructions into
612614
# separate extensions (zicsr, zifencei). Detect and add if supported.
613-
RISCV64_ZICSR := $(shell echo "" | $(CC) -march=rv64imac_zicsr -x c -c - -o /dev/null 2>/dev/null && echo _zicsr)
614-
RISCV64_ZIFENCEI := $(shell echo "" | $(CC) -march=rv64imac_zifencei -x c -c - -o /dev/null 2>/dev/null && echo _zifencei)
615+
# Note: use $(CROSS_COMPILE)gcc directly because CC is not yet defined
616+
# at this point in the Makefile (it's set later in the USE_GCC block).
617+
RISCV64_ZICSR := $(shell echo "" | $(CROSS_COMPILE)gcc -march=rv64imac_zicsr -x c -c - -o /dev/null 2>/dev/null && echo _zicsr)
618+
RISCV64_ZIFENCEI := $(shell echo "" | $(CROSS_COMPILE)gcc -march=rv64imac_zifencei -x c -c - -o /dev/null 2>/dev/null && echo _zifencei)
615619

616620
ifeq ($(RISCV_MMODE),1)
617621
# E51 core: rv64imac (no FPU, no crypto extensions)

0 commit comments

Comments
 (0)