国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā)

這篇具有很好參考價(jià)值的文章主要介紹了【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。


芯片:W25N01GVZEIG

一、硬件介紹

datasheet上的描述:
【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)

  • SLC工藝
  • 2KB*65536頁
  • 10萬次擦寫次數(shù)

【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)
焊好以后用CH341A讀了一下
【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)

V3s的啟動(dòng)順序

【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)
上面這張圖描述了soc啟動(dòng)的四個(gè)順序,分別是usb啟動(dòng)、sd卡啟動(dòng)、spi norflash啟動(dòng)、spi nandflash啟動(dòng)四種方式。前面的測試中一直走的是sd卡啟動(dòng),但是從成本和穩(wěn)定性上說,spi nandflash其實(shí)是最合適的。

sd 卡需要卡座拔插,在震動(dòng)環(huán)境下不穩(wěn)定,容易接觸不良,容量大,其實(shí)也貴,相當(dāng)于EMMC。
spi nor flash容量一般在16MB左右,也有32MB和64MB的,但是價(jià)格較貴。
2023年9月16日15:36:26,在某寶上數(shù)據(jù)對(duì)比一下

容量 接口 型號(hào) 價(jià)格
16MB spi nor flash W25Q128JVSIM 3.8¥
32MB spi nor flash W25Q256JVEIQ 7.1¥
128MB spi nand flash W25N01GVZEIG 4.0¥
256MB spi nand flash W25N02KVZEIR 5.9¥

所以,16M/32M 的spi nor flash 真的沒有什么優(yōu)勢。做非常簡單的應(yīng)用還可以,其他就算了吧。故以后自己玩也要玩nand flash吧,nor flash沒有什么應(yīng)用場景。

有興趣可以看看,我之前的記錄:

全志V3s學(xué)習(xí)記錄:Nor Flash使用(一)

全志V3s學(xué)習(xí)記錄:Nor Flash使用(二)

二、驅(qū)動(dòng)支持

U-Boot驅(qū)動(dòng)

使用:http://sources.buildroot.net/uboot/u-boot-2022.04.tar.bz2
【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)

主線 Linux 驅(qū)動(dòng)已經(jīng)支持

4.19 及其以后的版本支持 spi nand
https://github.com/torvalds/linux/blob/v4.19/drivers/mtd/nand/spi/winbond.c

目前主線Linux已經(jīng)支持winbond:W25N01GVZEIG,如下:

在線Linux Kernel代碼:https://elixir.bootlin.com/linux/v5.2.20/source/drivers/mtd/nand/spi/winbond.c

【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)

static const struct spinand_info winbond_spinand_table[] = {
	SPINAND_INFO("W25M02GV", 0xAB,
		     NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 2),
		     NAND_ECCREQ(1, 512),
		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
					      &write_cache_variants,
					      &update_cache_variants),
		     0,
		     SPINAND_ECCINFO(&w25m02gv_ooblayout, NULL),
		     SPINAND_SELECT_TARGET(w25m02gv_select_target)),
	SPINAND_INFO("W25N01GV", 0xAA,
		     NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
		     NAND_ECCREQ(1, 512),
		     SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
					      &write_cache_variants,
					      &update_cache_variants),
		     0,
		     SPINAND_ECCINFO(&w25m02gv_ooblayout, NULL)),
};

三、燒錄工具 xfel

之前燒錄spi nor flash的時(shí)候,使用的是sunxi-fel工具,如果需要燒錄spi nand flash image,就需要xfel

https://github.com/xboot/xfel

或者 git https://github.com/xboot/xfel.git

下載直接選main,解壓、直接make就可以了。

  • 解壓
  • make
  • sudo make install

需要安裝sudo apt-get install libusb-1.0-0-dev libusb-dev libudev-dev

usage:
    xfel version                                        - Show chip version
    xfel hexdump <address> <length>                     - Dumps memory region in hex
    xfel dump <address> <length>                        - Binary memory dump to stdout
    xfel read32 <address>                               - Read 32-bits value from device memory
    xfel write32 <address> <value>                      - Write 32-bits value to device memory
    xfel read <address> <length> <file>                 - Read memory to file
    xfel write <address> <file>                         - Write file to memory
    xfel exec <address>                                 - Call function address
    xfel reset                                          - Reset device using watchdog
    xfel sid                                            - Show sid information
    xfel jtag                                           - Enable jtag debug
    xfel ddr [type]                                     - Initial ddr controller with optional type
    xfel sign <public-key> <private-key> <file>         - Generate ecdsa256 signature file for sha256 of sid
    xfel spinor                                         - Detect spi nor flash
    xfel spinor erase <address> <length>                - Erase spi nor flash
    xfel spinor read <address> <length> <file>          - Read spi nor flash to file
    xfel spinor write <address> <file>                  - Write file to spi nor flash
    xfel spinand                                        - Detect spi nand flash
    xfel spinand erase <address> <length>               - Erase spi nand flash
    xfel spinand read <address> <length> <file>         - Read spi nand flash to file
    xfel spinand write <address> <file>                 - Write file to spi nand flash
    xfel spinand splwrite <split-size> <address> <file> - Write file to spi nand flash with split support
    xfel extra [...]                                    - The extra commands
liefyuan@ubuntu:~$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 010: ID 048d:5702 Integrated Technology Express, Inc. 
Bus 002 Device 009: ID 1f3a:efe8 Onda (unverified) V972 tablet in flashing mode
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 002 Device 009: ID 1f3a:efe8 Onda (unverified) V972 tablet in flashing mode

liefyuan@ubuntu:~$ xfel version
AWUSBFEX ID=0x00168100(V3S/S3) dflag=0x44 dlength=0x08 scratchpad=0x00007e00

這就是ubuntu識(shí)別出來進(jìn)入U(xiǎn)SB升級(jí)模式的V3s了。

簡單使用一下:

liefyuan@ubuntu:~$ xfel spinand
Found spi nand flash 'W25N01GV' with 134217728 bytes
liefyuan@ubuntu:~$ xfel version
AWUSBFEX ID=0x00168100(V3S/S3) dflag=0x44 dlength=0x08 scratchpad=0x00007e00
liefyuan@ubuntu:~$ sudo xfel spinand erase 0x0 0x100000
[sudo] password for liefyuan: 
 12% [======                                          ] 4.334 MB/s, ETA 00:00    
 25% [============                                    ] 4.334 MB/s, ETA 00:00    
 38% [==================                              ] 4.377 MB/s, ETA 00:00    
 50% [========================                        ] 4.363 MB/s, ETA 00:00    
 62% [==============================                  ] 4.386 MB/s, ETA 00:00    
 75% [====================================            ] 4.348 MB/s, ETA 00:00    
 88% [==========================================      ] 4.392 MB/s, ETA 00:00   
 100% [================================================] 1024.000 KB, 4.382 MB/s        

四、構(gòu)建U-Boot(官方的Uboot)

地址:http://sources.buildroot.net/uboot/u-boot-2022.04.tar.bz2

驅(qū)動(dòng)是支持的:

