Giter Site home page Giter Site logo

low-speed-linux-experimental-platform / temu Goto Github PK

View Code? Open in Web Editor NEW
45.0 1.0 4.0 1.01 MB

A full-system instruction-level RISC-V SoC emulator, THU pirate version qemu on target rv32ima_zicsr_zicnt_sstc. Support running mainline Linux.

CMake 0.11% C 74.46% Makefile 0.60% Assembly 24.24% Python 0.58%
risc-v riscv-emulator qemu riscv-linux rv32ima

temu's Introduction

TEMU (Tailored Emulator)

本项目的英文全称为Tailored Emulator,其中的字母T绝对与清华大学没有任何关系。本命名为致敬QEMU用。

Description

该项目是一个基于C语言编写的RISC-V模拟器,支持rv32ima_zicsr_zicnt_sstc架构和sv32内存分页结构。 模拟器实现了指令级别的模拟,即使用C解释执行其描述的内存操作与运算等。本模拟器虚拟了SoC的常见体系结构, 支持运行主线Linux。我们模拟的SoC,在本文档中,都会基于OpenSBI+U-Boot的方式来进行内核启动前的工作。

Getting Started

Dependencies

  • OpenSBI, U-Boot(Optional), Linux Kernel的二进制文件
  • cmake工具链
  • mkimage (Optional)
  • riscv-gnu-toolchain(Optional,如果你希望自己编译RISC-V平台的目标二进制文件,我这里使用buildroot制作的riscv32-buildroot-linux-gnu-作为我的交叉编译工具链)
  • (WIP) 将此项目的代码移植到WINDOWS以及OSX平台

Compiling

编译TEMU模拟器

mkdir build && cd build
cmake .. -DCMAKE_C_COMPILER=gcc
make

编译OpenSBI固件

这里需要用到本项目移植过llep实验平台的OpenSBI来编译固件。我们使用fw_jump型固件来完成从OpenSBIU-Boot的跳转。

make PLATFORM=llep CROSS_COMPILE=riscv32-buildroot-linux-gnu- -j64

编译通过后,我们需要的fw_jump.bin会出现在build/platform/llep/firmware中。

编译U-Boot

这里也需要用到本项目移植过llep实验平台的U-Boot

make xxxdefconfig # TODO
make CROSS_COMPILE=riscv32-buildroot-linux-gnu- -j64

此时,U-Boot根目录内的u-boot.bin即为u-boot本体的二进制文件。u-boot.dtb就是我们设备树的二进制文件。我们整个模拟系统都会以这个 u-boot.dtb作为我们的设备树。

编译Kernel

这里还需要用到本项目移植过llep实验平台的Kernel。需要注意的是,我们将根文件系统与内核捆绑在一起,所以需要保证你有已经制作好的cpio格式的文件系统。我们的文件系统将作为ramfs挂载在内存上。

make xxxdefconfig # TODO
make ARCH=riscv CROSS_COMPILE=riscv32-buildroot-linux-gnu- -j64

arch/riscv/boot/Image就是我们内核的无压缩的镜像。这个镜像包含了内核从虚拟地址0xc0000000开始一直到结束的内存的所有内容。0xc0000000是我们 进入内核的入口的虚拟地址,TEMU将从起始地址(此时内核没有开启虚拟内存,这个地址通常为0x80000000,等页表生效后这个地址就被映射到了0xc0000000)开始取第一条内核的指令并继续运行。但是U-Boot并不能直接运行这个纯二进制文件,因为U-Boot不知道这是什么类型的操作系统,不知道应该怎么传参或者运行它。所以我们需要使用mkimage工具将arch/riscv/boot/Image打包为U-Boot能识别的uImage文件,其实就是给arch/riscv/boot/Image加了一个0x40大小的头。

mkimage -A riscv -O linux -T kernel -C none -a 0x80000000 -e 0x80000000 -d arch/riscv/boot/Image uImage

由于我们没有实现rvc压缩指令,所以我们的内核二进制文件会比较大。我们需要压缩uImageuImage.gz。这个uImage.gz不像arm架构的zImage,可以实现自解压,因此我们在进入U-Boot后还需要手动解压uImage.gz到指定的地址(即0x80000000)。

gzip -c uImage > uImage.gz

Executing program (Using U-Boot Example)

  • 确保你拥有RISC-V指令集的二进制文件,本项目目前仅支持装载bin,即objcopy的输出,暂时不支持直接加载ELF,且加载ELF对于系统级别的模拟意义不大
  • 这些二进制文件可以在这里下载:TEMU Booting Binaries,可以直接使用wget下载到linux中。
  • 这里给出使用TEMU加载OpenSBIU-BootKernel二进制文件的使用例。

Usage (32MiB Version)

