1. 程式人生 > 其它 >嵌入式Linux--全志V3s--NOR Flash的使用(二)移植Nor Flash

嵌入式Linux--全志V3s--NOR Flash的使用(二)移植Nor Flash

技術標籤:嵌入式linux嵌入式Linux

目錄

嵌入式Linux–全志V3s–NOR Flash的使用(一)

一、上電失敗

嵌入式Linux–全志V3s–NOR Flash的使用(一)詳細的描述了所有的操作,但是最後還是上電失敗!列印資訊如下:


U-Boot SPL 2017.01-rc2-00073-gdd6e874-dirty (
Feb 06 2021 - 12:07:28) DRAM: 64 MiB Trying to boot from sunxi SPI U-Boot 2017.01-rc2-00073-gdd6e874-dirty (Feb 06 2021 - 12:07:28 +0800) Allwinner Technology CPU: Allwinner V3s (SUN8I 1681) Model: Lichee Pi Zero DRAM: 64 MiB MMC: SUNXI SD/MMC: 0 SF: unrecognized JEDEC id bytes: 0b, 40, 18 *** Warning - spi_flash_probe(
) failed, using default environment Setting up a 800x480 lcd console (overscan 0x0) dotclock: 33000kHz = 33000kHz: (1 * 3MHz * 66) / 6 In: [email protected] Out: [email protected] Err: [email protected] U-Boot 2017.01-rc2-00073-gdd6e874-dirty (Feb 06 2021 - 12:07:28 +0800) Allwinner Technology CPU: Allwinner V3s (
SUN8I 1681) Model: Lichee Pi Zero DRAM: 64 MiB MMC: SUNXI SD/MMC: 0 SF: unrecognized JEDEC id bytes: 0b, 40, 18 *** Warning - spi_flash_probe() failed, using default environment Setting up a 800x480 lcd console (overscan 0x0) dotclock: 33000kHz = 33000kHz: (1 * 3MHz * 66) / 6 In: [email protected] Out: [email protected] Err: [email protected] Net: No ethernet found. starting USB... No controllers found Hit any key to stop autoboot: 0 SF: unrecognized JEDEC id bytes: 0b, 40, 18 Failed to initialize SPI flash at 0:0 (error -2) No SPI flash selected. Please run `sf probe' No SPI flash selected. Please run `sf probe' => sf probe SF: unrecognized JEDEC id bytes: 0b, 40, 18 Failed to initialize SPI flash at 0:0 (error -2)

初步判斷是flash沒有被識別到!於是只能移植了!

二、移植nor flash

spi-flash 啟動適配

uboot移植nor-flash

 需要移植的 flash 為 xt25f128b,經過查詢資料手冊,發現和 winbond w25qxxx 系列的 flash 相容性很高,硬體特性、指令基本一樣,於是覺得基於 w25qxxx 系列進行移植。

1、配置Uboot支援

首先配置uboot支援winbond,通過圖形化配置:

  • 配置Uboot支援nor flash圖形化配置:make ARCH=arm menuconfig

2、配置Linux Kernel支援

在這裡插入圖片描述
首先找到這個錯誤在哪裡
uboot工程:drivers/mtd/spi/spi_flash.c

static const struct spi_flash_info *spi_flash_read_id(struct spi_flash *flash)
{
    ...
    tmp = spi_flash_cmd(flash->spi, CMD_READ_ID, id, SPI_FLASH_MAX_ID_LEN);
    ...

    info = spi_flash_ids;
    for (; info->name != NULL; info++) {
        if (info->id_len) {
            if (!memcmp(info->id, id, info->id_len))
                return info;
        }
    }

    printf("SF: unrecognized JEDEC id bytes: %02x, %02x, %02x\n",
           id[0], id[1], id[2]);
    return ERR_PTR(-ENODEV);
}

由於需要移植的 flash 晶片特性和 w25qxxx 系列的 flash 相似,所以可以直接複製過來,修改後如下

uboot工程:drivers/mtd/spi/spi_flash_ids.c

onst struct spi_flash_info spi_flash_ids[] = {
    ...
    {"w25q128fw",      INFO(0xef6018, 0x0,  64 * 1024,   256, RD_FULL | WR_QPP | SECT_4K) },
    {"xt25f128b",      INFO(0x0b4018, 0x0,  64 * 1024,   256, RD_FULL | WR_QPP | SECT_4K) },
    ...
};

上面的資料格式為:

