RISC-V 麻雀 D1s Buildroot 基本笔录

文章目录

    • 前言
    • 麻雀
    • Buildroot
    • 开机日志
    • 系统探索
    • OpenSBI
    • QEMU Buildroot RISCV
    • 参考

前言

RISC-V, BSD许可证之下自由使用的CPU设计, 最早是2010年加州大学伯克利分校的几个教授设计的, 几乎可以为所欲为的许可协议, RV32主要用于MCU, RV64主要用于SOC, 还有RV128等. 现在很多国产芯片用RISCV缝合上自己多年的积累, 做出不少广受欢迎的芯片, 比如下面的这几个:

  • 嘉楠的 K210, 还有已经发布的K510, RV64双核架构
  • 沁恒(接口见长, 代表芯片CH340), 带高速USB(内置PHY, 480Mbps)和千兆以太网MAC(或10M-PHY)的CH32V307, RV32架构, 入选第十七届全国大学生智能车竞赛的芯片
  • 乐鑫(物联网和开源作品中杀疯的ESP模组) 的 ESP32-C3 芯片, RV32, 搭配自家的WiFi
  • 全志D1s, 内置祖传DDR2, LQFP封装, 直接跑Linux, RV64, 阿里平头哥玄铁C906主核, 22nm

很多大学或科研单位也慢慢开始拿RISC-V来学习或者流片…

本篇主角是全志的D1s(丝印F133-A), 阿里平头哥玄铁C906主核,64bit RISC-V指令集, 22nm工艺, 1.0 GHz

D1s与D1的区别:

  • D1s是eLQFP封装, D1是BGA封装
  • D1s内置64MB DDR2, D1没有
  • D1 比 D1s 多了 HDMI 和 HiFi 4 音频 DSP
  • D1-H 用于官方的哪吒开发板, 论坛里说 应HDMI组织要求,全志D1芯片因集成了HDMI功能,需在芯片型号后标注“-H”,故将“D1”型号芯片统一改为“D1-H”

SBC, Single-Board Computer

麻雀

芒果派产

以下:

  • 拿到的是1.6版本的硬件
  • 调试串口在双排排针第四排, 印有T R丝印, 该双排排针的1脚为GND, 自己找个USB转串口的小板子接上
  • 板子背面可以自己焊接一个 SPI Flash
  • 板载 RTL8189 WiFi模组(SDIO接口, 802.11n, 150Mbps)
  • 引出的两个TypeC分别是USB OTG 和 USB HOST, 不是USB转串口
  • TypeC的CC1和CC2引脚各自下拉5.1K电阻, 所以可以直接拿市面上通用的65W充电器往上怼
  • 板载麦克风, 留出Audio口
  • 正面留出MIPI口, 树莓派的MIPI屏应该可用?
  • 背面最短的FPC座是触摸芯片接口, 如GT911?
  • 背面中等的FPC座可以接DVP接口摄像头模组, 如OV2640 / OV5640 / OV7725?
  • 背面最长的FPC座是RGB 6-6-6

接下来依然是抄作业, 过流程, 混脸熟…

Buildroot

来自100ask发出来的 麻雀D1s开发板支持buildroot 一件构建了。 | 全志在线开发者论坛 (debugdump.com), 我还没准备动身, 老师傅们半山腰都栽满了鲜花果树, 到山顶的索道都快修好了, 索性先坐上去吧…

写成脚本的形式, 一开始用的buildroot官方的包构建的, 报ln错误, 还贴心的手动复制了过去, 结果还是xxx… 心里默念啊这, 韦老师...后来发现是自己抄作业抄错了… 用Ubuntu18构建(后来在Ubuntu20构建也通过了)

#!/bin/bash

# buildroot环境配置
sudo apt install -y debianutils sed make binutils build-essential gcc g++ bash patch gzip bzip2 perl tar cpio unzip rsync file bc git wget python cvs mercurial subversion android-tools-mkbootimg

# 获取和解压定制的支持全志D1S的buildroot
git clone https://github.com/100askTeam/buildroot_aw-ol.git  buildroot
git clone -b main https://github.com/100askTeam/buildroot-external-mq.git

cd buildroot

# 使用 mq_core_defconfig 配置文件
make BR2_EXTERNAL=../buildroot-external-mq mq_core_defconfig

# 原有源配置查看
# cat .config | grep -E "BR2_KERNEL_MIRROR|BR2_GNU_MIRROR|BR2_LUAROCKS_MIRROR|BR2_CPAN_MIRROR"
# 切换到国内源, 测试一把, 发现还没有不切换快, 特别是里面有下python-3.9.4, 慢到飞起, 这一步换源省了, 不换了
# echo 'BR2_KERNEL_MIRROR="https://mirror.bjtu.edu.cn/kernel/"' >> .config
# echo 'BR2_GNU_MIRROR="http://mirrors.nju.edu.cn/gnu/"' >> .config
# echo 'BR2_LUAROCKS_MIRROR="https://luarocks.cn"' >> .config
# echo 'BR2_CPAN_MIRROR="http://mirrors.nju.edu.cn/CPAN/"' >> .config

make menuconfig

# 如何往终端发送ESC ESC ENTER

# 配置完成就可以开始构建了, 13:48~14:45
make -j $(nproc)
# 最后应该会打印
# INFO: hdimage(sdcard.img): adding partition 'boot0' from 'boot0_sdcard.fex' ...
# INFO: hdimage(sdcard.img): adding partition 'boot-packages' from 'boot_package.fex' ...
# INFO: hdimage(sdcard.img): adding partition 'env' (in MBR) from 'env.fex' ...
# INFO: hdimage(sdcard.img): adding partition 'env-redund' (in MBR) from 'env.fex' ...
# INFO: hdimage(sdcard.img): adding partition 'boot' (in MBR) from 'boot.vfat' ...
# INFO: hdimage(sdcard.img): adding partition 'rootfs' (in MBR) from 'rootfs.ext4' ...
# INFO: hdimage(sdcard.img): writing GPT
# INFO: hdimage(sdcard.img): writing hybrid MBR

最后输出的images如下

$ ls -lh output/images/
total 106M
-rwxr-xr-x 1 d d  48K Jan 12 22:45 board.dtb
-rw-r--r-- 1 d d  64K Jan 12 22:45 boot0_nand.fex
-rw-r--r-- 1 d d  64K Jan 12 22:45 boot0_sdcard.fex
-rw-r--r-- 1 d d  48K Jan 12 22:45 boot0_spinor.fex
-rw-r--r-- 1 d d 9.2M Jan 12 22:45 boot.img
-rwxr-xr-x 1 d d  381 Jan 12 22:45 boot_package.cfg
-rw-r--r-- 1 d d 992K Jan 12 22:45 boot_package.fex
-rw-r--r-- 1 d d  32M Jan 12 22:45 boot.vfat
-rwxr-xr-x 1 d d 1.8M Jan 12 22:45 dragonsecboot
-rwxr-xr-x 1 d d  680 Jan 12 22:45 env.cfg
-rw-r--r-- 1 d d 128K Jan 12 22:45 env.fex
-rw-r--r-- 1 d d  61K Jan 12 22:02 fw_dynamic.bin
-rw-r--r-- 1 d d 356K Jan 12 22:02 fw_dynamic.elf
-rw-r--r-- 1 d d  61K Jan 12 22:02 fw_jump.bin
-rw-r--r-- 1 d d 355K Jan 12 22:02 fw_jump.elf
-rw-r--r-- 1 d d 9.1M Jan 12 22:45 Image
-rw-r--r-- 1 d d   12 Jan 12 22:45 ramdisk.img
-rw-r--r-- 1 d d 500M Jan 12 22:45 rootfs.ext2
lrwxrwxrwx 1 d d   11 Jan 12 22:45 rootfs.ext4 -> rootfs.ext2
-rw-r--r-- 1 d d 9.9M Jan 12 22:45 rootfs.tar
-rw-r--r-- 1 d d 550M Jan 12 22:45 sdcard.img
-rw-r--r-- 1 d d 878K Jan 12 22:33 u-boot-sun20iw1p1.bin