Preparations
Usage: temu [-ram/-rom/-addr 0x80000000] [-printreg] -exec=program.bin [-with=addr#file.bin]

Example:
--addr=0x81fa0000
--exec=fw_jump.bin
--with=0x80000000#u-boot.bin
--with=0x81ffd800#u-boot.dtb
--with=0x813a0000#uImage.gz

使用以下命令启动TEMU

./temu --addr=0x81fa0000 --exec=fw_jump.bin \
--with=0x80000000#u-boot.bin \
--with=0x81ffd800#u-boot.dtb \
--with=0x813a0000#uImage.gz

如果成功启动,TEMU首先会打印OpenSBI的启动信息,接着打印U-Boot的信息。

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

Platform Name             : Low-speed Linux Experimental Platform
Platform Features         : medeleg
Platform HART Count       : 1
Platform IPI Device       : ---
Platform Timer Device     : --- @ 0Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform PMU Device       : ---
Platform Reboot Device    : ---
Platform Shutdown Device  : ---
Platform Suspend Device   : ---
Platform CPPC Device      : ---
Firmware Base             : 0x81fa0000
Firmware Size             : 178 KB
Firmware RW Offset        : 0x20000
Firmware RW Size          : 50 KB
Firmware Heap Offset      : 0x24000
Firmware Heap Size        : 34 KB (total), 2 KB (reserved), 8 KB (used), 23 KB (free)
Firmware Scratch Size     : 4096 B (total), 160 B (used), 3936 B (free)
Runtime SBI Version       : 2.0

Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x12500000-0x12500fff M: (I,R,W) S/U: (R,W)
Domain0 Region01          : 0x81fc0000-0x81fcffff M: (R,W) S/U: ()
Domain0 Region02          : 0x81fa0000-0x81fbffff M: (R,X) S/U: ()
Domain0 Region03          : 0x00000000-0xffffffff M: () S/U: (R,W,X)
Domain0 Next Address      : 0x80000000
Domain0 Next Arg1         : 0x81ffd800
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes
Domain0 SysSuspend        : yes

Boot HART ID              : 0
Boot HART Domain          : root
Boot HART Priv Version    : v1.12
Boot HART Base ISA        : rv32ia
Boot HART ISA Extensions  : sstc,zicntr
Boot HART PMP Count       : 0
Boot HART PMP Granularity : 0 bits
Boot HART PMP Address Bits: 0
Boot HART MHPM Info       : 0 (0x00000000)
Boot HART Debug Triggers  : 0 triggers
Boot HART MIDELEG         : 0x00000222
Boot HART MEDELEG         : 0x0000b109


U-Boot 2024.04-rc2-g4e147dba9e-dirty (Mar 07 2024 - 23:15:04 +0800)Low-speed Linux Experimental Platform

DRAM:  31.6 MiB
Core:  11 devices, 8 uclasses, devicetree: separate
Loading Environment from nowhere... OK
In:    uart@12500000
Out:   uart@12500000
Err:   uart@12500000
Net:   No ethernet found.
llep@temu => 
Jumping to Kernel

U-Boot Command-Line Interface下输入以下命令:

unzip 0x813a0000 0x80000000 # 解压uImage.gz到0x80000000
setenv bootargs earlycon=sbi console=ttyS0,115200 root=/dev/ram0 # 设置启动参数
bootm 0x80000000 - 0x81ffd800 # 从0x80000000启动,传递0x81ffd800(设备树地址),作为参数

接下来就会进入内核,输出如下:

llep@temu => unzip 0x813a0000 0x80000000
Uncompressed size: 6436780 = 0x6237AC
llep@temu => setenv bootargs earlycon=sbi console=ttyS0,115200 root=/dev/ram0
llep@temu => bootm 0x80000000 - 0x81ffd800
## Booting kernel from Legacy Image at 80000000 ...
   Image Name:   
   Created:      2024-03-13   6:26:24 UTC
   Image Type:   RISC-V Linux Kernel Image (uncompressed)
   Data Size:    6436716 Bytes = 6.1 MiB
   Load Address: 80000000
   Entry Point:  80000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 81ffd800
   Booting using the fdt blob at 0x81ffd800
Working FDT set to 81ffd800
   Loading Kernel Image to 80000000
   Using Device Tree in place at 81ffd800, end 82001de3
Working FDT set to 81ffd800

Starting kernel ...

[    0.000000][    T0] Linux version 6.8.0-rc4-00006-gd90188ef7a29-dirty (root@hyz-wsl) (riscv32-buildroot-linux-gnu-gcc.br_real (Buildroot -ge725bb3-dirty) 12.3.0, GNU ld (GNU Binutils) 2.40) #172 Wed Mar 13 14:26:22 CST 2024
[    0.000000][    T0] SBI specification v2.0 detected
[    0.000000][    T0] SBI implementation ID=0x1 Version=0x10004
[    0.000000][    T0] SBI TIME extension detected
[    0.000000][    T0] SBI IPI extension detected
[    0.000000][    T0] SBI RFENCE extension detected
[    0.000000][    T0] SBI DBCN extension detected
[    0.000000][    T0] earlycon: sbi0 at I/O port 0x0 (options '')
[    0.000000][    T0] printk: legacy bootconsole [sbi0] enabled
[    0.000000][    T0] [paging_init] Test of earlycon printk
[    0.000000][    T0] Zone ranges:
[    0.000000][    T0]   Normal   [mem 0x0000000080000000-0x0000000081f9ffff]
[    0.000000][    T0] Movable zone start for each node
[    0.000000][    T0] Early memory node ranges
[    0.000000][    T0]   node   0: [mem 0x0000000080000000-0x0000000081f9ffff]
[    0.000000][    T0] Initmem setup node 0 [mem 0x0000000080000000-0x0000000081f9ffff]
[    0.000000][    T0] riscv: base ISA extensions aim
[    0.000000][    T0] riscv: ELF capabilities aim
[    0.000000][    T0] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000][    T0] pcpu-alloc: [0] 0 
[    0.000000][    T0] Kernel command line: earlycon=sbi console=ttyS0,115200 root=/dev/ram0
[    0.000000][    T0] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes, linear)
[    0.000000][    T0] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.000000][    T0] Built 1 zonelists, mobility grouping on.  Total pages: 8032
[    0.000000][    T0] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000][    T0] Memory: 25672K/32384K available (2003K kernel code, 180K rwdata, 409K rodata, 3688K init, 69K bss, 6712K reserved, 0K cma-reserved)
[    0.000000][    T0] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000][    T0] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000][    T0] riscv-intc: 32 local interrupts mapped
[    0.000000][    T0] plic: interrupt-controller@c000000: mapped 16 interrupts with 1 handlers for 2 contexts.
[    0.000000][    T0] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x171024e7e0, max_idle_ns: 440795205315 ns
[    0.000004][    T0] sched_clock: 64 bits at 100MHz, resolution 10ns, wraps every 4398046511100ns
[    0.001214][    T0] Console: colour dummy device 80x25
[    0.001421][    T0] Calibrating delay loop (skipped), value calculated using timer frequency.. 200.00 BogoMIPS (lpj=400000)
[    0.001636][    T0] pid_max: default: 32768 minimum: 301
[    0.002144][    T0] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.002335][    T0] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.008176][    T1] ASID allocator using 9 bits (512 entries)
[    0.010342][    T1] devtmpfs: initialized
[    0.015524][    T1] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.015743][    T1] futex hash table entries: 256 (order: 0, 7168 bytes, linear)
[    0.019971][    T1] platform soc: Fixed dependency cycle(s) with /soc/interrupt-controller@c000000
[    0.026063][    T1] clocksource: Switched to clocksource riscv_clocksource
[    0.082379][    T1] workingset: timestamp_bits=30 max_order=13 bucket_order=0
[    0.084394][    T1] io scheduler mq-deadline registered
[    0.084513][    T1] io scheduler kyber registered
[    0.533974][    T1] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.541813][    T1] serial8250_probe
[    0.542378][    T1] dw8250_probe
[    0.542904][    T1] devm_ioremap membase 2751467520 regs->start 307232768 resource_size(regs) 256
[    0.543209][    T1] uart_16550_compatible, handle_irq = 3223019076
[    0.543336][    T1] dw8250_probe: p->type 1
[    0.545478][    T1] printk: legacy console [ttyS0] disabled
[    0.566918][    T1] 12500000.uart: ttyS0 at MMIO 0x12500000 (irq = 2, base_baud = 72000) is a 16550A
[    0.567187][    T1] printk: legacy console [ttyS0] enabled
[    0.567187][    T1] printk: legacy console [ttyS0] enabled
[    0.567522][    T1] printk: legacy bootconsole [sbi0] disabled
[    0.567522][    T1] printk: legacy bootconsole [sbi0] disabled
[    0.569739][    T1] serial8250_register_8250_port: 0
[    0.575056][    T1] brd: module loaded
[    0.575224][    T1] start plist test
[    0.645973][    T1] end plist test
[    0.684215][    T1] clk: Disabling unused clocks
[    0.685918][    T1] request_irq 0 up->port.irq 2 up->port.irqflags 128 ttyS0 dev_id 3230340672 handle_irq 3223019076
[    0.701479][    T1] Freeing unused kernel image (initmem) memory: 3688K
[    0.701684][    T1] Kernel memory protection not selected by kernel config.
[    0.701903][    T1] Run /init as init process
[    0.702096][    T1]   with arguments:
[    0.702225][    T1]     /init
[    0.702346][    T1]   with environment:
[    0.702480][    T1]     HOME=/
[    0.702602][    T1]     TERM=linux
Saving 256 bits of non-creditable seed for next boot
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Starting network: ip: socket: Function not implemented
ip: socket: Function not implemented
Waiting for interface eth0 to appear............... timeout!
run-parts: /etc/network/if-pre-up.d/wait_iface: exit status 1
FAIL

