Skip to content

Commit 609fd81

Browse files
dgarskedanielinux
authored andcommitted
Fixes for PolarFire SoC eMMC/SD to stabilize and add read DMA support. Refactor the RISC-V boot/vector code for use on both 32-bit and 64-bit architectures.
1 parent e02d38b commit 609fd81

File tree

14 files changed

+1100
-549
lines changed

14 files changed

+1100
-549
lines changed

arch.mk

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ ifeq ($(ARCH),RENESAS_RX)
542542
endif
543543

544544

545-
## RISCV
545+
## RISCV (32-bit)
546546
ifeq ($(ARCH),RISCV)
547547
CROSS_COMPILE?=riscv32-unknown-elf-
548548
ARCH_FLAGS=-march=rv32imac -mabi=ilp32 -mcmodel=medany
@@ -555,11 +555,12 @@ ifeq ($(ARCH),RISCV)
555555
CFLAGS +=-ffunction-sections -fdata-sections
556556
LDFLAGS+=-Wl,--gc-sections
557557

558-
OBJS+=src/boot_riscv.o src/vector_riscv.o
558+
# Unified RISC-V boot code (32/64-bit via __riscv_xlen)
559+
OBJS+=src/boot_riscv_start.o src/boot_riscv.o src/vector_riscv.o
559560
ARCH_FLASH_OFFSET=0x20010000
560561
endif
561562

562-
## RISCV64
563+
## RISCV64 (64-bit)
563564
ifeq ($(ARCH),RISCV64)
564565
CROSS_COMPILE?=riscv64-unknown-elf-
565566
CFLAGS+=-DMMU -DWOLFBOOT_DUALBOOT
@@ -568,15 +569,16 @@ ifeq ($(ARCH),RISCV64)
568569
OBJS += src/gpt.o
569570
OBJS += src/disk.o
570571
ARCH_FLAGS=-march=rv64imafd -mabi=lp64d -mcmodel=medany
571-
CFLAGS+=-fno-builtin-printf -DUSE_M_TIME -g -nostartfiles -DARCH_RISCV64
572+
CFLAGS+=-fno-builtin-printf -DUSE_M_TIME -g -nostartfiles -DARCH_RISCV -DARCH_RISCV64
572573
CFLAGS+=$(ARCH_FLAGS)
573574
LDFLAGS+=$(ARCH_FLAGS)
574575

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

579-
OBJS+=src/boot_riscv64_start.o src/boot_riscv64.o src/vector_riscv64.o
580+
# Unified RISC-V boot code (32/64-bit via __riscv_xlen)
581+
OBJS+=src/boot_riscv_start.o src/boot_riscv.o src/vector_riscv.o
580582

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

config/examples/polarfire_mpfs250.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ WOLFBOOT_LOAD_ADDRESS?=0x8E000000
4848
WOLFBOOT_NO_PARTITIONS=1
4949
CFLAGS_EXTRA+=-DBOOT_PART_A=1
5050
CFLAGS_EXTRA+=-DBOOT_PART_B=2
51-
# Speed up disk partition read (1MB chunks)
52-
CFLAGS_EXTRA+=-DDISK_BLOCK_SIZE=0x100000
51+
# Speed up disk partition read (512KB chunks)
52+
CFLAGS_EXTRA+=-DDISK_BLOCK_SIZE=0x80000
5353

5454
# DTS (Device Tree)
5555
WOLFBOOT_LOAD_DTS_ADDRESS?=0x8A000000

docs/Targets.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ set architecture riscv:rv64
10341034
### PolarFire Example Boot Output
10351035

10361036
```
1037-
wolfBoot Version: 2.7.0 (Dec 22 2025 14:14:37)
1037+
wolfBoot Version: 2.7.0 (Dec 29 2025 11:34:01)
10381038
Reading MBR...
10391039
Found GPT PTE at sector 1
10401040
Found valid boot signature in MBR
@@ -1054,19 +1054,18 @@ Checking secondary OS image in 0,2...
10541054
Versions, A:1 B:1
10551055
Load address 0x8E000000
10561056
Attempting boot from P:A
1057-
Boot partition: 0x801FFDA0 (sz 19767000, ver 0x1, type 0x601)
1058-
Loading image from disk...done.
1059-
Boot partition: 0x8E000000 (sz 19767000, ver 0x1, type 0x601)
1060-
Checking image integrity...done.
1061-
Verifying image signature...done.
1057+
Boot partition: 0x801FFD80 (sz 19767004, ver 0x1, type 0x601)
1058+
Loading image from disk...done. (846 ms)
1059+
Boot partition: 0x8E000000 (sz 19767004, ver 0x1, type 0x601)
1060+
Checking image integrity...done. (1507 ms)
1061+
Verifying image signature...done. (68 ms)
10621062
Firmware Valid.
1063-
Flattened uImage Tree: Version 17, Size 19767000
1063+
Flattened uImage Tree: Version 17, Size 19767004
10641064
Loading Image kernel-1: 0x8E0002C8 -> 0x80200000 (19745280 bytes)
10651065
Image kernel-1: 0x80200000 (19745280 bytes)
10661066
Loading Image fdt-1: 0x8F2D4DCC -> 0x8A000000 (19897 bytes)
10671067
Image fdt-1: 0x8A000000 (19897 bytes)
10681068
Loading DTS: 0x8A000000 -> 0x8A000000 (19897 bytes)
1069-
Loading elf at 0x80200000
10701069
Invalid elf, falling back to raw binary
10711070
Booting at 80200000
10721071
[ 0.000000] Linux version 6.12.22-linux4microchip+fpga-2025.07-g032a7095303a (oe-user@oe-host) (riscv64-oe-linux-gcc (GCC) 13.3.0, GNU ld (GNU Binutils) 2.42.0.20240723) #1 SMP Tue Jul 22 10:04:20 UTC 2025
@@ -1078,14 +1077,13 @@ Booting at 80200000
10781077
[ 0.000000] SBI RFENCE extension detected
10791078
[ 0.000000] SBI SRST extension detected
10801079
[ 0.000000] earlycon: ns16550a0 at MMIO32 0x0000000020100000 (options '115200n8')
1080+
[ 0.000000] printk: legacy bootconsole [ns16550a0] enabled
10811081
...
10821082
```
10831083

10841084
### PolarFire TODO
10851085

10861086
* Add eMMC/SD features:
1087-
- Improve mmc_delay and timeout handling
1088-
- DMA read support
10891087
- Write support
10901088
- eMMC support (not just SD)
10911089
* Add support for reading serial number and modifying ethernet MAC in device tree

0 commit comments

Comments
 (0)