镜像写入TF卡

# 输出文件为 output/images/sdcard.img
# windows 下可以用 rufus wind32diskimage等, 或者
# linux dd命令写入sd卡, /dev/sdX中的sdX 指的是tf卡设备的主分区, 可以df -h 看看容量是否对得上
$ sudo dd if=output/images/sdcard.img of=/dev/sdX bs=1M

# 比如我的, 一开始手抖写成/dev/sdb1, 708MB/s, 结果啥反应没有, 分区可以有很多(sdb1/2/3/4), 但都属于sdb设备的, 乖乖改成sdb
$ sudo dd if=output/images/sdcard.img of=/dev/sdb bs=1M
[sudo] password for d: 
549+1 records in
549+1 records out
575930880 bytes (576 MB, 549 MiB) copied, 10.2029 s, 56.4 MB/s
# 56MB/s是正常的, 百兆以上的可能不正常

开机日志

板子双排排针第四排, 有两个引脚标有T R丝印, 就是调试串口了, 再加上排针所在的1脚GND

找块CH340的小板子接上, 打开串口115200-8-N-1, 笔记本的65W TypeC电源插上任意TypeC口供电, 然后就可以串口终端看到, 中文注释是后加的(有些是D1-H修改过来的信息, opensbi --> u-boot --> kernel --> login), 上电后大概7s到登录

[222]HELLO! BOOT0 is starting!
[225]BOOT0 commit : 603490b
[227]set pll start
[229]periph0 has been enabled
[232]set pll end
[234][pmu]: bus read error
[236]board init ok
[238]ZQ value = 0x2f***********
[241]get_pmu_exist() = -1
[244]ddr_efuse_type: 0xa
[246][AUTO DEBUG] single rank and full DQ!
[250]ddr_efuse_type: 0xa
[253][AUTO DEBUG] rank 0 row = 13 
[256][AUTO DEBUG] rank 0 bank = 4 
[260][AUTO DEBUG] rank 0 page size = 2 KB 
[263]DRAM BOOT DRIVE INFO: V0.24
[266]DRAM CLK = 528 MHz	# DDR2时钟528MHz
[269]DRAM Type = 2 (2:DDR2,3:DDR3)
[272]DRAMC read ODT  off.
[274]DRAM ODT off.
[276]ddr_efuse_type: 0xa
[279]DRAM SIZE =64 M	# 64MB片上RAM
[283]DRAM simple test OK.
[285]dram size =64
[287]card no is 0
[289]sdcard 0 line count 4
[291][mmc]: mmc driver ver 2021-04-2 16:45
[300][mmc]: Wrong media type 0x0
[303][mmc]: ***Try SD card 0***
[312][mmc]: HSSDR52/SDR25 4 bit
[315][mmc]: 50000000 Hz	# TF卡 时钟50MHz
[317][mmc]: 122240 MB	# 120GB
[319][mmc]: ***SD/MMC 0 init OK!!!***
[367]Loading boot-pkg Succeed(index=0).
[370]Entry_name        = opensbi	# RISC-V指令集的SBI标准规定了类Unix平台下操作系统运行环境的规范.OpenSBI是它的一种实现.
[373]Entry_name        = u-boot
[377]Entry_name        = dtb
[380]mmc not para
[382]Jump to second Boot.

OpenSBI v0.6
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name          : T-HEAD Xuantie Platform	# 平头哥 玄铁
Platform HART Features : RV64ACDFIMSUVX	# RISC-V RV64
Platform Max HARTs     : 1
Current Hart           : 0
Firmware Base          : 0x40000400
Firmware Size          : 75 KB
Runtime SBI Version    : 0.2

MIDELEG : 0x0000000000000222
MEDELEG : 0x000000000000b1ff
PMP0    : 0x0000000040000000-0x000000004001ffff (A)
PMP1    : 0x0000000040000000-0x000000007fffffff (A,R,W,X)
PMP2    : 0x0000000080000000-0x00000000bfffffff (A,R,W,X)
PMP3    : 0x0000000000020000-0x0000000000027fff (A,.459][mmc]: mmc driver ver uboot2018:2021-04-16 14:23:00-1
[00.464][mmc]: get sdc_type fail and use default host:tm1.
[00.470][mmc]: can't find node "mmc0",will add new node
[00.475][mmc]: fdt err returned 
[00.479][mmc]: Using default timing para
[00.483][mmc]: SUNXI SDMMC Controller Version:0x50310	# Sunxi, 全志的?
[00.501][mmc]: card_caps:0x3000000a
[00.504][mmc]: host_caps:0x3000003f
[00.519]set disp.dev2_output_type fail. using defval=0
[00.541]Get bootloader and boot-resource partition number fail!
[00.570]out of usb burn from boot: not need burn key
[02.014]
Starting kernel ...	# 内核启动