Welcome to Buildroot
buildroot login: root
login[63]: root login on 'console'
# uname -a
Linux buildroot 6.8.0-rc4-00006-gd90188ef7a29-dirty #172 Wed Mar 13 14:26:22 CST 2024 riscv32 GNU/Linux
# cat /proc/cpuinfo
processor       : 0
hart            : 0
isa             : rv32ima
mmu             : sv32
mvendorid       : 0x0
marchid         : 0x0
mimpid          : 0x0
hart isa        : rv32ima

# 

Documentation (TODO)

CPU Architect

我们没有对微架构的描述,因为我们是解释执行指令,所以简化了许多微架构设计的内容。本项目模拟的SoC没有缓存(后续会加上), 也不存在任何总线,我们对SoC的仿真类似于操作系统中的宏内核的概念,指令解释与外设模拟都是同时实现的,可以直接调用。

以下是CPU解释执行指令的有关代码:

  • src/decode.c:解释并执行指令
  • src/machine.c:取指,模拟外设,中断等特权态处理
  • src/mem.c:模拟内存控制器对内存进行读写
  • src/vm.c:实现对虚拟地址的转换,以及对物理内存的读写
  • src/zicsr.c:实现特权架构

支持的ISA

rv32ima_zicsr_zicnt_sstc

  • i:整数指令
  • m:硬件乘法
  • a:原子指令
  • zicsr:特权架构支持
  • zicnt:CSR寄存器的计数器支持
  • sstc:特权架构Supervisor级别定时器中断支持。这个扩展给运行在Supervisor模式的软件 (后续都称为操作系统)也添加了timetimecmp寄存器,允许操作系统读写这两个寄存器来实现直接在Supervisor模式进行处理的 定时器中断。(如果你学习过xv6,你会发现xv6只会在Machine特权态下处理定时器的中断,并且它还在手册里明确指出了risc-v规定 定时器中断只能在Machine Mode下处理。但是如果实现了sstc拓展,这个过程可以得到很大的简化。)

内存映射

类型 Base Address Size
ROM 0x0000_0000 64KiB
RAM 0x8000_0000 32MiB
UART 0x1250_0000 0x100
PLIC 0x0c00_0000 0x400000

对于OpenSBI+U-Boot+Linux启动方案,RAM在上电时应该由TEMU模拟first stage bootloader,将二进制文件加载到以下位置。

地址 可用空间 描述
0x8000_0000 (x) 上电时这里为u-boot.bin。u-boot重定位后,内核将被解压到此处,并从此处开始运行
0x813a_0000 10MiB 压缩过的内核,即uImage.gz,存储于此地址
0x81da_0000 2MiB U-Boot将在上电后从0x8000_0000重定位至此处
0x81fa_0000 384KiB OpenSBI的固定地址。这一段逻辑上是只读的
0x81ff_d800 10KiB 设备树的二进制文件

32MiB内存方案下,内核可用的内存大小约为30.625MiB

MMU模型

实现sv32内存模型。具体的risc-v特权态手册里都写了。这个页表就两级,实现起来比较容易。

CSR寄存器支持

实现的CSR请参考include/zicsr.h,但是真正使用过的CSR是以下几个:

  • sstatus
  • sie
  • stvec
  • sepc
  • scause
  • stval
  • sip
  • stimecmp
  • stimecmph
  • satp
  • mstatus
  • medeleg
  • mideleg
  • mie
  • mtvec
  • mepc
  • mcause
  • mcause
  • mtval
  • mip
  • scontext
  • cycle
  • time
  • cycleh
  • timeh
  • mvendorid

需要注意的是,以上列出的寄存器,只是我们代码中显式调用了的。对于某些软件,你必须实现我们在include/zicsr.h的这些寄存器。它必须存在,尽管 我并没有实现它们具体的功能。

异常与中断

(WIP)

uart 16550a

(WIP)

PLIC中断控制器

(WIP)

我们实现的是t-headplic,而不是sifiveplic控制器。

Authors

Obvious.

Version History

This is blamed to git history.

Acknowledgments

Inspiration, code snippets, etc.

temu's People

Contributors

gtxzsxxk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

temu's Issues

32MiB Plan

32MiB

0x0000_0000: ROM START

0x8000_0000: U-boot, (Kernel Decompress Start)
512KiB U-boot

0x813a_0000: Compressed Kernel at
10MiB

0x81da_0000: Uboot reloc
2MiB

0x81fa_0000:  OpenSBI
384KiB

0x81ff_d800: FDT
10KiB

0x8200_0000: RAM end 32MiB
unzip 0x813a0000 0x80000000
setenv bootargs earlycon=sbi console=ttyS0,115200 root=/dev/ram0
bootm 0x80000000 - 0x81ffd800
make ARCH=riscv CROSS_COMPILE=riscv32-buildroot-linux-gnu- -j64 && \
mkimage -A riscv -O linux -T kernel -C none -a 0x80000000 -e 0x80000000 -d arch/riscv/boot/Image uImage && \
gzip -c uImage > uImage.gz

Available memory for kernel: 30.625MiB

--addr=0x81fa0000
--exec=fw_jump.bin
--with=0x80000000#u-boot.bin
--with=0x81ffd800#u-boot.dtb
--with=0x813a0000#uImage.gz

Be able to run OpenSBI firmware!

D:\code\temu\cmake-build-debug\temu fw_jump.bin -ram

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

Platform Name             : Low-speed Linux Experimental Platform
Platform Features         : medeleg
Platform HART Count       : 1
Platform IPI Device       : ---
Platform Timer Device     : --- @ 0Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform PMU Device       : ---
Platform Reboot Device    : ---
Platform Shutdown Device  : ---
Platform Suspend Device   : ---
Platform CPPC Device      : ---
Firmware Base             : 0x2000000
Firmware Size             : 178 KB
Firmware RW Offset        : 0x20000
Firmware RW Size          : 50 KB
Firmware Heap Offset      : 0x24000
Firmware Heap Size        : 34 KB (total), 2 KB (reserved), 9 KB (used), 22 KB (free)
Firmware Scratch Size     : 4096 B (total), 164 B (used), 3932 B (free)
Runtime SBI Version       : 2.0

Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x12500000-0x12500fff M: (I,R,W) S/U: (R,W)
Domain0 Region01          : 0x02020000-0x0202ffff M: (R,W) S/U: ()
Domain0 Region02          : 0x02000000-0x0201ffff M: (R,X) S/U: ()
Domain0 Region03          : 0x00000000-0xffffffff M: () S/U: (R,W,X)
Domain0 Next Address      : 0x02400000
Domain0 Next Arg1         : 0x00000000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes
Domain0 SysSuspend        : yes

