全志 Tina Linux 存储介质切换:eMMC,SPI NAND,SPI NOR,SD Card,SD NAND

时间:2022-10-14 13:54:42

存储切换方法

SDK切换存储介质需要修改board.dts、sys_config.fex、内核配置、TINA系统配置。另外,在spinor 存储介质下,通过 u-boot-sun8iw21p1.bin 进行烧录,u-boot-spinor-sun8iw21p1.bin 启动,使用sys_partition_nor.fex作为分区表。在非spinor介质(spinand、emmc、sdnand),通过u-boot-sun8iw21p1.bin进行烧录和启动,使用sys_partition.fex作为分区表。下文将介绍spinor切换spinandspinand切换spinorspinor切换emmcspinor切换sdnand四种切换方式。

  • sys_config.fex中只要关注storage_type选项,这个选项决定使用哪一种存储介质,配置后在pack过程,会自动打包对应介质的二进制文件。
  [target]
  storage_type = xxx
  其中storage_type | 0:nand | 1:sd | 2:emmc | 3:spinor  | 4:emmc3 | 5:spinand  | 6:sd1 |

spinor切换spinand

sys_config.fex修改

[target]
- storage_type = 3
+ storage_type = 5

board.dts/uboot-board.dts修改

&spi0 {
-	status = "disabled";
+	status = "okay";
	spi-nand@0 {
-		status="disabled";
+		status="okay";
	};
};

uboot编译

编译u-boot-sun8iw21p1.bin,spinand使用u-boot-sun8iw21p1.bin进行烧录、启动。
cboot切换到uboot目录,编辑configs/sun8iw21p1_defconfig
CONFIG_SUNXI_UBIFS=y   //SDK发布默认已选上
执行mboot               //编译
确保device/config/chips/vxxx/bin/u-boot-sun8iw21p1.bin已更新

内核配置

make kernel_menuconfig 层层选中
内核驱动配置
Device Driver --->
   Memory Technology Device (MTD) support --->
      sunxi-nand  --->
          <*> AWNAND CHOICE (Allwinner MTD SPINAND Device Support)  --->
      -*-   Enable UBI - Unsorted block images  --->
         [*]   Read-only block devices on top of UBI volumes
         
内核文件系统配置
File systems --->
   [*] Miscellaneous filesystems  --->
      <*>   UBIFS file system support

TINA环境配置

make menuconfig 层层选中
Target Images  --->
   Boot (SD Card) Kernel format (boot.img)  ---> //默认选中
   [ ] For storage less than 32M, enable this when using ota  //取消勾选
   
Global build settings  --->
   [*] Strip unnecessary functions from libraries  //取消勾选
   
Utilities  --->
   <*> mtd-utils --->
      <*>   mtd-utils-mkfs.ubifs

spinand切换spinor

切换部分原文链接:https://bbs.aw-ol.com/topic/1701/

sys_config.fex修改

[target]
- storage_type = 5
+ storage_type = 3

board.dts/uboot-board.dts修改

&spi0 {
-	status = "okay";
+	status = "disabled";
	spi-nand@0 {
-		status="okay";
+		status="disabled";
	};
};

内核配置

make kernel_menuconfig 层层选中
内核驱动配置
Device Driver --->
   Memory Technology Device (MTD) support --->
      sunxi-nand  --->  //取消勾选
   Self-contained MTD device drivers  --->
      <*> Support most SPI Flash chips (AT26DF, M25P, W25X, ...)  //确认已选中
   <*>   SPI-NOR device support  --->    
内核文件系统配置
File systems --->
   [*] Miscellaneous filesystems  --->
      <*>   Journalling Flash File System v2 (JFFS2) support

TINA环境配置

make menuconfig 层层选中
Target Images  --->
   [*] For storage less than 32M, enable this when using ota  //选中
   
Global build settings  --->
   [*] Strip unnecessary functions from libraries  //选中
   
Utilities  --->
   <*> mtd-utils
      <*>   mtd-utils-mkfs.jffs2  //选中

spinor切换emmc

sys_config.fex修改

[target]
- storage_type = 3
+ storage_type = 2

内核配置

make kernel_menuconfig 层层选中
[*] Enable the block layer  --->
   [*]   Support for large (2TB+) block devices and files
   [*]   Block layer SG support v4
Device Drivers  --->
   < > Memory Technology Device (MTD) support  --->  //取消勾选
   [*] Block devices  --->  //确认勾选
File systems  --->
   <*> The Extended 4 (ext4) filesystem

TINA环境配置

make menuconfig 层层选中
Target Images  --->
   Boot (SD Card) Kernel format (boot.img)  ---> //默认选中
   [ ] For storage less than 32M, enable this when using ota  //取消勾选
   
Global build settings  --->
   [ ] Strip unnecessary functions from libraries  //取消勾选
   
Utilities  --->
   Filesystem  --->
      <*> e2fsprogs //选中

spinor切换sdnand

sys_config.fex修改

