SPINOR启动
3.1. setup.h
路径:lichee/linux-5.4/include/uapi/asm-generic/setup.h
1、修改COMMAND_LINE_SIZE宏大小至1024,
3.2. boot_package_nor.cfg
路径:lichee/device/config/f133/configs/default/boot_package_nor.cfg
1、修改item=u-boot, u-boot-spinor.fex为u-boot.fex,
3.3. env.cfg
路径:lichee/device/config/f133/configs/default/env.cfg
1、增加nor_root=/dev/mtdblock5
2、增加
setargs_nor=setenv bootargs ubi.mtd=${mtd_name} ubi.block=0,${root_partition} earlyprintk=${earlyprintk} clk_ignore_unused initcall_debug=${initcall_debug} console=${console} loglevel=${loglevel} root=${nor_root} rootfstype=${rootfstype} init=${init} partitions=${partitions} cma=${cma} snum=${snum} mac_addr=${mac} wifi_mac=${wifi_mac} bt_mac=${bt_mac} specialstr=${specialstr} gpt=1
3、修改bootcmd=run setargs_nor boot_normal
参考图如下:
3.4. board.dts
路径:lichee/device/config/f133/configs/evb1/linux-5.4/board.dts
1、增加spi-nor@0结点的配置,并确保节点spi0和子节点spi-nor@0的status="okay",如下:
spi-nor@0 {
compatible = "jedec,spi-nor";
spi-max-frequency=<30000000>;
reg = <0x0>;
spi-rx-bus-width=<0x01>;
spi-tx-bus-width=<0x01>;
status="okay";
};
参考图如下:
3.5. sys_config.fex配置文件
路径:device\config\chips\f133\configs\evb1
1、修改storage_type = 3
3.6. kernel_menuconfig配置
1、进入make kernel_menuconfig -> Device Drivers -> Memory Technology Device (MTD) Support,选择SUNXI partitioning support和SPI-NOR device support配置;
2、进入make kernel_menuconfig -> Device Drivers -> SPI support,选择SPI memory externsion;
选择SPI memory externsion
3.7. 裁剪固件小于10MBytes
3.7.1. 内核裁剪
编译窗口输入make kernel_menuconfig
3.7.1.1. 关闭网络支持
Networking support --->
3.7.1.2. 开启MTD/spinor支持
---> Device Drivers
---> <> Memory Technology Device (MTD) support --->
---> <> SUNXI partitioning support
---> <*> SPI-NOR device support --->
3.7.1.3. 关闭dump reg支持
---> Device Drivers
---> < > dump reg driver for sunxi platform
3.7.1.4. 关闭Remote Controller支持
---> Device Drivers
Remote Controller support ----
3.7.1.5. 关闭Multimedia支持
---> Device Drivers
---> < > Multimedia support ----
3.7.1.6. 关闭Sound card支持
---> Device Drivers
--- > <*> Sound card support --->
--- > < > Advanced Linux Sound Architecture ----
3.7.1.7. 关闭部分Cryptographic API支持
---> -*- Cryptographic API --->
Disable run-time self tests
--- > < > RSA algorithm
--- > < > ECDH algorithm
--- > < > CCM support
--- > < > GCM/GMAC support
--- > < > CTR support
--- > < > Sequence Number IV Generator
--- > < > Null algorithms
--- > < > ECB support
--- > < > CMAC support
--- > < > GHASH hash function
--- > < > AES cipher algorithms
--- > < > ARC4 cipher algorithm
--- > < > Deflate compression algorithm --- > < > LZO compression algorithm
--- > < > Zstd compression algorithm
---> < > NIST SP800-90A DRBG ----
---> < > Jitterentropy Non-Deterministic Random Number Generator
Hardware crypto devices ----
---> < > SHA224 and SHA256 digest algorithm
---> < > HMAC support
---> < > Cryptographic algorithm manager
3.7.1.8. 关闭XZ decompression支持
---> Library routines --->
--- > < > XZ decompression support
DMA Contiguous Memory Allocator
3.7.2. 应用裁剪
编译窗口输入make menuconfig
3.7.2.1. 关闭smartva
---> Gui --->
---> Littlevgl --->
---> < > smartva
lvgl-8.0.1 use sunxifb cache
lvgl-8.0.1 use sunxifb double buffer
3.7.2.2. 关闭cedarx
---> Allwinner --->
---> < > libcedarx
3.7.2.3. 关闭alsa
---> Allwinner --->
---> < > alsa-conf-aw
---> Utilities --->
< > alsa-utils
3.7.2.4. 关闭网络
---> Kernel modules --->
---> Wireless Drivers --->
---> < > kmod-net-xr819s
---> Firmware --->
---> < > xr819s-firmware
---> Base system --->
---> <*> busybox
---> Networking Utilities --->
Enable IPv6 support
hostname
ifconfig
ip
ntpd
ping
route
wget
udhcpc (DHCP client)
---> Allwinner --->
---> < > swupdate
---> < > ota-burnboot
---> < > wifimanager
---> Network --->
---> < > iw
---> WirelessAPD --->
---> < > wpa-cli
---> < > wpad-basic
---> < > hostapd-common
---> Libraries --->
---> Firewall --->
---> < > libip4tc
---> < > libip6tc
---> < > libxtables
---> Base system --->
---> < > dnsmasq
---> < > netifd
3.7.2.5. 关闭input模块
---> Kernel modules --->
---> Input modules --->
---> < > kmod-net-xr819s
---> < > kmod-touchscreen-gt9xxnew
---> < > kmod-input-evdev
---> < > kmod-input-core
3.7.2.6. 关闭其他库
---> Base system --->
---> < > jsonfilter
---> < > ubus
---> < > ubusd
---> Allwinner --->
---> < > liballwinner-base
---> < > libuapi
---> Libraries --->
---> < > alsa-lib
---> < > libconfig
---> < > libfreetype
---> < > libncurses
---> < > libncursesw
---> < > terminfo
---> < > libuci
---> < > libubus
---> < > libspeexdsp
---> Compression --->
---> < > libbz2
---> SSL --->
---> < > libopenssl
---> < > libnl-tiny
---> Multimedia --->
---> < > fdk-aac
---> Utilities --->
---> < > jshn
---> < > strace
---> Libraries --->
---> < > libblobmsg-json
---> < > libjson-c
---> < > libubox
3.8. sys_partition_nor.fex
路径:device/config/chips/f133/configs/evb1/sys_partition_nor.fex
此文件为spinor的分区配置文件,打包过程中可能出现分区太小导致镜像装载失败的情况
此时需要修改对应分区大小,或对内核或者文件系统进行裁剪。
各分区大小配置参考样本如下:
3.9. 问题归纳
1)启动过程中,看到如下打印,才能确认spinorflash工作正常,否则请确认spi的gpio配置是否有冲突,或者spinorflash驱动和dts是否配置正常。