我是靠谱客的博主 谦让雪糕,这篇文章主要介绍嵌入式Linux--全志V3s--NOR Flash的使用(二)移植Nor Flash一、上电失败二、移植nor flash三、成功上电,但内核没有识别出分区终于成功了!,现在分享给大家,希望可以做个参考。

目录

  • 一、上电失败
  • 二、移植nor flash
    • 1、配置Uboot支持
    • 2、配置Linux Kernel支持
    • 重新编译U-Boot和Kernel
      • 1、编译U-Boot
      • 2、编译Kernel
      • 3、打包烧录
  • 三、成功上电,但内核没有识别出分区
    • 1、分析
      • 未识别出分区表
      • Kernel 内核模块没有添加SPI Flash型号
          • Kernel中添加型号的SPI Flash
    • random: crng init done一直阻塞--坑解析
      • **坑1**、上面没有打印分区表意味着这个内核没有配置好:Device Drivers ‣ Memory Technology Device (MTD) support ><*> Command line partition table parsing,可是我明明配置好了的啊!后面才发现
      • **坑2** bootargs参数`root=/dev/mtdblock3`没有用!还是要用`root=31:03`才行!
      • **坑3** kernel新添加的spiflash不要加SECT_4K
  • 终于成功了!

嵌入式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:    serial@01c28000
Out:   serial@01c28000
Err:   serial@01c28000


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:    serial@01c28000
Out:   serial@01c28000
Err:   serial@01c28000
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, %02xn",
           id[0], id[1], id[2]);
    return ERR_PTR(-ENODEV);
}

由于需要移植的 flash 芯片特性和 w25qxxx 系列的 flash 相似,所以可以直接复制过来,修改后如下

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