[02.017][mmc]: MMC Device 2 not found
[02.021][mmc]: mmc 2 not find, so not exit
[    0.000000] OF: fdt: Ignoring memory range 0x40000000 - 0x40200000
# Linux内核版本 5.4.61, 后面的d@ubuntu是我的用户名和主机名, 编译时间 Jan 12 22:40:19 PST 2022
[    0.000000] Linux version 5.4.61 (d@ubuntu) (riscv64-unknown-linux-gnu-gcc (C-SKY RISCV Tools V1.8.4 B20200702) 8.1.0, GNU ld (GNU Binutils) 2.32) #1 PREEMPT Wed Jan 12 22:40:19 PST 2022
[    0.000000] cma: Reserved 8 MiB at 0x0000000043800000	# cma ? 保留8MB???
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000040200000-0x0000000043ffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000040200000-0x0000000043ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000040200000-0x0000000043ffffff]
[    0.000000] On node 0 totalpages: 15872
[    0.000000]   DMA32 zone: 217 pages used for memmap
[    0.000000]   DMA32 zone: 0 pages reserved
[    0.000000]   DMA32 zone: 15872 pages, LIFO batch:3
[    0.000000] elf_hwcap is 0x20112d
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 15655
# 这里出现的 androidboot, 怎么缝合的... 好像是全志其它产品线的??
# 调试串口 ttyS0, 115200
[    0.000000] Kernel command line: earlyprintk=sunxi-uart,0x02500000 clk_ignore_unused initcall_debug=0 console=ttyS0,115200 loglevel=8 root=/dev/mmcblk0p4  init=/sbin/init partitions=ext4 cma=8M  gpt=1 androidboot.hardware=sun20iw1p1 boot_type=1 androidboot.boot_type=1 gpt=1 uboot_message=2018.05(01/05/2022-03:36:39) mbr_offset=1556480 disp_reserve=4096000,0x0000000042b1b280 androidboot.dramsize=64 
[    0.000000] Dentry cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.000000] Inode-cache hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.000000] Sorting __ex_table...
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 39688K/63488K available (6040K kernel code, 645K rwdata, 2096K rodata, 272K init, 253K bss, 15608K reserved, 8192K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] rcu: Preemptible hierarchical RCU implementation.
[    0.000000]  Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
[    0.000000] plic: mapped 200 interrupts with 1 handlers for 2 contexts.
[    0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0]
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[    0.000007] sched_clock: 64 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    0.000026] riscv_timer_clockevent depends on broadcast, but no broadcast function available
[    0.000359] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000985] Console: colour dummy device 80x25
[    0.001028] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[    0.001046] pid_max: default: 32768 minimum: 301
[    0.001218] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.001239] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.003234] ASID allocator initialised with 65536 entries
[    0.003428] rcu: Hierarchical SRCU implementation.
[    0.004149] devtmpfs: initialized
[    0.016245] random: get_random_u32 called from bucket_table_alloc.isra.31+0x4e/0x15e with crng_init=0
[    0.017316] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.017355] futex hash table entries: 256 (order: 0, 6144 bytes, linear)
[    0.017875] pinctrl core: initialized pinctrl subsystem
[    0.019388] NET: Registered protocol family 16
[    0.021534] DMA: preallocated 256 KiB pool for atomic allocations
[    0.022241] cpuidle: using governor menu
[    0.063931] rtc_ccu: sunxi ccu init OK
[    0.072394] clock: sunxi ccu init OK
[    0.073507] clock: sunxi ccu init OK
[    0.115016] iommu: Default domain type: Translated 
[    0.115220] sunxi iommu: irq = 4
[    0.116453] SCSI subsystem initialized
[    0.116826] usbcore: registered new interface driver usbfs
[    0.116913] usbcore: registered new interface driver hub
[    0.117038] usbcore: registered new device driver usb
[    0.117218] mc: Linux media interface: v0.10
[    0.117302] videodev: Linux video capture interface: v2.00
[    0.118545] sunxi-msgbox-amp 3003000.msgbox: invalid resource
[    0.119360] Advanced Linux Sound Architecture Driver Initialized.
[    0.120008] Bluetooth: Core ver 2.22
[    0.120095] NET: Registered protocol family 31
[    0.120107] Bluetooth: HCI device and connection manager initialized
[    0.120129] Bluetooth: HCI socket layer initialized
[    0.120144] Bluetooth: L2CAP socket layer initialized
[    0.120182] Bluetooth: SCO socket layer initialized
[    0.120652] pwm module init!
[    0.123252] clocksource: Switched to clocksource riscv_clocksource
[    0.136284] sun8iw20-pinctrl 2000000.pinctrl: initialized sunXi PIO driver
[    0.154570] thermal_sys: Registered thermal governor 'step_wise'
[    0.154577] thermal_sys: Registered thermal governor 'user_space'
[    0.155175] NET: Registered protocol family 2
[    0.156070] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.156121] TCP established hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.156142] TCP bind hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.156157] TCP: Hash tables configured (established 512 bind 512)
[    0.156332] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.156380] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.156648] NET: Registered protocol family 1
[    0.159497] Initialise system trusted keyrings
[    0.159820] workingset: timestamp_bits=62 max_order=14 bucket_order=0
[    0.167746] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.186919] Key type asymmetric registered
[    0.186938] Asymmetric key parser 'x509' registered
[    0.187018] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 249)
[    0.187032] io scheduler mq-deadline registered
[    0.187040] io scheduler kyber registered
[    0.187064] atomic64_test: passed
[    0.188408] [DISP]disp_module_init
[    0.189089] disp 5000000.disp: Adding to iommu group 0
[    0.189860] [DISP] disp_init,line:2385:
[    0.189866] smooth display screen:0 type:1 mode:4
[    0.218248] disp 5000000.disp: 5000000.disp supply vcc-lcd not found, using dummy regulator
[    0.218523] disp 5000000.disp: 5000000.disp supply vcc-pd not found, using dummy regulator
[    0.231063] [DISP] disp_sys_pwm_request,line:442:
[    0.231070] disp_sys_pwm_request pwm 8 fail! -517
[    0.231086] [DISP] disp_sys_pwm_config,line:509:
[    0.231089] disp_sys_pwm_Config, handle is NULL!
[    0.231768] display_fb_request,fb_id:0
[    0.245857] [DISP] Fb_copy_boot_fb,line:1506:
[    0.245864] src_height(1280) > dst_height(480),please cut the height
[    0.246383] disp_al_manager_apply ouput_type:1
[    0.246592] [DISP] lcd_clk_config,line:731:
[    0.246606] disp 0, clk: pll(198000000),clk(198000000),dclk(33000000) dsi_rate(198000000)
[    0.246606]      clk real:pll(288000000),clk(288000000),dclk(48000000) dsi_rate(0)
[    0.246666] [DISP] disp_sys_gpio_request,line:276:
[    0.246673] disp_sys_gpio_request failed, gpio_name=lcd_bl_en, gpio=123, value=0, ret=-517
[    0.246687] [DISP] disp_sys_pwm_request,line:442:
[    0.246691] disp_sys_pwm_request pwm 8 fail! -517
[    0.247275] [DISP]disp_module_init finish
[    0.248201] sunxi_sid_init()506 - insmod ok
[    0.256497] sun8iw20-pinctrl 2000000.pinctrl: 2000000.pinctrl supply vcc-pe not found, using dummy regulator
[    0.257186] uart uart0: get regulator failed
[    0.257218] uart uart0: uart0 supply uart not found, using dummy regulator
[    0.257586] uart0: ttyS0 at MMIO 0x2500000 (irq = 18, base_baud = 1500000) is a SUNXI
[    0.257617] sw_console_setup()1808 - console setup baud 115200 parity n bits 8, flow n
[    1.053936] printk: console [ttyS0] enabled
[    1.059513] sun8iw20-pinctrl 2000000.pinctrl: 2000000.pinctrl supply vcc-pg not found, using dummy regulator
[    1.071033] uart uart1: get regulator failed
[    1.075873] uart uart1: uart1 supply uart not found, using dummy regulator
[    1.083989] uart1: ttyS1 at MMIO 0x2500400 (irq = 19, base_baud = 1500000) is a SUNXI
[    1.093633] sun8iw20-pinctrl 2000000.pinctrl: 2000000.pinctrl supply vcc-pb not found, using dummy regulator
[    1.105088] uart uart3: get regulator failed
[    1.109871] uart uart3: uart3 supply uart not found, using dummy regulator
[    1.117984] uart3: ttyS3 at MMIO 0x2500c00 (irq = 21, base_baud = 1500000) is a SUNXI
[    1.127980] misc dump reg init
[    1.132327] sunxi-rfkill soc@3000000:rfkill@0: module version: v1.0.9
[    1.139593] sunxi-rfkill soc@3000000:rfkill@0: devm_pinctrl_get() failed!
[    1.147209] sunxi-rfkill soc@3000000:rfkill@0: get gpio chip_en failed
[    1.154531] sunxi-rfkill soc@3000000:rfkill@0: get gpio power_en failed
[    1.161923] sunxi-rfkill soc@3000000:rfkill@0: wlan_busnum (1)
[    1.168463] sunxi-rfkill soc@3000000:rfkill@0: Missing wlan_power.
[    1.175429] sunxi-rfkill soc@3000000:rfkill@0: wlan_regon gpio=204 assert=1
[    1.183332] sunxi-rfkill soc@3000000:rfkill@0: wlan_hostwake gpio=202 assert=1
[    1.191431] sunxi-rfkill soc@3000000:rfkill@0: wakeup source is enabled
[    1.199133] sunxi-rfkill soc@3000000:rfkill@0: Missing bt_power.
[    1.205939] sunxi-rfkill soc@3000000:rfkill@0: bt_rst gpio=207 assert=0
[    1.214116] [ADDR_MGT] addr_mgt_probe: module version: v1.0.9
[    1.221751] [ADDR_MGT] addr_mgt_probe: success.
[    1.228319] libphy: Fixed MDIO Bus: probed
[    1.232896] CAN device driver interface
[    1.237573] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.244908] sunxi-ehci: EHCI SUNXI driver
[    1.249922] get ehci0-controller wakeup-source is fail.
[    1.255922] sunxi ehci0-controller don't init wakeup source
[    1.262144] [sunxi-ehci0]: probe, pdev->name: 4101000.ehci0-controller, sunxi_ehci: 0xffffffe000904940, 0x:ffffffd004079000, irq_no:2e
[    1.275661] [sunxi-ehci0]: Not init ehci0
[    1.280536] get ehci1-controller wakeup-source is fail.
[    1.286557] sunxi ehci1-controller don't init wakeup source
[    1.292782] [sunxi-ehci1]: probe, pdev->name: 4200000.ehci1-controller, sunxi_ehci: 0xffffffe000904d00, 0x:ffffffd00407d000, irq_no:31
[    1.306328] hci: sunxi_insmod_ehci()600 WARN: get supply failed
[    1.312971] sunxi-ehci 4200000.ehci1-controller: EHCI Host Controller
[    1.320255] sunxi-ehci 4200000.ehci1-controller: new USB bus registered, assigned bus number 1
[    1.330128] sunxi-ehci 4200000.ehci1-controller: irq 49, io mem 0x04200000
[    1.363296] sunxi-ehci 4200000.ehci1-controller: USB 2.0 started, EHCI 1.00
[    1.372177] hub 1-0:1.0: USB hub found
[    1.376509] hub 1-0:1.0: 1 port detected
[    1.381806] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    1.388829] sunxi-ohci: OHCI SUNXI driver
[    1.393950] get ohci0-controller wakeup-source is fail.
[    1.399902] sunxi ohci0-controller don't init wakeup source
[    1.406182] [sunxi-ohci0]: probe, pdev->name: 4101400.ohci0-controller, sunxi_ohci: 0xffffffe000905480
[    1.416590] [sunxi-ohci0]: Not init ohci0
[    1.421482] get ohci1-controller wakeup-source is fail.
[    1.427498] sunxi ohci1-controller don't init wakeup source
[    1.433763] [sunxi-ohci1]: probe, pdev->name: 4200400.ohci1-controller, sunxi_ohci: 0xffffffe000905840
[    1.444199] hci: sunxi_insmod_ohci()265 WARN: get supply failed
[    1.450845] sunxi-ohci 4200400.ohci1-controller: OHCI Host Controller
[    1.458110] sunxi-ohci 4200400.ohci1-controller: new USB bus registered, assigned bus number 2
[    1.467960] sunxi-ohci 4200400.ohci1-controller: irq 50, io mem 0x04200400
[    1.548370] hub 2-0:1.0: USB hub found
[    1.552645] hub 2-0:1.0: 1 port detected
[    1.558323] usbcore: registered new interface driver uas
[    1.564549] usbcore: registered new interface driver usb-storage
[    1.571328] usbcore: registered new interface driver ums-alauda
[    1.578111] usbcore: registered new interface driver ums-cypress
[    1.584944] usbcore: registered new interface driver ums-datafab
[    1.591707] usbcore: registered new interface driver ums_eneub6250
[    1.598732] usbcore: registered new interface driver ums-freecom
[    1.605578] usbcore: registered new interface driver ums-isd200
[    1.612256] usbcore: registered new interface driver ums-jumpshot
[    1.619200] usbcore: registered new interface driver ums-karma
[    1.625840] usbcore: registered new interface driver ums-onetouch
[    1.632725] usbcore: registered new interface driver ums-realtek
[    1.639562] usbcore: registered new interface driver ums-sddr09
[    1.646299] usbcore: registered new interface driver ums-sddr55
[    1.652991] usbcore: registered new interface driver ums-usbat
[    1.660042] mousedev: PS/2 mouse device common for all mice
[    1.667147] ts probe start
[    1.667576] input: 2009c00.rtp as /devices/platform/soc@3000000/2009c00.rtp/input/input0
[    1.680233] ts probe success
[    1.680643] sunxi_gpadc_init,1968, success
[    1.689299] sunxi-rtc 7090000.rtc: errata__fix_alarm_day_reg_default_value(): ALARM0_DAY_REG=0, set it to 1
[    1.701669] sunxi-rtc 7090000.rtc: registered as rtc0
[    1.707473] sunxi-rtc 7090000.rtc: setting system clock to 1970-01-01T00:00:03 UTC (3)
[    1.716373] sunxi-rtc 7090000.rtc: sunxi rtc probed
[    1.722216] i2c /dev entries driver
[    1.726285] IR NEC protocol handler initialized
[    1.731340] IR RC5(x/sz) protocol handler initialized
[    1.737012] IR RC6 protocol handler initialized
[    1.742062] IR JVC protocol handler initialized
[    1.747135] IR Sony protocol handler initialized
[    1.752283] IR SANYO protocol handler initialized
[    1.757551] IR Sharp protocol handler initialized
[    1.762796] IR MCE Keyboard/mouse protocol handler initialized
[    1.769323] IR XMP protocol handler initialized
[    1.774393] ir_imon_decoder: IR iMON protocol handler initialized
[    1.781186] IR RCMM protocol handler initialized
[    1.787053] sunxi cedar version 1.1
[    1.791240] sunxi-cedar 1c0e000.ve: Adding to iommu group 0
[    1.797556] VE: install start!!!
[    1.797556] 
[    1.803112] VE: cedar-ve the get irq is 6
[    1.803112] 
[    1.809514] VE: ve_debug_proc_info:(____ptrval____), data:(____ptrval____), lock:(____ptrval____)
[    1.809514] 
[    1.821109] VE: install end!!!
[    1.821109] 
[    1.827679] sunxi-wdt 6011000.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[    1.836864] Bluetooth: HCI UART driver ver 2.3
[    1.841823] Bluetooth: HCI UART protocol H4 registered
[    1.847604] Bluetooth: HCI UART protocol BCSP registered
[    1.853550] Bluetooth: XRadio Bluetooth LPM Mode Driver Ver 1.0.10
[    1.860863] [XR_BT_LPM] bluesleep_probe: bt_wake polarity: 1
[    1.867317] [XR_BT_LPM] bluesleep_probe: host_wake polarity: 1
[    1.873912] [XR_BT_LPM] bluesleep_probe: wakeup source is disabled!
[    1.873912] 
[    1.882548] [XR_BT_LPM] bluesleep_probe: uart_index(1)
[    1.891545] sunxi-mmc 4020000.sdmmc: SD/MMC/SDIO Host Controller Driver(v4.19 2021-03-24 19:50)
[    1.901581] sunxi-mmc 4020000.sdmmc: ***ctl-spec-caps*** 8
[    1.907812] sunxi-mmc 4020000.sdmmc: No vmmc regulator found
[    1.914155] sunxi-mmc 4020000.sdmmc: No vqmmc regulator found
[    1.920563] sunxi-mmc 4020000.sdmmc: No vdmmc regulator found
[    1.926993] sunxi-mmc 4020000.sdmmc: No vd33sw regulator found
[    1.933526] sunxi-mmc 4020000.sdmmc: No vd18sw regulator found
[    1.940031] sunxi-mmc 4020000.sdmmc: No vq33sw regulator found
[    1.946560] sunxi-mmc 4020000.sdmmc: No vq18sw regulator found
[    1.953636] sunxi-mmc 4020000.sdmmc: Got CD GPIO
[    1.959111] sunxi-mmc 4020000.sdmmc: set cd-gpios as 24M fail
[    1.965862] sunxi-mmc 4020000.sdmmc: sdc set ios:clk 0Hz bm PP pm UP vdd 21 width 1 timing LEGACY(SDR12) dt B
[    1.977023] sunxi-mmc 4020000.sdmmc: no vqmmc,Check if there is regulator
[    1.997178] sunxi-mmc 4020000.sdmmc: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    2.021640] sunxi-mmc 4020000.sdmmc: detmode:gpio irq
[    2.027365] sunxi-mmc 4020000.sdmmc: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    2.039688] sunxi-mmc 4021000.sdmmc: SD/MMC/SDIO Host Controller Driver(v4.19 2021-03-24 19:50)
[    2.049846] sunxi-mmc 4021000.sdmmc: ***ctl-spec-caps*** 8
[    2.056115] sunxi-mmc 4021000.sdmmc: No vmmc regulator found
[    2.062475] sunxi-mmc 4021000.sdmmc: No vqmmc regulator found
[    2.068949] sunxi-mmc 4020000.sdmmc: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    2.080532] sunxi-mmc 4021000.sdmmc: No vdmmc regulator found
[    2.086968] sunxi-mmc 4021000.sdmmc: No vd33sw regulator found
[    2.093617] sunxi-mmc 4021000.sdmmc: No vd18sw regulator found
[    2.100175] sunxi-mmc 4021000.sdmmc: No vq33sw regulator found
[    2.106765] sunxi-mmc 4021000.sdmmc: No vq18sw regulator found
[    2.113376] sunxi-mmc 4021000.sdmmc: Cann't get pin bias hs pinstate,check if needed
[    2.122062] sunxi-mmc 4020000.sdmmc: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    2.134846] sunxi-mmc 4021000.sdmmc: sdc set ios:clk 0Hz bm PP pm UP vdd 21 width 1 timing LEGACY(SDR12) dt B
[    2.146061] sunxi-mmc 4021000.sdmmc: no vqmmc,Check if there is regulator
[    2.155008] sunxi-mmc 4020000.sdmmc: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    2.166609] sunxi-mmc 4021000.sdmmc: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    2.190929] sunxi-mmc 4021000.sdmmc: detmode:manually by software
[    2.198639] sunxi-mmc 4021000.sdmmc: smc 1 p1 err, cmd 52, RTO !!
[    2.206223] usbcore: registered new interface driver usbhid
[    2.212488] sunxi-mmc 4021000.sdmmc: smc 1 p1 err, cmd 52, RTO !!
[    2.219397] sunxi-mmc 4021000.sdmmc: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    2.231018] usbhid: USB HID core driver
[    2.237600] usbcore: registered new interface driver snd-usb-audio
[    2.244668] sunxi-mmc 4021000.sdmmc: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing LEGACY(SDR12) dt B
[    2.256284] mmc0: host does not support reading read-only switch, assuming write-enable
[    2.268716] [AUDIOCODEC][sunxi_codec_parse_params][2094]:digital_vol:0, lineout_vol:26, mic1gain:19, mic2gain:19 pa_msleep:120, pa_level:1, pa_pwr_level:1
[    2.268716] 
[    2.286049] [AUDIOCODEC][sunxi_codec_parse_params][2130]:adcdrc_cfg:0, adchpf_cfg:1, dacdrc_cfg:0, dachpf:0
[    2.297040] sunxi-mmc 4020000.sdmmc: sdc set ios:clk 400000Hz bm PP pm ON vdd 21 width 1 timing SD-HS(SDR25) dt B
[    2.309140] [AUDIOCODEC][sunxi_internal_codec_probe][2266]:codec probe finished
[    2.317319] sunxi-mmc 4021000.sdmmc: smc 1 p1 err, cmd 5, RTO !!
[    2.324245] sunxi-mmc 4020000.sdmmc: sdc set ios:clk 50000000Hz bm PP pm ON vdd 21 width 1 timing SD-HS(SDR25) dt B
[    2.335900] sunxi-mmc 4021000.sdmmc: smc 1 p1 err, cmd 5, RTO !!
[    2.343491] sunxi-mmc 4021000.sdmmc: smc 1 p1 err, cmd 5, RTO !!
[    2.350247] sunxi-mmc 4020000.sdmmc: sdc set ios:clk 50000000Hz bm PP pm ON vdd 21 width 4 timing SD-HS(SDR25) dt B
[    2.362770] sunxi-mmc 4021000.sdmmc: smc 1 p1 err, cmd 5, RTO !!
[    2.369573] sunxi-mmc 4021000.sdmmc: sdc set ios:clk 0Hz bm PP pm OFF vdd 0 width 1 timing LEGACY(SDR12) dt B
[    2.380773] mmc0: new high speed SDXC card at address 59b4
[    2.387055] sid_rd_ver_reg()254 - ver >= 4, soc ver:5
[    2.392742] debugfs: Directory '203034c.dummy_cpudai' with parent 'audiocodec' already present!
[    2.404134] mmcblk0: mmc0:59b4 ED2S5 119 GiB 
[    2.412123] [SNDCODEC][sunxi_card_init][583]:card init finished
[    2.424173] sunxi-codec-machine 2030340.sound: 2030000.codec <-> 203034c.dummy_cpudai mapping ok
[    2.434276] GPT:Primary header thinks Alt. header is not at the end of the disk.
[    2.442532] GPT:1124864 != 250347519
[    2.448209] input: audiocodec sunxi Audio Jack as /devices/platform/soc@3000000/2030340.sound/sound/card0/input1
[    2.459629] GPT:Alternate GPT header not at the end of the disk.
[    2.467150] [SNDCODEC][sunxi_card_dev_probe][832]:register card finished
[    2.474697] GPT:1124864 != 250347519
[    2.478682] GPT: Use GNU Parted to correct GPT errors.
[    2.485243] rpmsg_hifi 3003000.msgbox.sunxi,dsp-msgbox.514.258: id:sunxi,dsp-msgbox new channel: 0x202 -> 0x102!
[    2.496724]  mmcblk0: p1 p2 p3 p4
[    2.502758] rpmsg_hifi 3003000.msgbox.sunxi,dsp-msgbox.514.258: rpmsg hifi[0] client driver is probed
[    2.514881] NET: Registered protocol family 10
[    2.521215] Segment Routing with IPv6
[    2.525675] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    2.533182] NET: Registered protocol family 17
[    2.538323] can: controller area network core (rev 20170425 abi 9)
[    2.545416] NET: Registered protocol family 29
[    2.550382] can: raw protocol (rev 20170425)
[    2.555189] can: broadcast manager protocol (rev 20170425 t)
[    2.561514] can: netlink gateway (rev 20190810) max_hops=1
[    2.568042] Bluetooth: RFCOMM TTY layer initialized
[    2.573614] Bluetooth: RFCOMM socket layer initialized
[    2.579378] Bluetooth: RFCOMM ver 1.11
[    2.584786] Loading compiled-in X.509 certificates
# HDMI 是 D1-H 芯片的, D1s没有
[    2.592833] HDMI 2.0 driver init start!
[    2.597225] boot_hdmi=false
[    2.600414] ERROR: pinctrl_get for HDMI2.0 DDC fail
[    2.607610] HDMI2.0 module init end
[    2.640251] twi twi2: twi2 supply twi not found, using dummy regulator
[    2.653776] sunxi_i2c_probe()2262 - [i2c2] probe success
[    2.666154] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    2.677874] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    2.685548] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[    2.695275] clk: Not disabling unused clocks
[    2.700049] ALSA device list:
[    2.703506] cfg80211: failed to load regulatory.db
[    2.708938]   #0: audiocodec
[    2.712165] alloc_fd: slot 0 not NULL!
[    2.724830] EXT4-fs (mmcblk0p4): mounted filesystem with ordered data mode. Opts: (null)
[    2.734075] VFS: Mounted root (ext4 filesystem) readonly on device 179:4.
[    2.742495] devtmpfs: mounted
[    2.746276] Freeing unused kernel memory: 272K
[    2.751232] This architecture does not have kernel memory protection.
[    2.758509] Run /sbin/init as init process
[    2.895093] EXT4-fs (mmcblk0p4): re-mounted. Opts: (null)
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Populating /dev using udev: [    3.133453] [SNDCODEC][sunxi_check_hs_detect_status][191]:plugin --> switch:1
[    3.172062] udevd[103]: starting version 3.2.9
[    3.185789] random: udevd: uninitialized urandom read (16 bytes read)
[    3.194955] random: udevd: uninitialized urandom read (16 bytes read)
[    3.202281] random: udevd: uninitialized urandom read (16 bytes read)
[    3.251495] udevd[104]: starting eudev-3.2.9
done

