File tree Expand file tree Collapse file tree 4 files changed +17
-10
lines changed
Expand file tree Collapse file tree 4 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -563,7 +563,10 @@ endif
563563# # RISCV (32-bit)
564564ifeq ($(ARCH ) ,RISCV)
565565 CROSS_COMPILE? =riscv32-unknown-elf-
566- ARCH_FLAGS=-march =rv32imac -mabi=ilp32 -mcmodel=medany
566+ # 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)
569+ ARCH_FLAGS=-march =rv32imac$(RISCV32_ZICSR )$(RISCV32_ZIFENCEI ) -mabi=ilp32 -mcmodel=medany
567570 CFLAGS+ =-fno-builtin-printf -DUSE_M_TIME -g -nostartfiles -DARCH_RISCV
568571 CFLAGS+ =$(ARCH_FLAGS )
569572 LDFLAGS+ =$(ARCH_FLAGS )
@@ -605,12 +608,17 @@ ifeq ($(ARCH),RISCV64)
605608 UPDATE_OBJS? =src/update_ram.o
606609 endif
607610
611+ # GCC 12+ / binutils 2.38+ split CSR and fence.i instructions into
612+ # 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+
608616 ifeq ($(RISCV_MMODE),1)
609617 # E51 core: rv64imac (no FPU, no crypto extensions)
610- ARCH_FLAGS=-march =rv64imac -mabi=lp64 -mcmodel=medany
618+ ARCH_FLAGS=-march =rv64imac$( RISCV64_ZICSR )$( RISCV64_ZIFENCEI ) -mabi=lp64 -mcmodel=medany
611619 else
612620 # U54 cores: rv64gc (with FPU)
613- ARCH_FLAGS=-march =rv64imafd -mabi=lp64d -mcmodel=medany
621+ ARCH_FLAGS=-march =rv64imafd$( RISCV64_ZICSR )$( RISCV64_ZIFENCEI ) -mabi=lp64d -mcmodel=medany
614622
615623 # FDT support required
616624 CFLAGS+ =-DWOLFBOOT_FDT
Original file line number Diff line number Diff line change 8383#define MODE_PREFIX (__suffix ) s##__suffix
8484#endif
8585
86-
87-
8886/* ============================================================================
8987 * CSR Access Macros
9088 * ============================================================================ */
Original file line number Diff line number Diff line change @@ -419,7 +419,7 @@ void do_boot(const uint32_t *app_offset)
419419#endif
420420#ifdef MMU
421421 unsigned long dts_addr ;
422- #else
422+ #elif __riscv_xlen == 64
423423 unsigned long dts_addr = 0 ;
424424#endif
425425
Original file line number Diff line number Diff line change @@ -63,11 +63,12 @@ _reset:
6363 * 5. Handle multi-hart (E51 runs, U54s park in WFI)
6464 * ======================================================================== */
6565
66- #if 0 //def TARGET_mpfs250
66+ /* Early UART initialization for M-mode boot on MPFS.
67+ * Intentionally disabled: only needed for low-level bring-up debug
68+ * to enable serial output before C runtime is available.
69+ * To re-enable, change the guard to `#ifdef TARGET_mpfs250`. */
70+ #if 0
6771 /*
68- * Early UART initialization for M-mode boot on MPFS.
69- * This enables debug output during the boot sequence.
70- */
7172 li t0, 0x20000000 /* UART0 base */
7273 li t1, 0x20002000 /* SYSREG_BASE */
7374 /* Enable UART0 clock */
You can’t perform that action at this time.
0 commit comments