Boot HART ID              : 0
Boot HART Domain          : root
Boot HART Priv Version    : v1.12
Boot HART Base ISA        : rv32ia
Boot HART ISA Extensions  : smaia,smstateen,sscofpmf,sstc,zicntr,smcntrpmf,sdtrig
Boot HART PMP Count       : 0
Boot HART PMP Granularity : 5 bits
Boot HART PMP Address Bits: 26
Boot HART MHPM Info       : 0 (0x00000000)
Boot HART Debug Triggers  : 1 triggers
Boot HART MIDELEG         : 0x00002222
Boot HART MEDELEG         : 0x0000b109

Process finished with exit code -1

Run u-boot in debug-mode

All we use is simple. All for a simple run. We don't have fsbl so far.

  • opensbi fw_jump
  • uboot embedded fdt
# ./temu --ram --exec=fw_jump.bin --with=0x03000000#u-boot.bin

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

Platform Name             : Low-speed Linux Experimental Platform
Platform Features         : medeleg
Platform HART Count       : 1
Platform IPI Device       : ---
Platform Timer Device     : --- @ 0Hz
Platform Console Device   : uart8250
Platform HSM Device       : ---
Platform PMU Device       : ---
Platform Reboot Device    : ---
Platform Shutdown Device  : ---
Platform Suspend Device   : ---
Platform CPPC Device      : ---
Firmware Base             : 0x2000000
Firmware Size             : 178 KB
Firmware RW Offset        : 0x20000
Firmware RW Size          : 50 KB
Firmware Heap Offset      : 0x24000
Firmware Heap Size        : 34 KB (total), 2 KB (reserved), 8 KB (used), 23 KB (free)
Firmware Scratch Size     : 4096 B (total), 160 B (used), 3936 B (free)
Runtime SBI Version       : 2.0

Domain0 Name              : root
Domain0 Boot HART         : 0
Domain0 HARTs             : 0*
Domain0 Region00          : 0x12500000-0x12500fff M: (I,R,W) S/U: (R,W)
Domain0 Region01          : 0x02020000-0x0202ffff M: (R,W) S/U: ()
Domain0 Region02          : 0x02000000-0x0201ffff M: (R,X) S/U: ()
Domain0 Region03          : 0x00000000-0xffffffff M: () S/U: (R,W,X)
Domain0 Next Address      : 0x03000000
Domain0 Next Arg1         : 0x00000000
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes
Domain0 SysSuspend        : yes

Boot HART ID              : 0
Boot HART Domain          : root
Boot HART Priv Version    : v1.10
Boot HART Base ISA        : rv32ia
Boot HART ISA Extensions  : zicntr
Boot HART PMP Count       : 0
Boot HART PMP Granularity : 0 bits
Boot HART PMP Address Bits: 0
Boot HART MHPM Info       : 0 (0x00000000)
Boot HART Debug Triggers  : 0 triggers
Boot HART MIDELEG         : 0x00000222
Boot HART MEDELEG         : 0x0000b109


U-Boot 2024.04-rc2-gc9522f470b-dirty (Feb 17 2024 - 21:50:25 +0800)Low-speed Linux Experimental Platform

DRAM:  160 MiB
Core:  8 devices, 8 uclasses, devicetree: embed
Loading Environment from nowhere... OK
In:    uart@12500000
Out:   uart@12500000
Err:   uart@12500000
Net:   No ethernet found.
llep@temu => bdinfo
boot_params = 0x00000000
DRAM bank   = 0x00000000
-> start    = 0x02000000
-> size     = 0x0a000000
flashstart  = 0x00000000
flashsize   = 0x00000000
flashoffset = 0x00000000
baudrate    = 115200 bps
relocaddr   = 0x0bfa6000
reloc off   = 0x08fa6000
Build       = 32-bit
current eth = unknown
eth-1addr   = (not set)
IP addr     = <NULL>
fdt_blob    = 0x0304caa0
new_fdt     = 0x00000000
fdt_size    = 0x00000000
lmb_dump_all:
 memory.cnt = 0x1 / max = 0x10
 memory[0]      [0x2000000-0xbffffff], 0x0a000000 bytes flags: 0
 reserved.cnt = 0x1 / max = 0x10
 reserved[0]    [0xbf9a0c0-0xbffffff], 0x00065f40 bytes flags: 0
devicetree  = embed
serial addr = 0x12500000
 width      = 0x00000001
 shift      = 0x00000000
 offset     = 0x00000000
 clock      = 0x00119400
llep@temu => help
?         - alias for 'help'
base      - print or set address offset
bdinfo    - print Board Info structure
blkcache  - block cache diagnostics and control
boot      - boot default, i.e., run 'bootcmd'
bootd     - boot default, i.e., run 'bootcmd'
bootelf   - Boot from an ELF image in memory
bootflow  - Boot flows
booti     - boot Linux kernel 'Image' format from memory
bootm     - boot application image from memory
bootp     - boot image via network using BOOTP/TFTP protocol
bootvx    - Boot vxWorks from an ELF image
cmp       - memory compare
coninfo   - print console devices and information
cp        - memory copy
cpu       - display information about CPUs
crc32     - checksum calculation
dm        - Driver model low level access
echo      - echo args to console
editenv   - edit environment variable
env       - environment handling commands
fdt       - flattened device tree utility commands
go        - start application at address 'addr'
gzwrite   - unzip and write memory to block device
help      - print command description/usage
iminfo    - print header information for application image
imxtract  - extract a part of a multi-image
itest     - return true/false on integer compare
loadb     - load binary file over serial line (kermit mode)
loads     - load S-Record file over serial line
loadx     - load binary file over serial line (xmodem mode)
loady     - load binary file over serial line (ymodem mode)
loop      - infinite loop on address range
lzmadec   - lzma uncompress a memory region
md        - memory display
mm        - memory modify (auto-incrementing address)
mw        - memory write (fill)
net       - NET sub-system
nm        - memory modify (constant address)
panic     - Panic with optional message
printenv  - print environment variables
reset     - Perform RESET of the CPU
run       - run commands in an environment variable
setenv    - set environment variables
setexpr   - set environment variable as the result of eval expression
sleep     - delay execution for some time
source    - run script from memory
tftpboot  - load file via network using TFTP protocol
unlz4     - lz4 uncompress a memory region
unzip     - unzip a memory region
version   - print monitor, compiler and linker version
llep@temu => iminfo