const 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:xt25f128b@0 {
		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:    serial@01c28000
Out:   serial@01c28000
Err:   serial@01c28000

说明已经识别到了xt25f128b芯片!

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:   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+ (liefyuan@ubuntu) (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:    serial@01c28000
Out:   serial@01c28000
Err:   serial@01c28000


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:    serial@01c28000
Out:   serial@01c28000
Err:   serial@01c28000
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+ (liefyuan@ubuntu) (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/cpu@0 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 <giometti@linux.it>
[    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

然后一直就处在这里!

Kernel 内核模块没有添加SPI Flash型号

  • 在上一节中,有对Uboot中添加SPI Flash的支持,也有添加新的SPI Flash型号
  • 那是不是在Kernel中也要添加SPI Flash的支持和添加新的SPI Flash型号?

20210517又有时间继续这个项目了!看到打印信息有这个错误:

[    0.754303] console [ttyS0] enabled
[    0.758513] [drm] Initialized
[    0.764471] m25p80 spi32766.0: unrecognized JEDEC id bytes: 0b, 40, 18
[    0.771032] m25p80: probe of spi32766.0 failed with error -2
[    0.777143] libphy: Fixed MDIO Bus: probed
[    0.781489] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver

SPI Flash怎么变成了“m25p80”
不对啊,Uboot命令行里面可以检测到啊

=> sf probe
SF: Detected xt25f128b with page size 256 Bytes, erase size 4 KiB, total 16 MiB

根据这个:https://blog.csdn.net/whereisdog/article/details/82319993

Kernel中添加型号的SPI Flash

在内核源码工程目录:./drivers/mtd/spi-nor/spi-nor.c
打印信息就从这里发出来的:

static const struct flash_info *spi_nor_read_id(struct spi_nor *nor)
{
    int         tmp;
    u8          id[SPI_NOR_MAX_ID_LEN];
    const struct flash_info *info;

    tmp = nor->read_reg(nor, SPINOR_OP_RDID, id, SPI_NOR_MAX_ID_LEN);
    if (tmp < 0) {
        dev_dbg(nor->dev, "error %d reading JEDEC IDn", tmp);
        return ERR_PTR(tmp);
    }

    for (tmp = 0; tmp < ARRAY_SIZE(spi_nor_ids) - 1; tmp++) {
        info = &spi_nor_ids[tmp];
        if (info->id_len) {
            if (!memcmp(info->id, id, info->id_len))
                return &spi_nor_ids[tmp];
        }
    }
    dev_err(nor->dev, "unrecognized JEDEC id bytes: %02x, %02x, %02xn",
        id[0], id[1], id[2]);
    return ERR_PTR(-ENODEV);
}

从上面可以看到

    for (tmp = 0; tmp < ARRAY_SIZE(spi_nor_ids) - 1; tmp++) {
        info = &spi_nor_ids[tmp];
        if (info->id_len) {
            if (!memcmp(info->id, id, info->id_len))
                return &spi_nor_ids[tmp];
        }
    }

它是从数组里面一个一个进行匹配的,所以只需要在这里添加我的那个新的spi flash芯片型号就可以了,如下:
{ "xt25f128b", INFO(0x0b4018, 0, 64 * 1024, 256, SECT_4K) },


/* NOTE: double check command sets and memory organization when you add
 * more nor chips.  This current list focusses on newer chips, which
 * have been converging on command sets which including JEDEC ID.
 *
 * All newly added entries should describe *hardware* and should use SECT_4K
 * (or SECT_4K_PMC) if hardware supports erasing 4 KiB sectors. For usage
 * scenarios excluding small sectors there is config option that can be
 * disabled: CONFIG_MTD_SPI_NOR_USE_4K_SECTORS.
 * For historical (and compatibility) reasons (before we got above config) some
 * old entries may be missing 4K flag.
 */
static const struct flash_info spi_nor_ids[] = {
	...
	...
    { "w25q80", INFO(0xef5014, 0, 64 * 1024,  16, SECT_4K) },
    { "w25q80bl", INFO(0xef4014, 0, 64 * 1024,  16, SECT_4K) },
    { "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, SECT_4K) },
    { "w25q256", INFO(0xef4019, 0, 64 * 1024, 512, SECT_4K) },
  { "xt25f128b", INFO(0x0b4018, 0, 64 * 1024, 256, SECT_4K) },
    /* Catalyst / On Semiconductor -- non-JEDEC */
    { "cat25c11", CAT25_INFO(  16, 8, 16, 1, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
    { "cat25c03", CAT25_INFO(  32, 8, 16, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
    { "cat25c09", CAT25_INFO( 128, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
    { "cat25c17", CAT25_INFO( 256, 8, 32, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
    { "cat25128", CAT25_INFO(2048, 8, 64, 2, SPI_NOR_NO_ERASE | SPI_NOR_NO_FR) },
    { },
};

OK,重新编译下载!

没有报那个错误了!


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

U-Boot 2017.01-rc2-00073-gdd6e874-dirty (Feb 07 2021 - 22:55:12 +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:    serial@01c28000
Out:   serial@01c28000
Err:   serial@01c28000


U-Boot 2017.01-rc2-00073-gdd6e874-dirty (Feb 07 2021 - 22:55:12 +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:    serial@01c28000
Out:   serial@01c28000
Err:   serial@01c28000
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+ (liefyuan@ubuntu) (gcc version 4.9.4 (Linaro GCC 4.9-2017.01) ) #8 SMP Tue May 18 01:20:08 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=spi32766.0:1M(uboot)ro,64k(dtb)ro,4M(kernel)ro,-(rootfs) root=/dev/mtdblock3 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.000006] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    0.000018] Switching to timer-based delay loop, resolution 41ns
[    0.000135] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000347] Console: colour dummy device 80x30
[    0.000384] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[    0.000401] pid_max: default: 32768 minimum: 301
[    0.000536] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.000547] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.001256] CPU: Testing write buffer coherency: ok
[    0.001673] /cpus/cpu@0 missing clock-frequency property
[    0.001698] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.002072] Setting up static identity map for 0x40100000 - 0x40100058
[    0.002811] smp: Bringing up secondary CPUs ...
[    0.002830] smp: Brought up 1 node, 1 CPU
[    0.002839] SMP: Total of 1 processors activated (48.00 BogoMIPS).
[    0.002846] CPU: All CPU(s) started in SVC mode.
[    0.003633] devtmpfs: initialized
[    0.006420] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[    0.006721] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.006752] futex hash table entries: 256 (order: 2, 16384 bytes)
[    0.006914] pinctrl core: initialized pinctrl subsystem
[    0.007930] NET: Registered protocol family 16
[    0.008423] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.009643] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[    0.009662] hw-breakpoint: maximum watchpoint size is 8 bytes.
[    0.021175] SCSI subsystem initialized
[    0.021448] usbcore: registered new interface driver usbfs
[    0.021509] usbcore: registered new interface driver hub
[    0.021608] usbcore: registered new device driver usb
[    0.021840] pps_core: LinuxPPS API ver. 1 registered
[    0.021851] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.021874] PTP clock support registered
[    0.022079] Advanced Linux Sound Architecture Driver Initialized.
[    0.023910] clocksource: Switched to clocksource arch_sys_counter
[    0.024757] simple-framebuffer 43e89000.framebuffer: framebuffer at 0x43e89000, 0x177000 bytes, mapped to 0xc4080000
[    0.024778] simple-framebuffer 43e89000.framebuffer: format=x8r8g8b8, mode=800x480x32, linelength=3200
[    0.031635] Console: switching to colour frame buffer device 100x30
[    0.037794] simple-framebuffer 43e89000.framebuffer: fb0: simplefb registered!
[    0.047788] NET: Registered protocol family 2
[    0.048414] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.048447] TCP bind hash table entries: 1024 (order: 1, 8192 bytes)
[    0.048471] TCP: Hash tables configured (established 1024 bind 1024)
[    0.048558] UDP hash table entries: 256 (order: 1, 8192 bytes)
[    0.048605] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
[    0.048814] NET: Registered protocol family 1
[    0.049443] RPC: Registered named UNIX socket transport module.
[    0.049464] RPC: Registered udp transport module.
[    0.049470] RPC: Registered tcp transport module.
[    0.049475] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.051707] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[    0.060830] NFS: Registering the id_resolver key type
[    0.060883] Key type id_resolver registered
[    0.060891] Key type id_legacy registered
[    0.065099] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 249)
[    0.065123] io scheduler noop registered
[    0.065129] io scheduler deadline registered
[    0.065302] io scheduler cfq registered (default)
[    0.069494] sun8i-v3s-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[    0.139352] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[    0.142658] console [ttyS0] disabled
[    0.162947] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 31, base_baud = 1500000) is a U6_16550A
[    0.754479] console [ttyS0] enabled
[    0.758687] [drm] Initialized
[    0.764678] m25p80 spi32766.0: xt25f128b (16384 Kbytes)
[    0.771412] libphy: Fixed MDIO Bus: probed
[    0.775915] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.782441] ehci-platform: EHCI generic platform driver
[    0.787823] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.794058] ohci-platform: OHCI generic platform driver
[    0.799792] udc-core: couldn't find an available UDC - added [g_cdc] to list of pending drivers
[    0.809511] sun6i-rtc 1c20400.rtc: rtc core: registered rtc-sun6i as rtc0
[    0.816417] sun6i-rtc 1c20400.rtc: RTC enabled
[    0.820963] i2c /dev entries driver
[    0.825834] input: ns2009_ts as /devices/platform/soc/1c2ac00.i2c/i2c-0/0-0048/input/input0
[    0.835533] sunxi-wdt 1c20ca0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[    0.903943] sunxi-mmc 1c0f000.mmc: base:0xc405f000 irq:23
[    0.910272] usbcore: registered new interface driver usbhid
[    0.915928] usbhid: USB HID core driver
[    0.921538] NET: Registered protocol family 17
[    0.926232] Key type dns_resolver registered
[    0.930654] Registering SWP/SWPB emulation handler
[    0.941933] usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[    0.949940] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    0.955791] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 1
[    0.967046] hub 1-0:1.0: USB hub found
[    0.970921] hub 1-0:1.0: 1 port detected
[    0.975719] using random self ethernet address
[    0.980212] using random host ethernet address
[    0.985784] usb0: HOST MAC de:31:86:47:1f:c8
[    0.990102] usb0: MAC 3a:da:31:6f:f2:9b
[    0.994084] g_cdc gadget: CDC Composite Gadget, version: King Kamehameha Day 2008
[    1.001562] g_cdc gadget: g_cdc ready
[    1.005633] sun6i-rtc 1c20400.rtc: setting system clock to 1970-01-01 02:35:48 UTC (9348)
[    1.014105] vcc3v0: disabling
[    1.017083] vcc5v0: disabling
[    1.020047] ALSA device list:
[    1.023007]   No soundcards found.
[    1.027412] Waiting for root device /dev/mtdblock3...
[   12.225492] random: fast init done
[  241.824734] random: crng init done

可是它还是卡在最后这一步啊!
屏幕的左上角有个“_”在一闪一闪的,工作电流209mA

random: crng init done一直阻塞–坑解析

坑1、上面没有打印分区表意味着这个内核没有配置好:Device Drivers ‣ Memory Technology Device (MTD) support ><*> Command line partition table parsing,可是我明明配置好了的啊!后面才发现

在这里插入图片描述
每次图形化配置好后,运行make ARCH =arm licheepi_zero_defconfig所有的图形化配置都会清除!正确做法就是不运行这句!

只运行:

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

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

就可以了!

坑2 bootargs参数root=/dev/mtdblock3没有用!还是要用root=31:03才行!

坑3 kernel新添加的spiflash不要加SECT_4K

错误的写法:

   { "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, SECT_4K) },
    { "w25q256", INFO(0xef4019, 0, 64 * 1024, 512, SECT_4K) },
  { "xt25f128b", INFO(0x0b4018, 0, 64 * 1024, 256, SECT_4K) },

正确的写法:

 { "w25q128", INFO(0xef4018, 0, 64 * 1024, 256, SECT_4K) },
    { "w25q256", INFO(0xef4019, 0, 64 * 1024, 512, SECT_4K) },
  { "xt25f128b", INFO(0x0b4018, 0, 64 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },

总的来说,就是jffs2格式的文件系统一直没有挂载成功!

终于成功了!

2021年5月24日01:30:06 终于成功了!


U-Boot 2017.01-rc2-00073-gdd6e874-dirty (Feb 07 2021 - 22:55:12 +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
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:   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 42dff4bf ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.10.15-licheepi-zero+ (liefyuan@ubuntu) (gcc version 4.9.4 (Linaro GCC 4.9-2017.01) ) #12 SMP Mon May 24 01:18:26 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 with Dock
[    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=spi32766.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, 1416K rodata, 1024K init, 262K 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 - 0xc0a31fc0   ( 200 kB)
[    0.000000]        .bss : 0xc0a33000 - 0xc0a74a1c   ( 263 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.000142] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000356] Console: colour dummy device 80x30
[    0.000393] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[    0.000411] pid_max: default: 32768 minimum: 301
[    0.000546] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.000557] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.001255] CPU: Testing write buffer coherency: ok
[    0.001652] /cpus/cpu@0 missing clock-frequency property
[    0.001676] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.002035] Setting up static identity map for 0x40100000 - 0x40100058
[    0.002753] smp: Bringing up secondary CPUs ...
[    0.002770] smp: Brought up 1 node, 1 CPU
[    0.002779] SMP: Total of 1 processors activated (48.00 BogoMIPS).
[    0.002787] CPU: All CPU(s) started in SVC mode.
[    0.003577] devtmpfs: initialized
[    0.006578] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[    0.006881] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.006912] futex hash table entries: 256 (order: 2, 16384 bytes)
[    0.007070] pinctrl core: initialized pinctrl subsystem
[    0.008062] NET: Registered protocol family 16
[    0.008553] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.009802] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[    0.009821] hw-breakpoint: maximum watchpoint size is 8 bytes.
[    0.021969] SCSI subsystem initialized
[    0.022262] usbcore: registered new interface driver usbfs
[    0.022344] usbcore: registered new interface driver hub
[    0.022446] usbcore: registered new device driver usb
[    0.022678] pps_core: LinuxPPS API ver. 1 registered
[    0.022687] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.022709] PTP clock support registered
[    0.022916] Advanced Linux Sound Architecture Driver Initialized.
[    0.024760] clocksource: Switched to clocksource arch_sys_counter
[    0.025618] simple-framebuffer 43e89000.framebuffer: framebuffer at 0x43e89000, 0x177000 bytes, mapped to 0xc4080000
[    0.025637] simple-framebuffer 43e89000.framebuffer: format=x8r8g8b8, mode=800x480x32, linelength=3200
[    0.032500] Console: switching to colour frame buffer device 100x30
[    0.038656] simple-framebuffer 43e89000.framebuffer: fb0: simplefb registered!
[    0.048676] NET: Registered protocol family 2
[    0.049317] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.049352] TCP bind hash table entries: 1024 (order: 1, 8192 bytes)
[    0.049376] TCP: Hash tables configured (established 1024 bind 1024)
[    0.049469] UDP hash table entries: 256 (order: 1, 8192 bytes)
[    0.049516] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
[    0.049749] NET: Registered protocol family 1
[    0.050363] RPC: Registered named UNIX socket transport module.
[    0.050383] RPC: Registered udp transport module.
[    0.050389] RPC: Registered tcp transport module.
[    0.050395] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.052649] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[    0.061910] NFS: Registering the id_resolver key type
[    0.061962] Key type id_resolver registered
[    0.061969] Key type id_legacy registered
[    0.062019] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[    0.066786] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 249)
[    0.066811] io scheduler noop registered
[    0.066818] io scheduler deadline registered
[    0.067038] io scheduler cfq registered (default)
[    0.071234] sun8i-v3s-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[    0.140880] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[    0.144138] console [ttyS0] disabled
[    0.164419] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 34, base_baud = 1500000) is a U6_16550A
[    0.762205] console [ttyS0] enabled
[    0.766427] [drm] Initialized
[    0.772480] m25p80 spi32766.0: xt25f128b (16384 Kbytes)
[    0.777835] 4 cmdlinepart partitions found on MTD device spi32766.0
[    0.784095] Creating 4 MTD partitions on "spi32766.0":
[    0.789259] 0x000000000000-0x000000100000 : "uboot"
[    0.794892] 0x000000100000-0x000000110000 : "dtb"
[    0.800041] 0x000000110000-0x000000510000 : "kernel"
[    0.805490] 0x000000510000-0x000001000000 : "rootfs"
[    0.811226] libphy: Fixed MDIO Bus: probed
[    0.815718] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.822245] ehci-platform: EHCI generic platform driver
[    0.827630] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.833828] ohci-platform: OHCI generic platform driver
[    0.839573] udc-core: couldn't find an available UDC - added [g_cdc] to list of pending drivers
[    0.849116] input: 1c22800.lradc as /devices/platform/soc/1c22800.lradc/input/input0
[    0.858118] sun6i-rtc 1c20400.rtc: rtc core: registered rtc-sun6i as rtc0
[    0.865052] sun6i-rtc 1c20400.rtc: RTC enabled
[    0.869622] i2c /dev entries driver
[    0.874571] input: ns2009_ts as /devices/platform/soc/1c2ac00.i2c/i2c-0/0-0048/input/input1
[    0.884164] sunxi-wdt 1c20ca0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[    0.944799] sunxi-mmc 1c0f000.mmc: base:0xc406d000 irq:23
[    1.004785] sunxi-mmc 1c10000.mmc: base:0xc4071000 irq:24
[    1.011138] usbcore: registered new interface driver usbhid
[    1.016798] usbhid: USB HID core driver
[    1.022149] sun4i-codec 1c22c00.codec: ASoC: /soc/codec-analog@01c23000 not registered
[    1.030200] sun4i-codec 1c22c00.codec: Failed to register our card
[    1.037309] NET: Registered protocol family 17
[    1.041911] Key type dns_resolver registered
[    1.046442] Registering SWP/SWPB emulation handler
[    1.059926] usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[    1.067898] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    1.073665] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 1
[    1.082966] hub 1-0:1.0: USB hub found
[    1.086972] hub 1-0:1.0: 1 port detected
[    1.091685] using random self ethernet address
[    1.096269] using random host ethernet address
[    1.101774] usb0: HOST MAC 12:52:5d:07:8d:50
[    1.106203] usb0: MAC 76:58:ad:d5:05:e0
[    1.110089] g_cdc gadget: CDC Composite Gadget, version: King Kamehameha Day 2008
[    1.117608] g_cdc gadget: g_cdc ready
[    1.123773] sun4i-codec 1c22c00.codec: Codec <-> 1c22c00.codec mapping ok
[    1.132779] sun6i-rtc 1c20400.rtc: setting system clock to 1970-01-01 00:01:40 UTC (100)
[    1.141200] vcc5v0: disabling
[    1.144173] ALSA device list:
[    1.147200]   #0: V3s Audio Codec
[    1.153628] random: fast init done
[    1.194215] random: crng init done
[    3.411262] VFS: Mounted root (jffs2 filesystem) on device 31:3.
[    3.418287] devtmpfs: mounted
[    3.422554] Freeing unused kernel memory: 1024K
[    3.842408] ------------[ cut here ]------------
[    3.847186] WARNING: CPU: 0 PID: 1 at drivers/mtd/spi-nor/spi-nor.c:1182 spi_nor_write+0x128/0x190
[    3.856181] Writing at offset 164 into a NOR page. Writing partial pages may decrease reliability and increase wear of NOR flash.
[    3.856185] Modules linked in:
[    3.870896] CPU: 0 PID: 1 Comm: init Not tainted 4.10.15-licheepi-zero+ #12
[    3.877846] Hardware name: Allwinner sun8i Family
[    3.882577] [<c010e308>] (unwind_backtrace) from [<c010b10c>] (show_stack+0x10/0x14)
[    3.890321] [<c010b10c>] (show_stack) from [<c03431c0>] (dump_stack+0x94/0xa8)
[    3.897542] [<c03431c0>] (dump_stack) from [<c011b430>] (__warn+0xe8/0x100)
[    3.904501] [<c011b430>] (__warn) from [<c011b480>] (warn_slowpath_fmt+0x38/0x48)
[    3.911979] [<c011b480>] (warn_slowpath_fmt) from [<c044e198>] (spi_nor_write+0x128/0x190)
[    3.920239] [<c044e198>] (spi_nor_write) from [<c04467a0>] (mtd_writev+0xa4/0xec)
[    3.927719] [<c04467a0>] (mtd_writev) from [<c02f9350>] (jffs2_flash_writev+0x3f4/0x470)
[    3.935799] [<c02f9350>] (jffs2_flash_writev) from [<c02f21f0>] (jffs2_write_dnode+0xc8/0x324)
[    3.944404] [<c02f21f0>] (jffs2_write_dnode) from [<c02f2b04>] (jffs2_do_create+0x90/0x230)
[    3.952748] [<c02f2b04>] (jffs2_do_create) from [<c02ed1fc>] (jffs2_create+0xa0/0x120)
[    3.960661] [<c02ed1fc>] (jffs2_create) from [<c01fd7cc>] (path_openat+0xb10/0xf9c)
[    3.968314] [<c01fd7cc>] (path_openat) from [<c01fe9cc>] (do_filp_open+0x5c/0xc0)
[    3.975794] [<c01fe9cc>] (do_filp_open) from [<c01edf00>] (do_sys_open+0x10c/0x1bc)
[    3.983438] [<c01edf00>] (do_sys_open) from [<c01075c0>] (ret_fast_syscall+0x0/0x3c)
[    3.991230] ---[ end trace 5511d1e89aad5d33 ]---
Starting logging: OK
Starting mdev...
modprobe: can't change directory to '/lib/modules': No such file or directory
Initializing random number generator... done.
Starting network: OK

Welcome to Lichee Pi
Lichee login:
Welcome to Lichee Pi
Lichee login: root
# ls
# ls
# cd /
# ls
bin      lib      media    proc     sbin     usr
dev      lib32    mnt      root     sys      var
etc      linuxrc  opt      run      tmp
#

最后

以上就是谦让雪糕最近收集整理的关于嵌入式Linux--全志V3s--NOR Flash的使用(二)移植Nor Flash一、上电失败二、移植nor flash三、成功上电,但内核没有识别出分区终于成功了!的全部内容,更多相关嵌入式Linux--全志V3s--NOR内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(55)

评论列表共有 0 条评论

立即
投稿
返回
顶部