liefyuan@ubuntu:~/V3s/u-boot-2022.04$ find ./ -name "winbond.c"
./drivers/mtd/nand/spi/winbond.c

先編譯一下

先編譯一下看看有沒有什么問題

make ARCH=arm LicheePi_Zero_defconfig
make ARCH=arm menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

最后一步報(bào)錯(cuò)了,交叉編譯器版本太老了。

*** Your GCC is older than 6.0 and is not supported
arch/arm/config.mk:74: recipe for target 'checkgcc6' failed
make: *** [checkgcc6] Error 1

換個(gè)高版本的交叉編譯器!
再裝個(gè)軟件:sudo apt install swig

初步編譯成功了!

開始spi nand flash 代碼層面的適配

拷貝spl_spinand_sunxi.c到arch/arm/mach-sunxi目錄下,文件地址:

https://github.com/bamkrs/openwrt/blob/dolphinpi-spinand/package/boot/uboot-sunxi/src/arch/arm/mach-sunxi/spl_spinand_sunxi.c

spl_spinand_sunxi.c需要做一些修改:

  • 添加頭文件
  • 添加函數(shù)調(diào)用參數(shù)
// add by liefyuan
#include <image.h>
#include <linux/delay.h>
 
 
ret = spl_parse_image_header(spl_image, bootdev, header); // modified by liefyuan

然后在,arch/arm/mach-sunxi/Kconfig 文件中添加內(nèi)容:

config SPL_SPINAND_SUNXI
	bool "Support for SPI Nand Flash on Allwinner SoCs in SPL"
	depends on MACH_SUN8I_V3S
	help
	  Enable support for SPI Nand Flash. This option allows SPL to read from
	  sunxi SPI Nand Flash. It uses the same method as the boot ROM, so does
	  not need any extra configuration.

1043gg 處添加吧

然后在 arch/arm/mach-sunxi/Makefile添加 spl_spinand_sunxi.c的編譯選項(xiàng)

ifdef CONFIG_SPL_BUILD
obj-$(CONFIG_MACH_SUNIV)	+= dram_suniv.o
obj-$(CONFIG_DRAM_SUN4I)	+= dram_sun4i.o
obj-$(CONFIG_DRAM_SUN6I)	+= dram_sun6i.o
obj-$(CONFIG_DRAM_SUN8I_A23)	+= dram_sun8i_a23.o
obj-$(CONFIG_DRAM_SUN8I_A33)	+= dram_sun8i_a33.o
obj-$(CONFIG_DRAM_SUN8I_A83T)	+= dram_sun8i_a83t.o
obj-$(CONFIG_DRAM_SUN9I)	+= dram_sun9i.o
obj-$(CONFIG_SPL_SPI_SUNXI)	+= spl_spi_sunxi.o
obj-$(CONFIG_SUNXI_DRAM_DW)	+= dram_sunxi_dw.o
obj-$(CONFIG_SUNXI_DRAM_DW)	+= dram_timings/
obj-$(CONFIG_DRAM_SUN50I_H6)	+= dram_sun50i_h6.o
obj-$(CONFIG_DRAM_SUN50I_H6)	+= dram_timings/
obj-$(CONFIG_DRAM_SUN50I_H616)	+= dram_sun50i_h616.o
obj-$(CONFIG_DRAM_SUN50I_H616)	+= dram_timings/
obj-$(CONFIG_SPL_SPINAND_SUNXI)    += spl_spinand_sunxi.o
endif

繼續(xù),在 arch/arm/dts/sun8i-v3s-licheepi-zero.dts文件中添加spi0的內(nèi)容:

&spi0 {
    pinctrl-0 = <&spi0_pins>;
    pinctrl-names = "default";
    status = "okay";
    flash@0 {
        #address-cells = <1>;
        #size-cells = <1>;
        compatible = "spi-nand";
        reg = <0>;
        spi-max-frequency = <50000000>;
	};
};

最后,在 include/configs/sun8i.h添加內(nèi)容,要在#include <configs/sunxi-common.h>之前添加。

#ifdef CONFIG_BOOTCOMMAND
#undef CONFIG_BOOTCOMMAND
#endif

#ifdef COFNIG_BOOTARGS
#undef CONFIG_BOOTARGS
#endif


#define CONFIG_BOOTCOMMAND  "mtd read spi-nand0 0x41800000 0x100000 0x20000; "  \
                            "mtd read spi-nand0 0x41000000 0x120000 0x500000; " \
                            "bootz 0x41000000 - 0x41800000"

#define CONFIG_BOOTARGS    "console=ttyS0,115200 earlyprintk panic=5 rootwait " \
                            "mtdparts=spi0.0:1M(uboot)ro,128k(dtb)ro,5M(kernel)ro,-(rootfs) ubi.mtd=3 root=ubi0:rootfs rw rootfstype=ubifs"

修改menuconfig配置

命令:make ARCH=arm menuconfig

ARM architecture配置Support for SPI Nand Flash on Allwinner SoCs in SPL

【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)

Boot options 取消 Enable boot arguments

【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)

打開Device Drivers下面的SPI Support

【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)

在Device Drivers下面 MTD Support 中勾選 Enable MTD layer Driver Model for MTD driver

【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)

在Command line interface的Device access commands勾選 mtd,這樣后續(xù)生成的uboot中才會(huì)有MTD相關(guān)的命令,類似于SPI NOR Flash添加的sf命令

【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)

Environment 取消勾選 Environment is in SPI flash,這個(gè)選項(xiàng)是在打開SPI Support之后才會(huì)被看到

【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)OK,更改完畢。

再次編譯一下就OK了。

make ARCH=arm LicheePi_Zero_defconfig
make ARCH=arm menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

修改uboot輸出文件使其可以在spinandflash上運(yùn)行

此時(shí),u-boot-sunxi-with-spl.bin還不能被直接下載到nand flash。因?yàn)閂3s默認(rèn)從spi nand flash加載page內(nèi)容,是1個(gè)page加載1KB。我使用的是winbond的W25N01GVZEIG,它的page是2KB。

腳本地址:https://github.com/bamkrs/openwrt/blob/dolphinpi-spinand/target/linux/sunxi/image/gen_sunxi_spinand_onlyboot_img.sh

運(yùn)行命令:

./gen_sunxi_spinand_onlyboot_img.sh split.bin u-boot-sunxi-with-spl.bin 2048 128

其中split.bin代表生成的目標(biāo)文件,u-boot-sunxi-with-spl.bin表示剛剛編譯好的uboot文件,2048代表page大小,單位是byte,而128則代表block大小,單位是k byte。

下載修改后的uboot文件到spinandflash文件

liefyuan@ubuntu:~/V3s/u-boot-3s-spi-experimental$ sudo xfel spinand erase 0x0 0x100000
[sudo] password for liefyuan: 
100% [================================================] 1024.000 KB, 4.381 MB/s        
liefyuan@ubuntu:~/V3s/u-boot-3s-spi-experimental$ sudo xfel spinand write 0x0 split.bin
100% [================================================] 505.250 KB, 91.550 KB/s        