[target]
- storage_type = 3
+ storage_type = 1

board.dts修改

&sdc2 {
	non-removable;
	bus-width = <8>;
	mmc-ddr-1_8v;
	mmc-hs200-1_8v;
	mmc-hs400-1_8v;
	no-sdio;
-	no-sd;
+	//no-sd;
	ctl-spec-caps = <0x308>;
	cap-mmc-highspeed;
	sunxi-power-save-mode;
	sunxi-dis-signal-vol-sw;
	max-frequency = <100000000>;
	vmmc-supply = <&reg_dcdc1>;
	/*emmc io vol 3.3v*/
	vqmmc-supply = <&reg_bldo1>;
	/*emmc io vol 1.8v*/
	/*vqmmc-supply = <&reg_eldo1>;*/
	status = "disabled";
};

内核配置

make kernel_menuconfig 层层选中
[*] Enable the block layer  --->
   [*]   Support for large (2TB+) block devices and files
   [*]   Block layer SG support v4
Device Drivers  --->
   < > Memory Technology Device (MTD) support  --->  //取消勾选
   [*] Block devices  --->  //确认勾选
File systems  --->
   <*> The Extended 4 (ext4) filesystem

TINA环境配置

make menuconfig 层层选中
Target Images  --->
   Boot (SD Card) Kernel format (boot.img)  ---> //默认选中
   [ ] For storage less than 32M, enable this when using ota  //取消勾选
   
Global build settings  --->
   [ ] Strip unnecessary functions from libraries  //取消勾选
   
Utilities  --->
   Filesystem  --->
      <*> e2fsprogs //选中

Tina 一般支持nor, nand, mmc 三种介质。

更具体的,nand分为并口nand和spinand,mmc分emmc和sd卡

主要需要区分的是nor和其他介质,因为需要打包的部分有所不同。

即,emmc和nand,sd卡一般可共用一份固件,而nor则需使用另一份固件

sys_config配置

在sys_config中有一个配置项,storage_type,取值及含义如下

;----------------------------------------------------------------------------------
; storage_type 0:nand 1:sd 2:emmc 3:spinor 4:emmc3 5:spinand 6:sd1
;----------------------------------------------------------------------------------
[target]
storage_type = xxx

对于nor的方案,必须配置为

 storage_type = 3

对于其他介质,storage_type则不能配置为3

spinand切换为spinor

sys_config 设置介质为nor

[target]
storage_type = 3

配置所用nor的大小

[norflash]
size		= 16   

内核配置

 make kernel_menuconfig --->
	Device Drivers --->
                < >Block devices  (取消选中)
	Device Drivers --->
		<*>Memory Technology Device (MTD) support
                        <*>OpenFirmware partitioning information support
			<*>SUNXI partitioning support
       <*>   Caching block device access to MTD devices
			<*>   SPI-NOR device support  (对于linux4.9,先选这个,下面的选项才出现)
			Self-contained MTD device drivers  --->
				 <*> Support most SPI Flash chips (AT26DF, M25P, W25X, ...)
  File systems  --->
    < > The Extended 4 (ext4) filesystem(取消选中)
  File systems  --->
    [*] Miscellaneous filesystems  ---> 
     <*>   Journalling Flash File System v2 (JFFS2) support(选中)
  [*] Enable the block layer  --->
    [ ]   Support for large (2TB+) block devices and files(取消选中)

menuconfig配置

make menuconfig --->
       Utilities  --->
                <*> mtd-utils (选择) --->
                        <*> mtd-utils-mkfs.jffs2
make menuconfig --->
       Utilities  --->
                Filesystem  --->
                        < > e2fsprogs(取消选择)

spinor切换为spinand

sys_config 设置介质为spinand

[target]
storage_type = 5

内核配置

 make kernel_menuconfig --->
      Device Drivers --->
                 [*]Block devices --->
                         <*>   sunxi nand flash driver
      Device Drivers --->
		< >Memory Technology Device (MTD) support(取消选择)
       [*] Enable the block layer  --->
                [*]   Support for large (2TB+) block devices and files 
      File systems  --->
               <*> The Extended 4 (ext4) filesystem

menuconfig 配置

make menuconfig --->
       Utilities  --->
                < > mtd-utils (取消选择)
                Filesystem  --->
                        <*> e2fsprogs

分区表配置 注意点

对于nand,rootfs_data分区,使用ext4格式。分配太小的话可能会创建失败。

FAQ

使用mkfs.ext4等工具的时候出现

/usr/sbin/fsck.ext4 -y /dev/by-name/rootfs_data
Error loading shared library /home/wuguanling/workspace/project/v316-sdv-tina/out/v316-sdv/staging_dir/target/rootfs/lib/libc.so: No such file or directory (needed by /usr/lib/libext2fs.so.2)

关闭以下选项:

make menuconfig
   | --- Global build settings
		| --- []strip unnecessary functions for libraries  

原文链接:https://bbs.aw-ol.com/topic/1701/ 作者@YterAA