经过上面的移植u-boot基本上能用了,但仍有很多要完善的地方,继续修改使u-boot更好用
开发环境:
系统:ubuntu 10.04.4
单板:tq2440
NAND FLASH:K9F1216U0A 256MB
NOR Flash:EN29LV160AB 2MB
SDRAM:HY57V561620 x2 64MB
NET:DM9000AEP
编译器:arm-linux-gcc-4.3.2
目标:
1.支持NOR Flash启动,串口正常输出
2.支持NAND启动
3.支持DM9000网卡
4.裁剪u-boot及制作补丁
1.环境变量存放修改
change@change:~$ cd Si/TQ2440/u-boot-2012.04.01/
change@change:~/Si/TQ2440/u-boot-2012.04.01$ grep "default environment" * -nR
common/env_common.c:175: "using default environment\n\n",
找到默认环境变量common/env_common.c:43:再根据它再配置文件TQ2440.h设置
#define CONFIG_BOOTARGS "console=ttySAC0 root=/dev/mtdblock3"
#define CONFIG_BOOTCOMMAND "nand read 30000000 kernel;bootm 30000000 " //设置bootcmd就会有倒数计时
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_IPADDR 172.16.1.111
#define CONFIG_SERVERIP 172.16.1.132
#define CONFIG_ETHADDR 00:0c:29:4d:e4:f4
修改分区TQ2440.h
#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
#define CONFIG_ENV_IS_IN_NAND
#define CONFIG_ENV_OFFSET 0x00040000
#define CONFIG_ENV_SIZE 0x20000
#define CONFIG_ENV_RANGE CONFIG_ENV_SIZE
2.裁剪u-boot
同样修改配置文件TQ2440.h
/************************************************************
* USB support (currently only works with D-cache off)
************************************************************/
//#define CONFIG_USB_OHCI
//#define CONFIG_USB_KEYBOARD
//#define CONFIG_USB_STORAGE
//#define CONFIG_DOS_PARTITION
//#define CONFIG_RTC_S3C24X0
/*
* BOOTP options
*/
//#define CONFIG_BOOTP_BOOTFILESIZE
//#define CONFIG_BOOTP_BOOTPATH
//#define CONFIG_BOOTP_GATEWAY
//#define CONFIG_BOOTP_HOSTNAME
#define CONFIG_CMD_BSP
#define CONFIG_CMD_CACHE
//#define CONFIG_CMD_DATE
//#define CONFIG_CMD_DHCP
#define CONFIG_CMD_ELF
#define CONFIG_CMD_NAND
#define CONFIG_CMD_PING
#define CONFIG_CMD_REGINFO
//#define CONFIG_CMD_USB
/*
* File system
*/
//#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
3.定义宏支持mtdpart
在配置文件TQ2440.h增加
#define CONFIG_CMD_MTDPARTS
#define CONFIG_MTD_DEVICE
#define MTDIDS_DEFAULT "nand0=TQ2440-0"
#define MTDPARTS_DEFAULT "mtdparts=TQ2440-0:256k(u-boot),"
\
"128k(params),"
\
"2M(kernel),"
\
"-(rootfs)"
在arch/arm/lib/board.c增加mtdpart_init初始化函数
run_command("mtdparts default", 0);//***add
//mtdparts_init();//***add
/* main_loop() can return to retry autoboot, if so just run it again. */
for (;;) {
main_loop();
}
编译、烧写、测试
change@change:~/Si/TQ2440/u-boot-2012.04.01$ make distclean
change@change:~/Si/TQ2440/u-boot-2012.04.01$ make TQ2440_config
Configuring for TQ2440 board...
change@change:~/Si/TQ2440/u-boot-2012.04.01$ make
编译成功,看看经过裁剪的u-boot大小
change@change:~/Si/TQ2440/u-boot-2012.04.01$ ls u-boot.bin -l
-rwxr-xr-x 1 change change 216852 2013-05-03 20:05 u-boot.bin
change@change:~/Si/TQ2440/u-boot-2012.04.01$ cp u-boot.bin /home/change/work/tftpboot/
现在直接用移植的u-boot烧写新的u-boot,单板拨到NAND启动
U-Boot 2012.04.01 (May 03 2013 - 17:33:12)
CPUID: 32440001
FCLK: 400 MHz
HCLK: 100 MHz
PCLK: 50 MHz
DRAM: 64 MiB
WARNING: Caches not enabled
Flash: 2 MiB
NAND: 256 MiB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: dm9000
TQ2440 # set ipaddr 172.16.1.111
TQ2440 # set gatewayip 172.16.1.1
TQ2440 # set serverip 172.16.1.132
TQ2440 # tftp 0x32000000 u-boot.bin
dm9000 i/o: 0x20000000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:00:00:00:00:00
could not establish link
*** ERROR: `ethaddr' not set
dm9000 i/o: 0x20000000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:00:00:00:00:00
could not establish link
TQ2440 # set ethaddr 00:0c:29:4d:e4:f4
TQ2440 #tftp 0x32000000 u-boot.bin
dm9000 i/o: 0x20000000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:00:0c:29:4d:e4
could not establish link
Using dm9000 device
TFTP from server 172.16.1.132; our IP address is 172.16.1.111
Filename 'u-boot.bin'.
Load address: 0x32000000
Loading: ###############
done
Bytes transferred = 216852 (34f14 hex)
TQ2440 # nand erase 0 0x80000
NAND erase: device 0 offset 0x0, size 0x80000
Erasing at 0x60000 -- 100% complete.
OK
TQ2440 # nand write 0x32000000 0 0x40000
NAND write: device 0 offset 0x0, size 0x40000
262144 bytes written: OK
TQ2440 #
烧写成功,现在重启,仍是NAND启动,串口115200 8 n 1
U-Boot 2012.04.01 (May 03 2013 - 20:04:26)
CPUID: 32440001
FCLK: 400 MHz
HCLK: 100 MHz
PCLK: 50 MHz
DRAM: 64 MiB
WARNING: Caches not enabled
Flash: 2 MiB
NAND: 256 MiB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: dm9000
Hit any key to stop autoboot: 0
TQ2440 # m<INTERRUPT>
TQ2440 # mtdpart
device nand0 <TQ2440-0>, # parts = 4
#: name size offset mask_flags
0: u-boot 0x00040000 0x00000000 0
1: params 0x00020000 0x00040000 0
2: kernel 0x00200000 0x00060000 0
3: rootfs 0x0fda0000 0x00260000 0
active partition: nand0,0 - (u-boot) 0x00040000 @ 0x00000000
defaults:
mtdids : nand0=TQ2440-0
mtdparts: mtdparts=TQ2440-0:256k(u-boot),128k(params),2M(kernel),-(rootfs)
TQ2440 # ping 172.16.1.132
dm9000 i/o: 0x20000000, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:0c:29:4d:e4:f4
could not establish link
Using dm9000 device
host 172.16.1.132 is alive
TQ2440 # save
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x40000 -- 100% complete.
Writing to Nand... done
TQ2440 #
移植的u-boot基本正常,暂时还没发现其它问题,可以跑了。还有micro2440单板与TQ2440移植过程类似,参考这个移植就行。