#define CONFIG_AUTO_COMPLETE
mini2440.h中定义宏
#define CONFIG_SYS_PROMPT "SMDK2410 # "
改为
#define CONFIG_SYS_PROMPT "[mini2440@u-boot]# "
这样在命令行前面的提示就变成了[mini2440@u-boot]#
修改u-boot,使其支持nand flash的烧写与读写工作。
在drivers/mtd/nand 目录下将s3c2410_nand.c复制为s3c2440_nand.c,并修改Makefile,
COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o后添加
COBJS-$(CONFIG_NAND_S3C2440) += s3c2440_nand.o
CONFIG_NAND_S3C2440控制s3c2440_nand.c文件是否编译,在mini2440.h中添加
#define CONFIG_NAND_S3C2440
去掉
#define CONFIG_NAND_S3C2410
把之前去掉定义的CONFIG_CMD_NAND重新开启约第101行
修改如下
#define CONFIG_CMD_NAND
#ifdef CONFIG_CMD_NAND
#ifdef CONFIG_S3C2410
#define CONFIG_NAND_S3C2410
#define CONFIG_SYS_S3C2410_NAND_HWECC
#else
#define CONFIG_NAND_S3C2440
#define CONFIG_SYS_S3C2440_NAND_HWECC
#endif
#define CONFIG_SYS_MAX_NAND_DEVICE 1
#define CONFIG_SYS_NAND_BASE 0x4E000000
#endif
将s3c2440_nand.c
#define S3C2440_NFCONF_TACLS(x) ((x)<<8)#define S3C2440_NFCONF_TWRPH1(x) ((x)<<4)
去掉如下内容约146行
#if 0
cfg = S3C2410_NFCONF_EN;
cfg |= S3C2410_NFCONF_TACLS(tacls - 1);
cfg |= S3C2410_NFCONF_TWRPH0(twrph0 - 1);
cfg |= S3C2410_NFCONF_TWRPH1(twrph1 - 1);
writel(cfg, &nand_reg->nfconf);
#endif
为了搞nand flash的烧写速度,可以将
tacls = 4;
twrph0 = 8;
twrph1 = 8;
改为:
tacls = 4;
twrph0 = 8;
twrph1 = 8;
为了使能NAND Flash控制器, 初始化ECC, 禁止片选
应添加:
cfg = ((tacls-1)<<12) | ((tacls-1)<<8) | ((tacls-1)<<4);
writel(cfg, &nand_reg->nfconf);
writel((1<<4) | (0<<1) | (1<<0), &nand_reg->nfcont);
将board_nand_init函数中的
nand->select_chip = NULL;
改为
nand->select_chip = s3c2440_select_nand;
并在board_nand_init函数前添加函数:
}
将s3c2440_nand.c程序中的所有s3c2410改为s3c2440
将static void S3C2440_hwcontrol(struct mtd_info *mtd, int dat, unsigned int ctrl)函数改为
static void S3C2440_hwcontrol(struct mtd_info *mtd, int dat, unsigned int ctrl)
{
struct s3c2440_nand *nand = s3c2440_get_base_nand();
if (ctrl & NAND_CLE)
{
/* 写命令 */
writeb(dat, &nand->nfcmd);
}
else if(ctrl & NAND_ALE)
{
/* 写地址 */
writeb(dat, &nand->nfaddr);
}
}
(11)、 修改u-boot支持DM9000网卡
#define CONFIG_CS8900
#define CONFIG_CS8900_BASE 0x19000300
#define CONFIG_CS8900_BUS16 */
改为:
#define CONFIG_DRIVER_DM9000
#define CONFIG_DM9000_BASE 0x20000000
#define DM9000_IO CONFIG_DM9000_BASE
#define DM9000_DATA (CONFIG_DM9000_BASE + 4)
在mini2440.c中的函数board_eth_init中添加
#ifdef CONFIG_DRIVER_DM9000
rc = dm9000_initialize(bis);
#endif
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_IPADDR 10.8.12.230
#define CONFIG_SERVERIP 10.8.12.1
#define CONFIG_ETHADDR 00:0c:29:4d:e4:f4
#define CONFIG_BOOTARGS "noinitrd console=ttySAC0,115200 root=/dev/mtdblock3 init=/linuxrc"
#define CONFIG_BOOTCOMMAND "nand read c31000000 0x60000 0x500000;bootm c31000000"
而u-boot源码提供环境变量的保存saveenv位置是在nor flash中,故应去掉宏
#if 0
#define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + 0x070000)
#define CONFIG_ENV_IS_IN_FLASH
#define CONFIG_ENV_SIZE 0x10000
/* allow to overwrite serial and ethaddr */
#define CONFIG_ENV_OVERWRITE
#endif
修改为保存位置在nand flash中
#define CONFIG_ENV_IS_IN_NAND 1
#define CONFIG_ENV_OFFSET 0x40000
#define CONFIG_ENV_SIZE 0x20000
#define CONFIG_ENV_RANGE CONFIG_ENV_SIZE //擦除单位
在board.c的board_init_r函数中添加代码:649行
#endif
run_command("mtdparts default", 0);
/* main_loop() can return to retry autoboot, if so just run it again. */
为了能启动mini2440的linux内核,必须修改mini2440.c文件中
将 board_init函数中的
gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
改为:
gd->bd->bi_arch_number = MACH_TYPE_MINI2440;
修改u-boot支持yaffs文件系统的烧写在配置文件中定义宏:
#define CONFIG_CMD_NAND_YAFFS
在common/cmd_nand.c的第670行左右:
将
ret = nand_write_skip_bad(nand, off, &rwsize,
(u_char *)addr,
WITH_INLINE_OOB);
改为:
ret = nand_write_skip_bad(nand, off, &rwsize,
(u_char *)addr,
WITH_YAFFS_OOB);
关掉mini2440.h中filesystem中的定义(使编译出得u-boot.bin文件不会太大)
#if 0
#define CONFIG_CMD_FAT
#define CONFIG_CMD_EXT2
#define CONFIG_CMD_UBI
#define CONFIG_CMD_UBIFS
#define CONFIG_CMD_MTDPARTS
#define CONFIG_MTD_DEVICE
#define CONFIG_MTD_PARTITIONS
//#define CONFIG_YAFFS2
#define CONFIG_RBTREE
#endif
将start.S里面的:
bl board_init_f
到
#ifdef CONFIG_NAND_SPL
之间的代码全部删除
最后编译
make distclean
make mini2440_config
make
通过supervivi将u-boot.bin烧到nand flash中,即完成了u-boot的移植,移植过程中笔误的地方也请大家原谅,欢迎留言,我会尽快给大家回复。