Welcome to Buildroot
buildroot login: [    6.203302] hdmi_hpd_sys_config_release
[    6.283498] 
[    6.283498] insmod_device_driver
[    6.283498] 
[   10.286828] random: fast init done

系统探索

这里为了高亮显示, 命令前的 # 改成 $

# 默认登录名 root, 无密码

# 内核信息
$ uname -a
Linux buildroot 5.4.61 #1 PREEMPT Wed Jan 12 22:40:19 PST 2022 riscv64 GNU/Linux

# CPU信息, RV64
$ cat /proc/cpuinfo
processor       : 0
hart            : 0
isa             : rv64imafdcvu	# isa: Instruction Set Architecture, 指令集架构, 常见CISC, RISC, EPIC等
mmu             : sv39	# mmu: Memory Management Unit, 内存管理单元
# https://zhuanlan.zhihu.com/p/263372436
# SV39 支持39位虚拟内存空间, 参考上面链接

# 内存信息, 参考https://blog.51cto.com/xujpxm/1961072
# 或者用free命令
$ cat /proc/meminfo
MemTotal:          48152 kB	# 可供系统支配的内存, 除去了BIOS和内核保留的内存
MemFree:           18736 kB	# 系统尚未使用的内存
MemAvailable:      22308 kB # 应用程序可用内存数 MemAvailable≈MemFree+Buffers+Cached
...
# free
              total        used        free      shared  buff/cache   available
