Skip to content

Commit f2a12ce

Browse files
committed
Fix CI build errors
1 parent bc95fc5 commit f2a12ce

File tree

12 files changed

+50
-20
lines changed

12 files changed

+50
-20
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,20 @@ jobs:
8787
- name: Download and install RISC-V toolchain (riscv32)
8888
if: ${{ inputs.arch == 'riscv' }}
8989
run: |
90-
wget -q https://github.com/riscv-collab/riscv-gnu-toolchain/releases/latest/download/riscv32-elf-ubuntu-24.04-gcc.tar.xz
91-
tar -xf riscv32-elf-ubuntu-24.04-gcc.tar.xz
90+
wget -q https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2025.01.17/riscv32-elf-ubuntu-24.04-gcc-nightly-2025.01.17-nightly.tar.xz
91+
echo "cc7855191591487a344e142271b6de5c33e07c173a6529dd695aa9dd26a20fff riscv32-elf-ubuntu-24.04-gcc-nightly-2025.01.17-nightly.tar.xz" | sha256sum -c -
92+
tar -xf riscv32-elf-ubuntu-24.04-gcc-nightly-2025.01.17-nightly.tar.xz
9293
echo "$GITHUB_WORKSPACE/riscv/bin" >> $GITHUB_PATH
9394
$GITHUB_WORKSPACE/riscv/bin/riscv32-unknown-elf-gcc --version
9495
95-
- name: Install RISC-V toolchain (riscv64)
96+
- name: Download and install RISC-V toolchain (riscv64)
9697
if: ${{ inputs.arch == 'riscv64' }}
9798
run: |
98-
sudo apt-get install -y gcc-riscv64-unknown-elf binutils-riscv64-unknown-elf
99-
riscv64-unknown-elf-gcc --version
99+
wget -q https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2025.01.17/riscv64-elf-ubuntu-24.04-gcc-nightly-2025.01.17-nightly.tar.xz
100+
echo "a4fa9babf81452e4f7171432276dcbd95faa2cdbefcffe00b920f486ec79e0ea riscv64-elf-ubuntu-24.04-gcc-nightly-2025.01.17-nightly.tar.xz" | sha256sum -c -
101+
tar -xf riscv64-elf-ubuntu-24.04-gcc-nightly-2025.01.17-nightly.tar.xz
102+
echo "$GITHUB_WORKSPACE/riscv/bin" >> $GITHUB_PATH
103+
$GITHUB_WORKSPACE/riscv/bin/riscv64-unknown-elf-gcc --version
100104
101105
# ============================================================
102106
# Build wolfboot

arch.mk

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,16 @@ ifeq ($(ARCH),RISCV)
582582
CFLAGS+=-march=rv32imac$(RISCV32_ZICSR)$(RISCV32_ZIFENCEI) -mabi=ilp32 -mcmodel=medany
583583
# Linking: base march (no extension suffixes) for multilib lookup
584584
LDFLAGS+=-march=rv32imac -mabi=ilp32 -mcmodel=medany
585+
# Some prebuilt toolchains lack rv32imac/ilp32 multilib (only ship the
586+
# default rv32gc/ilp32d). Detect and fall back to -nostdlib with the
587+
# default-multilib libgcc.
588+
RISCV_LINK_TEST := $(shell echo "void _start(void){}" | \
589+
$(CROSS_COMPILE)gcc -march=rv32imac -mabi=ilp32 -nostartfiles \
590+
-x c - -o /dev/null 2>/dev/null && echo ok)
591+
ifneq ($(RISCV_LINK_TEST),ok)
592+
LDFLAGS+=-nostdlib -Wl,--no-warn-mismatch
593+
LIBS+=$(shell $(CROSS_COMPILE)gcc -print-libgcc-file-name)
594+
endif
585595
MATH_OBJS += $(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_c32.o
586596

587597
# Prune unused functions and data
@@ -639,6 +649,14 @@ ifeq ($(ARCH),RISCV64)
639649
# E51 core: rv64imac (no FPU, no crypto extensions)
640650
CFLAGS+=-march=rv64imac$(RISCV64_ZICSR)$(RISCV64_ZIFENCEI) -mabi=lp64 -mcmodel=medany
641651
LDFLAGS+=-march=rv64imac -mabi=lp64 -mcmodel=medany
652+
# Multilib fallback (see RISCV 32-bit section comment)
653+
RISCV_LINK_TEST := $(shell echo "void _start(void){}" | \
654+
$(CROSS_COMPILE)gcc -march=rv64imac -mabi=lp64 -nostartfiles \
655+
-x c - -o /dev/null 2>/dev/null && echo ok)
656+
ifneq ($(RISCV_LINK_TEST),ok)
657+
LDFLAGS+=-nostdlib -Wl,--no-warn-mismatch
658+
LIBS+=$(shell $(CROSS_COMPILE)gcc -print-libgcc-file-name)
659+
endif
642660
else
643661
# U54 cores: rv64gc (with FPU)
644662
CFLAGS+=-march=rv64imafd$(RISCV64_ZICSR)$(RISCV64_ZIFENCEI) -mabi=lp64d -mcmodel=medany

hal/mpfs250.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ int mpfs_read_serial_number(uint8_t *serial)
222222
SCBCTRL_REG(SERVICES_CR_OFFSET) = cmd;
223223

224224
/* Wait for request bit to clear (command accepted) */
225-
timeout = 10000;
225+
timeout = MPFS_SCB_TIMEOUT;
226226
while ((SCBCTRL_REG(SERVICES_CR_OFFSET) & SERVICES_CR_REQ_MASK) && timeout > 0) {
227227
timeout--;
228228
}
@@ -232,7 +232,7 @@ int mpfs_read_serial_number(uint8_t *serial)
232232
}
233233