/* Used when the "_ext_id" is two bytes at most */
#define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags)    \
        .id = {                         \
            ...
        .id_len = (!(_jedec_id) ? 0 : (3 + ((_ext_id) ? 2 : 0))),   \
        .sector_size = (_sector_size),              \
        .n_sectors = (_n_sectors),              \
        .page_size = 256,                   \
        .flags = (_flags),

修改之後如下:

#ifdef CONFIG_SPI_FLASH_WINBOND     /* WINBOND */
    {"w25p80",     INFO(0xef2014, 0x0,  64 * 1024,    16, 0) },
    {"w25p16",     INFO(0xef2015, 0x0,  64 * 1024,    32, 0) },
    {"w25p32",     INFO(0xef2016, 0x0,  64 * 1024,    64, 0) },
    {"w25x40",     INFO(0xef3013, 0x0,  64 * 1024,     8, SECT_4K) },
    {"w25x16",     INFO(0xef3015, 0x0,  64 * 1024,    32, SECT_4K) },
    {"w25x32",     INFO(0xef3016, 0x0,  64 * 1024,    64, SECT_4K) },
    {"w25x64",     INFO(0xef3017, 0x0,  64 * 1024,   128, SECT_4K) },
    {"w25q80bl",       INFO(0xef4014, 0x0,  64 * 1024,    16, RD_FULL | WR_QPP | SECT_4K) },
    {"w25q16cl",       INFO(0xef4015, 0x0,  64 * 1024,    32, RD_FULL | WR_QPP | SECT_4K) },
    {"w25q32bv",       INFO(0xef4016, 0x0,  64 * 1024,    64, RD_FULL | WR_QPP | SECT_4K) },
    {"w25q64cv",       INFO(0xef4017, 0x0,  64 * 1024,   128, RD_FULL | WR_QPP | SECT_4K) },
    {"w25q128bv",      INFO(0xef4018, 0x0,  64 * 1024,   256, RD_FULL | WR_QPP | SECT_4K) },
    {"w25q256",    INFO(0xef4019, 0x0,  64 * 1024,   512, RD_FULL | WR_QPP | SECT_4K) },
    {"w25q80bw",       INFO(0xef5014, 0x0,  64 * 1024,    16, RD_FULL | WR_QPP | SECT_4K) },
    {"w25q16dw",       INFO(0xef6015, 0x0,  64 * 1024,    32, RD_FULL | WR_QPP | SECT_4K) },
    {"w25q32dw",       INFO(0xef6016, 0x0,  64 * 1024,    64, RD_FULL | WR_QPP | SECT_4K) },
    {"w25q64dw",       INFO(0xef6017, 0x0,  64 * 1024,   128, RD_FULL | WR_QPP | SECT_4K) },
    {"w25q128fw",      INFO(0xef6018, 0x0,  64 * 1024,   256, RD_FULL | WR_QPP | SECT_4K) },
    {"xt25f128b",      INFO(0x0b4018, 0x0,  64 * 1024,   256, RD_FULL | WR_QPP | SECT_4K) },
#endif

修改裝置樹中的 flash 相關的宣告,新增上新增加的 flash 型號

&spi0 {
	status = "okay";
	
	xt25f128b:[email protected] {
		compatible = "winbond, xt25f128b", "jedec,spi-nor";
		reg = <0x0>;
		spi-max-frequency = <50000000>;
		#address-cells = <1>;
		#size-cells = <1>;
	};
};

充新編譯Uboot和Kernel燒錄以後:

U-Boot 2017.01-rc2-00073-gdd6e874-dirty (Feb 07 2021 - 14:27:05 +0800) Allwinner Technology

CPU:   Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM:  64 MiB
MMC:   SUNXI SD/MMC: 0
SF: Detected xt25f128b with page size 256 Bytes, erase size 4 KiB, total 16 MiB
*** Warning - bad CRC, using default environment

Setting up a 800x480 lcd console (overscan 0x0)
dotclock: 33000kHz = 33000kHz: (1 * 3MHz * 66) / 6
In:    [email protected]
Out:   [email protected]
Err:   [email protected]

說明已經識別到了xt25f128b晶片!

Setting up a 800x480 lcd console (overscan 0x0)
dotclock: 33000kHz = 33000kHz: (1 * 3MHz * 66) / 6
In:    [email protected]
Out:   [email protected]
Err:   [email protected]
Net:   No ethernet found.
starting USB...
No controllers found
Hit any key to stop autoboot:  0
SF: Detected xt25f128b with page size 256 Bytes, erase size 4 KiB, total 16 MiB
device 0 offset 0x100000, size 0x10000
SF: 65536 bytes @ 0x100000 Read: OK
device 0 offset 0x110000, size 0x400000
SF: 4194304 bytes @ 0x110000 Read: OK
## Flattened Device Tree blob at 41800000
   Booting using the fdt blob at 0x41800000
   Loading Device Tree to 42dfa000, end 42dff21a ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.10.15-licheepi-zero+ ([email protected]) (gcc version 4.9.4 (Linaro GCC 4.9-2017.01) ) #4 SMP Sun Feb 7 15:46:52 CST 2021
[    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
[    0.000000] Memory policy: Data cache writealloc

說明已經可以正常載入kernel!

但是:

[    1.044031] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)

Kernel panic
核心崩潰!原因是無法掛載(mount)根檔案系統,因為一個不知道的儲存塊(31:3)。而這個裡的配置來自於對Uboot的一個啟動引數的配置:

Uboot工程:include/configs/sun8i.h

#define CONFIG_BOOTCOMMAND   "sf probe 0; "                           \
                             "sf read 0x41800000 0x100000 0x10000; "  \
                             "sf read 0x41000000 0x110000 0x400000; " \
                             "bootz 0x41000000 - 0x41800000"

 #define CONFIG_BOOTARGS      "console=ttyS0,115200 earlyprintk panic=5 rootwait " \
                             "mtdparts=spi32766.0:1M(uboot)ro,64k(dtb)ro,4M(kernel)ro,-(rootfs) root=31:03 rw rootfstype=jffs2"

(1)環境命令解析:

  • sf probe 0;//初始化Flash裝置(CS拉低)

  • sf read 0x41800000 0x100000 0x10000; //從flash0x100000(1MB)位置讀取dtb放到記憶體0x41800000偏移處。 //如果是bsp的bin,則是0x41d00000

  • sf read 0x41000000 0x110000 0x400000;//從flash0x110000(1MB+64KB)位置讀取dtb放到記憶體0x41000000偏移處。

  • bootz 0x41000000 (核心地址)- 0x41800000(dtb地址) // 啟動核心

(2)啟動引數解析

  • console=ttyS0,115200 earlyprintk panic=5 rootwait

    • console=ttyS0,115200在串列埠0上輸出資訊,波特率為115200
    • earlyprintk
    • panic=5
    • rootwait
  • mtdparts=spi32766.0:1M(uboot)ro,64k(dtb)ro,4M(kernel)ro,-(rootfs) root=31:03 rw rootfstype=jffs2 //spi32766.0是裝置名,後面是分割槽大小,名字,讀寫屬性。

    • mtdparts=spi32766.0:1M(uboot)ro,64k(dtb)ro,4M(kernel)ro,-(rootfs)
    • root=31:03 rw rootfstype=jffs2表示根檔案系統是mtd3;jffs2格式

重新編譯U-Boot和Kernel

1、編譯U-Boot

可選:make ARCH=arm menuconfig

  • 清除:make clean
  • 配置編譯檔案(我的螢幕是5寸):make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_800x480LCD_defconfig
  • 編譯:time make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- 2>&1 | tee build.log

2、編譯Kernel

  • 清除:make clean

  • make ARCH=arm licheepi_zero_defconfig

  • make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j16

  • make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- dtbs

3、打包燒錄

  • 進入fel模式:MISO接地上電
  • 打包:./pakage.sh
  • 燒錄:sudo sunxi-fel -p spiflash-write 0 flashimg.bin

三、成功上電,但核心沒有識別出分割槽


U-Boot SPL 2017.01-rc2-00073-gdd6e874-dirty (Feb 07 2021 - 14:27:05)
DRAM: 64 MiB
Trying to boot from sunxi SPI

U-Boot 2017.01-rc2-00073-gdd6e874-dirty (Feb 07 2021 - 14:27:05 +0800) Allwinner Technology

CPU:   Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM:  64 MiB
MMC:   SUNXI SD/MMC: 0
SF: Detected xt25f128b with page size 256 Bytes, erase size 4 KiB, total 16 MiB
*** Warning - bad CRC, using default environment

Setting up a 800x480 lcd console (overscan 0x0)
dotclock: 33000kHz = 33000kHz: (1 * 3MHz * 66) / 6
In:    [email protected]
Out:   [email protected]
Err:   [email protected]


U-Boot 2017.01-rc2-00073-gdd6e874-dirty (Feb 07 2021 - 14:27:05 +0800) Allwinner Technology

CPU:   Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM:  64 MiB
MMC:   SUNXI SD/MMC: 0
SF: Detected xt25f128b with page size 256 Bytes, erase size 4 KiB, total 16 MiB
*** Warning - bad CRC, using default environment

Setting up a 800x480 lcd console (overscan 0x0)
dotclock: 33000kHz = 33000kHz: (1 * 3MHz * 66) / 6
In:    [email protected]
Out:   [email protected]
Err:   [email protected]
Net:   No ethernet found.
starting USB...
No controllers found
Hit any key to stop autoboot:  0
SF: Detected xt25f128b with page size 256 Bytes, erase size 4 KiB, total 16 MiB
device 0 offset 0x100000, size 0x10000
SF: 65536 bytes @ 0x100000 Read: OK
device 0 offset 0x110000, size 0x400000
SF: 4194304 bytes @ 0x110000 Read: OK
## Flattened Device Tree blob at 41800000
   Booting using the fdt blob at 0x41800000
   Loading Device Tree to 42dfa000, end 42dff216 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.10.15-licheepi-zero+ ([email protected]) (gcc version 4.9.4 (Linaro GCC 4.9-2017.01) ) #3 SMP Sun Feb 7 12:26:29 CST 2021
[    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
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] percpu: Embedded 14 pages/cpu @c3dea000 s24768 r8192 d24384 u57344
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 15883
[    0.000000] Kernel command line: console=ttyS0,115200 earlyprintk panic=5 rootwait mtdparts=spi32767.0:1M(uboot)ro,64k(dtb)ro,4M(kernel)ro,-(rootfs) root=31:03 rw rootfstype=jffs2
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Memory: 53644K/64036K available (6144K kernel code, 199K rwdata, 1392K rodata, 1024K init, 260K bss, 10392K reserved, 0K cma-reserved, 0K highmem)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xc4000000 - 0xff800000   ( 952 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xc3e89000   (  62 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[    0.000000]       .text : 0xc0008000 - 0xc0700000   (7136 kB)
[    0.000000]       .init : 0xc0900000 - 0xc0a00000   (1024 kB)
[    0.000000]       .data : 0xc0a00000 - 0xc0a31ec0   ( 200 kB)
[    0.000000]        .bss : 0xc0a33000 - 0xc0a7405c   ( 261 kB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Hierarchical RCU implementation.
[    0.000000]  Build-time adjustment of leaf fanout to 32.
[    0.000000]  RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=1.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=1
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000000] arm_arch_timer: Architected 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.000007] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    0.000019] Switching to timer-based delay loop, resolution 41ns
[    0.000140] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000350] Console: colour dummy device 80x30
[    0.000387] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[    0.000403] pid_max: default: 32768 minimum: 301
[    0.000534] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.000546] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.001258] CPU: Testing write buffer coherency: ok
[    0.001665] /cpus/[email protected] missing clock-frequency property
[    0.001690] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.002053] Setting up static identity map for 0x40100000 - 0x40100058
[    0.002792] smp: Bringing up secondary CPUs ...
[    0.002809] smp: Brought up 1 node, 1 CPU
[    0.002818] SMP: Total of 1 processors activated (48.00 BogoMIPS).
[    0.002825] CPU: All CPU(s) started in SVC mode.
[    0.003614] devtmpfs: initialized
[    0.006398] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[    0.006698] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.006728] futex hash table entries: 256 (order: 2, 16384 bytes)
[    0.006887] pinctrl core: initialized pinctrl subsystem
[    0.007904] NET: Registered protocol family 16
[    0.008400] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.009633] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[    0.009652] hw-breakpoint: maximum watchpoint size is 8 bytes.
[    0.021185] SCSI subsystem initialized
[    0.021458] usbcore: registered new interface driver usbfs
[    0.021520] usbcore: registered new interface driver hub
[    0.021617] usbcore: registered new device driver usb
[    0.021854] pps_core: LinuxPPS API ver. 1 registered
[    0.021865] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]>
[    0.021888] PTP clock support registered
[    0.022094] Advanced Linux Sound Architecture Driver Initialized.
[    0.023920] clocksource: Switched to clocksource arch_sys_counter
[    0.024783] simple-framebuffer 43e89000.framebuffer: framebuffer at 0x43e89000, 0x177000 bytes, mapped to 0xc4080000
[    0.024805] simple-framebuffer 43e89000.framebuffer: format=x8r8g8b8, mode=800x480x32, linelength=3200
[    0.031666] Console: switching to colour frame buffer device 100x30
[    0.037828] simple-framebuffer 43e89000.framebuffer: fb0: simplefb registered!
[    0.047735] NET: Registered protocol family 2
[    0.048359] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.048388] TCP bind hash table entries: 1024 (order: 1, 8192 bytes)
[    0.048412] TCP: Hash tables configured (established 1024 bind 1024)
[    0.048501] UDP hash table entries: 256 (order: 1, 8192 bytes)
[    0.048547] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
[    0.048766] NET: Registered protocol family 1
[    0.049404] RPC: Registered named UNIX socket transport module.
[    0.049426] RPC: Registered udp transport module.
[    0.049431] RPC: Registered tcp transport module.
[    0.049436] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.051675] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[    0.060841] NFS: Registering the id_resolver key type
[    0.060901] Key type id_resolver registered
[    0.060907] Key type id_legacy registered
[    0.065110] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 249)
[    0.065132] io scheduler noop registered
[    0.065139] io scheduler deadline registered
[    0.065315] io scheduler cfq registered (default)
[    0.069507] sun8i-v3s-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[    0.139470] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[    0.142783] console [ttyS0] disabled
[    0.163075] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 31, base_baud = 1500000) is a U6_16550A
[    0.753726] console [ttyS0] enabled
[    0.757953] [drm] Initialized
[    0.763794] m25p80 spi32766.0: unrecognized JEDEC id bytes: 0b, 40, 18
[    0.770451] m25p80: probe of spi32766.0 failed with error -2
[    0.776520] libphy: Fixed MDIO Bus: probed
[    0.780858] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.787456] ehci-platform: EHCI generic platform driver
[    0.792772] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.799004] ohci-platform: OHCI generic platform driver
[    0.804739] udc-core: couldn't find an available UDC - added [g_cdc] to list of pending drivers
[    0.814475] sun6i-rtc 1c20400.rtc: rtc core: registered rtc-sun6i as rtc0
[    0.821271] sun6i-rtc 1c20400.rtc: RTC enabled
[    0.825882] i2c /dev entries driver
[    0.830690] input: ns2009_ts as /devices/platform/soc/1c2ac00.i2c/i2c-0/0-0048/input/input0
[    0.840250] sunxi-wdt 1c20ca0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[    0.903959] sunxi-mmc 1c0f000.mmc: base:0xc405f000 irq:23
[    0.910308] usbcore: registered new interface driver usbhid
[    0.915970] usbhid: USB HID core driver
[    0.921561] NET: Registered protocol family 17
[    0.926255] Key type dns_resolver registered
[    0.930675] Registering SWP/SWPB emulation handler
[    0.941954] usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[    0.949952] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    0.955807] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 1
[    0.967104] hub 1-0:1.0: USB hub found
[    0.970997] hub 1-0:1.0: 1 port detected
[    0.975764] using random self ethernet address
[    0.980256] using random host ethernet address
[    0.985823] usb0: HOST MAC 2e:b3:f9:5c:71:a1
[    0.990142] usb0: MAC c6:fe:95:81:01:eb
[    0.994127] g_cdc gadget: CDC Composite Gadget, version: King Kamehameha Day 2008
[    1.001604] g_cdc gadget: g_cdc ready
[    1.005636] sun6i-rtc 1c20400.rtc: setting system clock to 1970-01-01 00:01:55 UTC (115)
[    1.014027] vcc3v0: disabling
[    1.017005] vcc5v0: disabling
[    1.019968] ALSA device list:
[    1.022929]   No soundcards found.
[    1.028053] VFS: Cannot open root device "31:03" or unknown-block(31,3): error -19
[    1.035753] Please append a correct "root=" boot option; here are the available partitions:
[    1.044127] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)
[    1.052471] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.10.15-licheepi-zero+ #3
[    1.059767] Hardware name: Allwinner sun8i Family
[    1.064508] [<c010e308>] (unwind_backtrace) from [<c010b10c>] (show_stack+0x10/0x14)
[    1.072254] [<c010b10c>] (show_stack) from [<c0333380>] (dump_stack+0x94/0xa8)
[    1.079477] [<c0333380>] (dump_stack) from [<c01a53f0>] (panic+0xdc/0x254)
[    1.086355] [<c01a53f0>] (panic) from [<c0901180>] (mount_block_root+0x18c/0x260)
[    1.093833] [<c0901180>] (mount_block_root) from [<c0901370>] (mount_root+0x11c/0x124)
[    1.101742] [<c0901370>] (mount_root) from [<c09014d0>] (prepare_namespace+0x158/0x19c)
[    1.109740] [<c09014d0>] (prepare_namespace) from [<c0900e50>] (kernel_init_freeable+0x1e8/0x1f8)
[    1.118607] [<c0900e50>] (kernel_init_freeable) from [<c0642940>] (kernel_init+0x8/0x114)
[    1.126780] [<c0642940>] (kernel_init) from [<c0107678>] (ret_from_fork+0x14/0x3c)
[    1.134349] Rebooting in 5 seconds..