寫入文件是nandflash的由0開始的地址空間。

上電:


U-Boot SPL 2022.04 (Sep 17 2023 - 22:00:15 +0800)
DRAM: 64 MiB
Trying to boot from sunxi SPI-NAND
sunxi SPI-NAND: Found Winbond W25N01GVxxIG (efaa21)
sunxi SPI-NAND: Loading u-boot from 0x20000
sunxi SPI-NAND: u-boot hcrc OK!


U-Boot 2022.04 (Sep 17 2023 - 22:00:15 +0800) Allwinner Technology

CPU:   Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM:  64 MiB
Core:  23 devices, 11 uclasses, devicetree: separate
WDT:   Not starting watchdog@1c20ca0
MMC:   mmc@1c0f000: 0
Loading Environment from FAT... Card did not respond to voltage select! : -110
In:    serial@1c28000
Out:   serial@1c28000
Err:   serial@1c28000
Net:   No ethernet found.
Hit any key to stop autoboot:  0
Reading 131072 byte(s) (64 page(s)) at offset 0x00100000
Reading 5242880 byte(s) (2560 page(s)) at offset 0x00120000
zimage: Bad magic!
=>

五、構(gòu)建Linux Kernel

源碼:https://github.com/Lichee-Pi/linux/tree/zero-5.2.y

修改設(shè)備樹

修改 chosen

chosen {
		bootargs = "console=ttyS0,115200 earlyprintk panic=5 rootwait mtdparts=spi0.0:1M(uboot)ro,128k(dtb)ro,5M(kernel)ro,-(rootfs) ubi.mtd=3 root=ubi0:rootfs rw rootfstype=ubifs";
	};

增加SPI0節(jié)點(diǎn)

文件地址:linux-zero-5.2.y/arch/arm/boot/dts/sun8i-v3s-licheepi-zero.dts

&spi0 {
	status ="okay";
	
	spi_nand: spi_nand@0 {
        #address-cells = <1>;
        #size-cells = <1>;
        compatible = "spi-nand";
        reg = <0>;
        spi-max-frequency = <50000000>;
 
		partition@0 {
			label = "uboot";
			reg = <0x0 0x100000>;
			read-only;
		};
 
		partition@100000 {
			label = "dtb";
			reg = <0x100000 0x20000>;
			read-only;
		};
 
		partition@120000 {
			label = "kernel";
			reg = <0x120000 0x500000>;
			read-only;
		};
 
		partition@620000 {
			label = "rootfs";
			reg = <0x620000 0x79E0000>;
		};
	};
};

menuconfig里面配置增加驅(qū)動(dòng)支持

命令:make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Memory Technology Device (MTD) support 勾選 SPI NAND device Support 和 Enable UBI - Unsorted block image【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)

File Systems的Miscellaneous filesystems中勾選UBIFS file system support, 這一步需要?jiǎng)偛诺腅nable UBI打開之后才能看到

【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)

編譯Linux Kernel

  • 清除:make clean

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

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

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

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

燒錄 Linux Kernel

sudo xfel spinand erase 0x100000 0x20000
sudo xfel spinand write 0x100000 sun8i-v3s-licheepi-zero-with-800x480-lcd.dtb
sudo xfel spinand erase 0x120000 0x500000
sudo xfel spinand write 0x120000 zImage

上電:


U-Boot SPL 2022.04 (Sep 17 2023 - 22:00:15 +0800)
DRAM: 64 MiB
Trying to boot from sunxi SPI-NAND
sunxi SPI-NAND: Found Winbond W25N01GVxxIG (efaa21)
sunxi SPI-NAND: Loading u-boot from 0x20000
sunxi SPI-NAND: u-boot hcrc OK!


U-Boot 2022.04 (Sep 17 2023 - 22:00:15 +0800) Allwinner Technology

CPU:   Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM:  64 MiB
Core:  23 devices, 11 uclasses, devicetree: separate
WDT:   Not starting watchdog@1c20ca0
MMC:   mmc@1c0f000: 0
Loading Environment from FAT... Card did not respond to voltage select! : -110
In:    serial@1c28000
Out:   serial@1c28000
Err:   serial@1c28000
Net:   No ethernet found.
Hit any key to stop autoboot:  0
Reading 131072 byte(s) (64 page(s)) at offset 0x00100000
Reading 5242880 byte(s) (2560 page(s)) at offset 0x00120000
zimage: Bad magic!
=>
U-Boot SPL 2022.04 (Sep 17 2023 - 22:00:15 +0800)
DRAM: 64 MiB
Trying to boot from sunxi SPI-NAND
sunxi SPI-NAND: Found Winbond W25N01GVxxIG (efaa21)
sunxi SPI-NAND: Loading u-boot from 0x20000
sunxi SPI-NAND: u-boot hcrc OK!


U-Boot 2022.04 (Sep 17 2023 - 22:00:15 +0800) Allwinner Technology