234234
/* Wait for busy bit to clear (command completed) */
235-
timeout = 10000;
235+
timeout = MPFS_SCB_TIMEOUT;
236236
while (mpfs_scb_mailbox_busy() && timeout > 0) {
237237
timeout--;
238238
}
@@ -1268,6 +1268,8 @@ static void uart_config_baud(unsigned long base, uint32_t baudrate)
12681268
uint32_t div_int = div_x64 / 64u;
12691269
uint32_t div_frac = div_x64 - (div_int * 64u);
12701270
div_frac += (div_x128 - (div_int * 128u)) - (div_frac * 2u);
1271+
if (div_frac > 63u)
1272+
div_frac = 63u;
12711273
if (div_int > (uint32_t)UINT16_MAX)
12721274
return;
12731275
MMUART_LCR(base) |= DLAB_MASK;

hal/mpfs250.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ typedef struct {
295295
volatile uint32_t shared_mem_marker; /* 0x08: Init marker */
296296
volatile uint32_t shared_mem_status; /* 0x0C: Status */
297297
volatile uint64_t* shared_mem; /* 0x10: Shared memory pointer */
298-
volatile uint64_t reserved[2]; /* 0x18: Reserved/padding */
299-
} HLS_DATA; /* 64 bytes */
298+
volatile uint64_t reserved[5]; /* 0x18: Reserved/padding to 64 bytes */
299+
} HLS_DATA; /* 64 bytes total */
300300
#endif /* __ASSEMBLER__ */
301301

302302
#define HLS_MAIN_HART_STARTED 0x12344321UL

hal/nxp_t2080.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
2020
*/
2121
#include <stdint.h>
22+
#include <stddef.h>
2223
#include "target.h"
2324
#include "printf.h"
2425
#include "image.h" /* for RAMFUNCTION */

include/printf.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@
4848

4949
/* support for wolfBoot_printf logging */
5050
#if defined(PRINTF_ENABLED) && !defined(WOLFBOOT_NO_PRINTF)
51-
# include <stdio.h>
51+
# if !defined(DEBUG_UART) && !defined(DEBUG_ZYNQ) && !defined(WOLFBOOT_DEBUG_EFI)
52+
# include <stdio.h>
53+
# endif
5254
# if defined(DEBUG_ZYNQ) && !defined(USE_QNX) && !defined(DEBUG_UART)
5355
# include "xil_printf.h"
5456
# define wolfBoot_printf(_f_, ...) xil_printf(_f_, ##__VA_ARGS__)

src/boot_riscv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ void do_boot(const uint32_t *app_offset)
273273
unsigned long dts_addr;
274274
hal_dts_fixup((uint32_t*)dts_offset);
275275
dts_addr = (unsigned long)dts_offset;
276-
#else
276+
#elif defined(WOLFBOOT_RISCV_MMODE) || __riscv_xlen == 64
277277
unsigned long dts_addr = 0;
278278
#endif
279279

src/boot_riscv_start.S

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,11 @@ _copy_params:
121121
li t0, MIE_MSIE /* wake only on IPI */
122122
csrw mie, t0
123123

124-
/* Set up per-hart stack: base + (hartid+1)*STACK_SIZE_PER_HART */
124+
/* Set up per-hart stack: base + hartid*STACK_SIZE_PER_HART */
125125
csrr a0, mhartid
126126
la t0, _secondary_hart_stack_base
127127
li t1, STACK_SIZE_PER_HART
128-
addi a1, a0, 1
129-
mul t2, a1, t1
128+
mul t2, a0, t1
130129
add sp, t0, t2
131130
li t0, -16
132131
and sp, sp, t0

src/string.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#if defined(_RENESAS_RA_)
3131
#include <stdint.h>
3232
#endif
33-
#ifndef TARGET_library
33+
#if !defined(TARGET_library) && defined(__STDC_HOSTED__) && __STDC_HOSTED__
3434
#include <string.h>
3535
#else
3636
size_t strlen(const char *s); /* forward declaration */
@@ -289,7 +289,7 @@ void RAMFUNCTION *memcpy(void *dst, const void *src, size_t n)
289289
}
290290
#endif /* IAR */
291291

292-
#ifndef __IAR_SYSTEMS_ICC__
292+
#if !defined(__IAR_SYSTEMS_ICC__) && !defined(TARGET_X86_64_EFI)
293293
void *memmove(void *dst, const void *src, size_t n)
294294
{
295295
int i;
@@ -306,7 +306,7 @@ void *memmove(void *dst, const void *src, size_t n)
306306
return memcpy(dst, src, n);
307307
}
308308
}
309-
#endif
309+
#endif /* !IAR && !X86_64_EFI */
310310
#endif /* __CCRX__ Renesas CCRX */
311311
#endif /* WOLFBOOT_USE_STDLIBC */
312312

src/x86/exceptions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ int setup_interrupts()
202202

203203
void deinit_interrupts()
204204
{
205-
idt_descriptor.base = (uintptr_t)NULL;
205+
idt_descriptor.base = (uintptr_t)0;
206206
idt_descriptor.limit = 0xffff;
207207
asm ("cli\r\n");
208208
asm ("lidt %0\r\n" : : "m"(idt_descriptor));

0 commit comments

Comments
 (0)