新手发帖,很多方面都是刚入门,有错误的地方请大家见谅,欢迎批评指正
经过下面的移植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
搭建开发环境详见ubuntu 10.04.4开发环境配置。
目标:
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_NETMASK255.255.255.0
#define CONFIG_IPADDR172.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_SIZE0x10000
/* 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移植程过相似,参考这个移植就行。
文章结束给大家分享下程序员的一些笑话语录:
一个程序员对自己的未来很迷茫,于是去问上帝。
"万能的上帝呀,请你告诉我,我的未来会怎样?"
上帝说"我的孩子,你去问Lippman,他现在领导的程序员的队伍可能是地球上最大的"
于是他去问Lippman。
Lippman说"程序员的未来就是驾驭程序员"
这个程序员对这个未来不满意,于是他又去问上帝。
"万能的上帝呀,请你告诉我,我的未来会怎样?"
上帝说"我的孩子,你去问Gates,他现在所拥有的财产可能是地球上最多的"
于是他去问Gates。
Gates说"程序员的未来就是榨取程序员"
这个程序员对这个未来不满意,于是他又去问上帝。
"万能的上帝呀,请你告诉我,我的未来会怎样?"
上帝说"我的孩子,你去问侯捷,他写的计算机书的读者可能是地球上最多的"
于是他去问侯捷。
侯捷说"程序员的未来就是诱惑程序员"
这个程序员对这个未来不满意,于是他又去问上帝。
"万能的上帝呀,请你告诉我,我的未来会怎样?"
上帝摇摇头"唉,我的孩子,你还是别当程序员了")