1、分析

未識別出分割槽表

在上面的列印資訊中沒有出現

[    0.847372] 0x000000000000-0x000000100000 : "u-boot"
[    0.854799] 0x000000100000-0x000000110000 : "dtb"
[    0.861985] 0x000000110000-0x000000510000 : "kernel"
[    0.869390] 0x000000510000-0x000001000000 : "rootfs"

應該是沒有識別到分割槽表,檢查了一下應是沒有在核心裡面開啟Device Drivers ‣ Memory Technology Device (MTD) support ,的 <*> Command line partition table parsing 支援。重新配置重新編譯一下核心:

還是不行!

可以目的還是沒有達到,一直在復位:

[    1.028053] VFS: Cannot open root device "31:03" or unknown-block(31,3): error -19
[    1.035753] Please append a correct "root=" boot option; here are the available partitions:
[    1.044127] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)
[    1.052471] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.10.15-licheepi-zero+ #3
[    1.059767] Hardware name: Allwinner sun8i Family
[    1.064508] [<c010e308>] (unwind_backtrace) from [<c010b10c>] (show_stack+0x10/0x14)
[    1.072254] [<c010b10c>] (show_stack) from [<c0333380>] (dump_stack+0x94/0xa8)
[    1.079477] [<c0333380>] (dump_stack) from [<c01a53f0>] (panic+0xdc/0x254)
[    1.086355] [<c01a53f0>] (panic) from [<c0901180>] (mount_block_root+0x18c/0x260)
[    1.093833] [<c0901180>] (mount_block_root) from [<c0901370>] (mount_root+0x11c/0x124)
[    1.101742] [<c0901370>] (mount_root) from [<c09014d0>] (prepare_namespace+0x158/0x19c)
[    1.109740] [<c09014d0>] (prepare_namespace) from [<c0900e50>] (kernel_init_freeable+0x1e8/0x1f8)
[    1.118607] [<c0900e50>] (kernel_init_freeable) from [<c0642940>] (kernel_init+0x8/0x114)
[    1.126780] [<c0642940>] (kernel_init) from [<c0107678>] (ret_from_fork+0x14/0x3c)
[    1.134349] Rebooting in 5 seconds..

