文章目录
- 前言
- 一、U-Boot 适配 Ethernet
- 1、配置 U-Boot
- 2、修改 dts 文件
- 3、编译
- 4、烧写到 SD 卡
- 5、测试
- <1>、查看启动打印信息
- <2>、ping 测试
- 二、Kernel 适配 Ethernet
- 1、配置 kernel
- 2、修改 dts 文件
- 3、编译
- 4、拷贝到 SD 卡
- 5、测试
- <1>、启动网络接口,并查看网络信息
- <2>、ping 测试
- 三、通过 tftp下载 zImage 和 dts,通过 nfs 挂载文件系统
- 1、设置 bootcmd
- 2、设置 bootargs
- 3、保存
- 四、挂载效果
- 1、从 tftp 下载 kernel 及通过 nfs 挂载 rootfs
- 2、直接从 SD 卡加载 kernel 和 rootfs
前言
传输文件每次都插拔 SD 卡太麻烦了,还是使用网线传输文件比较快,借此机会讲述一下 通过 tftp下载 kernel 和 nfs 挂载文件系统
一、U-Boot 适配 Ethernet
我使用的 uboot 是 2017.01 版本的,U-Boot 2017 已经支持了 sun8i-emac 的驱动,只需要在编译时选上并且修改 dts 就行。
1、配置 U-Boot
①、进入u-boot源码目录,执行
make menuconfig
②、Device Drivers -> Network device support 按照下图进行配置
2、修改 dts 文件
①、修改 sun8i-v3s-licheepi-zero.dts
find ./ -name sun8i-v3s-licheepi-zero.dts
vi ./arch/arm/dts/sun8i-v3s-licheepi-zero.dts
这里说明一下:下面的是 git 的对比功能,+ 就是表示比原来增加的部分,也就是我们需要编写的部分。(可以根据 + 前面和后面的部分准确的定位)
sun8i-v3s-licheepi-zero.dts:
diff --git a/arch/arm/dts/sun8i-v3s-licheepi-zero.dts b/arch/arm/dts/sun8i-v3s-licheepi-zero.dts
index 3d9168c..b8b9fc3 100644
--- a/arch/arm/dts/sun8i-v3s-licheepi-zero.dts
+++ b/arch/arm/dts/sun8i-v3s-licheepi-zero.dts
@@ -49,6 +49,7 @@
compatible = "licheepi,licheepi-zero", "allwinner,sun8i-v3s";
aliases {
+ ethernet0 = &emac;
serial0 = &uart0;
};
@@ -81,3 +82,14 @@
usb0_id_det-gpio = <&pio 5 6 GPIO_ACTIVE_HIGH>;
status = "okay";
};
+
+&emac {
+ phy = <&phy0>;
+ phy-mode = "mii";
+ allwinner,use-internal-phy;
+ allwinner,leds-active-low;
+ status = "okay";
+ phy0: ethernet-phy@0 {
+ reg = <1>;
+ };
+};
②、修改 sun8i-v3s.dtsi
find ./ -name sun8i-v3s.dtsi
vi ./arch/arm/dts/sun8i-v3s.dtsi
sun8i-v3s.dtsi:
diff --git a/arch/arm/dts/sun8i-v3s.dtsi b/arch/arm/dts/sun8i-v3s.dtsi
index ebefc0f..cb81dd5 100644
--- a/arch/arm/dts/sun8i-v3s.dtsi
+++ b/arch/arm/dts/sun8i-v3s.dtsi
@@ -96,6 +96,11 @@
#size-cells = <1>;
ranges;
+ syscon: syscon@01c00000 {
+ compatible = "allwinner,sun8i-h3-syscon","syscon";
+ reg = <0x01c00000 0x34>;
+ };
+
mmc0: mmc@01c0f000 {
compatible = "allwinner,sun7i-a20-mmc";
reg = <0x01c0f000 0x1000>;
@@ -208,6 +213,17 @@
interrupt-controller;
#interrupt-cells = <3>;
+ emac_rgmii_pins: emac0@0 {
+ allwinner,pins = "PD0", "PD1", "PD2", "PD3",
+ "PD4", "PD5", "PD7",
+ "PD8", "PD9", "PD10",
+ "PD12", "PD13", "PD15",
+ "PD16", "PD17";
+ allwinner,function = "emac";
+ allwinner,drive = <SUN4I_PINCTRL_40_MA>;
+ allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
+ };
+
uart0_pins_a: uart0@0 {
pins = "PB8", "PB9";
function = "uart0";
@@ -270,6 +286,20 @@
status = "disabled";
};
+ emac: ethernet@1c30000 {
+ compatible = "allwinner,sun8i-h3-emac";
+ reg = <0x01c30000 0x104>, <0x01c00030 0x4>;
+ reg-names = "emac", "syscon";
+ interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
+ resets = <&ccu RST_BUS_EMAC>, <&ccu RST_BUS_EPHY>;
+ reset-names = "ahb", "ephy";
+ clocks = <&ccu CLK_BUS_EMAC>, <&ccu CLK_BUS_EPHY>;
+ clock-names = "ahb", "ephy";
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+ };
+
gic: interrupt-controller@01c81000 {
compatible = "arm,cortex-a7-gic", "arm,cortex-a15-gic";
reg = <0x01c81000 0x1000>,
3、编译
time make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- 2>&1 | tee build.log
ls
4、烧写到 SD 卡
sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8
5、测试
<1>、查看启动打印信息
有下面红框的部分说明配置成功。
<2>、ping 测试
在ping网络之前我们需要先设置 ip
①、设置主机端(ubuntu)网络信息
可以参考之前写的一个文章在 ubuntu 配置两个网卡,一个用来上外网,一个用来连接板子 i.mx287学习笔记-ubuntu虚拟机网络配置同时连接WIFI上外网和连接以太网与i.mx287开发板通信
②、设置开发板端网络信息
setenv ipaddr 192.168.25.20
setenv gatewayip 192.168.25.1
setenv netmask 255.255.255.0
setenv serverip 192.168.25.25
saveenv
③、在单板端 ping 主机
ping 192.168.25.25
失败了,看到当前电脑防火墙都处于开启状态,应该是这个原因,关闭电脑端防火墙再次测试
成功了
二、Kernel 适配 Ethernet
我使用的 kernel 是 5.2.0 版本
1、配置 kernel
<1>、配置以太网网络
在 linux 根目录下
make menuconfig
Device Drivers -> Network device support -> Ethernet driver support
按照如下配置:
因为我们后面还需要通过nfs挂载文件系统,所以我们还需要继续配置
<2>、配置NFS文件系统相关网络
Networking support -> Networking options
按照如下配置:
<3>、配置 NFS 文件系统
File systems -> Network File Systems
按照如下配置:
2、修改 dts 文件
5.2 版本的 dock 版本的设备树中已经添加了。
3、编译
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4
得到 zImage 和 sun8i-v3s-licheepi-zero-dock.dtb
4、拷贝到 SD 卡
sudo cp ./arch/arm/boot/zImage ./arch/arm/boot/dts/sun8i-v3s-licheepi-zero-dock.dtb /media/Gnep/KERNEL/
5、测试
<1>、启动网络接口,并查看网络信息
ifconfig eth0 up
ifconfig
<2>、ping 测试
①、在单板端 ping 主机
ifconfig eth0 192.168.25.20
ping 192.168.25.25
②、在主机端 ping 单板
ping 192.168.25.20
可以看到,互 ping 成功
三、通过 tftp下载 zImage 和 dts,通过 nfs 挂载文件系统
搭建 NFS 服务器以及 TFTP 服务器的方法可以参考这个:SSH 服务器、NFS 服务器、TFTP 服务器详解及测试
首先确保 sun8i-v3s-licheepi-zero-dock.dtb 和 zImage拷贝到了 /tftpboot 目录下,/nfsroot 下为 rootfs.tar 解压缩后的文件
1、设置 bootcmd
setenv bootcmd 'setenv bootm_boot_mode sec;setenv ipaddr 192.168.25.20;setenv serverip 192.168.25.25;tftp 41000000 zImage;tftp 41800000 sun8i-v3s-licheepi-zero-dock.dtb;bootz 0x41000000 - 0x41800000'
2、设置 bootargs
setenv bootargs root=/dev/nfs nfsroot=192.168.25.25:/nfsroot,nfsvers=4 rw ip=192.168.25.20:192.168.25.25:192.168.25.1:255.255.255.0::eth0:off init=/linuxrc console=ttyS0,115200
3、保存
saveenv
四、挂载效果
1、从 tftp 下载 kernel 及通过 nfs 挂载 rootfs
一个启动的完整打印信息
U-Boot SPL 2017.01-rc2-00057-g32ab1804cd-dirty (Apr 29 2023 - 10:11:46)
DRAM: 64 MiB
Trying to boot from MMC1
U-Boot 2017.01-rc2-00057-g32ab1804cd-dirty (Apr 29 2023 - 10:11:46 +0800) Allwinner Technology
CPU: Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM: 64 MiB
MMC: SUNXI SD/MMC: 0
Setting up a 800x480 lcd console (overscan 0x0)
dotclock: 33000kHz = 33000kHz: (1 * 3MHz * 66) / 6
In: serial@01c28000
Out: serial@01c28000
Err: serial@01c28000
U-Boot 2017.01-rc2-00057-g32ab1804cd-dirty (Apr 29 2023 - 10:11:46 +0800) Allwinner Technology
CPU: Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM: 64 MiB
MMC: SUNXI SD/MMC: 0
Setting up a 800x480 lcd console (overscan 0x0)
dotclock: 33000kHz = 33000kHz: (1 * 3MHz * 66) / 6
In: serial@01c28000
Out: serial@01c28000 Err: serial@01c28000 Net: phy interface0 eth0: ethernet@1c30000 starting USB... No controllers found Hit any key to stop autoboot: 0 Using ethernet@1c30000 device TFTP from server 192.168.25.25; our IP address is 192.168.25.20
Filename 'zImage'.
Load address: 0x41000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#####################################################
654.3 KiB/s
done
Bytes transferred = 4580840 (45e5e8 hex)
Using ethernet@1c30000 device
TFTP from server 192.168.25.25; our IP address is 192.168.25.20
Filename 'sun8i-v3s-licheepi-zero-dock.dtb'.
Load address: 0x41800000
Loading: #
1.4 MiB/s
done
Bytes transferred = 12100 (2f44 hex)
## Flattened Device Tree blob at 41800000
Booting using the fdt blob at 0x41800000
Loading Device Tree to 42dfa000, end 42dfff43 ... OK
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 5.2.0-licheepi-zero+ (Gnep@lpvm) (gcc version 6.3.1 20170404 (Linaro GCC 6.3-2017.05)) #2 SMP Fri Apr 28 18:59:07 CST 2023
[ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
[ 0.000000] CPU: div instructions available: patching division code
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] OF: fdt: Machine model: Lichee Pi Zero with Dock
[ 0.000000] Memory policy: Data cache writealloc
[ 0.000000] percpu: Embedded 16 pages/cpu s34508 r8192 d22836 u65536
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 15883
[ 0.000000] Kernel command line: root=/dev/nfs rw nfsroot=192.168.25.25:/nfsroot ip=192.168.25.20:192.168.25.25:192.168.0.1:255.255.255.0::eth0:off init=/linuxrc console=ttyS0,115200
[ 0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes, linear)
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 52500K/64036K available (7168K kernel code, 308K rwdata, 1824K rodata, 1024K init, 265K bss, 11536K reserved, 0K cma-reserved, 0K highmem)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] rcu: Hierarchical RCU implementation.
[ 0.000000] rcu: RCU event tracing is enabled.
[ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=1.
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[ 0.000000] random: get_random_bytes called from start_kernel+0x300/0x48c with crng_init=0
[ 0.000000] arch_timer: cp15 timer(s) running at 24.00MHz (virt).
[ 0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[ 0.000009] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[ 0.000022] Switching to timer-based delay loop, resolution 41ns
[ 0.000212] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[ 0.000461] Console: colour dummy device 80x30
[ 0.000520] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[ 0.000537] pid_max: default: 32768 minimum: 301
[ 0.000702] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.000720] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.001557] CPU: Testing write buffer coherency: ok
[ 0.002103] /cpus/cpu@0 missing clock-frequency property
[ 0.002130] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[ 0.002909] Setting up static identity map for 0x40100000 - 0x40100060
[ 0.003123] rcu: Hierarchical SRCU implementation.
[ 0.003661] smp: Bringing up secondary CPUs ...
[ 0.003680] smp: Brought up 1 node, 1 CPU
[ 0.003691] SMP: Total of 1 processors activated (48.00 BogoMIPS).
[ 0.003699] CPU: All CPU(s) started in SVC mode.
[ 0.004769] devtmpfs: initialized
[ 0.008308] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[ 0.008649] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[ 0.008682] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[ 0.008938] pinctrl core: initialized pinctrl subsystem
[ 0.010084] NET: Registered protocol family 16
[ 0.010633] DMA: preallocated 256 KiB pool for atomic coherent allocations
[ 0.011923] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[ 0.011942] hw-breakpoint: maximum watchpoint size is 8 bytes.
[ 0.037193] SCSI subsystem initialized
[ 0.037489] usbcore: registered new interface driver usbfs
[ 0.037548] usbcore: registered new interface driver hub
[ 0.037653] usbcore: registered new device driver usb
[ 0.037892] mc: Linux media interface: v0.10
[ 0.037937] videodev: Linux video capture interface: v2.00
[ 0.038161] Advanced Linux Sound Architecture Driver Initialized.
[ 0.039524] clocksource: Switched to clocksource arch_sys_counter
[ 0.052538] NET: Registered protocol family 2
[ 0.053376] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
[ 0.053419] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.053443] TCP bind hash table entries: 1024 (order: 1, 8192 bytes, linear)
[ 0.053466] TCP: Hash tables configured (established 1024 bind 1024)
[ 0.053627] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.053680] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.053982] NET: Registered protocol family 1
[ 0.054958] RPC: Registered named UNIX socket transport module.
[ 0.054982] RPC: Registered udp transport module.
[ 0.054989] RPC: Registered tcp transport module.
[ 0.054994] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.056788] Initialise system trusted keyrings
[ 0.057239] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[ 0.065782] NFS: Registering the id_resolver key type
[ 0.065846] Key type id_resolver registered
[ 0.065854] Key type id_legacy registered
[ 0.065875] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[ 0.095649] Key type asymmetric registered
[ 0.095670] Asymmetric key parser 'x509' registered
[ 0.095778] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
[ 0.095791] io scheduler mq-deadline registered
[ 0.095798] io scheduler kyber registered
[ 0.096744] sun4i-usb-phy 1c19400.phy: Couldn't request ID GPIO
[ 0.100714] sun8i-v3s-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[ 0.173113] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[ 0.175639] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pb not found, using dummy regulator
[ 0.176811] printk: console [ttyS0] disabled
[ 0.197122] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 36, base_baud = 1500000) is a U6_16550A
[ 0.752469] printk: console [ttyS0] enabled
[ 0.781975] libphy: Fixed MDIO Bus: probed
[ 0.786651] dwmac-sun8i 1c30000.ethernet: PTP uses main clock
[ 0.792553] dwmac-sun8i 1c30000.ethernet: No regulator found
[ 0.798765] dwmac-sun8i 1c30000.ethernet: Current syscon value is not the default 148000 (expect 58000)
[ 0.808256] dwmac-sun8i 1c30000.ethernet: No HW DMA feature register supported
[ 0.815498] dwmac-sun8i 1c30000.ethernet: RX Checksum Offload Engine supported
[ 0.822727] dwmac-sun8i 1c30000.ethernet: COE Type 2
[ 0.827686] dwmac-sun8i 1c30000.ethernet: TX Checksum insertion supported
[ 0.834477] dwmac-sun8i 1c30000.ethernet: Normal descriptors
[ 0.840139] dwmac-sun8i 1c30000.ethernet: Chain mode enabled
[ 0.846038] libphy: stmmac: probed
[ 0.850227] dwmac-sun8i 1c30000.ethernet: Found internal PHY node
[ 0.856507] libphy: mdio_mux: probed
[ 0.860194] dwmac-sun8i 1c30000.ethernet: Switch mux to internal PHY
[ 0.866551] dwmac-sun8i 1c30000.ethernet: Powering internal PHY
[ 0.873692] libphy: mdio_mux: probed
[ 0.877618] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 0.884264] ehci-platform: EHCI generic platform driver
[ 0.889864] ehci-platform 1c1a000.usb: EHCI Host Controller
[ 0.895482] ehci-platform 1c1a000.usb: new USB bus registered, assigned bus number 1
[ 0.903473] ehci-platform 1c1a000.usb: irq 26, io mem 0x01c1a000
[ 0.939522] ehci-platform 1c1a000.usb: USB 2.0 started, EHCI 1.00
[ 0.946731] hub 1-0:1.0: USB hub found
[ 0.950688] hub 1-0:1.0: 1 port detected
[ 0.955319] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 0.961673] ohci-platform: OHCI generic platform driver
[ 0.967232] ohci-platform 1c1a400.usb: Generic Platform OHCI controller
[ 0.973983] ohci-platform 1c1a400.usb: new USB bus registered, assigned bus number 2
[ 0.981968] ohci-platform 1c1a400.usb: irq 27, io mem 0x01c1a400
[ 1.054635] hub 2-0:1.0: USB hub found
[ 1.058476] hub 2-0:1.0: 1 port detected
[ 1.065805] usbcore: registered new interface driver usb-storage
[ 1.073126] input: 1c22800.lradc as /devices/platform/soc/1c22800.lradc/input/input0
[ 1.082466] sun6i-rtc 1c20400.rtc: registered as rtc0
[ 1.087531] sun6i-rtc 1c20400.rtc: RTC enabled
[ 1.092257] i2c /dev entries driver
[ 1.097240] input: ns2009_ts as /devices/platform/soc/1c2ac00.i2c/i2c-0/0-0048/input/input1
[ 1.107098] sunxi-wdt 1c20ca0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[ 1.115841] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pf not found, using dummy regulator
[ 1.152381] sunxi-mmc 1c0f000.mmc: initialized, max. request size: 16384 KB
[ 1.159694] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pg not found, using dummy regulator
[ 1.194701] sunxi-mmc 1c10000.mmc: initialized, max. request size: 16384 KB
[ 1.202863] usbcore: registered new interface driver usbhid
[ 1.208440] usbhid: USB HID core driver
[ 1.214579] sun4i-codec 1c22c00.codec: ASoC: codec-analog@01c23000 not registered
[ 1.222222] sun4i-codec 1c22c00.codec: Failed to register our card
[ 1.229758] Initializing XFRM netlink socket
[ 1.234073] NET: Registered protocol family 17
[ 1.239133] Key type dns_resolver registered
[ 1.243720] Registering SWP/SWPB emulation handler
[ 1.249908] Loading compiled-in X.509 certificates
[ 1.260419] simple-framebuffer 43e89000.framebuffer: framebuffer at 0x43e89000, 0x177000 bytes, mapped to 0x(ptrval)
[ 1.271064] simple-framebuffer 43e89000.framebuffer: format=x8r8g8b8, mode=800x480x32, linelength=3200
[ 1.287363] Console: switching to colour frame buffer device 100x30
[ 1.299918] simple-framebuffer 43e89000.framebuffer: fb0: simplefb registered!
[ 1.308771] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[ 1.320289] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[ 1.326056] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 3
[ 1.335557] hub 3-0:1.0: USB hub found
[ 1.339632] hub 3-0:1.0: 1 port detected
[ 1.343629] mmc0: host does not support reading read-only switch, assuming write-enable
[ 1.354261] debugfs: Directory '1c22c00.codec' with parent 'V3s Audio Codec' already present!
[ 1.362947] sun4i-codec 1c22c00.codec: ASoC: Failed to create component debugfs directory: -17
[ 1.373146] sun4i-codec 1c22c00.codec: Codec <-> 1c22c00.codec mapping ok
[ 1.380873] mmc0: new high speed SDHC card at address 1234
[ 1.388193] sun6i-rtc 1c20400.rtc: setting system clock to 1970-01-01T06:46:28 UTC (24388)
[ 1.398686] mmcblk0: mmc0:1234 SA08G 7.21 GiB
[ 1.404611] dwmac-sun8i 1c30000.ethernet eth0: PHY [0.1:01] driver [Generic PHY]
[ 1.413624] dwmac-sun8i 1c30000.ethernet eth0: No Safety Features support found
[ 1.421018] dwmac-sun8i 1c30000.ethernet eth0: No MAC Management Counters available
[ 1.428671] dwmac-sun8i 1c30000.ethernet eth0: PTP not supported by HW
[ 1.435250] dwmac-sun8i 1c30000.ethernet eth0: configuring for phy/mii link mode
[ 1.444023] mmcblk0: p1 p2
[ 5.609819] dwmac-sun8i 1c30000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
[ 5.669538] IP-Config: Complete:
[ 5.672778] device=eth0, hwaddr=02:00:f4:0d:32:47, ipaddr=192.168.25.20, mask=255.255.255.0, gw=192.168.0.1
[ 5.682972] host=192.168.25.20, domain=, nis-domain=(none)
[ 5.688886] bootserver=192.168.25.25, rootserver=192.168.25.25, rootpath=
[ 5.696337] IP-Config: Gateway not on directly connected network
[ 5.702515] vcc5v0: disabling
[ 5.705487] ALSA device list:
[ 5.708453] #0: V3s Audio Codec
[ 9.166191] random: fast init done
[ 103.536444] VFS: Unable to mount root fs via NFS, trying floppy.
[ 103.543316] VFS: Cannot open root device "nfs" or unknown-block(2,0): error -6
[ 103.550663] Please append a correct "root=" boot option; here are the available partitions:
[ 103.559021] b300 7563264 mmcblk0
[ 103.559025] driver: mmcblk
[ 103.565852] b301 32768 mmcblk0p1 49bfda8b-01
[ 103.565854]
[ 103.572664] b302 7529472 mmcblk0p2 49bfda8b-02
[ 103.572665]
[ 103.579470] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
[ 103.587729] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.2.0-licheepi-zero+ #2
[ 103.594852] Hardware name: Allwinner sun8i Family
[ 103.599588] [<c010ed14>] (unwind_backtrace) from [<c010b72c>] (show_stack+0x10/0x14)
[ 103.607329] [<c010b72c>] (show_stack) from [<c07374f0>] (dump_stack+0x84/0x98)
[ 103.614550] [<c07374f0>] (dump_stack) from [<c011dddc>] (panic+0x110/0x2fc)
[ 103.621512] [<c011dddc>] (panic) from [<c0a0136c>] (mount_block_root+0x1a0/0x288)
[ 103.628991] [<c0a0136c>] (mount_block_root) from [<c0a01598>] (mount_root+0x144/0x160)
[ 103.636902] [<c0a01598>] (mount_root) from [<c0a01704>] (prepare_namespace+0x150/0x194)
[ 103.644903] [<c0a01704>] (prepare_namespace) from [<c074f944>] (kernel_init+0x8/0x10c)
[ 103.652815] [<c074f944>] (kernel_init) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
[ 103.660373] Exception stack(0xc3833fb0 to 0xc3833ff8)
[ 103.665420] 3fa0: 00000000 00000000 00000000 00000000
[ 103.673588] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 103.681754] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 103.688376] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0) ]---
可以看到 tftp 下载没有问题,但是在 nfs 挂载的时候却可以出现了报错
[ 103.536444] VFS: Unable to mount root fs via NFS, trying floppy.
[ 103.543316] VFS: Cannot open root device “nfs” or unknown-block(2,0):
于是上网找了很多方法尝试,发现这个问题遇到的人还真不少,但是我尝试了很多种方法都没有解决,我所使用的 ubuntu 版本是 22.04,这里罗列一下我所参考的几篇文章
https://blog.csdn.net/hannibaychty/article/details/126984843
https://blog.csdn.net/seeyouwlx/article/details/128428709
https://blog.csdn.net/register_k/article/details/120113228
https://blog.csdn.net/lengyuefeng212/article/details/121217025
这个问题耗费了我一天的精力,等有时间再继续排查吧。
2、直接从 SD 卡加载 kernel 和 rootfs
启动到系统下,执行下列命令
ifconfig eth0 up
ifconfig eth0 192.168.25.20
ping 192.168.25.25
mount -t nfs 192.168.25.25:/nfsroot /mnt -o nolock
上述挂载成功,和下述 nfs 服务器中的文件一致
从这里可以说明 kernel 中有关 nfs 的配置没问题,因此 “VFS: Unable to mount root fs via NFS, trying floppy.” 这个报错并不是 nfs 配置导致的问题,具体问题后面有时间再继续排查。
我的qq:2442391036,欢迎交流!