Mem:          48152       19452       18844          96        9856       22420
Swap:             0           0           0

# 磁盘信息
$ df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root               476.2M     11.4M    435.8M   3% /
devtmpfs                 19.4M         0     19.4M   0% /dev
tmpfs                    23.5M         0     23.5M   0% /dev/shm
tmpfs                    23.5M     24.0K     23.5M   0% /tmp
tmpfs                    23.5M     72.0K     23.4M   0% /run

# 分区
$ cat /proc/partitions
major minor  #blocks  name

 179        0  125173760 mmcblk0
 179        1        128 mmcblk0p1
 179        2        128 mmcblk0p2
 179        3      32768 mmcblk0p3
 179        4     512000 mmcblk0p4
 
# 网络信息, 默认没有支持板载的 RTL8189 WiFi模组(802.11n, 最高150Mbps, SDIO接口)
$ ip link
1: lo: <LOOPBACK> mtu 65536 qdisc noop qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: sit0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0 
$ ifconfig

OpenSBI

riscv-software-src/opensbi: RISC-V Open Source Supervisor Binary Interface (github.com)

RISC-V指令集的SBI标准规定了类Unix平台下操作系统运行环境的规范.OpenSBI是它的一种实现.

**RISC-V Supervisor 二进制接口 (SBI)**是以下各项之间的推荐接口:

  • 在 M 模式下运行的特定于平台的固件,以及在 S 模式或 HS 模式下执行的引导加载程序、虚拟机管理程序或通用操作系统。

  • 在 HS 模式下运行的虚拟机管理程序,以及在 VS 模式下执行的引导加载程序或通用操作系统。

