天天看點

TQ2440 u-boot-2012.04.01移植六完善u-boot

經過上面的移植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.環境變量存放修改

[email protected]:~$ cd Si/TQ2440/u-boot-2012.04.01/

[email protected]:~/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

#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

//#define CONFIG_USB_OHCI

//#define CONFIG_USB_KEYBOARD

//#define CONFIG_USB_STORAGE

//#define CONFIG_DOS_PARTITION

//#define CONFIG_RTC_S3C24X0

//#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

//#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);/

for (;;) {

main_loop();

}

編譯、燒寫、測試

[email protected]:~/Si/TQ2440/u-boot-2012.04.01$ make distclean 

[email protected]:~/Si/TQ2440/u-boot-2012.04.01$ make TQ2440_config 

Configuring for TQ2440 board...

[email protected]:~/Si/TQ2440/u-boot-2012.04.01$ make

編譯成功,看看經過裁剪的u-boot大小

[email protected]:~/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

[email protected]:~/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移植過程類似,參考這個移植就行。