NetBSD/riscv on PIC64GX Curiosity Kit

まあ、これも出オチなんですが。

最初から付いてるSDカードが、

     start      size  index  contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 222 Unused
256 25320 13 GPT part - BIOS Boot   ← U-Boot
25576 217088 15 GPT part - EFI System  ← 普通のEFIパーティション
242664 8192 12 GPT part - Linux data  ← CIDATA(FATっぽいけどよく知らん)
250856 62083063 1 GPT part - Linux data  ← 普通の?Ubuntu Linux (ext4)
62333919 23584 Unused

といった感じで、普通にU-BootからEFI経由で起動してるので、別のSDカードにddでコピーしたあと使えるところはそのまま使って、

  • EFIパーティションのbootriscv64.efiをNetBSDのやつに置き換え
  • セカンダリGPTヘッダ/テーブルがないのでgpt resizeだったかrestoreだったかを
  • index 1のtypeをffsにして、newfsして/netbsdを置く(どうせuserland置いても略)

以上!

OpenSBI v1.2
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|

Platform Name : Microchip PIC64GX(R)
Platform Features : medeleg
Platform HART Count : 5
Platform IPI Device : aclint-mswi
Platform Timer Device : aclint-mtimer @ 1000000Hz
Platform Console Device : mmuart
Platform HSM Device : pic64gx_hsm
Platform PMU Device : ---
Platform Reboot Device : pic64gx_reset
Platform Shutdown Device : pic64gx_reset
Firmware Base : 0xa000000
Firmware Size : 129 KB
Runtime SBI Version : 1.0

Domain0 Name : root
Domain0 Boot HART : 1
Domain0 HARTs : 1,2,3,4
Domain0 Region00 : 0x0000000002008000-0x000000000200bfff (I)
Domain0 Region01 : 0x0000000002000000-0x0000000002007fff (I)
Domain0 Region02 : 0x000000000a000000-0x000000000a03ffff ()
Domain0 Region03 : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address : 0x0000000080200000
Domain0 Next Arg1 : 0x000000000a021488
Domain0 Next Mode : S-mode
Domain0 SysReset : yes

Domain1 Name : build_pic64gx/u-boot.bin
Domain1 Boot HART : 1
Domain1 HARTs : 1*,2*,3*,4*
Domain1 Region00 : 0x000000000a000000-0x000000000a03ffff ()
Domain1 Region01 : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain1 Next Address : 0x0000000080200000
Domain1 Next Arg1 : 0x000000000a021488
Domain1 Next Mode : S-mode
Domain1 SysReset : yes

Boot HART ID : 1
Boot HART Domain : build_pic64gx/u-boot.bin
Boot HART Priv Version : v1.10
Boot HART Base ISA : rv64imafdc
Boot HART ISA Extensions : none
Boot HART PMP Count : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 36
Boot HART MHPM Count : 2
Boot HART MIDELEG : 0x0000000000000222
Boot HART MEDELEG : 0x000000000000b109


U-Boot 2023.07.02-pic64gx-2024.06-0ubuntu1 (Jul 15 2024 - 15:46:09 +0000)

CPU: rv64imafdc
Model: Microchip PIC64GX Curiosity Kit
DRAM: 1 GiB
Core: 49 devices, 10 uclasses, devicetree: separate
MMC: mmc@20008000: 0
Loading Environment from nowhere... OK
In: serial@20100000
Out: serial@20100000
Err: serial@20100000
Net: eth0: ethernet@20110000
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:f...
BootOrder not defined
EFI boot manager: Cannot load any image
Found EFI removable media binary efi/boot/bootriscv64.efi
185024 bytes read in 38 ms (4.6 MiB/s)
Booting /efi\boot\bootriscv64.efi

  \\-__,------,___.