CPU:   Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM:  64 MiB
Core:  23 devices, 11 uclasses, devicetree: separate
WDT:   Not starting watchdog@1c20ca0
MMC:   mmc@1c0f000: 0
Loading Environment from FAT... Card did not respond to voltage select! : -110
In:    serial@1c28000
Out:   serial@1c28000
Err:   serial@1c28000
Net:   No ethernet found.
Hit any key to stop autoboot:  0
Reading 131072 byte(s) (64 page(s)) at offset 0x00100000
Reading 5242880 byte(s) (2560 page(s)) at offset 0x00120000
Kernel image @ 0x41000000 [ 0x000000 - 0x4462a8 ]
## Flattened Device Tree blob at 41800000
   Booting using the fdt blob at 0x41800000
   Loading Device Tree to 42df9000, end 42dff021 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.2.0-licheepi-zero (liefyuan@ubuntu) (gcc version 6.3.1 20170404 (Linaro GCC 6.3-2017.05)) #2 SMP Sun Sep 17 22:22:36 HKT 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
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: Using PSCI v0.1 Function IDs from DT
[    0.000000] percpu: Embedded 16 pages/cpu s34508 r8192 d22836 u65536
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 16256
[    0.000000] Kernel command line: console=ttyS0,115200 earlyprintk panic=5 rootwait mtdparts=spi0.0:1M(uboot)ro,128k(dtb)ro,5M(kernel)ro,-(rootfs) ubi.mtd=3 root=ubi0:rootfs rw rootfstype=ubifs
[    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: 54004K/65536K available (7168K kernel code, 309K rwdata, 1748K rodata, 1024K init, 257K bss, 11532K 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] GIC: GICv2 detected, but range too small and irqchip.gicv2_force_probe not set
[    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 (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[    0.000008] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    0.000020] Switching to timer-based delay loop, resolution 41ns
[    0.000207] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000453] Console: colour dummy device 80x30
[    0.000509] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[    0.000524] pid_max: default: 32768 minimum: 301
[    0.000684] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.000699] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.001494] CPU: Testing write buffer coherency: ok
[    0.001994] /cpus/cpu@0 missing clock-frequency property
[    0.002020] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.002813] Setting up static identity map for 0x40100000 - 0x40100060
[    0.003023] rcu: Hierarchical SRCU implementation.
[    0.003573] smp: Bringing up secondary CPUs ...
[    0.003593] smp: Brought up 1 node, 1 CPU
[    0.003602] SMP: Total of 1 processors activated (48.00 BogoMIPS).
[    0.003609] CPU: All CPU(s) started in HYP mode.
[    0.003614] CPU: Virtualization extensions available.
[    0.004673] devtmpfs: initialized
[    0.008316] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[    0.008615] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.008646] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[    0.008884] pinctrl core: initialized pinctrl subsystem
[    0.010035] NET: Registered protocol family 16
[    0.010553] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.011815] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[    0.011835] hw-breakpoint: maximum watchpoint size is 8 bytes.
[    0.039592] SCSI subsystem initialized
[    0.039760] usbcore: registered new interface driver usbfs
[    0.039851] usbcore: registered new interface driver hub
[    0.039964] usbcore: registered new device driver usb
[    0.040374] mc: Linux media interface: v0.10
[    0.040435] videodev: Linux video capture interface: v2.00
[    0.040647] Advanced Linux Sound Architecture Driver Initialized.
[    0.042457] clocksource: Switched to clocksource arch_sys_counter
[    0.054799] NET: Registered protocol family 2
[    0.055598] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
[    0.055636] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.055662] TCP bind hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.055687] TCP: Hash tables configured (established 1024 bind 1024)
[    0.055836] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.055887] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.056173] NET: Registered protocol family 1
[    0.058034] Initialise system trusted keyrings
[    0.058413] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[    0.095330] Key type asymmetric registered
[    0.095353] Asymmetric key parser 'x509' registered
[    0.095451] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
[    0.095463] io scheduler mq-deadline registered
[    0.095469] io scheduler kyber registered
[    0.096519] sun4i-usb-phy 1c19400.phy: Couldn't request ID GPIO
[    0.100286] sun8i-v3s-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[    0.100703] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pb not found, using dummy regulator
[    0.101422] pwm-backlight backlight: backlight supply power not found, using dummy regulator
[    0.207095] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[    0.210551] printk: console [ttyS0] disabled
[    0.230855] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 34, base_baud = 1500000) is a U6_16550A
[    0.776897] printk: console [ttyS0] enabled
[    0.782886] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pe not found, using dummy regulator
[    0.816159] panel-simple panel: panel supply power not found, using dummy regulator
[    0.825484] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pc not found, using dummy regulator
[    0.837018] spi-nand spi0.0: Winbond SPI NAND was found.
[    0.842346] spi-nand spi0.0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
[    0.851243] 4 fixed-partitions partitions found on MTD device spi0.0
[    0.857692] Creating 4 MTD partitions on "spi0.0":
[    0.862530] 0x000000000000-0x000000100000 : "uboot"
[    0.870375] 0x000000100000-0x000000120000 : "dtb"
[    0.876231] 0x000000120000-0x000000620000 : "kernel"
[    0.882331] random: fast init done
[    0.895871] 0x000000620000-0x000008000000 : "rootfs"
[    1.066735] random: crng init done
[    1.153103] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.159637] ehci-platform: EHCI generic platform driver
[    1.165246] ehci-platform 1c1a000.usb: EHCI Host Controller
[    1.170857] ehci-platform 1c1a000.usb: new USB bus registered, assigned bus number 1
[    1.178853] ehci-platform 1c1a000.usb: irq 26, io mem 0x01c1a000
[    1.212460] ehci-platform 1c1a000.usb: USB 2.0 started, EHCI 1.00
[    1.219633] hub 1-0:1.0: USB hub found
[    1.223604] hub 1-0:1.0: 1 port detected
[    1.228232] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    1.234555] ohci-platform: OHCI generic platform driver
[    1.240097] ohci-platform 1c1a400.usb: Generic Platform OHCI controller
[    1.246819] ohci-platform 1c1a400.usb: new USB bus registered, assigned bus number 2
[    1.254782] ohci-platform 1c1a400.usb: irq 27, io mem 0x01c1a400
[    1.327507] hub 2-0:1.0: USB hub found
[    1.331344] hub 2-0:1.0: 1 port detected
[    1.338664] usbcore: registered new interface driver usb-storage
[    1.346267] sun6i-rtc 1c20400.rtc: registered as rtc0
[    1.351329] sun6i-rtc 1c20400.rtc: RTC enabled
[    1.356070] i2c /dev entries driver
[    1.360924] input: ns2009_ts as /devices/platform/soc/1c2ac00.i2c/i2c-0/0-0048/input/input0
[    1.370612] sunxi-wdt 1c20ca0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[    1.379328] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pf not found, using dummy regulator
[    1.415092] sunxi-mmc 1c0f000.mmc: initialized, max. request size: 16384 KB
[    1.422648] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pg not found, using dummy regulator
[    1.434001] usbcore: registered new interface driver usbhid
[    1.439580] usbhid: USB HID core driver
[    1.446187] Initializing XFRM netlink socket
[    1.450498] NET: Registered protocol family 17
[    1.455640] Registering SWP/SWPB emulation handler
[    1.461540] Loading compiled-in X.509 certificates
[    1.475480] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pe not found, using dummy regulator
[    1.488036] sun4i-drm display-engine: bound 1100000.mixer (ops 0xc0848700)
[    1.495606] sun4i-drm display-engine: bound 1c0c000.lcd-controller (ops 0xc08459fc)
[    1.503340] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[    1.509947] [drm] No driver support for vblank timestamp query.
[    1.516932] [drm] Initialized sun4i-drm 1.0.0 20150629 for display-engine on minor 0
[    1.577191] Console: switching to colour frame buffer device 100x30
[    1.605681] sun4i-drm display-engine: fb0: sun4i-drmdrmfb frame buffer device
[    1.613678] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[    1.625209] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    1.630975] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 3
[    1.640115] hub 3-0:1.0: USB hub found
[    1.644084] hub 3-0:1.0: 1 port detected
[    1.649367] ubi0: attaching mtd3
[    2.218438] ubi0: scanning is finished
[    2.222200] ubi0: empty MTD device detected
[    2.255116] ubi0: attached mtd3 (name "rootfs", size 121 MiB)
[    2.260921] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[    2.267867] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[    2.274665] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[    2.281615] ubi0: good PEBs: 975, bad PEBs: 0, corrupted PEBs: 0
[    2.287644] ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
[    2.294873] ubi0: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 2177542106
[    2.304004] ubi0: available PEBs: 951, total reserved PEBs: 24, PEBs reserved for bad PEB handling: 20
[    2.313392] sun6i-rtc 1c20400.rtc: setting system clock to 1970-01-01T00:34:30 UTC (2070)
[    2.321843] vcc3v0: disabling
[    2.324878] vcc3v3: disabling
[    2.327871] vcc5v0: disabling
[    2.330836] ALSA device list:
[    2.333827]   No soundcards found.
[    2.337799] ubi0: background thread "ubi_bgt0d" started, PID 93
[    2.349302] VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0): error -19
[    2.357403] Please append a correct "root=" boot option; here are the available partitions:
[    2.365795] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    2.374055] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.2.0-licheepi-zero #2
[    2.381091] Hardware name: Allwinner sun8i Family
[    2.385824] [<c010ed14>] (unwind_backtrace) from [<c010b72c>] (show_stack+0x10/0x14)
[    2.393566] [<c010b72c>] (show_stack) from [<c071a650>] (dump_stack+0x84/0x98)
[    2.400788] [<c071a650>] (dump_stack) from [<c011dddc>] (panic+0x110/0x2fc)
[    2.407750] [<c011dddc>] (panic) from [<c0a01358>] (mount_block_root+0x214/0x2f0)
[    2.415229] [<c0a01358>] (mount_block_root) from [<c0a01558>] (prepare_namespace+0x9c/0x194)
[    2.423660] [<c0a01558>] (prepare_namespace) from [<c0732aa4>] (kernel_init+0x8/0x10c)
[    2.431570] [<c0732aa4>] (kernel_init) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
[    2.439128] Exception stack(0xc3833fb0 to 0xc3833ff8)
[    2.444175] 3fa0:                                     00000000 00000000 00000000 00000000
[    2.452343] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    2.460508] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    2.467127] Rebooting in 5 seconds..