重點是:

[    1.028053] VFS: Cannot open root device "31:03" or unknown-block(31,3): error -19
[    1.035753] Please append a correct "root=" boot option; here are the available partitions:
[    1.044127] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)

之前寫在uboot裡面的一段配置如下:

#define CONFIG_BOOTCOMMAND   "sf probe 0; "                           \
                             "sf read 0x41800000 0x100000 0x10000; "  \
                             "sf read 0x41000000 0x110000 0x400000; " \
                             "bootz 0x41000000 - 0x41800000"

 #define CONFIG_BOOTARGS      "console=ttyS0,115200 earlyprintk panic=5 rootwait " \
                             "mtdparts=spi32766.0:1M(uboot)ro,64k(dtb)ro,4M(kernel)ro,-(rootfs) root=31:03 rw rootfstype=jffs2"

https://whycan.com/t_493.html 這裡有說可能是bootargs設定的問題可以改成:

"mtdparts=spi32766.0:1M(uboot)ro,64k(dtb)ro,4M(kernel)ro,-(rootfs) root=mtdblock3 rw rootfstype=jffs2"

就是將root=31:03改為 root=mtdblock3
這樣就不會Kernel panic如下:

[    1.033112]   No soundcards found.
[    1.037431] Waiting for root device /dev/mtdblock3...
[   12.229935] random: fast init done
[  241.824919] random: crng init done

然後一直就處在這裡!