卡在starting kernel

注意一下设备树和自己的内核是不是匹配的

Waiting for root device /dev/mmcblk0p2..

1
2
3
4
[    1.041445] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[ 1.050235] cfg80211: failed to load regulatory.db
[ 1.055609] Waiting for root device /dev/mmcblk0p2...
[ 5.586971] random: fast init done

重新编译根文件系统中

正常启动的启动信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
U-Boot 2018.01-05676-g00188782ee (Aug 09 2018 - 18:49:43 +0800) Allwinner Technology
...
## Flattened Device Tree blob at 80c00000
Booting using the fdt blob at 0x80c00000
Loading Device Tree to 80e60000, end 80e65160 ... OK

Starting kernel ...

[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 4.15.0-rc8-licheepi-nano+ (root@biglion-MRC-WX0) (gcc version 7.2.0 (Ubuntu/Linaro 7.2.0-6ubuntu1)) #69 Wed Apr 4 17:47:49 CST 2018
...
[ 1.164113] mmc0: host does not support reading read-only switch, assuming write-enable
[ 1.181541] mmc0: new high speed SDXC card at address aaaa
[ 1.197164] mmcblk0: mmc0:aaaa SC64G 59.5 GiB
[ 1.212431] mmcblk0: p1 p2
...
[ 1.571650] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[ 1.588783] cfg80211: failed to load regulatory.db
[ 1.606673] EXT4-fs (mmcblk0p2): couldn't mount as ext3 due to feature incompatibilities
[ 1.653887] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 1.670848] VFS: Mounted root (ext4 filesystem) on device 179:2.
[ 1.688953] devtmpfs: mounted
[ 1.706149] Freeing unused kernel memory: 1024K
[ 1.869936] EXT4-fs (mmcblk0p2): re-mounted. Opts: data=ordered
Starting logging: OK
Initializing random number generator... done.

Welcome to Lichee Pi
Lichee login:

错误启动时的信息

1
2
3
4
5
6
7
8
9
10
11
Starting kernel ...

[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 5.2.0-licheepi-nano (zhuhao@sipeed_ai) (gcc version 7.4.1 20181213 [linaro-7.4-2019.02 revision 56ec6f6b99cc167ff0c2f8e1a2eed33b1edc85d4] (Linaro GCC 7.4-2019.02)) #1 Tue Jul 16 08:26:30 UTC 2019
...
[ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
...
[ 1.046636] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[ 1.055426] cfg80211: failed to load regulatory.db
[ 1.060972] Waiting for root device /dev/mmcblk0p2...
[ 5.617756] random: fast init done

发现无法启动时的启动信息中缺少了 mmc 驱动加载的相关信息,怀疑可能没有加载 mmc 驱动导致设备无法读取根文件系统

最后发现还是设备树的问题,linux 5.2 主线中的设备树中没有添加 mmc 相关的配置,在添加 mmc 相关的配置后重新编译,设备替换为正确的设备数后,启动成功

以后移植内核的时候需要注意一下设备树文件

spi 启动

正常启动的打印信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[    0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 4.15.0-next-20180202-licheepi-nano+ (biglion@biglion-MRC-WX0) (gcc version 7.2.0 (Ubuntu/Linaro 7.2.0-6ubuntu1)) #107 Sat May 19 11:56:16 CST 2018
...
[ 0.129219] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
...
[ 0.782259] m25p80 spi0.0: w25q128 (16384 Kbytes)
...
[ 0.813807] Creating 4 MTD partitions on "spi0.0":
[ 0.818652] 0x000000000000-0x000000100000 : "u-boot"
[ 0.825860] 0x000000100000-0x000000110000 : "dtb"
[ 0.833036] 0x000000110000-0x000000510000 : "kernel"
[ 0.840417] 0x000000510000-0x000001000000 : "rootfs"
...
[ 0.915838] sun4i-drm display-engine: bound 1e60000.display-backend (ops 0xc0633630)
[ 0.923836] sun4i-tcon 1c0c000.lcd-controller: Missing LVDS properties, Please upgrade your DT
[ 0.932515] sun4i-tcon 1c0c000.lcd-controller: LVDS output disabled
[ 0.939657] sun4i-drm display-engine: bound 1c0c000.lcd-controller (ops 0xc0632848)
[ 0.947435] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[ 0.954034] [drm] No driver support for vblank timestamp query.
[ 1.093614] Console: switching to colour frame buffer device 100x30
[ 1.116657] sun4i-drm display-engine: fb0: frame buffer device
[ 1.123722] [drm] Initialized sun4i-drm 1.0.0 20150629 for display-engine on minor 0
...
[ 3.590404] VFS: Mounted root (jffs2 filesystem) on device 31:3.
[ 3.598132] devtmpfs: mounted
[ 3.607538] Freeing unused kernel memory: 1024K

无法启动的打印信息

1
2
3
4
5
6
7
8
[    0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Linux version 4.15.0-next-20180202-licheepi-nano+ (biglion@biglion-MRC-WX0) (gcc version 7.2.0 (Ubuntu/Linaro 7.2.0-6ubuntu1)) #107 Sat May 19 11:56:16 CST 2018
...
[ 0.157377] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
...
[ 0.820678] m25p80 spi0.0: w25q128 (16384 Kbytes)
...
[ 0.954065] Waiting for root device /dev/mtdblock3...

之所以会卡在 Waiting for root device /dev/mtdblock3 是因为内核没有开启 MTD_BLOCK 的支持,在内核中开启后,重新编译烧录,启动成功

VFS: Cannot open root device "mtdblock3" or unknown-block(31,3): error -19

1
2
3
4
5
6
7
8
9
10
[    1.308757] VFS: Cannot open root device "mtdblock3" or unknown-block(31,3): error -19
[ 1.316804] Please append a correct "root=" boot option; here are the available partitions:
[ 1.325238] 1f00 1024 mtdblock0
[ 1.325248] (driver?)
[ 1.331790] 1f01 64 mtdblock1
[ 1.331795] (driver?)
[ 1.338392] 1f02 4160 mtdblock2
[ 1.338400] (driver?)
[ 1.344983] 1f03 11136 mtdblock3
[ 1.344990] (driver?)

这种情况注意你的内核中对文件系统的支持,与实际的根目录格式是否一致

比如我的情况就是根目录是 jffs2 的格式,那么内核在配置的时候就要开启 jffs2 的支持