[Linux]u-boot_2014移植(五)支持NOR_Flash Nand_Flash

[Linux]u-boot_2014移植(五)支持NOR_Flash Nand_Flash

个人博客https://aeneag.xyz/

艾恩凝

2021/6/5

NOR_Flash

jedec_flash.c

jedec_table[] 中添加如下

 1#ifdef CONFIG_SYS_FLASH_LEGACY_JZ2440
 2	{
 3		.mfr_id 	= (u16)MX_MANUFACT,  /* 厂家ID */
 4		.dev_id 	= 0X2249,			 /* 设备ID */
 5		.name		= "MXIC MT29LV160DB",
 6		.uaddr		= {  /* NOR flash看到解锁地址 */
 7			[1] = MTD_UADDR_0x0555_0x02AA /* x16 */
 8		},
 9		.DevSize	= SIZE_2MiB,	/* 总大小 */
10		.CmdSet 	= P_ID_AMD_STD,
11		.NumEraseRegions= 4,
12		.regions	= {
13			ERASEINFO(16*1024, 1),
14			ERASEINFO(8*1024, 2),
15			ERASEINFO(32*1024, 1),
16			ERASEINFO(64*1024, 31), 
17		}
18	},
19#endif

smdk2440.h

在该文件下添加两个宏

1#define CONFIG_SYS_MAX_FLASH_SECT	(128)
2#define CONFIG_SYS_FLASH_LEGACY_JZ2440

Nand_Flash

在smdk2440.h中定义:

1#defineCONFIG_CMD_NAND
2
3#define CONFIG_ENV_IS_IN_NAND
4#define CONFIG_ENV_OFFSET		0x40000
5#define CONFIG_ENV_SIZE			0x20000
6#define CONFIG_ENV_RANGE		CONFIG_ENV_SIZE
7
8#define CONFIG_NAND_S3C2440
9#define CONFIG_SYS_S3C2440_NAND_HWECC

在driver/mtd/nand/下的makefile 中增加:obj-$(CONFIG_NAND_S3C2440) +=s3c2440_nand.o,并将s3c2410_nand.c拷贝为s3c2440_nand.c。将s3c2440_nand.c里面的2410全部替换为2440

board_nand_init

drivers\mtd\nand\s3c2440_nand.c 中,修改如下

nandfl.png

同时将

1nand->select_chip =NULL;

改为

1nand->select_chip = s3c2440_nand_select;

s3c2440_hwcontrol

将此函数改为如下

 1static void s3c2440_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 2{
 3	struct s3c2440_nand *nand = s3c2440_get_base_nand();
 4
 5	if (ctrl & NAND_CLE)
 6	{
 7		/* senf command */
 8		writeb(cmd, &nand->nfcmd);
 9	}
10	else if(ctrl & NAND_ALE)
11	{
12		/* send address */
13		writeb(cmd, &nand->nfaddr); 
14	}
15}

添加s3c2440_nand_select

 1static void s3c2440_nand_select(struct mtd_info *mtd, int chipnr)
 2{
 3	struct s3c2440_nand *nand = s3c2440_get_base_nand();
 4
 5	switch (chipnr) {
 6	case -1:
 7		nand->nfcont |= (1<<1);
 8		break;
 9	case 0:
10		nand->nfcont &= ~(1<<1);
11		break;
12
13	default:
14		BUG();
15	}
16
17}

end

至此,可以支持nor flash 和nand flash了

u-boot移植系列目录

上一篇[Linux]u-boot_2014移植(四)支持nand启动

下一篇[Linux]u-boot_2014移植(六)支持DM9000网卡和设置环境变量分区


    


公众号'艾恩凝'
个人公众号
个人微信
个人微信
    吾心信其可行,
          则移山填海之难,
                  终有成功之日!
                                  ——孙文
    评论
    0 评论
avatar

取消