我的目标是修改opensbi中的寄存器值让我可以在用户态读取rdcycle等性能寄存器值,经过一系列努力我已经将相关寄存器设置完成 但是每一次我换了sdcard上的/boot/fw_dynamic.bin文件后 可以正常打印信息 但是总会卡在启动上(大概率是因为选择了非0号hart)
下图是我试着启动的日志 总会卡住(由于我只能上传一张图片 直接查看附录的日志输出)
我发现每一次正常启动时总是从hart0开始的,但是为什么我修改了源码重新build就会无法启动
我已经尝试了从官方opensbi v1.6版本和**thead-opensbi构建我的opensbi,但是都会无法启动 只有使用**https://fast-mirror.isrc.ac.cn/revyos/extra/images/meles/20251226/中sdcard中/boot目录下的opensbi二进制文件才可以正常启动 这个是什么原因?
还有我发现thead-opensbi的版本是0.9而不是官方给的镜像中1.6版本,那么我想知道官方构建这个opensbi使用的源码在哪里?
附录: 基于thead-opensbi修改的启动日志
_____ _ _____ _____ _ __
| __ \ (_)/ ____| __ \| |/ /
| |__) | _ _ _ _| (___ | | | | ' /
| _ / | | | | | | |\___ \| | | | <
| | \ \ |_| | |_| | |____) | |__| | . \
|_| \_\__,_|\__, |_|_____/|_____/|_|\_\
__/ |
|___/
-- Presented by ISCAS
-----------------------------------------
U-Boot SPL 2020.01-g0028a957-dirty (Mar 02 2026 - 17:15:08 +0800)
FM[1] lpddr4x dualrank freq=3733 64bit dbi_off=n sdram init
image has no header
U-Boot 2020.01-g0028a957-dirty (Mar 02 2026 - 17:15:08 +0800)
CPU: rv64imafdcvsu
Model: Milk-V Meles
DRAM: 8 GiB
aon wakeup by gpio enabled
aon wakeup by rtc enabled
iic id:0 addr_mode:0 speed:2
C910 CPU FREQ: 750MHz
MMC: sdhci@ffe7080000: 0, sd@ffe7090000: 1
Loading Environment from MMC... Card did not respond to voltage select!
*** Warning - No block device, using default environment
In: serial@ffe7014000
Out: serial
Err: serial
light_c910_set_gpio_output_high: trying to set gpio output high
light_c910_set_gpio_output_high: trying to set gpio output high
Use random addr as fixed mac addr
Saving Environment to MMC... Card did not respond to voltage select!
No block device
Failed (1)
ethaddr: a2:f3:03:9b:10:f6
eth1addr: a2:f3:03:9b:10:f7
Net: ethernet@ffe7070000 (eth0) using MAC address - a2:f3:03:9b:10:f6
eth0: ethernet@ffe7070000
Hit any key to stop autoboot: 0
Unknown command 'usb' - try 'help'
53192 bytes read in 3 ms (16.9 MiB/s)
pmic_dev_num:2 offset:60 addr:1099510546492
regu_num:17 offset:178 addr:1099510546610
-->pmic_dev_num:2 offset:60
-->regu_num:17 offset:178
5281216 bytes read in 58 ms (86.8 MiB/s)
1736 bytes read in 2 ms (847.7 KiB/s)
90608 bytes read in 3 ms (28.8 MiB/s)
Card did not respond to voltage select!
Block device mmc 0 not supported
ERROR:runcmd read mmc 0:1 0xffe65a00 0 8 failed!
Retrieving file: /extlinux/extlinux.conf
935 bytes read in 4 ms (227.5 KiB/s)
U-Boot menu
1: RevyOS GNU/Linux 6.6.119-th1520
2: RevyOS GNU/Linux 6.6.119-th1520 (rescue target)
Enter choice: 1: RevyOS GNU/Linux 6.6.119-th1520
Retrieving file: /initrd.img-6.6.119-th1520
22279227 bytes read in 256 ms (83 MiB/s)
Retrieving file: /vmlinuz-6.6.119-th1520
14205105 bytes read in 154 ms (88 MiB/s)
append: root=PARTUUID=80a5a8e9-c744-491a-93c1-4f4194fd690b console=ttyS0,115200 rootwait rw earlycon clk_ignore_unused loglevel=7 eth= rootrwoptions=rw,noatime rootrwreset=yes
Retrieving file: /dtbs/linux-image-6.6.119-th1520/thead/th1520-milkv-meles-16g.dtb
65816 bytes read in 5 ms (12.6 MiB/s)
Uncompressing Kernel Image
Kernel image compression size = 0x08000000, address = 0x20000000
Loading Ramdisk to 18ac0000, end 19fff43b ... OK
Using Device Tree in place at 0000000003800000, end 0000000003813117
Starting kernel ...
## fdt has no reset_sample
OpenSBI v0.9
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|
Platform Name : Milk-V Meles
Platform Features : mfdeleg
Platform HART Count : 4
Platform IPI Device : clint
Platform Timer Device : clint
Platform Console Device : uart8250
Platform HSM Device : ---
Platform SysReset Device : ---
Firmware Base : 0x0
Firmware Size : 144 KB
MCOUNTEREN : 0xffffffff
MCOUNTINHIBIT : 0x0
SCOUNTEREN : 0xffffffff
MCOUNTERWEN (thead) : 0x0
MCOUNTERINTEN (thead) : 0x0
MCOUNTEROF (thead) : 0x0
SHPMINHIBIT (thead) : 0x0
MHPMCR (thead) : 0x0
MHPMSR (thead) : 0x0
MHPMER (thead) : 0x0
SHPMCR (thead) : 0x0
SHPMSR (thead) : 0x0
SHPMER (thead) : 0x0
Runtime SBI Version : 0.3
Domain0 Name : root
Domain0 Boot HART : 3
Domain0 HARTs : 0*,1*,2*,3*
Domain0 Region00 : 0x000000ffdc000000-0x000000ffdc00ffff (I)
Domain0 Region01 : 0x0000000000000000-0x000000000003ffff ()
Domain0 Region02 : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address : 0x0000000000200000
Domain0 Next Arg1 : 0x0000000003800000
Domain0 Next Mode : S-mode
Domain0 SysReset : yes
core:3 light_final_init: line:250 enter. cold_boot:1
core:3 HSM device set: light-ppu
thead: before mcounteren=0xffffffff mcountinh=0x0 scounteren=0xffffffff
thead: before mcounterwen=0x0 mhpmcr=0x0 shpmcr=0x0 shpm_inh=0x0
thead: after mcounteren=0xffffffff mcountinh=0x0 scounteren=0xffffffff
thead: after mcounterwen=0x5 mhpmcr=0x3 shpmcr=0x3 shpm_inh=0x0
Boot HART ID : 3
Boot HART Domain : root
Boot HART ISA : rv64imafdcvsux
Boot HART Features : scounteren,mcounteren,time
Boot HART PMP Count : 0
Boot HART PMP Granularity : 0
Boot HART PMP Address Bits: 0
Boot HART MHPM Count : 16
Boot HART MHPM Count : 16
Boot HART MIDELEG : 0x0000000000000222
Boot HART MEDELEG : 0x000000000000b109
[ 0.000000] Linux version 6.6.119-th1520 (builder@revyos-riscv-builder) (riscv64-linux-gnu-gcc-14 (Ubuntu 14.2.0-19ubuntu2) 14.2.0, GNU ld (GNU Binutils for Ubuntu) 2.44) #2025.12.24.18.43+2a44b04d6 SMP Wed Dec 24 19:01:45 UTC 2025
[ 0.000000] random: crng init done
[ 0.000000] Machine model: Milk-V Meles
[ 0.000000] SBI specification v0.3 detected
[ 0.000000] SBI implementation ID=0x1 Version=0x9
[ 0.000000] SBI TIME extension detected
[ 0.000000] SBI IPI extension detected
[ 0.000000] SBI RFENCE extension detected
[ 0.000000] earlycon: uart0 at MMIO32 0x000000ffe7014000 (options '115200n8')
[ 0.000000] printk: bootconsole [uart0] enabled
[ 0.000000] efi: UEFI not found.
[ 0.000000] Reserved memory: created CMA memory pool at 0x00000003e4000000, size 320 MiB
[ 0.000000] OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool
[ 0.000000] OF: reserved mem: 0x00000003e4000000..0x00000003f7ffffff (327680 KiB) map reusable linux,cma
[ 0.000000] OF: reserved mem: 0x0000000000000000..0x000000000003ffff (256 KiB) nomap non-reusable mmode_resv0@0
[ 0.000000] OF: reserved mem: 0x0000000010000000..0x00000000166fffff (105472 KiB) nomap non-reusable framebuffer@10000000
[ 0.000000] OF: reserved mem: 0x000000001e000000..0x000000001e00ffff (64 KiB) map non-reusable memory@1E000000
[ 0.000000] OF: reserved mem: 0x0000000020000000..0x000000002027ffff (2560 KiB) map non-reusable memory@20000000
[ 0.000000] OF: reserved mem: 0x0000000020400000..0x000000002067ffff (2560 KiB) map non-reusable memory@20400000
[ 0.000000] OF: reserved mem: 0x0000000032000000..0x0000000032dfffff (14336 KiB) map non-reusable memory@32000000
[ 0.000000] OF: reserved mem: 0x0000000032e00000..0x00000000333fffff (6144 KiB) map non-reusable memory@32E00000
[ 0.000000] OF: reserved mem: 0x0000000033400000..0x00000000335fffff (2048 KiB) map non-reusable memory@33400000
[ 0.000000] OF: reserved mem: 0x0000000033600000..0x00000000337fffff (2048 KiB) map non-reusable memory@33600000
[ 0.000000] OF: reserved mem: 0x0000000038400000..0x000000003a1fffff (30720 KiB) nomap non-reusable memory@38400000
[ 0.000000] NUMA: No NUMA configuration found
[ 0.000000] NUMA: Faking a node at [mem 0x0000000000200000-0x00000003ffffffff]
[ 0.000000] NUMA: NODE_DATA [mem 0x3ffd8bb80-0x3ffd8dfff]
[ 0.000000] Zone ranges:
[ 0.000000] DMA32 [mem 0x0000000000200000-0x00000000ffffffff]
[ 0.000000] Normal [mem 0x0000000100000000-0x00000003ffffffff]
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000000200000-0x000000000fffffff]
[ 0.000000] node 0: [mem 0x0000000010000000-0x00000000166fffff]
[ 0.000000] node 0: [mem 0x0000000016700000-0x00000000383fffff]
[ 0.000000] node 0: [mem 0x0000000038400000-0x000000003a1fffff]
[ 0.000000] node 0: [mem 0x000000003a200000-0x00000003ffffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000000200000-0x00000003ffffffff]
[ 0.000000] On node 0, zone DMA32: 512 pages in unavailable ranges
[ 0.000000] SBI HSM extension detected
[ 0.000000] riscv: base ISA extensions acdfim
[ 0.000000] riscv: ELF capabilities acdfim
[ 0.000000] Queued spinlock using Ziccrse: enabled
[ 0.000000] percpu: Embedded 29 pages/cpu s80808 r8192 d29784 u118784
[ 0.000000] Kernel command line: root=PARTUUID=80a5a8e9-c744-491a-93c1-4f4194fd690b console=ttyS0,115200 rootwait rw earlycon clk_ignore_unused loglevel=7 eth= rootrwoptions=rw,noatime rootrwreset=yes
[ 0.000000] Unknown kernel command line parameters "eth= rootrwoptions=rw,noatime rootrwreset=yes", will be passed to user space.
[ 0.000000] Dentry cache hash table entries: 2097152 (order: 12, 16777216 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 1048576 (order: 11, 8388608 bytes, linear)
[ 0.000000] Fallback order for Node 0: 0
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 4128264
[ 0.000000] Policy zone: Normal
[ 0.000000] mem auto-init: stack:all(zero), heap alloc:on, heap free:off
[ 0.000000] software IO TLB: area num 4.
[ 0.000000] software IO TLB: mapped [mem 0x00000000fbfff000-0x00000000fffff000] (64MB)
[ 0.000000] Memory: 4030072K/16775168K available (10554K kernel code, 5081K rwdata, 14336K rodata, 2754K init, 523K bss, 617024K reserved, 327680K cma-reserved)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[ 0.000000] ftrace: allocating 38093 entries in 149 pages
[ 0.000000] ftrace: allocated 149 pages with 4 groups
[ 0.000000] rcu: Hierarchical RCU implementation.
[ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=64 to nr_cpu_ids=4.
[ 0.000000] Rude variant of Tasks RCU enabled.
[ 0.000000] Tracing variant of Tasks RCU enabled.
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[ 0.000000] riscv-intc: 64 local interrupts mapped
[ 0.000000] plic: interrupt-controller@ffd8000000: mapped 240 interrupts with 4 handlers for 8 contexts.
[ 0.000000] riscv: providing IPIs using ACLINT SSWI IPI extension
[ 0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1623fa770, max_idle_ns: 881590404476 ns
[ 0.000001] sched_clock: 64 bits at 3000kHz, resolution 333ns, wraps every 4398046511097ns
[ 0.008674] riscv-timer: Timer interrupt in S-mode is available via xtheadsstc extension
[ 0.017937] Console: colour dummy device 80x25
[ 0.022822] Calibrating delay loop (skipped), value calculated using timer frequency.. 6.00 BogoMIPS (lpj=12000)
[ 0.033528] pid_max: default: 32768 minimum: 301
[ 0.038744] LSM: initializing lsm=capability,landlock,yama,apparmor,tomoyo,bpf,integrity
[ 0.047311] landlock: Up and running.
[ 0.051158] Yama: becoming mindful.
[ 0.054941] AppArmor: AppArmor initialized
[ 0.059253] TOMOYO Linux initialized
[ 0.063116] LSM support for eBPF active
[ 0.067410] Mount-cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[ 0.075413] Mountpoint-cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[ 0.088188] RCU Tasks Rude: Setting shift to 2 and lim to 1 rcu_task_cb_adjust=1 rcu_task_cpu_ids=4.
[ 0.097976] RCU Tasks Trace: Setting shift to 2 and lim to 1 rcu_task_cb_adjust=1 rcu_task_cpu_ids=4.
[ 0.107803] riscv: ELF compat mode unsupported
[ 0.107881] ASID allocator using 16 bits (65536 entries)
[ 0.118367] rcu: Hierarchical SRCU implementation.
[ 0.123410] rcu: Max phase no-delay instances is 1000.
[ 0.130074] EFI services will not be available.
[ 0.135418] smp: Bringing up secondary CPUs ...
core:3 light_hart_start: line:196 enter
core:0 light_final_init: line:250 enter. cold_boot:0
core:3 light_hart_start: line:203 exit
core:0 HSM device set: light-ppu
