Tina Linux(2)---第一个固件,SPI NAND

2024-06-10 07:43:56 浏览数 (1)

在网上一直没有找到一篇专门讲SPI NAND介质改动的文章。实际上需要修改的地方很少,但是由于自己不熟悉,也折腾了不少时间。这篇文章更多是自己折腾过程的记录。同时也给可能遇到同样问题的小伙伴一个参考。

一、修改存储方式

修改存储介质为SPI NAND;

路径:nano ./device/config/chips/t113/configs/evb1/sys_config.fex

[target]

storage_type = 5

burn_key = 0

如果是自己制作的设备,可能因为电源或者外围电路设计不是很达标,会导致各种烧录问题,也可以在这个文件里面修改DDR和CPU频率,降频后可以实现烧录。

;*****************************************************************************

;sdram configuration

;

;*****************************************************************************

[dram_para]

dram_clk = 480

dram_type = 3

二、修改设备树

使能spi0和SPI NAND,SDK默认是打开的:

路径:./device/config/chips/t113/configs/evb1/board.dts

&spi0 {

clock-frequency = <100000000>;

pinctrl-0 = <&spi0_pins_a &spi0_pins_b>;

pinctrl-1 = <&spi0_pins_c>;

pinctrl-names = "default", "sleep";

/*spi-supply = <&reg_dcdc1>;*/

spi_slave_mode = <0>;

spi0_cs_number = <1>;

spi0_cs_bitmap = <1>;

status = "okay";

spi-nand@0 {

compatible = "spi-nand";

spi-max-frequency=<100000000>;

reg = <0x0>;

spi-rx-bus-width=<0x01>;

spi-tx-bus-width=<0x01>;

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="disabled";

};

};

三、修改环境参数

修改uboot启动的环境参数,选择从SPI NAND启动;

路劲:./device/config/chips/t113/configs/evb1/env.cfg

bootcmd=run setargs_nand boot_normal

#bootcmd=run setargs_mmc boot_normal

四、内核配置

4.1 make kernel_menuconfig 层层选中

这里SDK也是默认配置好了

内核驱动配置

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

4.2 make menuconfig 层层选中

这里SDK也是默认配置好了

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

五、编译,烧录,启动

export SOURCE_DATE_EPOCH=253402300799

source build/envsetup.sh

lunch

6

make

六、拓展--增加不支持芯片的方法,(仅供参考,非必要不使用)

例子:重新在kernel中添加GD NAND Flash GD5F1GQ4UBYIG的相关参数: 下面是添加的Nand Flash参数,需要同时在

代码语言:javascript复制
tina-d1-h/lichee/brandy-2.0/u-boot-2018/drivers/mtd/awnand/spinand/physic/id.c

代码语言:javascript复制
tina-d1-h/lichee/linux-5.4/drivers/mtd/awnand/spinand/physic/id.c

添加下面的参数。

代码语言:javascript复制
struct aw_spinand_phy_info gigadevice[] =
{
	{
		.Model		= "GD5F1GQ4UBYIG",
		.NandID		= {0xc8, 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
		.DieCntPerChip  = 1,
		.SectCntPerPage = 4,
		.PageCntPerBlk  = 64,
		.BlkCntPerDie	= 1024,
		.OobSizePerPage = 64,
		.OperationOpt	= SPINAND_QUAD_READ | SPINAND_QUAD_PROGRAM |
			SPINAND_DUAL_READ,
		.MaxEraseTimes  = 50000,
		.EccFlag	= HAS_EXT_ECC_SE01,
		.EccType	= BIT4_LIMIT5_TO_7_ERR8_LIMIT_12,
		.EccProtectedType = SIZE16_OFF4_LEN8_OFF4,
		.BadBlockFlag	= BAD_BLK_FLAG_FRIST_1_PAGE,
	},
	......
}

附录

参考链接:

0 人点赞