Nezha D1 runs Arch Linux RISC-V rootfs through TF Card
Make Debian RISC-V TF startup card of RVBoards
- For details, please refer to here: "RVBoards Nezha" D1 Debian system image and installation method
- Add the pits that are not mentioned here
- according to The kernel cannot access and mount rootfs Introduction here
[ 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) ]---
It indicates that the SD card you use has GPT partition table residue, so the kernel does not know how to find rootfs. (it seems that you forgot to use wipefs to clean up the GPT backup partition table before burning) the solution is as follows:
- Insert the faulty SD card into the PC and clear the remaining partition table through gdisk. The process is as follows:
# sdX represents the disk number of TF/SD card. Here, take sdf as an example $ 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.
- You can also erase the partition information of the TF card through wipefs
# sdX indicates TF/SD card disk number 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
-
If the startup disk tool is made by Quanzhi's TF card on win 10, please use PhoenixCardv4.2.7.7z The version updated at 08:56:40 on July 14, 2021. Otherwise, there will be some bad problems, such as the startup card cannot be formatted and cannot be made successfully.
-
Optional action: expand the partition size of the root file system:
Insert the card reader into the linux system and perform the following operations to expand the partition size of the root file system: (the X of sdX indicates your actual card reader drive letter)
sudo e2fsck -f /dev/sdX7 sudo resize2fs -p /dev/sdX7
Start Debian RISC-V TF Card
- Use the USB2TTL serial port tool to link the debug port of D1 and insert TF into the TF card seat of D1,
- Use minicom to connect serial port
# Pay attention to the connection. If the keyboard input information cannot be received by the serial port, please turn off the hardware flow control of minicom. # Close minicom hardware flow control $ sudo minicom -s +------[set up]---------+ | File name and path | | File transfer protocol | | Serial port settings | | Modem and dial up | | Screen and keyboard | | Save settings as dfl | | Save settings as | | Leave this screen | | leave Minicom | +-------------------+ #Select serial port settings -----------+ +-----------------------------------------------------------------------+ | | A - Serial device : /dev/modem | | | B - Lock file location : /var/run || | C - Dial in procedure : | | | D - Dial out procedure : | | | E - Bps/Par/Bits : 115200 8N1 | | | F - Hardware flow control : no | | G - Software flow control : no | | 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 | | | | | | Change settings? | | +-----------------------------------------------------------------------+ | | # Press F to switch the hardware flow control, select close, press back to the workshop for confirmation, return to the main interface and save the settings. # Connect D1 serial port $ minicom -c on -b 115200 -D /dev/ttyUSB0
- Use the Type-C data line to connect the OTG interface, and minicom will output the corresponding startup information
- If there is no accident, it will enter Debian RISC-V system
- Debian RISC-V system default user name: root password: rvboards
Replace Arch Linux RISC-V rootfs
- Foreign sunxi-linux Nezha Describes how to migrate the mainline kernel
- Fat cat Arch Linux RISC-V project
- Download arch risc-v rootfs system
# Add archriscv-20210601 tar. Download ZST to ~ / $ wget -c https://archriscv.felixc.at/images/archriscv-20210601.tar.zst
- Power off D1, pull out the TF card and mount it to the computer through the card reader
- Backing up rootfs of Debian RISC-V
# Here, take sde5 as an example to find the rootfs disk according to the actual situation $ mount /dev/sde5 /mnt $ cd /mnt # Backup current Debian RISC-V rootfs $ tar -zcvf . ~/debian-riscv-`date -s`.tar.xz # Delete Debian RISC-V rootfs $ sudo rm -rf . # Add archriscv-20210601 tar. Extract ZST to / mnt # Arch Linux users $ sudo bsdtar -xvf ~/archriscv-20210601.tar.zst -C /mnt/ # Non Arch Linux users rely on the zstd library. Users who do not have this library can install it by themselves sudo tar -I zstd -xvf ~/archriscv-20210601.tar.zst -C /mnt/
- Start the Arch Linux RISC-V virtual machine. The default root password of Arch Linux RISC-V is sifive
$ sudo systemd-nspawn -D /mnt/ --machine archriscv -a -U # The default root password of Arch Linux RISC-V is sifive
- Configure the static IP address of Arch Linux RISC-V
# Here, the default network card is eth0 as an example. Actually, the network card information is obtained through 'ip addr' # View network status sudo systemctl status systemd-networkd # Configuring static IP files through cat 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 # Add the service to the startup self startup sudo systemctl reenable systemd-networkd # Restart the system sudo reboot # View IP ip addr // Or ifconfig # If static IP becomes dynamic IP after restart, you can check whether it is caused by 'networkmanager'. If so, please execute the following command to uninstall sudo pacman -Rsn `pacman -Qsq networkmanager` network-manager-applet
- Configure / etc/fstab
# This makes some of the root directories of sew avoidable /dev/mmcblk0p5 / ext4 rw 0 1
-
Modify mirror source
In case of SSL connection error, see the following:
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
# Replace https with http sed -i 's_https_http_g' /etc/pacman.conf
If the download speed is slow, you can change to another mirror station:
sed -i 's_archriscv.felixc.at_mirrors.wsyu.edu.cn/archriscv_g' /etc/pacman.conf
- Exit Arch Linux RISC-V virtual machine
Ctrl + D # or exit
- Unmount / mnt partition
sudo umount -R /mnt
- Safely eject the TF card, insert the D1 TF card holder, and power the OTG interface. No accident, you can enter the rootfs of archlinux risc-v