OpenSBI项目的目标是为在M模式下执行的特定于平台的固件提供RISC-V SBI规范的开源参考实现

OpenSBI 之后才是 U-Boot, 然后是 Kernel(可以是Linux, 也可以RT Thread).

可以参考 OpenSBI 编译和运行 - 知乎 (zhihu.com), 在 Ubuntu18/20 上实现一把, 这里就略了

QEMU Buildroot RISCV

如果没有板子, 又想探索RISC-V, 可以用QEMU和Buildroot. 这里留下Ubuntu20下用Buildroot构建RV64平台的Linux, 用QEMU启动的操作记录

Buildroot

#!/bin/bash

# Ubuntu20下测试
# 环境预装
sudo apt install -y debianutils sed make binutils build-essential gcc g++ bash patch gzip bzip2 perl tar cpio unzip rsync file bc git

# 获取buildroot
wget https://buildroot.org/downloads/buildroot-2021.02.8.tar.gz

# 解压到指定文件夹, -C, 解压到指定目录, --strip-components 1, 删除最外层结构
mkdir buildroot && tar -zxvf buildroot-2021.02.8.tar.gz -C ./buildroot --strip-components 1 && cd buildroot

# 加载 qemu rv64 配置
make qemu_riscv64_virt_defconfig	

# 切换到国内源
echo 'BR2_KERNEL_MIRROR="https://mirror.bjtu.edu.cn/kernel/"' >> .config
echo 'BR2_GNU_MIRROR="http://mirrors.nju.edu.cn/gnu/"' >> .config
echo 'BR2_LUAROCKS_MIRROR="https://luarocks.cn"' >> .config
echo 'BR2_CPAN_MIRROR="http://mirrors.nju.edu.cn/CPAN/"' >> .config
make menuconfig

# 开始构建, 17:47~18:20
make -j $(nproc)

查看输出

# 还是上面的buildroot路径
$ ls -lh output/images/
total 18M
-rw-r--r-- 1 z z  94K Jan 13 02:17 fw_dynamic.bin
-rw-r--r-- 1 z z 635K Jan 13 02:17 fw_dynamic.elf
-rw-r--r-- 1 z z  94K Jan 13 02:17 fw_jump.bin
-rw-r--r-- 1 z z 634K Jan 13 02:17 fw_jump.elf
-rw-r--r-- 1 z z  17M Jan 13 02:20 Image
-rw-r--r-- 1 z z  60M Jan 13 02:20 rootfs.ext2
-rw-r--r-- 1 z z 2.3M Jan 13 02:20 rootfs.tar
-rwxr-xr-x 1 z z  477 Jan 13 02:20 start-qemu.sh