## Checking Image at 00000000 ...
Unknown image format!
llep@temu => printenv
baudrate=115200
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
fdt_high=0xffffffffffffffff
fdtcontroladdr=304caa0
initrd_high=0xffffffffffffffff
kernel_addr_r=0x05a00000
kernel_comp_addr_r=0x09000000
kernel_comp_size=0x4000000
loadaddr=0x0
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then part uuid ${devtype} ${devnum}:${distro_bootpart} distro_bootpart_uuid ; run scan_dev_for_boot; fi; done; setenv devplist
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo EXTLINUX FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
stderr=uart@12500000
stdin=uart@12500000
stdout=uart@12500000

Environment size: 1655/8188 bytes
llep@temu => panic

resetting ...
reset not supported yet
### ERROR ### Please RESET the board ###

Linux has earlycon outputs!

I am too happy

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

Platform Name             : Low-speed Linux Experimental Platform
Platform Features         : medeleg
Platform HART Count       : 1
Platform IPI Device       : ---
Platform Timer Device     : --- @ 0Hz
Platform Console Device   : uart8250
Platf00-0x80fcffff M: (R,W) S/U: ()
Domain0 Region02          : 0x80fa0000-0x80fbffff M: (R,X) S/U: ()
Domain0 Region03          : 0x00000000-0xffffffff M: () S/U: (R,W,X)
Domain0 Next Address      : 0x80000000
Domain0 Next Arg1         : 0x80ffd800
Domain0 Next Mode         : S-mode
Domain0 SysReset          : yes
Domain0 SysSuspend        : yes

Boot HART ID              : 0
Boot HART Domain          : root
Boot HART Priv Version    : v1.10
Boot HART Base ISA        : rv32ia
Boot HART ISA Extensions  : zicntr
Boot HART PMP Count       : 0
Boot HART PMP Granularity : 0 bits
Boot HART PMP Address Bits: 0
Boot HART MHPM Info       : 0 (0x00000000)
Boot HART Debug Triggers  : 0 triggers
Boot HART MIDELEG         : 0x00000222
Boot HART MEDELEG         : 0x0000b109


U-Boot 2024.04-rc2-gc7fa4f0df9-dirty (Feb 27 2024 - 21:30:47 +0800)Low-speed Linux Experimental Platform

DRAM:  15.6 MiB
Core:  8 devices, 8 uclasses, devicetree: separate
Loading Environment from nowhere... OK
In:    uart@12500000
Out:   uart@12500000
Err:   uart@12500000
Net:   No ethernet found.
llep@temu => unzip 0x80aa0000 0x80000000
unzip 0x80aa0000 0x80000000
Uncompressed size: 5213612 = 0x4F8DAC
llep@temu => setenv bootargs "earlycon=sbi"
setenv bootargs "earlycon=sbi"
llep@temu => bootm 0x80000000 - 0x80ffd800
bootm 0x80000000 - 0x80ffd800
## Booting kernel from Legacy Image at 80000000 ...
   Image Name:   
   Created:      2024-02-28  15:22:24 UTC
   Image Type:   RISC-V Linux Kernel Image (uncompressed)
   Data Size:    5213548 Bytes = 5 MiB
   Load Address: 80000000
   Entry Point:  80000000
   Verifying Checksum ... data 2147483712 len 5213548 dcrc 915660109 img_crc 915660109
OK
## Flattened Device Tree blob at 80ffd800
   Booting using the fdt blob at 0x80ffd800
Working FDT set to 80ffd80
   Loading Kernel Image to 80000000
do_bootm_linux flag=0x00000100 
   Using Device Tree in place at 80ffd800, end 81001e8c
Working FDT set to 80ffd800
do_bootm_linux flag=0x00000400 

Starting kernel ...

Jump to kernel now: 0x80000000
[    0.000000][    T0] Linux version 6.8.0-rc4-00002-g6a5b9ce15e61-dirty (root@hyz-wsl) (riscv32-buildroot-linux-gnu-gcc.br_real (Buildroot -ge725bb3-dirty) 12.3.0, GNU ld (GNU Binutils) 2.40) #29 Wed Feb 28 23:21:30 CST 2024
[    0.000000][    T0] Machine model: snps,emsdp
[    0.000000][    T0] SBI specification v2.0 detected
[    0.000000][    T0] SBI implementation ID=0x1 Version=0x10004
[    0.000000][    T0] SBI TIME extension detected
[    0.000000][    T0] SBI IPI extension detected
[    0.000000][    T0] SBI RFENCE extension detected
[    0.000000][    T0] SBI DBCN extension detected
[    0.000000][    T0] earlycon: sbi0 at I/O port 0x0 (options '')
[    0.000000][    T0] printk: legacy bootconsole [sbi0] enabled
[    0.000000][    T0] [paging_init] Test of earlycon printk
[    0.000000][    T0] Zone ranges:
[    0.000000][    T0]   Normal   [mem 0x0000000080000000-0x0000000080f9ffff]
[    0.000000][    T0] Movable zone start for each node
[    0.000000][    T0] Early memory node ranges
[    0.000000][    T0]   node   0: [mem 0x0000000080000000-0x0000000080f9ffff]
[    0.000000][    T0] Initmem setup node 0 [mem 0x0000000080000000-0x0000000080f9ffff]
[    ][    T0] On node 0, zone Normal: 28768 pages in unavailable ranges
[    0.000000][    T0] Unable to find cpu node
[    0.000000][    T0] Falling back to deprecated "riscv,isa"
[    0.000000][    T0] Unable to find cpu node
[    0.000000][    T0] riscv: base ISA extensions 
[    0.000000][    T0] riscv: ELF capabilities 
[    0.000000][    T0] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000][    T0] pcpu-alloc: [0] 0 
[    0.000000][    T0] Kernel command line: "earlycon=sbi"
[    0.000000][    T0] Dentry cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.000000][    T0] Inode-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.000000][    T0] Built 1 zonelists, mobility grouping off.  Total pages: 3968
[    0.000000][    T0] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000][    T0] Memory: 9684K/16000K available (3895K kernel code, 219K rwdata, 768K rodata, 204K init, 125K bss, 6316K reserved, 0K cma-reserved)
[    0.000000][    T0] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000][    T0] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000][    T0] Kernel panic - not syncing: No interrupt controller found.
[    0.000000][    T0] CPU: 0 PID: 0 Comm: swapper Not tainted 6.8.0-rc4-00002-g6a5b9ce15e61-dirty #29
[    0.000000][    T0] Hardware name: snps,emsdp (DT)
[    0.000000][    T0] Call Trace:
[    0.000000][    T0] [<c0004b70>] dump_backtrace+0x2c/0x3c
[    0.000000][    T0] [<c03bb1a8>] show_stack+0x44/0x5c
[    0.000000][    T0] [<c03c3600>] dump_stack_lvl+0x34/0x54
[    0.000000][    T0] [<c03c363c>] dump_stack+0x1c/0x2c
[    0.000000][    T0] [<c03bb53c>] panic+0x13c/0x300
[    0.000000][    T0] [<c03d2d5c>] init_IRQ+0x3c/0x4c
[    0.000000][    T0] [<c03cfa88>] start_kernel+0x3ec/0x564
[    0.000000][    T0] ---[ end Kernel panic - not syncing: No interrupt controller found. ]---

