哪吒 D1 通过 TF 卡运行 Arch Linux RISC-V rootfs
制作 RVBoards 的 Debian RISC-V TF 启动卡
- 详细资料参考这里 :「RVBoards-哪吒」D1 Debian系统镜像和安装方法
- 补充下这里面没提到的坑
| [ 9.015501] md: Waiting for all devices to be available before autodetect |
| [ 9.039910] md: If you don't use raid, use raid=noautodetect |
| [ 9.064235] md: Autodetecting RAID arrays. |
| [ 9.085291] md: autorun ... |
| [ 9.104713] md: ... autorun DONE. |
| [ 9.126379] List of all partitions: |
| [ 9.146691] b300 15558144 mmcblk0 |
| [ 9.146697] driver: mmcblk |
| [ 9.186490] b301 1048576 mmcblk0p1 1676bb7b-c349-4f5b-a48a-0f77d0cb680b |
| [ 9.186495] |
| [ 9.228663] b302 32 mmcblk0p2 de35d1f7-9081-4f33-8952-3bc51a4b10c6 |
| [ 9.228668] |
| [ 9.270932] b303 16384 mmcblk0p3 47aae416-9ac3-47dc-a4f4-8023251eaefc |
| [ 9.270937] |
| [ 9.313210] b304 14491119 mmcblk0p4 b93e5544-034f-41b7-b64d-1d7c2a5cfe58 |
| [ 9.313214] |
| [ 9.355206] No filesystem could mount root, tried: |
| [ 9.355212] ext4 |
| [ 9.376478] |
| [ 9.411420] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(179,4) |
| [ 9.436391] CPU: 0 PID: 1 Comm: swapper Not tainted 5.4.61 #3 |
| [ 9.458151] Call Trace: |
| [ 9.475929] [<ffffffe0000d6598>] walk_stackframe+0x0/0xc4 |
| [ 9.496999] [<ffffffe0000d6838>] show_stack+0x3c/0x46 |
| [ 9.517441] [<ffffffe000bb19f6>] dump_stack+0x24/0x2c |
| [ 9.537749] [<ffffffe0000e1f0a>] panic+0x100/0x32a |
| [ 9.557557] [<ffffffe000001522>] 0xffffffe000001522 |
| [ 9.577224] [<ffffffe0000015e2>] 0xffffffe0000015e2 |
| [ 9.596711] [<ffffffe00000173c>] 0xffffffe00000173c |
| [ 9.616044] [<ffffffe00000105e>] 0xffffffe00000105e |
| [ 9.635113] [<ffffffe000bc6e5a>] kernel_init+0x1c/0x100 |
| [ 9.654494] [<ffffffe0000d4838>] ret_from_exception+0x0/0xc |
| [ 9.674194] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(179,4) ]--- |
| |
说明您使用的SD卡存在GPT分区表残留,导致内核不知道如何找到rootfs。(似乎您忘记了在烧写前使用 wipefs 清理 GPT 备份分区表) 解决的办法如下:
- 将出问题的SD卡插入PC,通过 gdisk 清除残余的分区表,过程如下:
| |
| $ sudo gdisk /dev/sdf |
| GPT fdisk (gdisk) version 1.0.5 |
| |
| Caution: invalid main GPT header, but valid backup; regenerating main header |
| from backup! |
| |
| Warning: Invalid CRC on main header data; loaded backup partition table. |
| Warning! Main and backup partition tables differ! Use the 'c' and 'e' options |
| on the recovery & transformation menu to examine the two tables. |
| |
| Warning! Main partition table CRC mismatch! Loaded backup partition table |
| instead of main partition table! |
| |
| Warning! One or more CRCs don't match. You should repair the disk! |
| Main header: ERROR |
| Backup header: OK |
| Main partition table: ERROR |
| Backup partition table: OK |
| |
| Partition table scan: |
| MBR: MBR only |
| BSD: not present |
| APM: not present |
| GPT: damaged |
| |
| Found valid MBR and corrupt GPT. Which do you want to use? (Using the |
| GPT MAY permit recovery of GPT data.) |
| 1 - MBR |
| 2 - GPT |
| 3 - Create blank GPT |
| |
| Your answer: 1 |
| |
| Command (? for help): p |
| Disk /dev/sdf: 62333952 sectors, 29.7 GiB |
| Model: Multi-Reader -3 |
| Sector size (logical/physical): 512/512 bytes |
| Disk identifier (GUID): 632BFA1B-F09D-42A8-82F4-5FAB32E41DC2 |
| Partition table holds up to 128 entries |
| Main partition table begins at sector 2 and ends at sector 33 |
| First usable sector is 34, last usable sector is 62333918 |
| Partitions will be aligned on 2048-sector boundaries |
| Total free space is 37084093 sectors (17.7 GiB) |
| |
| Number Start (sector) End (sector) Size Code Name |
| 2 69632 319487 122.0 MiB 0700 Microsoft basic data |
| 3 319488 1320959 489.0 MiB 8300 Linux filesystem |
| 4 1320960 25319423 11.4 GiB 8300 Linux filesystem |
| |
| Command (? for help): w |
| |
| Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING |
| PARTITIONS!! |
| |
| Do you want to proceed? (Y/N): y |
| OK; writing new GUID partition table (GPT) to /dev/sdf. |
| Warning: The kernel is still using the old partition table. |
| The new table will be used at the next reboot or after you |
| run partprobe(8) or kpartx(8) |
| The operation has completed successfully. |
| |
| |
- 还可以通过 wipefs 擦除 TF 卡的分区信息
| |
| sudo wipefs -a /dev/sdX |
| sudo dd if=Fedora-riscv64-d1-developer-xfce-with-esp-Rawhide-latest-sda.raw of=/dev/sdX status=progress bs=4M |
-
如果在 win 10 上通过 全志的 TF 卡制作启动盘工具请使用 PhoenixCardv4.2.7.7z 2021/07/14 08:56:40 更新的版本,否则会出现 启动卡无法格式化,无法制作成功等糟心的问题。
-
可选操作:扩展根文件系统分区尺寸:
插入读卡器到linux系统下,执行以下操作来扩展根文件系统分区尺寸:(sdX的X表示你实际的读卡器盘符字母)
| sudo e2fsck -f /dev/sdX7 |
| sudo resize2fs -p /dev/sdX7 |
| |
启动 Debian RISC-V TF卡
- 使用 USB2TTL 串口工具链接 D1 的 debug 口,插入 TF 到 D1 的 TF 卡座,
- 使用 minicom 连接串口
| |
| |
| $ sudo minicom -s |
| +------[设置]---------+ |
| | 文件名和路径 | |
| | 文件传输协定 | |
| | 串口设置 | |
| | 调制解调器和拨接 | |
| | 屏幕和键盘 | |
| | 保存设置为 dfl | |
| | 另存设置为… | |
| | 离开本画面 | |
| | 离开 Minicom | |
| +-------------------+ |
| |
| |
| -----------+ |
| |
| +-----------------------------------------------------------------------+ | |
| | A - 串行设备 : /dev/modem | | |
| | B - 锁文件位置 : /var/run || |
| | C - 拨入程序 : | | |
| | D - 拨出程序 : | | |
| | E - Bps/Par/Bits : 115200 8N1 | | |
| | F - 硬件流控制 : 否 | |
| | G - 软件流控制 : 否 | |
| | H - RS485 Enable : No | |
| | I - RS485 Rts On Send : No | | |
| | J - RS485 Rts After Send : No | |
| | K - RS485 Rx During Tx : No | |
| | L - RS485 Terminate Bus : No | | |
| | M - RS485 Delay Rts Before: 0 | |
| | N - RS485 Delay Rts After : 0 | | |
| | | | |
| | 变更设置? | | |
| +-----------------------------------------------------------------------+ | |
| |
| | |
| |
| |
| |
| $ minicom -c on -b 115200 -D /dev/ttyUSB0 |
- 使用 Type-C 数据线连接 OTG 接口,minicom 会输出相应启动信息
- 不出意外的话会进入 Debian RISC-V 的系统
- Debian RISC-V 系统默认用户名:
root
密码:rvboards
替换 Arch Linux RISC-V rootfs
- 国外的 sunxi-linux Nezha 介绍如何移植主线内核
- 肥猫的 Arch Linux RISC-V 项目
- 下载 arch risc-v rootfs 系统
| |
| $ wget -c https://archriscv.felixc.at/images/archriscv-20210601.tar.zst |
- 将 D1 断电,拔出 TF 卡,通过读卡器挂载到电脑上
- 备份 Debian RISC-V 的 rootfs
| |
| $ mount /dev/sde5 /mnt |
| $ cd /mnt |
| |
| $ tar -zcvf . ~/debian-riscv-`date -s`.tar.xz |
| |
| $ sudo rm -rf . |
| |
| |
| $ sudo bsdtar -xvf ~/archriscv-20210601.tar.zst -C /mnt/ |
| |
| sudo tar -I zstd -xvf ~/archriscv-20210601.tar.zst -C /mnt/ |
- 启动 Arch Linux RISC-V 虚拟机,Arch Linux RISC-V 的默认
root
密码为 sifive
| $ sudo systemd-nspawn -D /mnt/ --machine archriscv -a -U |
| |
- 配置 Arch Linux RISC-V 的静态 IP 地址
| |
| |
| sudo systemctl status systemd-networkd |
| |
| cat > /etc/systemd/network/10-static-eth0.network << EOF |
| [Match] |
| Name=eth0 |
| |
| [Network] |
| Address=192.168.1.199/24 |
| Gateway=192.168.1.1 |
| DNS=192.168.1.1 223.5.5.5 114.114.114.114 |
| EOF |
| |
| sudo systemctl reenable systemd-networkd |
| |
| sudo reboot |
| |
| ip addr // 或者 ifconfig |
| |
| sudo pacman -Rsn `pacman -Qsq networkmanager` network-manager-applet |
- 配置
/etc/fstab
| |
| /dev/mmcblk0p5 / ext4 rw 0 1 |
-
修改镜像源
如果是是 SSL
连接错误,如下:
| pacman -Syyus |
| .ac.cn/archriscv_archriscv.felixc.at_g' /etc/pacman.conf cat /etc/pacman.conf |
| :: Synchronizing package databases... |
| error: failed retrieving file 'core.db' from archriscv.felixc.at : SSL certificate problem: certificate is not yet valid |
| error: failed to update core (download library error) |
| error: failed retrieving file 'extra.db' from archriscv.felixc.at : SSL certificate problem: certificate is not yet valid |
| error: failed to update extra (download library error) |
| error: failed retrieving file 'community.db' from archriscv.felixc.at : SSL certificate problem: certificate is not yet valid |
| error: failed to update community (download library error) |
| error: failed to syn |
| |
| |
| sed -i 's_https_http_g' /etc/pacman.conf |
如果是下载速度慢可以换其他镜像站:
| sed -i 's_archriscv.felixc.at_mirrors.wsyu.edu.cn/archriscv_g' /etc/pacman.conf |
- 退出 Arch Linux RISC-V 虚拟机
- 卸载
/mnt
分区
- 安全弹出 TF 卡,插入 D1 TF 卡座,OTG 接口供电,不出意外是能进入 archlinux risc-v 的 rootfs
参考连接
Arch Linux 生命不息,折腾不止!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库