很好,上電成功了!

六、構(gòu)建文件系統(tǒng)

現(xiàn)成的文件系統(tǒng):
鏈接:https://pan.baidu.com/s/1-HMjT5BCYq0aImIJcQyJlw
提取碼:lief
–來自百度網(wǎng)盤超級(jí)會(huì)員V5的分享

系統(tǒng)名是:root
無密碼

spi nand flash 一般使用的文件系統(tǒng)是ubifs文件系統(tǒng)。涉及到兩個(gè)工具
第一步:先用mkfs.ubifs生成rootfs_ubifs.img文件,其中-d target就是根文件目錄的位置:

sudo mkfs.ubifs -x lzo -F -m 2048 -e 126976 -c 732 -o rootfs_ubifs.img -d target

第二步:用ubinize生成最終的ubi.img

sudo ubinize -o ubi.img -m 2048 -p 131072 -O 2048 -s 2048 ./ubinize.cfg  -v

ubinize.cfg文件

[rootfs-volume]
mode=ubi
image=rootfs_ubifs.img
vol_id=0
vol_size=92946432
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
vol_alignment=1

有了ubi.img之后,就可以使用xfel工具燒錄了。

sudo xfel spinand erase 0x620000 0x79DFFFF
sudo xfel spinand write 0x620000 ubi.img 

燒錄成功后,上電信息:

U-Boot SPL 2022.04 (Sep 17 2023 - 22:00:15 +0800)
DRAM: 64 MiB
Trying to boot from sunxi SPI-NAND
sunxi SPI-NAND: Found Winbond W25N01GVxxIG (efaa21)
sunxi SPI-NAND: Loading u-boot from 0x20000
sunxi SPI-NAND: u-boot hcrc OK!


U-Boot 2022.04 (Sep 17 2023 - 22:00:15 +0800) Allwinner Technology