Bug encountered when running init

Starting kernel ...

[    0.000000][    T0] Linux version 6.8.0-rc4-00003-g5c38432532a3-dirty (root@hyz-wsl) (riscv32-buildroot-linux-gnu-gcc.br_real (Buildroot -ge725bb3-dirty) 12.3.0, GNU ld (GNU Binutils) 2.40) #83 Thu Mar  7 19:23:55 CST 2024
[    0.000000][    T0] SBI specification v2.0 detected
[    0.000000][    T0] SBI implementation ID=0x1 Version=0x10004
[    0.000000][    T0] SBI TIME extension detected
[    0.000000][    T0] SBI IPI extension detected
[    0.000000][    T0] SBI RFENCE extension detected
[    0.000000][    T0] SBI DBCN extension detected
[    0.000000][    T0] earlycon: sbi0 at I/O port 0x0 (options '')
[    0.000000][    T0] printk: legacy bootconsole [sbi0] enabled
[    0.000000][    T0] [paging_init] Test of earlycon printk
[    0.000000][    T0] Zone ranges:
][    T0]   Normal   [mem 0x0000000080000000-0x0000000080f9ffff]
[    0.000000][    T0] Movable zone start for each node
[    0.000000][    T0] Early memory node ranges
[    0.000000][    T0]   node   0: [mem 0x0000000080000000-0x0000000080f9ffff]
[    0.000000][    T0] Initmem setup node 0 [mem 0x0000000080000000-0x0000000080f9ffff]
[    0.000000][    T0] riscv: base ISA extensions aim
[    0.000000][    T0] riscv: ELF capabilities aim
[    ][ 0]lloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000][    T0] pcpu-alloc: [0] 0 
[    0.000000][    T0] Kernel command line: earlycon=sbi,null console=ttyS0,115200
[    0.000000][    T0] Dentry cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.000000][    T0] Inode-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.000000][    T0] Built 1 zonelists, mobility grouping off.  Total pages: 3968
[    0.000000][    T0] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000][    T0] Memory: 9452K/16000K available (2002K kernel code, 176K rwdata, 409K rodata, 3685K init, 68K bss, 6548K reserved, 0K cma-reserved)
[    0.000000][    T0] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000][    T0] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000][    T0] riscv-intc: 32 local interrupts mapped
[    0.000000][    T0] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x171024e7e0, max_idle_ns: 440795205315 ns
[    0.000004][    T0] sched_clock: 64 bits at 100MHz, resolution 10ns, wraps every 4398046511100ns
[    0.001181][    T0] Console: colour dummy device 80x25
[    0.001321][    T0] univ8250_console_init
[    0.001483][    T0] Calibrating delay loop (skipped), value calculated using timer frequency.. 200.00 BogoMIPS (lpj=400000)
[    0.001697][    T0] pid_max: default: 32768 minimum: 301
[    0.002202][    T0] Mount-cache hash table entries:  0, 4096 bytes, linear)
[    0.0023  T0] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.008514][    T1] ASID allocator us bits (512 entries)
[    0.010629][    T1] devtmpfs: initialized
[    0.015259][    Turce: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.015477][    T1] futex hash table entries: 256 (order: 0, 7168 bytes, linear)
[    0.024678][    T1] clocksource: Switched to clocksource riscv_clocksource
[    0.289505][    T1] workingset: timestamp_bits=30 max_order=12 bucket_order=0
[    0.291578][    T1] io scheduler mq-deadline registered
[    0.291697][    T1] io scheduler kyber registered
[    0.592363][    T1] serial8250_init
[    0.592454][    T1] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.592658][    T1] uart_register_driver 0
[    0.592763][    T1] serial8250_pnp_init 0
[    0.592873][    loc (ptrval)
[    0.593226][    T1] platform_device_add 0
[    0.594057][    T1] uart_configure_port port->type 0 port->flags 1073741824
[    0.595924][    T1] uart_configure_poort->type 0 port->flags 1073741824
[    0.597886][    T1] uart_configure_port port->type 0 port->flags 1073741824
[    0.599783][    T1] uart_configure_port port->type 0 port->flags 1073741824
[    0.601572]tform_driver_register 0
[    0.601913][    T1] Serial probe1
[    0.602350][    T1] devm_ioremap membase 2684354560 regs->start 307232768 resource_size(regs) 256
[    0.602656][    T1] dw8250_probe: p->type 1
[    0.602767][    T1] serial8250_register_8250_port port->type 1
[    0.602890][    T1] serial8250_register_8250_port uart port->type 0
[    0.604998][    T1] printk: legacy console [ttyS0] disabled
[    0.605444][    T1] serial8250_register_8250_port port->type 1
[    0.606311][    T1] uart_configure_port port->type 0 port->flags 1895825472
[    0.606459][    T1] port->type = PORT_UNKNOWN 0
[    0.606571][    T1] autoconfig running
[    0.606671][    T1] autoconfig serial_in(up, UART_IIR) 193
[    0.606808][    T1] uart_configure_port port->type 15
[    0.606937][    T1] 12500000.uart: ttyS0 at MMIO 0x12500000 (irq = 1, base_baud = 72000) is a XScale
[    0.607125][    T1] prev_register_console 3227613032 0
[    0.607324][    T1] printk: legacy console [ttyS0] enabled
[    0.607324][    T1] printk: legacy console [ttyS0] enabled
[    0.607589][    T1] printk: legacy bootconsole [sbi0] disabled
[    0.607589][    T1] printk: legacy bootconsole [sbi0] disabled
[    0.610123][    T1] uart_add_one_port: 0
[    0.610259][    T1] serial8250_register_8250_port: 0
[    0.614717][    T1] brd: module loaded
[    0.614874][    T1] start plist test
[    0.713039][    T1] end plist test
[    0.751021][    T1] clk: Disabling unused clocks
[    0.769436][    T1] Freeing unused kernel image (initmem) memory: 3684K
[    0.769631][    T1] Kernel memory protection not selected by kernel config.
[    0.769836][    T1] Run /init as init process
[    0.769980][    T1]   with arguments:
[    0.770104][    T1]     /init
[    0.770220][    T1]   with environment:
[    0.770348][    T1]     HOME=/
[    0.770467][    T1]     TERM=linux
[    0.772055][    T1] BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:1589
[    0.772299][    T1] in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 1, name: init
[    0.772541][    T1] preempt_count: 0, expected: 0
[    0.772703][    T1] CPU: 0 PID: 1 Comm: init Not tainted 6.8.0-rc4-00003-g5c38432532a3-dirty #83
[    0.772974][    T1] Call Trace:
[    73098][    T1] [<c0004070>] dump_backtrace+0x2c/0x3c
[    0.773332][    T1] [<c00040bc>] show_stack+0x3c/0x50
[    0.773558][    T1] [<c01d6198>] dump_stack_lvl+0x34/0x50
[    0.773813][    T1] [<c01d61d0>] dump_stack+0x1c/0x2c
[    0.774060][    T1] [<c002960c>] __might_resched+0x120/0x130
[    0.7745][    T1] [<c0029684>] __might_sleep+0x68/0x80
[    0.774502][    T1] [<c01f28a4>] down_write_killable+0x2c/0x58
[    0.774777][    T1] [<c0086894>] vm_mmap_pgoff+0x54/0xc8
[    0.775032][    T1] [<c0086948>] vm_mmap+0x40/0x5c
[    0.775277][    T1] [<c0103be4>] elf_load+0x94/0x200
[   0.775506][    T1] [<c0104474>] load_elf_binary+0x6f8/0xe44
[    0.775752][    T1] [<c00c0d34>] bprm_execve+0x25c/0x38c
[    0.775973][    T1] [<c00c15e4>] kernel_execve+0x158/0x168
[    0.776201][    T1] [<c000108c>] run_init_process+0x8c/0xd0
[    0.776425][    T1] [<c01ef3bc>] kernel_init+0x70/0x134
[    0.776673][    T1] [<c01f5728>] ret_from_fork+0x14/0x24
[    0.786698][    T1] init[1]: unhandled signal 11 code 0x2 at 0x9566c974 in libc.so.6[9563a000+139000]
[    0.787077][    T1] CPU: 0 PID: 1 Comm: init Tainted: G        W         6.8.0-rc4-00003-g5c38432532a3-dirty #83
[    0.787378][    T1] epc : 9566c974 ra : 95658d24 sp : 9d356e70
[    0.787586][    T1]  gp : 69f800 tp : 9578c2c0 t0 : 9573cfac
[    0.787794][    T1]  t1 : 690ff0ac t2 : 0000000a s0 : 9d356ed4
[    0.787995][    T1]  s1 : 95793d90 a0 : 957764c8 a1 : 00000000
[    0.788197][    T1]  a2 : 00000000 a3 : 95775388 a4 : 00000001
[    0.788392][    T1]  a5 : 00000000 a6 : 9d356ed0 a7 : 5aff4045
[    0.788594][    T1]  s2 : 00000000 s3 : 00000000 s4 : 978[  0.788789][    T1]  s5 : 00000000 s6 : 00000000 s7 : 00000000
[    0.788978][    T1]  s8 : 00000000 s9 : 00000000 s10: 00000000
[    0.789167][    T1]  s11: 00000000 t3 : 95658cd4 t4 : 957903f4
[    0.789369][    T1]  t5 : 9d3569b8 t6 : 70000025
[    0.789539][    T1] status: 00000022 badaddr: 957764c8 cause: 00000005
[    0.789756][    T1] Code: Unable to access instruction at 0x9566c960.
[    0.790032][    T1] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
[    0.790257][    T1] CPU: 0 PID: 1 Comm: init Tainted: G        W          6.8.0-rc4-00003-g5c38432532a3-dirty #83
[    0.790558][    T1] Call Trace:
[    0.790682][    T1] [<c0004070>] dump_backtrace+0x2c/0x3c
[    0.790916][    T1] [<c00040bc>] show_stack+0x3c/0x50
[    0.791142][    T1] [<c01d6198>] dump_stack_lvl+0x34/0x50
[    0.791397][    T1] [<c01d61d0>] dump_stack+0x1c/0x2c
[    0.791644][    T1] [<c0009fe0>] panic+0x128/0x2c8
[    0.791890][    T1] [<c000bedc>] do_exit+0x1e0/0x6cc
[    0.792100][    T1] [<c000c52c>] do_group_exit+0x38/0xa0
[    0.792316][    T1] [<c0016058>] get_signal+0x1a0/0x600
[    0.792574][    T1] [<c0002cb8>] arch_do_signal_or_restart+0x80/0x2c0
[    0.792830][    T1] [<c01ef070>] irqentry_exit_to_user_mode+0x7c/0xa0
[    79104][    T1] [<c01ee898>] do_trap_load_fault+0x58/0xa8
[    0.793359][    T1] [<c01f5668>] ret_from_exception+0x0/0xac
[    0.793603][    T1] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---

plic causes panic

[    0.533803][    T1] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.542065][    T1] Serial probe1
[    0.542499][    T1] devm_ioremap membase 2751467520 regs->start 307232768 resource_size(regs) 256
[    0.542804][    T1] dw8250_probe: p->type 1
[    0.544943][     legacy console [ttyS0] disabled
[    0.566388][    T1] 12500000.uart: ttyS0 at MMIO 0x12500000 (irq = 1, base_baud = 72000) is a 16550A
[    0.566657][    T1] printk: legacy console [ttyS0] enabled
[    0.566657][    T1] printk: legacy console [ttyS0] enabled
[    0.566921][    T1] printk: legacy bootconsole [sbi0] disabled
[    0.566921][    T1] printk: legacy bootconsole [sbi0] disabled
[    0.569058][    T1] serial8250_register_8250_port: 0
[    0.574381][    T1] brd: module loaded
[    0.574538][    T1] start plist test
[    0.625515][    T1] end plist test
[    0.663751][    T1] clk: Disabling unused clocks
[    0.665372][    T1] BUG: spinlock bad magic on CPU#0, swapper/1
[    0.665565][    T1]  lock: 0xc0615a9c, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0
[    0.665831][    T1] CPU: 0 PID: 1 Comm: swapper Not tainted 6.8.0-rc4-00006-gd90188ef7a29-dirty #157
[    0.666108][    T1] Call Trace:
[    0.666232][    T1] [<c0004070>] dump_backtrace+0x2c/0x3c
[    0.666466][    T1] [<c00040bc>] show_stack+0x3c/0x50
[    0.666692][    T1] [<c01d6544>] dump_stack_lvl+0x34/0x50
[    0.666949][    T1] [<c01d657c>] dump_stack+0x1c/0x2c
[    0.667198][    T1] [<c0035ea8>] spin_bug+0x84/0xac
[    0.667421][    T1] [<c0035f60>] do_raw_spin_lock+0x34/0x84
[    0.667660][    T1] [<c01f5214>] _raw_spin_lock+0x24/0x34
[    0.667890][    T1] [<c0187a50>] plic_toggle.constprop.0+0x34/0xc4
[    0.668145][    T1] [<c0187b70>] plic_irq_toggle.constprop.0+0x60/0x68
[    0.668409][    T1] [<c0187b90>] plic_irq_enable+0x18/0x28
[    0.668648][    T1] [<c003fffc>] irq_enable+0x74/0x90
[    0.668869][    T1] [<c00400f8>] irq_startup+0xe0/0xe8
[    0.669092][    T1] [<c003ded0>] __setup_irq+0x584/0x6ac
[    0.669309][    T1] [<c003e188>] request_threaded_irq+0x190/0x1ac
[    0.669546][    T1] [<c01b06dc>] univ8250_setup_irq+0x19c/0x1d8
[    0.669815][    T1] [<c01b3ad4>] serial8250_do_startup+0x358/0x68c
[    0.670061][    T1] [<c01b3e38>] serial8250_startup+0x30/0x34
[    0.670296][    T1] [<c01ac7dc>] uart_startup+0xf8/0x1d4
[    0.670537][    T1] [<c01ac900>] uart_port_activate+0x48/0x74
[    0.670790][    T1] [<c01987b8>] tty_port_open+0x98/0xfc
[    0.6048][    T1] [<c01ab4ac>] uart_open+0x20/0x38
[    0.671274][    T1] [<c0191980>] tty_open+0x308/0x3c0
[    0.671505][    T1] [<c00bebe4>] chrdev_open+0x1ac/0x1c8
[    0.671764][    T1] [<c00b6ad8>] do_dentry_open+0x378/0x3b4
[    0.671995][    T1] [<c00b7bd4>] vfs_open+0x38/0x48
[    0.672214][    T1] [<c00ca0c0>] path_openat+0x9a0/0xa54
[    0.672464][    T1] [<c00ca1b8>] do_filp_open+0x44/0x98
[    0.672713][    T1] [<c00b8058>] file_open_name+0x40/0x54
[    0.672945][    T1] [<c00b80a8>] filp_open+0x3c/0x68
[    0.673167][    T1] [<c01f6edc>] console_on_rootfs+0x2c/0x80
[    0.673413][    T1] [<c01f70ec>] kernel_init_freeable+0x1bc/0x21c
[    0.673673][    T1] [<c01ef71c>] kernel_init+0x24/0x134
[    0.673923][    T1] [<c01f5ad4>] ret_from_fork+0x14/0x24
[    0.674156][    T1] plic: __plic_toggle enable_base 0 hwirq 10 1
[    0.674398][    T1] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[    0.674634][    T1] Oops [#1]
[    0.674761][    T1] CPU: 0 PID: 1 Comm: swapper Not tainted 6.8.0-rc4-00006-gd90188ef7a29-dirty #157
[    0.6038][    T1] epc : plic_toggle.constprop.0+0x74/0xc4
[    0.675266][    T1]  ra : plic_toggle.constprop.0+0x6c/0xc4
[    0.675494][    T1] epc : c0187a90 ra : c0187a88 sp : c0835ad0
[    0.675702][    T1]  gp : c0623a68 tp : c0830000 t0 : 3a000000
[    0.675909][    T1]  t1 : 00000070 t2 : 3a63696c s0 : c0835b00
[    0.676112][    T1]  s1 : 00000400 a0 : 0000002c a1 : 00000000
[    0.676305][    T1]  a2 : 00000000 a3 : 00000062 a4 : c060f930
[    0.676502][    T1]  a5 : 00000002 a6 : c06030f0 a7 : 00000018
[    0.676699][    T1]  s2 : 00000000 s3 : 00000001 s4 : c0616000
[    0.676894][    T1]  s5 : c0899234 s6 : 00000122 s7 : c08992c8
[    0.677098][    T1]  s8 : c0899260 s9 : c1231d80 s10: c05ea000
[    0.677305][    T1]  s11: 00000000 t3 : c062a973 t4 : c062a973
[    0.677507][    T1]  t5 : c062a974 t6 : c08359a0
[    0.677677][    T1] status: 00000120 badaddr: 00000000 cause: 0000000d
[    0.677883][    T1] [<c0187a90>] plic_toggle.constprop.0+0x74/0xc4
[    0.678138][    T1] [<c0187b70>] plic_irq_toggle.constprop.0+0x60/0x68
[    8401][    T1] [<c0187b90>] plic_irq_enable+0x18/0x28
[    0.678640][    T1] [<c003fffc>] irq_enable+0x74/0x90
[    0.678861][    T1] [<c00400f8>] irq_startup+0xe0/0xe8
[    09083][    T1] [<c003ded0>] __setup_irq+0x584/0x6ac
[    0.679301][    T1] [<c003e188>] request_threaded_irq+0x190/0x1ac
[    0.679538][    T1] [<c01b06dc>] univ8250_setup_irq+0x19c/0x1d8
[    0.679807][    T1] [<c01b3ad4>] serial8250_do_startup+0x358/0x68c
[    0.680052][    T1] [<c01b3e38>] serial8250_startup+0x30/0x34
[    0.80287][    T1] [<c01ac7dc>] uart_startup+0xf8/0x1d4
[    0.680528][    T1] [<c01ac900>] uart_port_activate+0x48/0x74
[    0.680781][    T1] [<c01987b8>] tty_port_open+0x98/0xfc
[    0.681039][    T1] [<c01ab4ac>] uart_open+0x20/0x38
[    0.681265][    T1] [<c0191980>] tty_open+0x308/0x3c0
[    0.681495][    T1] [<c00bebe4>] chrdev_open+0x1ac/0x1c8
[    0.681754][    T1] [<c00b6ad8>] do_dentry_open+0x378/0x3b4
[    0.681986][    T1] [<c00b7bd4>] vfs_open+0x38/0x48
[    0.682c00ca0c0>] path_openat+0x9a0/0xa54
[    0.682455][    T1] [<c00ca1b8>] do_filp_open+0x44/0x98
[    0.682703][    T1] [<c00b8058>] file_open_name+0x40/0x54
[    0.682935][    T1] [<c00b80a8>] filp_open+0x3c/0x68
[    0.683157][    T1] [<c01f6edc>] console_on_rootfs+0x2c/0x80
[    0.3403][    T1] [<c01f70ec>] kernel_init_freeable+0x1bc/0x21c
[    0.683663][    T1] [<c01ef71c>] kernel_init+0x24/0x134
[    0.683913][    T1] [<c01f5ad4>] ret_from_fork+0x14/0x24
[    0.684231][    T1] Code: 8933 0125 f097 ffea 80e7 df40 8063 0409 000f 0140 (2783) 0009 
[    0.684497][    T1] ---[ end trace 0000000000000000 ]---
[    0.684659][    T1] note: swapper[1] exited with preempt_count 2
[    0.684861][    T1] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
[    0.685089][    T1] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---

Address Mapping

Our memory are very rare, so

0x0000_0000: ROM START

0x0200_0000: RAM START
290KiB OpenSBI

0x0204_8800: FDT
10KiB

0x0204_B000: U-boot (Kernel decompress start)
512KiB U-boot

0x020c_B000: Kernel decompress space
8MiB

0x028c_B000: Compressed Kernel at
3MiB

0x02bc_B000: Uboot reloc

0x0300_0000: RAM END 16MiB

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.