QEMU, 安装略过, 这里直接启动


$ sudo qemu-system-riscv64 \
  -M virt -nographic \
  -bios output/images/fw_jump.elf \
  -kernel output/images/Image \
  -append "root=/dev/vda ro" \
  -drive file=output/images/rootfs.ext2,format=raw,id=hd0 \
  -device virtio-blk-device,drive=hd0 \
  -netdev user,id=net0 -device virtio-net-device,netdev=net0

启动日志, 也是(OpenSBI-->U-Boot-->Kernel)

OpenSBI v0.8
   ____                    _____ ____ _____
  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name       : riscv-virtio,qemu
Platform Features   : timer,mfdeleg
Platform HART Count : 1
Boot HART ID        : 0
Boot HART ISA       : rv64imafdcsu
BOOT HART Features  : pmp,scounteren,mcounteren,time
BOOT HART PMP Count : 16
Firmware Base       : 0x80000000
Firmware Size       : 116 KB
Runtime SBI Version : 0.2

MIDELEG : 0x0000000000000222
MEDELEG : 0x000000000000b109
PMP0    : 0x0000000080000000-0x000000008001ffff (A)
PMP1    : 0x0000000000000000-0xffffffffffffffff (A,R,W,X)
[    0.000000] Linux version 5.10.7 (z@ubuntu) (riscv64-buildroot-linux-uclibc-gcc.br_real (Buildroot 2021.02.8) 9.4.0, GNU ld (GNU Binutils) 2.35.2) #2 SMP Thu Jan 13 02:20:28 PST 2022
[    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
[    0.000000] efi: UEFI not found.
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000080200000-0x0000000087ffffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080200000-0x0000000087ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x0000000087ffffff]
[    0.000000] software IO TLB: mapped [mem 0x0000000083e3a000-0x0000000087e3a000] (64MB)
[    0.000000] SBI specification v0.2 detected
[    0.000000] SBI implementation ID=0x1 Version=0x8
[    0.000000] SBI v0.2 TIME extension detected
[    0.000000] SBI v0.2 IPI extension detected
[    0.000000] SBI v0.2 RFENCE extension detected
[    0.000000] SBI v0.2 HSM extension detected
[    0.000000] riscv: ISA extensions acdfimsu
[    0.000000] riscv: ELF capabilities acdfim
[    0.000000] percpu: Embedded 17 pages/cpu s32360 r8192 d29080 u69632
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 31815
[    0.000000] Kernel command line: root=/dev/vda ro
[    0.000000] Dentry cache hash table entries: 16384 (order: 5, 131072 bytes, linear)
[    0.000000] Inode-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.000000] Sorting __ex_table...
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 43380K/129024K available (6881K kernel code, 4195K rwdata, 4096K rodata, 223K init, 342K bss, 85644K reserved, 0K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.000000]       fixmap : 0xffffffcefee00000 - 0xffffffceff000000   (2048 kB)
[    0.000000]       pci io : 0xffffffceff000000 - 0xffffffcf00000000   (  16 MB)
[    0.000000]      vmemmap : 0xffffffcf00000000 - 0xffffffcfffffffff   (4095 MB)
[    0.000000]      vmalloc : 0xffffffd000000000 - 0xffffffdfffffffff   (65535 MB)
[    0.000000]       lowmem : 0xffffffe000000000 - 0xffffffe007e00000   ( 126 MB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=1.
[    0.000000] rcu:     RCU debug extended QS entry/exit.
[    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=1
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] riscv-intc: 64 local interrupts mapped
[    0.000000] plic: plic@c000000: mapped 53 interrupts with 1 handlers for 2 contexts.
[    0.000000] random: get_random_bytes called from start_kernel+0x312/0x484 with crng_init=0
[    0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0]
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x24e6a1710, max_idle_ns: 440795202120 ns
[    0.000129] sched_clock: 64 bits at 10MHz, resolution 100ns, wraps every 4398046511100ns
[    0.027448] Console: colour dummy device 80x25
[    0.029114] printk: console [tty0] enabled
[    0.031526] Calibrating delay loop (skipped), value calculated using timer frequency.. 20.00 BogoMIPS (lpj=40000)
[    0.031703] pid_max: default: 32768 minimum: 301
[    0.033129] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.033230] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.075639] rcu: Hierarchical SRCU implementation.
[    0.077310] EFI services will not be available.
[    0.079675] smp: Bringing up secondary CPUs ...
[    0.079778] smp: Brought up 1 node, 1 CPU
[    0.090523] devtmpfs: initialized
[    0.096765] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.097061] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[    0.103357] NET: Registered protocol family 16
[    0.192609] vgaarb: loaded
[    0.194657] SCSI subsystem initialized
[    0.197058] usbcore: registered new interface driver usbfs
[    0.197427] usbcore: registered new interface driver hub
[    0.197671] usbcore: registered new device driver usb
[    0.208508] clocksource: Switched to clocksource riscv_clocksource
[    0.225838] NET: Registered protocol family 2
[    0.230451] tcp_listen_portaddr_hash hash table entries: 128 (order: 0, 5120 bytes, linear)
[    0.230629] TCP established hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.230885] TCP bind hash table entries: 1024 (order: 3, 32768 bytes, linear)
[    0.231049] TCP: Hash tables configured (established 1024 bind 1024)
[    0.232159] UDP hash table entries: 256 (order: 2, 24576 bytes, linear)
[    0.232720] UDP-Lite hash table entries: 256 (order: 2, 24576 bytes, linear)
[    0.234825] NET: Registered protocol family 1
[    0.251345] RPC: Registered named UNIX socket transport module.
[    0.251533] RPC: Registered udp transport module.
[    0.251566] RPC: Registered tcp transport module.
[    0.251611] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.251791] PCI: CLS 0 bytes, default 64
[    0.257225] workingset: timestamp_bits=62 max_order=14 bucket_order=0
[    0.283960] NFS: Registering the id_resolver key type
[    0.285144] Key type id_resolver registered
[    0.285237] Key type id_legacy registered
[    0.285740] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.286415] 9p: Installing v9fs 9p2000 file system support
[    0.288142] NET: Registered protocol family 38
[    0.288640] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[    0.289155] io scheduler mq-deadline registered
[    0.289289] io scheduler kyber registered
[    0.299744] pci-host-generic 30000000.pci: host bridge /soc/pci@30000000 ranges:
[    0.300915] pci-host-generic 30000000.pci:       IO 0x0003000000..0x000300ffff -> 0x0000000000
[    0.301850] pci-host-generic 30000000.pci:      MEM 0x0040000000..0x007fffffff -> 0x0040000000
[    0.302015] pci-host-generic 30000000.pci:      MEM 0x0400000000..0x07ffffffff -> 0x0400000000
[    0.303826] pci-host-generic 30000000.pci: ECAM at [mem 0x30000000-0x3fffffff] for [bus 00-ff]
[    0.305181] pci-host-generic 30000000.pci: PCI host bridge to bus 0000:00
[    0.305773] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.305974] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
[    0.306052] pci_bus 0000:00: root bus resource [mem 0x40000000-0x7fffffff]
[    0.306125] pci_bus 0000:00: root bus resource [mem 0x400000000-0x7ffffffff]
[    0.307325] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000
[    0.401693] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.408783] 10000000.uart: ttyS0 at MMIO 0x10000000 (irq = 2, base_baud = 230400) is a 16550A
[    0.438209] printk: console [ttyS0] enabled
[    0.442539] [drm] radeon kernel modesetting enabled.
[    0.493504] loop: module loaded
[    0.545877] virtio_blk virtio0: [vda] 122880 512-byte logical blocks (62.9 MB/60.0 MiB)
[    0.546344] vda: detected capacity change from 0 to 62914560
[    0.584098] libphy: Fixed MDIO Bus: probed
[    0.591653] e1000e: Intel(R) PRO/1000 Network Driver
[    0.591934] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    0.592749] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.593296] ehci-pci: EHCI PCI platform driver
[    0.594195] ehci-platform: EHCI generic platform driver
[    0.610079] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.610910] ohci-pci: OHCI PCI platform driver
[    0.611568] ohci-platform: OHCI generic platform driver
[    0.614493] usbcore: registered new interface driver uas
[    0.615098] usbcore: registered new interface driver usb-storage
[    0.618038] mousedev: PS/2 mouse device common for all mice
[    0.626987] goldfish_rtc 101000.rtc: registered as rtc0
[    0.627891] goldfish_rtc 101000.rtc: setting system clock to 2022-01-13T10:35:59 UTC (1642070159)
[    0.631672] syscon-poweroff soc:poweroff: pm_power_off already claimed (____ptrval____) sbi_shutdown
[    0.632178] syscon-poweroff: probe of soc:poweroff failed with error -16
[    0.635264] usbcore: registered new interface driver usbhid
[    0.635765] usbhid: USB HID core driver
[    0.639040] NET: Registered protocol family 10
[    0.647223] Segment Routing with IPv6
[    0.648096] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    0.652770] NET: Registered protocol family 17
[    0.655504] 9pnet: Installing 9P2000 support
[    0.656218] Key type dns_resolver registered
[    0.657750] debug_vm_pgtable: [debug_vm_pgtable         ]: Validating architecture page table helpers
[    0.676954] EXT4-fs (vda): mounting ext2 file system using the ext4 subsystem
[    0.701937] EXT4-fs (vda): mounted filesystem without journal. Opts: (null)
[    0.703090] VFS: Mounted root (ext2 filesystem) readonly on device 254:0.
[    0.708240] devtmpfs: mounted
[    0.731269] Freeing unused kernel memory: 220K
[    0.732660] Run /sbin/init as init process
[    0.907614] EXT4-fs (vda): re-mounted. Opts: (null)
[    0.908174] ext2 filesystem being remounted at / supports timestamps until 2038 (0x7fffffff)
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Saving random seed: [    1.725500] random: dd: uninitialized urandom read (512 bytes read)
OK
Starting network: udhcpc: started, v1.33.2
[    2.478683] random: mktemp: uninitialized urandom read (6 bytes read)
udhcpc: sending discover
udhcpc: sending select for 10.0.2.15
udhcpc: lease of 10.0.2.15 obtained, lease time 86400
deleting routers
[    2.721551] random: mktemp: uninitialized urandom read (6 bytes read)
adding dns 10.0.2.3
OK