CPU:   Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM:  64 MiB
Core:  23 devices, 11 uclasses, devicetree: separate
WDT:   Not starting watchdog@1c20ca0
MMC:   mmc@1c0f000: 0
Loading Environment from FAT... Card did not respond to voltage select! : -110
In:    serial@1c28000
Out:   serial@1c28000
Err:   serial@1c28000
Net:   No ethernet found.
Hit any key to stop autoboot:  0
Reading 131072 byte(s) (64 page(s)) at offset 0x00100000
Reading 5242880 byte(s) (2560 page(s)) at offset 0x00120000
Kernel image @ 0x41000000 [ 0x000000 - 0x4462a8 ]
## Flattened Device Tree blob at 41800000
   Booting using the fdt blob at 0x41800000
   Loading Device Tree to 42df9000, end 42dff021 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.2.0-licheepi-zero (liefyuan@ubuntu) (gcc version 6.3.1 20170404 (Linaro GCC 6.3-2017.05)) #2 SMP Sun Sep 17 22:22:36 HKT 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
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: Using PSCI v0.1 Function IDs from DT
[    0.000000] percpu: Embedded 16 pages/cpu s34508 r8192 d22836 u65536
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 16256
[    0.000000] Kernel command line: console=ttyS0,115200 earlyprintk panic=5 rootwait mtdparts=spi0.0:1M(uboot)ro,128k(dtb)ro,5M(kernel)ro,-(rootfs) ubi.mtd=3 root=ubi0:rootfs rw rootfstype=ubifs
[    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: 54004K/65536K available (7168K kernel code, 309K rwdata, 1748K rodata, 1024K init, 257K bss, 11532K 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] GIC: GICv2 detected, but range too small and irqchip.gicv2_force_probe not set
[    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 (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[    0.000008] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    0.000021] Switching to timer-based delay loop, resolution 41ns
[    0.000203] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000445] Console: colour dummy device 80x30
[    0.000501] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[    0.000518] pid_max: default: 32768 minimum: 301
[    0.000678] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.000695] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.001498] CPU: Testing write buffer coherency: ok
[    0.002002] /cpus/cpu@0 missing clock-frequency property
[    0.002028] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.002792] Setting up static identity map for 0x40100000 - 0x40100060
[    0.003005] rcu: Hierarchical SRCU implementation.
[    0.003552] smp: Bringing up secondary CPUs ...
[    0.003574] smp: Brought up 1 node, 1 CPU
[    0.003584] SMP: Total of 1 processors activated (48.00 BogoMIPS).
[    0.003590] CPU: All CPU(s) started in HYP mode.
[    0.003595] CPU: Virtualization extensions available.
[    0.004666] devtmpfs: initialized
[    0.008313] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[    0.008616] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.008647] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[    0.008888] pinctrl core: initialized pinctrl subsystem
[    0.010027] NET: Registered protocol family 16
[    0.010546] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.011810] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[    0.011827] hw-breakpoint: maximum watchpoint size is 8 bytes.
[    0.039494] SCSI subsystem initialized
[    0.039663] usbcore: registered new interface driver usbfs
[    0.039754] usbcore: registered new interface driver hub
[    0.039863] usbcore: registered new device driver usb
[    0.040242] mc: Linux media interface: v0.10
[    0.040330] videodev: Linux video capture interface: v2.00
[    0.040556] Advanced Linux Sound Architecture Driver Initialized.
[    0.042370] clocksource: Switched to clocksource arch_sys_counter
[    0.054726] NET: Registered protocol family 2
[    0.055518] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
[    0.055555] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.055584] TCP bind hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.055607] TCP: Hash tables configured (established 1024 bind 1024)
[    0.055753] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.055807] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.056106] NET: Registered protocol family 1
[    0.057942] Initialise system trusted keyrings
[    0.058328] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[    0.095103] Key type asymmetric registered
[    0.095125] Asymmetric key parser 'x509' registered
[    0.095222] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
[    0.095235] io scheduler mq-deadline registered
[    0.095242] io scheduler kyber registered
[    0.096292] sun4i-usb-phy 1c19400.phy: Couldn't request ID GPIO
[    0.100066] sun8i-v3s-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[    0.100482] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pb not found, using dummy regulator
[    0.101204] pwm-backlight backlight: backlight supply power not found, using dummy regulator
[    0.206901] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[    0.210326] printk: console [ttyS0] disabled
[    0.230632] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 34, base_baud = 1500000) is a U6_16550A
[    0.776672] printk: console [ttyS0] enabled
[    0.782652] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pe not found, using dummy regulator
[    0.815920] panel-simple panel: panel supply power not found, using dummy regulator
[    0.825241] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pc not found, using dummy regulator
[    0.836785] spi-nand spi0.0: Winbond SPI NAND was found.
[    0.842113] spi-nand spi0.0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
[    0.851018] 4 fixed-partitions partitions found on MTD device spi0.0
[    0.857466] Creating 4 MTD partitions on "spi0.0":
[    0.862266] 0x000000000000-0x000000100000 : "uboot"
[    0.870113] 0x000000100000-0x000000120000 : "dtb"
[    0.875974] 0x000000120000-0x000000620000 : "kernel"
[    0.882146] random: fast init done
[    0.895633] 0x000000620000-0x000008000000 : "rootfs"
[    1.066444] random: crng init done
[    1.152066] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.158675] ehci-platform: EHCI generic platform driver
[    1.164241] ehci-platform 1c1a000.usb: EHCI Host Controller
[    1.169848] ehci-platform 1c1a000.usb: new USB bus registered, assigned bus number 1
[    1.177848] ehci-platform 1c1a000.usb: irq 26, io mem 0x01c1a000
[    1.212377] ehci-platform 1c1a000.usb: USB 2.0 started, EHCI 1.00
[    1.219546] hub 1-0:1.0: USB hub found
[    1.223520] hub 1-0:1.0: 1 port detected
[    1.228140] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    1.234467] ohci-platform: OHCI generic platform driver
[    1.240007] ohci-platform 1c1a400.usb: Generic Platform OHCI controller
[    1.246726] ohci-platform 1c1a400.usb: new USB bus registered, assigned bus number 2
[    1.254694] ohci-platform 1c1a400.usb: irq 27, io mem 0x01c1a400
[    1.327423] hub 2-0:1.0: USB hub found
[    1.331262] hub 2-0:1.0: 1 port detected
[    1.338553] usbcore: registered new interface driver usb-storage
[    1.346152] sun6i-rtc 1c20400.rtc: registered as rtc0
[    1.351212] sun6i-rtc 1c20400.rtc: RTC enabled
[    1.355953] i2c /dev entries driver
[    1.360813] input: ns2009_ts as /devices/platform/soc/1c2ac00.i2c/i2c-0/0-0048/input/input0
[    1.370500] sunxi-wdt 1c20ca0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[    1.379224] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pf not found, using dummy regulator
[    1.415004] sunxi-mmc 1c0f000.mmc: initialized, max. request size: 16384 KB
[    1.422572] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pg not found, using dummy regulator
[    1.433929] usbcore: registered new interface driver usbhid
[    1.439505] usbhid: USB HID core driver
[    1.446113] Initializing XFRM netlink socket
[    1.450423] NET: Registered protocol family 17
[    1.455540] Registering SWP/SWPB emulation handler
[    1.461453] Loading compiled-in X.509 certificates
[    1.475387] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pe not found, using dummy regulator
[    1.487938] sun4i-drm display-engine: bound 1100000.mixer (ops 0xc0848700)
[    1.495525] sun4i-drm display-engine: bound 1c0c000.lcd-controller (ops 0xc08459fc)
[    1.503262] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[    1.509869] [drm] No driver support for vblank timestamp query.
[    1.516859] [drm] Initialized sun4i-drm 1.0.0 20150629 for display-engine on minor 0
[    1.577117] Console: switching to colour frame buffer device 100x30
[    1.605592] sun4i-drm display-engine: fb0: sun4i-drmdrmfb frame buffer device
[    1.613580] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[    1.625097] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    1.630863] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 3
[    1.639991] hub 3-0:1.0: USB hub found
[    1.643951] hub 3-0:1.0: 1 port detected
[    1.649229] ubi0: attaching mtd3
[    2.236686] ubi0: scanning is finished
[    2.282072] ubi0: volume 0 ("rootfs") re-sized from 732 to 951 LEBs
[    2.289265] ubi0: attached mtd3 (name "rootfs", size 121 MiB)
[    2.295090] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
[    2.301957] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
[    2.308784] ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
[    2.315757] ubi0: good PEBs: 975, bad PEBs: 0, corrupted PEBs: 0
[    2.321756] ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
[    2.328991] ubi0: max/mean erase counter: 1/0, WL threshold: 4096, image sequence number: 405437201
[    2.338037] ubi0: available PEBs: 0, total reserved PEBs: 975, PEBs reserved for bad PEB handling: 20
[    2.347328] sun6i-rtc 1c20400.rtc: setting system clock to 1970-01-01T00:23:16 UTC (1396)
[    2.355804] vcc3v0: disabling
[    2.358782] vcc3v3: disabling
[    2.361746] vcc5v0: disabling
[    2.364799] ALSA device list:
[    2.367768]   No soundcards found.
[    2.371779] ubi0: background thread "ubi_bgt0d" started, PID 93
[    2.388321] UBIFS (ubi0:0): Mounting in unauthenticated mode
[    2.397175] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 94
[    2.495382] UBIFS (ubi0:0): start fixing up free space
[    2.933104] UBIFS (ubi0:0): free space fixup complete
[    2.988109] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[    2.995678] UBIFS (ubi0:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[    3.005611] UBIFS (ubi0:0): FS size: 91549696 bytes (87 MiB, 721 LEBs), journal size 9023488 bytes (8 MiB, 72 LEBs)
[    3.016060] UBIFS (ubi0:0): reserved for root: 0 bytes (0 KiB)
[    3.021893] UBIFS (ubi0:0): media format: w4/r0 (latest is w5/r0), UUID 0D89ACE3-5309-484C-888D-2628D2752C10, small LPT model
[    3.045981] VFS: Mounted root (ubifs filesystem) on device 0:13.
[    3.055787] devtmpfs: mounted
[    3.061247] Freeing unused kernel memory: 1024K
[    3.067684] Run /sbin/init as init process
Starting logging: OK
Starting mdev...
/etc/init.d/S10mdev: line 21: can't create /proc/sys/kernel/hotplug: nonexistent directory
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:
Welcome to Lichee Pi
Lichee login: root
# ls
# cd /
# ls
bin      lib      media    proc     sbin     usr
dev      lib32    mnt      root     sys      var
etc      linuxrc  opt      run      tmp
#
 

用戶名:root,無密碼
跑起來了??!

七、進(jìn)入文件系統(tǒng)后的操作

查看掛載的文件系統(tǒng)

# mount
ubi0:rootfs on / type ubifs (rw,relatime,assert=read-only,ubi=0,vol=0)
devtmpfs on /dev type devtmpfs (rw,relatime,size=27000k,nr_inodes=6750,mode=755)
proc on /proc type proc (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /dev/shm type tmpfs (rw,relatime,mode=777)
tmpfs on /tmp type tmpfs (rw,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755)
sysfs on /sys type sysfs (rw,relatime)

查看分區(qū)

# cat /proc/mtd*
dev:    size   erasesize  name
mtd0: 00100000 00020000 "uboot"
mtd1: 00020000 00020000 "dtb"
mtd2: 00500000 00020000 "kernel"
mtd3: 079e0000 00020000 "rootfs"
# ls /dev/mtd*
/dev/mtd0    /dev/mtd1    /dev/mtd2    /dev/mtd3
/dev/mtd0ro  /dev/mtd1ro  /dev/mtd2ro  /dev/mtd3ro

查看存儲(chǔ)

# df -h
Filesystem                Size      Used Available Use% Mounted on
ubi0:rootfs              80.1M      2.1M     78.0M   3% /
devtmpfs                 26.4M         0     26.4M   0% /dev
tmpfs                    26.9M         0     26.9M   0% /dev/shm
tmpfs                    26.9M     20.0K     26.8M   0% /tmp
tmpfs                    26.9M     16.0K     26.9M   0% /run

查看Linux內(nèi)核啟動(dòng)參數(shù)

# cat /proc/cmdline
console=ttyS0,115200 earlyprintk panic=5 rootwait mtdparts=spi0.0:1M(uboot)ro,128k(dtb)ro,5M(kernel)ro,-(rootfs) ubi.mtd=3 root=ubi0:rootfs rw rootfstype=ubifs

查看目錄信息

# ls -lh
total 0
drwxr-xr-x    2 1000     1000        4.5K Mar 24  2017 bin
drwxr-xr-x    8 root     root       12.3K Jan  1 00:35 dev
drwxr-xr-x    5 1000     1000        1.5K Jan  1 00:35 etc
drwxr-xr-x    2 1000     1000        2.3K Mar 24  2017 lib
lrwxrwxrwx    1 1000     1000           3 Sep 17  2023 lib32 -> lib
lrwxrwxrwx    1 1000     1000          11 Sep 17  2023 linuxrc -> bin/busybox
drwxr-xr-x    2 1000     1000         160 Feb 28  2017 media
drwxr-xr-x    2 1000     1000         160 Feb 28  2017 mnt
drwxr-xr-x    3 1000     1000         224 Feb 26  2022 opt
dr-xr-xr-x   44 root     root           0 Jan  1 00:00 proc
drwx------    2 1000     1000         232 Jan  1 00:35 root
drwxr-xr-x    3 root     root         140 Jan  1 00:35 run
drwxr-xr-x    2 1000     1000        3.5K Mar 24  2017 sbin
dr-xr-xr-x   12 root     root           0 Jan  1 00:35 sys
drwxrwxrwt    2 root     root          60 Jan  1 00:35 tmp
drwxr-xr-x    6 1000     1000         480 Mar 24  2017 usr
drwxr-xr-x    4 1000     1000         672 Mar 24  2017 var

八、總結(jié)

編譯Uboot

make clean
make ARCH=arm LicheePi_Zero_Spinand_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
./gen_sunxi_spinand_onlyboot_img.sh split.bin u-boot-sunxi-with-spl.bin 2048 128

編譯Linux Kernel

make clean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- licheepi_zero_spinand_defconfig
time make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j16
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- dtbs

九、打包

拷貝

cp ../u-boot-2022.04-spinand/split.bin ./
cp ../linux-zero-5.2.y-spinand/arch/arm/boot/zImage ./
cp ../linux-zero-5.2.y-spinand/arch/arm/boot/dts/sun8i-v3s-licheepi-zero.dtb ./
tar -xvf rootfs.tar

sudo ./step1_gen_rootfs_ubifs_img.sh
sudo ./step2_gen_ubi_img.sh
sudo ./step3_gen_flash_img.sh
0x0      ~ 0xFFFFF  : 0x100000    1 MiB
0x100000 ~ 0x11FFFF  : 0x20000     128 KiB
0x120000 ~ 0x61FFFF  : 0x500000    5 MiB
0x620000 ~ 0x7FFFFFF  : 0x79DFFFF  124800 KiB=121.875 MiB

打包腳本 step3_gen_flash_img.sh

#!/bin/bash
rm -f flashimg.bin
dd if=/dev/zero of=flashimg.bin bs=1M count=20
dd if=u-boot-sunxi-with-spl.bin_split_exp of=flashimg.bin bs=1K count=1024 conv=notrunc
dd if=sun8i-v3s-licheepi-zero.dtb of=flashimg.bin bs=1K count=128 seek=1024 conv=notrunc
dd if=zImage of=flashimg.bin bs=1K count=5120 seek=1152 conv=notrunc
dd if=ubi.img of=flashimg.bin  bs=1K seek=6272 conv=notrunc

燒錄:

sudo xfel spinand erase 0x0 0x8000000
sudo xfel spinand write 0 flashimg.bin

十、工程源碼

原始的文件:

【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)

鏈接:https://pan.baidu.com/s/1uvlJGbLpLvEWhCeeKw6o9w
提取碼:lief
–來自百度網(wǎng)盤超級(jí)會(huì)員V5的分享

配置好的文件:

【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā),V3s,嵌入式linux,嵌入式Linux驅(qū)動(dòng),驅(qū)動(dòng)開發(fā)