\\ __,---` NetBSD/riscv efiboot (riscv64)
\\ `---,_. Revision 2.15 (Tue Jan 27 08:48:21 UTC 2026)
\\-,_____,.---`
\\
\\
\\

Press return to boot now, any other key for boot prompt
booting netbsd - starting in 0 seconds.
4750420+2093704+1479668+617484 [611856+372281]=0xaf0eb0

------------
NetBSD start

sp: 0x0000_0000_bd20_3000
pc: 0x0000_0000_bca0_0080
hart: 0x0000_0000_0000_0001
dtb: 0x0000_0000_bd60_0000
vendor: 0x0000_0000_0000_0029
l1: 0x0000_0000_bd20_c000
l2: 0x0000_0000_bd20_b000
uspace: 0x0000_0000_bd20_1000
bootstk: 0x0000_0000_bd20_3000
vtopdiff:0xffff_ffbf_4360_0000

bss: 0x0000_0000_bd36_93f4 - 0x0000_0000_bd20_d000

l2pde: 0x0000_0000_bd20_b800: 0x0000_0000_2f48_3001

kern: 0x0000_0000_bd20_c000: 0x0000_0000_2f28_00ef
kern: 0x0000_0000_bd20_c008: 0x0000_0000_2f30_00ef
kern: 0x0000_0000_bd20_c010: 0x0000_0000_2f38_00ef
kern: 0x0000_0000_bd20_c018: 0x0000_0000_2f40_00ef
kern: 0x0000_0000_bd20_c020: 0x0000_0000_2f48_00ef
kern: 0x0000_0000_bd20_c028: 0x0000_0000_2f50_00ef
kern: 0x0000_0000_bd20_c030: 0x0000_0000_2f58_00ef
kern: 0x0000_0000_bd20_c038: 0x0000_0000_2f60_00ef
kern: 0x0000_0000_bd20_c040: 0x0000_0000_2f68_00ef
kern: 0x0000_0000_bd20_c048: 0x0000_0000_2f70_00ef
kern: 0x0000_0000_bd20_c050: 0x0000_0000_2f78_00ef
kern: 0x0000_0000_bd20_c058: 0x0000_0000_2f80_00ef
kern: 0x0000_0000_bd20_c060: 0x0000_0000_2f88_00ef
kern: 0x0000_0000_bd20_c068: 0x0000_0000_2f90_00ef
kern: 0x0000_0000_bd20_c070: 0x0000_0000_2f98_00ef
kern: 0x0000_0000_bd20_c078: 0x0000_0000_2fa0_00ef
dtb: 0x0000_0000_bd20_c080: 0x0000_0000_2f58_00e7
PM
[ 1.0000000] FDT<0xffffffc002000000>
[ 1.0000000] devmap 0xffffffc00082f610
[ 1.0000000] bootstrap
[ 1.0000000] stdout
[ 1.0000000] fdt size 4000/3960
[ 1.0000000] consinit ok
[ 1.0000000] NetBSD/riscv (fdt) booting ...
[ 1.0000000] FDT /memory @ 0x80000000 size 0x3dad8000
[ 1.0000000] FDT /memory @ 0xbdadc000 size 0x830000
[ 1.0000000] FDT /memory @ 0xbe314000 size 0x4000
[ 1.0000000] FDT /memory @ 0xbe322000 size 0x3000
[ 1.0000000] FDT /memory @ 0xbe32e000 size 0x1814000
[ 1.0000000] FDT /memory @ 0xbfb43000 size 0xbd000
[ 1.0000000] init_riscv: memory start 80000000 end bfc00000 (len 3fc00000)
[ 1.0000000] cpu_kernel_vm_init: kernel phys start 0xbca00000 end 0xbd400000
[ 1.0000000] dm: 0xffffffc00080bc10 : 0x200000e7
[ 1.0000000] bootargs:
[ 1.0000000] msgbufaddr = 0xffffffe0bfbf0000
[ 1.0000000] ------------------------------------------
[ 1.0000000] kern_vtopdiff = 0xffffffbf43600000
[ 1.0000000] memory_start = 0x 80000000
[ 1.0000000] memory_end = 0x bfc00000
[ 1.0000000] memory_size = 0x 3fc00000
[ 1.0000000] kernstart_phys = 0x bca00000
[ 1.0000000] kernend_phys = 0x bd400000
[ 1.0000000] msgbufaddr = 0xffffffe0bfbf0000
[ 1.0000000] VM_MIN_KERNEL_ADDRESS = 0xffffffc000000000
[ 1.0000000] kernstart_mega = 0xffffffc000000000
[ 1.0000000] kernstart = 0xffffffc000000000
[ 1.0000000] kernend = 0xffffffc000a00000
[ 1.0000000] kernend_mega = 0xffffffc000a00000
[ 1.0000000] VM_MAX_KERNEL_ADDRESS = 0xffffffd000000000
[ 1.0000000] pmap_direct_base = 0xffffffe000000000
[ 1.0000000] ------------------------------------------
[ 1.0000000] adding 0x80000000 - 0xbca00000 to freelist 0
[ 1.0000000] adding 0xbd400000 - 0xbd600000 to freelist 0
[ 1.0000000] adding 0xbd604000 - 0xbdad8000 to freelist 0
[ 1.0000000] adding 0xbdadc000 - 0xbe30c000 to freelist 0
[ 1.0000000] adding 0xbe314000 - 0xbe318000 to freelist 0
[ 1.0000000] adding 0xbe322000 - 0xbe325000 to freelist 0
[ 1.0000000] adding 0xbe32e000 - 0xbfb42000 to freelist 0
[ 1.0000000] adding 0xbfb43000 - 0xbfbf0000 to freelist 0
[ 1.0000000] common cpusets bs_pde 0xffffffc00080b000 ASID max 0 kcpusets nkmempages limits: ffffffc004000000 - ffffffd000000000
[ 1.0000000] kva : ffffffc004000000 - ffffffc055600000
[ 1.0000000] mpstart
[ 1.0000000] Loaded initial symtab at 0xffffffc000869cd0, strtab at 0xffffffc0008ff2e0, # entries 24216
[ 1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
[ 1.0000000] 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
[ 1.0000000] 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023,
[ 1.0000000] 2024, 2025, 2026
[ 1.0000000] The NetBSD Foundation, Inc. All rights reserved.
[ 1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
[ 1.0000000] The Regents of the University of California. All rights reserved.

[ 1.0000000] NetBSD 11.99.5 (GENERIC64) #0: Tue Jan 27 17:56:56 JST 2026
[ 1.0000000] compile@xaveria.iwate.ceres.ne.jp:/home/compile/build/20260127_11.99.5/riscv64/obj/sys/arch/riscv/compile/GENERIC64
[ 1.0000000] total memory = 1009 MB
[ 1.0000000] avail memory = 976 MB
[ 1.0000000] mainbus0 (root)
[ 1.0000000] simplebus0 at mainbus0: Microchip PIC64GX Curiosity Kit
[ 1.0000000] simplebus1 at simplebus0
[ 1.0000000] cpus0 at simplebus0
[ 1.0000000] simplebus2 at simplebus0
[ 1.0000000] cpu0 at cpus0: vendor 29 arch 1 imp. 0
[ 1.0000000] cpu1 at cpus0: vendor 29 arch 1 imp. 0
[ 1.0000000] cpu2 at cpus0: vendor 29 arch 1 imp. 0
[ 1.0000000] cpu3 at cpus0: vendor 29 arch 1 imp. 0
[ 1.0000000] intc0 at cpu0: local interrupt controller
[ 1.0000000] intc1 at cpu1: local interrupt controller
[ 1.0000000] intc2 at cpu2: local interrupt controller
[ 1.0000000] intc3 at cpu3: local interrupt controller
[ 1.0000000] fclock0 at simplebus0: 125000000 Hz fixed clock (refclk)
[ 1.0000000] plic0 at simplebus1: RISC-V PLIC (186 IRQs)
[ 1.0000000] /soc/clkcfg@20002000 at simplebus1 not configured
[ 1.0000000] /soc/ethernet@20110000 at simplebus1 not configured
[ 1.0000000] /soc/syscontroller at simplebus1 not configured
[ 1.0000000] /soc/clint@2000000 at simplebus1 not configured
[ 1.0000000] ccache0 at simplebus1: L2 cache controller. 2048 KiB/64B 32-way (1024 set).
[ 1.0000000] /soc/pdma@3000000 at simplebus1 not configured
[ 1.0000000] /soc/mmc@20008000 at simplebus1 not configured
[ 1.0000000] com0 at simplebus1: couldn't get frequency
[ 1.0000000] /soc/hwrandom at simplebus1 not configured
[ 1.0000000] WARNING: system needs entropy for security; see entropy(7)
[ 1.1599780] cpu_boot_secondary_processors: starting secondary processors
[ 1.1712700] cpu_boot_secondary_processors: secondary processors hatched. 4 running
[ 1.1999760] swwdog0: software watchdog initialized
[ 1.2099800] WARNING: 1 error while detecting hardware; check system log.
[ 1.2099800] boot device: <unknown>
[ 1.2199750] root device:

mmc(とかethernet)がnot configuredなので、ここまでしかたどり着かないのは同じですが、RZ/Fiveよりはドライバ作るハードルが低そうな気がする(作るとは言ってない)。

追記 (2026/1/31)

clkcfg, syscontroller, hwrandomはmicrochip独自で、ethernet, mmcはcadenceの、ほかはsifiveのと同じ(そのもの?)っぽい。PIC64GXの構成とPolarFire SoCの構成はほぼ同じみたいなので、この辺のドライバさえ用意できればBeagleV-Fireあたりもまとめて対応できそう?

で、いろんなソースコードをfind+grepってたらclkcfg, ethernet, mmcはOpenBSDにドライバがあるようなので、これを移植すればよさそう(というかOpenBSD使えばよいのでは?)

……とか思っていたら、OpenBSD/riscv64のページには “Note:PolarFire SoC Icicle Kit support is incomplete” とあって、まだだめっぽい。

関係ないけど、/soc/clkcfg@20002000 at simplebus1 not configured というメッセージが出ている一方で、そのへんにあるdtsは clkcfg@3e001000 になっていて、これをどう扱うのかはよくわかってない。