Welcome to Buildroot
buildroot login: root
# 

探索一番

# Linux 5.10.7
$ uname -a
Linux buildroot 5.10.7 #2 SMP Thu Jan 13 02:20:28 PST 2022 riscv64 GNU/Linux

$ cat /proc/cpuinf[  263.710999] random: fast init done
o
processor       : 0
hart            : 0
isa             : rv64imafdcsu	# 全志D1s为 rv64imafdcvu
mmu             : sv48		# 全志D1s为 sv39

$ cat /proc/meminfo
MemTotal:          43600 kB
MemFree:           22744 kB
MemAvailable:      22816 kB
... 

$ free
              total        used        free      shared  buff/cache   available
Mem:          43600       18180       22744          44        2676       22804
Swap:             0           0           0

$ df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                58.1M      2.9M     52.2M   5% /
devtmpfs                 21.2M         0     21.2M   0% /dev
tmpfs                    21.3M         0     21.3M   0% /dev/shm
tmpfs                    21.3M     24.0K     21.3M   0% /tmp
tmpfs                    21.3M     20.0K     21.3M   0% /run

$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
3: sit0@NONE: <NOARP> mtu 1480 qdisc noop qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
    
$ ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:56  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fec0::5054:ff:fe12:3456/64 Scope:Site
          inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1400 (1.3 KiB)  TX bytes:1290 (1.2 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          
# ping ubuntu20的ip可以通, 但是ubuntu20 ping 10.0.2.15不通
$ ping 192.168.65.128
PING 192.168.65.128 (192.168.65.128): 56 data bytes
64 bytes from 192.168.65.128: seq=0 ttl=255 time=4.495 ms
64 bytes from 192.168.65.128: seq=1 ttl=255 time=0.846 ms

# ping外网也能通
$ ping www.baidu.com
PING www.baidu.com (x.x.x.x): 56 data bytes
64 bytes from x.x.x.x: seq=0 ttl=255 time=7.006 ms
64 bytes from x.x.x.x: seq=1 ttl=255 time=6.713 ms

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.2.2        0.0.0.0         UG    0      0        0 eth0
10.0.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0

Ctrl+A, 然后按X可以退出系统

参考

  • 全志在线开发者论坛
  • WhyCan 哇酷开发者社区
  • 芒果派 mangopi
  • MangoPi SBC / Twitter
  • MangoPi SBC (github.com)
  • 芒果派麻雀到手试玩 | 全志在线开发者论坛 (aw-ol.com)
  • D1-H 开发板——哪吒 - D1-H (aw-ol.com)
  • D1 (allwinnertech.com)
  • tar解压到指定目录并且重名原始目录名_cqs_jition_51CTO博客
  • 韦东山/buildroot-external-mq (gitee.com)
  • 【惊】在麻雀上运行国产rt-smart系统 | 全志在线开发者论坛 (aw-ol.com)
  • 麻雀D1s开发板支持buildroot 一件构建了。 | 全志在线开发者论坛 (debugdump.com)
  • SdtElectronics/Xassette-Asterisk: Evaluation board for AllWinner’s RISC-V 64 SoC F133/D1s (github.com)
  • D1s - linux-sunxi.org
  • OpenSBI 主流程分析与总结_tugouxp的专栏-CSDN博客_opensbi
  • OpenSBI 编译和运行 - 知乎 (zhihu.com)
  • Linux MemFree与MemAvailable的区别_Jx战壕_51CTO博客
  • Linux系统下ifconfig命令使用及结果分析 - Polaris8 - 博客园 (cnblogs.com)
  • https://wiki.qemu.org/Documentation/Platforms/RISCV
  • https://wiki.debian.org/RISC-V
  • https://bootlin.com/pub/conferences/2019/cdl/opdenacker-embedded-linux-40minutes-riscv/opdenacker-embedded-linux-40minutes-riscv.pdf
  • uboot启动流程_RISCV64 opensbi启动过程_weixin_39530269的博客-CSDN博客

欢迎扫描二维码关注微信公众号, 及时获取最新文章:
在这里插入图片描述

你可能感兴趣的:(嵌入式Linux,risc-v,全志,D1s,Buildroot,麻雀)