鏈接:https://pan.baidu.com/s/1x2_cxEVv75nfhLBARodRwQ
提取碼:lief
–來自百度網(wǎng)盤超級(jí)會(huì)員V5的分享

參考:文章來源地址http://www.zghlxwxcb.cn/news/detail-723009.html

  • 全志V3S嵌入式驅(qū)動(dòng)開發(fā)(spi-nand image制作)
  • https://whycan.com/t_3123.html
  • https://whycan.com/viewtopic.php?pid=91704#p91704
  • https://whycan.com/p_80604.html

到了這里,關(guān)于【全志V3s】SPI NAND Flash 驅(qū)動(dòng)開發(fā)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 全志V3S嵌入式驅(qū)動(dòng)開發(fā)(wifi驅(qū)動(dòng))

    全志V3S嵌入式驅(qū)動(dòng)開發(fā)(wifi驅(qū)動(dòng))

    【 聲明:版權(quán)所有,歡迎轉(zhuǎn)載,請勿用于商業(yè)用途。 聯(lián)系信箱:feixiaoxing @163.com】 ? ? ? ? 荔枝派上面除了支持v3s自帶的有線網(wǎng)口,還帶有一個(gè)支持sd協(xié)議的esp 8089 wifi模塊。有了這個(gè)模塊,v3s沒有網(wǎng)線,也可以用它和外界聯(lián)系了。但是,我們實(shí)際測試下來,效果并不算很理

    2024年02月10日
    瀏覽(20)
  • 全志V3S嵌入式驅(qū)動(dòng)開發(fā)(觸摸屏驅(qū)動(dòng))

    全志V3S嵌入式驅(qū)動(dòng)開發(fā)(觸摸屏驅(qū)動(dòng))

    【 聲明:版權(quán)所有,歡迎轉(zhuǎn)載,請勿用于商業(yè)用途。 聯(lián)系信箱:feixiaoxing @163.com】 ? ? ? ? 所謂的觸摸屏,其實(shí)就是在普通的lcd屏幕之上,再加一層屏而已。這個(gè)屏是透明的,這樣客戶就可以看到下面lcd屏幕的內(nèi)容,另外一方面,通過觸摸信號(hào),還可以實(shí)現(xiàn)人和機(jī)器的自然

    2024年02月08日
    瀏覽(29)
  • 全志V3S嵌入式驅(qū)動(dòng)開發(fā)(多按鍵輸入驅(qū)動(dòng))

    全志V3S嵌入式驅(qū)動(dòng)開發(fā)(多按鍵輸入驅(qū)動(dòng))

    【 聲明:版權(quán)所有,歡迎轉(zhuǎn)載,請勿用于商業(yè)用途。 聯(lián)系信箱:feixiaoxing @163.com】 ? ? ? ? 前面我們說過,荔枝派的開發(fā)板上面,有4個(gè)按鍵本身不是通過gpio連接到soc上面的。它是通過ad的方法,連接到主芯片的。這個(gè)時(shí)候,不同的按鍵被按下的時(shí)候,就會(huì)生成不同的電壓或

    2024年02月07日
    瀏覽(28)
  • 全志V3S嵌入式驅(qū)動(dòng)開發(fā)(開發(fā)環(huán)境再升級(jí))

    【 聲明:版權(quán)所有,歡迎轉(zhuǎn)載,請勿用于商業(yè)用途。 聯(lián)系信箱:feixiaoxing @163.com】 ? ? ? ? 前面我們陸陸續(xù)續(xù)開發(fā)了差不多有10個(gè)驅(qū)動(dòng),涉及到網(wǎng)口、串口、音頻和視頻等幾個(gè)方面。但是整個(gè)開發(fā)的效率還是比較低的。每次開發(fā)調(diào)試的時(shí)候都很麻煩,譬如說,如果是驅(qū)動(dòng)代碼

    2024年02月08日
    瀏覽(32)
  • 全志V3S嵌入式驅(qū)動(dòng)開發(fā)(看原理圖)

    全志V3S嵌入式驅(qū)動(dòng)開發(fā)(看原理圖)

    【 聲明:版權(quán)所有,歡迎轉(zhuǎn)載,請勿用于商業(yè)用途。 聯(lián)系信箱:feixiaoxing @163.com】 ? ? ? ? 對(duì)于嵌入式軟件開發(fā)的同學(xué)來說,你可能不一定要會(huì)自己畫原理圖、做pcb板。但是,別人已經(jīng)設(shè)計(jì)好的原理圖,自己還是要看得懂、讀的明白的。此外,原理圖無非就是各種符號(hào)放在

    2024年02月06日
    瀏覽(21)
  • 全志V3S嵌入式驅(qū)動(dòng)開發(fā)(u盤寫讀)

    全志V3S嵌入式驅(qū)動(dòng)開發(fā)(u盤寫讀)

    【 聲明:版權(quán)所有,歡迎轉(zhuǎn)載,請勿用于商業(yè)用途。 聯(lián)系信箱:feixiaoxing @163.com】 ? ? ? ? 對(duì)于現(xiàn)在的soc來說,基本上usb是標(biāo)配的。它一般需要支持usb host、device和otg三種模式。 簡單解釋下,host模式,就是v3s把自己當(dāng)成了主機(jī),其他設(shè)備都是從設(shè)備;device模式,相當(dāng)于別人

    2024年02月09日
    瀏覽(27)
  • 全志V3S嵌入式驅(qū)動(dòng)開發(fā)(u盤寫讀)

    全志V3S嵌入式驅(qū)動(dòng)開發(fā)(u盤寫讀)

    【 聲明:版權(quán)所有,歡迎轉(zhuǎn)載,請勿用于商業(yè)用途。 聯(lián)系信箱:feixiaoxing @163.com】 ? ? ? ? 對(duì)于現(xiàn)在的soc來說,基本上usb是標(biāo)配的。它一般需要支持usb host、device和otg三種模式。 簡單解釋下,host模式,就是v3s把自己當(dāng)成了主機(jī),其他設(shè)備都是從設(shè)備;device模式,相當(dāng)于別人

    2024年02月09日
    瀏覽(21)
  • 全志V3S嵌入式驅(qū)動(dòng)開發(fā)(音頻輸出和音頻錄制)

    全志V3S嵌入式驅(qū)動(dòng)開發(fā)(音頻輸出和音頻錄制)

    【 聲明:版權(quán)所有,歡迎轉(zhuǎn)載,請勿用于商業(yè)用途。 聯(lián)系信箱:feixiaoxing @163.com】 ? ? ? ? 之前在芯片公司的時(shí)候,基本沒有看過音頻這一塊,只知道有個(gè)alsa框架這么個(gè)知識(shí)點(diǎn)。要驅(qū)動(dòng)音頻,需要兩部分,一部分就是底層驅(qū)動(dòng),一部分就是alsa上層接口,兩者缺一不可。 對(duì)

    2024年02月09日
    瀏覽(25)
  • 全志V3S嵌入式驅(qū)動(dòng)開發(fā)(屏幕花屏問題的解決)

    全志V3S嵌入式驅(qū)動(dòng)開發(fā)(屏幕花屏問題的解決)

    【 聲明:版權(quán)所有,歡迎轉(zhuǎn)載,請勿用于商業(yè)用途。 聯(lián)系信箱:feixiaoxing @163.com】 ? ? ? ? 之前我們測試過lcd屏幕驅(qū)動(dòng)以及觸控驅(qū)動(dòng)時(shí),當(dāng)時(shí)確實(shí)是成功的。但是由于這個(gè)屏幕是直接從旗艦店買的,價(jià)格略貴,有點(diǎn)超出成本。后來,陸陸續(xù)續(xù)從其他店家買了3塊lcd,測試的時(shí)

    2024年02月09日
    瀏覽(57)
  • 全志V3S嵌入式驅(qū)動(dòng)開發(fā)(解決kernel 5.2.y wifi驅(qū)動(dòng)問題)

    【 聲明:版權(quán)所有,歡迎轉(zhuǎn)載,請勿用于商業(yè)用途。 聯(lián)系信箱:feixiaoxing @163.com】 ? ? ? ? wifi模塊,之前測試的時(shí)候,開發(fā)板上用的是esp 8089,當(dāng)時(shí)內(nèi)核時(shí)4.14.y,測試結(jié)果也是通過的。印象不是太深的朋友可以回顧一下,鏈接地址在這, ? ? ? ? 那個(gè)時(shí)候測試,我們就說過

    2024年02月12日
    瀏覽(21)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包