首页 > 学院 > 操作系统 > 正文

u-boot-2014_04在TQ2440上的移植

2024-06-28 13:25:32
字体:
来源:转载
供稿:网友
u-boot-2014_04在TQ2440上的移植

本文详细介绍了新版本的u-boot-2014_04在tq2440平台上的移植过程,期间参考了网上的其他移植文档,还有韦东山的移植uboot视频,讲的很好。下面是共享链接,欢迎下载,一同学习。其中有移植文档和patch。

http://pan.baidu.com/s/1jGxEYQQ

作者:彭东林

邮箱:pengdonglin137@163.com

QQ:405728433

一、首先建立自己的开发板

二、 配置时钟三、 移植NOR Flash四、 移植网卡DM9000五、 支持NAND FLASH读写六、 修改代码支持NOR FLASH启动七、 保存环境变量到NAND FLASH并添加分区八、 支持NAND FLASH启动九、 支持烧写yaffs文件系统十、 添加NAND FLASH 硬件ECC十一、 最后十二、 制作补丁十三、 用到的一些命令:

到官网http://ftp.denx.de/pub/u-boot/下载u-boot-2014.04.tar.bz2

解压后在board/samsung/目录下仍然没有2440,虽然没有直接支持2440开发板,但其代码已经支持,只需添加相关配置即可。

一、首先建立自己的开发板

拷贝board/samsung/smdk2410/目录到board/tq2440

pengdl@debian:~/work/tq2440/u-boot-2014.04$cp-aboard/samsung/smdk2410/board/tq2440

进入board/tq2440目录修改

pengdl@debian:~/work/tq2440/u-boot-2014.04/board/tq2440$mvsmdk2410.ctq2440.c

修改该目录下的Makefile

obj-y :=tq2440.o

拷贝配置文件(使用相似的smdk2410开发板的配置文件)

pengdl@debian:~/work/tq2440/u-boot-2014.04$cpinclude/configs/smdk2410.hinclude/configs/tq2440.h

增加开发板配置选项

在顶层目录下的Makefile中搜索不到smdk2410

在顶层目录执行如下命令

pengdl@debian:~/work/tq2440/u-boot-2014.04$grep"smdk2410"*-nR

./boards.cfg:74:

smdk2410armarm920t-samsungs3c24x0

./MAINTAINERS:774: smdk2410 ARM920T

./board/samsung/smdk2410/Makefile:28:COBJS :=smdk2410.o

./board/tq2440/Makefile:28:COBJS :=smdk2410.o

./arch/arm/include/asm/mach-types.h:1646:#definemachine_is_smdk2410() (machine_arch_type==MACH_TYPE_SMDK2410)

./arch/arm/include/asm/mach-types.h:1648:#definemachine_is_smdk2410() (0)

从这里知道在顶层目录下的boards.cfg文件中定义了smdk2410开发板的配置选项,仿照它定义TQ2440开发板的配置选项

##Status,Arch,CPU:SPLCPU,SoC,Vendor,Boardname,Target,Options,Maintainers

###########################################################################################################

Activearmarm920ts3c24x0-tq2440tq2440--

由于我在board目录下创建开发板目录,所以Vendor指定为空

二、配置时钟

先大致看一下配置文件include/configs/tq2440.h

/*

*HighLevelConfigurationOptions

*(easytochange)

*/

#defineCONFIG_ARM920T /*ThisisanARM920TCore*/

#defineCONFIG_S3C24X0 /*inaSAMSUNGS3C24x0-typeSoC*/

#defineCONFIG_S3C2410 /*specificallyaSAMSUNGS3C2410SoC*/

#defineCONFIG_SMDK2410 /*onaSAMSUNGSMDK2410Board*/

这里是高级别的一些配置,配置了S3C2410SoC和SMDK2410Board,跟我使用的开发板不一致

根据我自己的开发板tq2440进行如下配置

//#defineCONFIG_S3C2410/*specificallyaSAMSUNGS3C2410SoC*/

#defineCONFIG_S3C2440

//#defineCONFIG_SMDK2410/*onaSAMSUNGSMDK2410Board*/

#defineCONFIG_AUTO_COMPLETE//开启命令自动补全

#defineCONFIG_SYS_PROMPT "TQ2440#" //命令提示符

屏蔽一些暂时不用的支持,用的时候再加上

#if0

#defineCONFIG_CS8900 /*wehaveaCS8900on-board*/

#defineCONFIG_CS8900_BASE 0x19000300

#defineCONFIG_CS8900_BUS16 /*thelinuxdriverdoesaccessesasshorts*/

#endif

#if0

#defineCONFIG_USB_OHCI

#defineCONFIG_USB_KEYBOARD

#defineCONFIG_USB_STORAGE

#defineCONFIG_DOS_PARTITION

#endif

//#defineCONFIG_CMD_DHCP

//#defineCONFIG_CMD_NAND

//#defineCONFIG_CMD_PING

//#defineCONFIG_CMD_REGINFO

//#defineCONFIG_CMD_USB

#if0

#defineCONFIG_CMD_FAT

#defineCONFIG_CMD_EXT2

#defineCONFIG_CMD_UBI

#defineCONFIG_CMD_UBIFS

#defineCONFIG_CMD_MTDPARTS

#defineCONFIG_MTD_DEVICE

#defineCONFIG_MTD_PARTITIONS

#defineCONFIG_YAFFS2

#defineCONFIG_RBTREE

#endif

看下链接脚本arch/arm/cpu/u-boot.lds

CPUDIR/start.o(.text*)

从这里可以知道u-boot执行的第一个文件是arch/arm/cpu/arm920t/start.S

/*FCLK:HCLK:PCLK=1:2:4*/

/*defaultFCLKis120MHz!*/

ldr r0,=CLKDIVN

mov r1,#3

str r1,[r0]

上面几行代码是针对S3C2410的

添加时钟初始化代码如下

#ifdefined(CONFIG_S3C2410)

ldr r1,=0x3ff

ldr r0,=INTSUBMSK

str r1,[r0]

#endif

#ifdefined(CONFIG_S3C2440)

ldr r1,=0x7fff

ldr r0,=INTSUBMSK //屏蔽子中断

str r1,[r0]

#endif/*CONFIG_S3C2440*/

#ifdefined(CONFIG_S3C2440)

#defineMPLLCON 0x4C000004 //系统主频配置寄存器

#defineUPLLCON 0x4C000008//USB频率配置寄存器

#defineCAMDIVN 0x4C000018//照相机时钟分频寄存器

ldrr0,=CAMDIVN

movr1,#0

strr1,[r0]

ldrr0,=CLKDIVN

movr1,#0x05

strr1,[r0]

/*如果HDIVN不等于0,CPU必须设置为异步总线模式*/

mrcp15,0,r0,c1,c0,0

orrr0,r0,#0xc0000000

mcrp15,0,r0,c1,c0,0

ldrr0,=UPLLCON

ldrr1,=0x38022//USB时钟48MHZ

strr1,[r0]

/*

**WhenyousetMPLL&UPLLvalues,youhavetosettheUPLL

**valuefirstandthentheMPLLvalue.(Needsintervals

**approximately7NOP)

*/

nop

nop

nop

nop

nop

nop

nop

ldrr0,=MPLLCON

ldrr1,=0x5c011//CPU时钟400MHZ

strr1,[r0]

#else

/*FCLK:HCLK:PCLK=1:2:4*/

/*defaultFCLKis120MHz!*/

ldr r0,=CLKDIVN

mov r1,#3

str r1,[r0]

#endif/*CONFIG_S3C2440*/

#endif /*CONFIG_S3C24X0*/

board/tq2440/tq2440.c中board_early_init_f()函数也初始化了时钟,因为我在start.S中已初始化了时钟,所以屏蔽掉board_early_init_f()中对时钟的初始化代码

// structs3c24x0_clock_power*constclk_power=

// s3c24x0_get_base_clock_power();

structs3c24x0_gpio*constgpio=s3c24x0_get_base_gpio();

#if0

/*toreducePLLlocktime,adjusttheLOCKTIMEregister*/

writel(0xFFFFFF,&clk_power->locktime);

/*configureMPLL*/

writel((M_MDIV<<12)+(M_PDIV<<4)+M_SDIV,

&clk_power->mpllcon);

/*somedelaybetweenMPLLandUPLL*/

pll_delay(4000);

/*configureUPLL*/

writel((U_M_MDIV<<12)+(U_M_PDIV<<4)+U_M_SDIV,

&clk_power->upllcon);

/*somedelaybetweenMPLLandUPLL*/

pll_delay(8000);

#endif

可以先配置u-boot支持直接烧写进内存SDRAM运行

修改配置文件tq2440.h

#defineCONFIG_SYS_TEXT_BASE 0x32000000

CONFIG_SYS_TEXT_BASE指定了代码的加载地址,待会编译好后生成可执行二进制文件u—boot.bin,就要把u-boot.bin下载到该地址

我们现在需要直接烧写进内存运行,而底层初始化代码还没移植,所以我们需要跳过底层初始化

查看arch/arm/cpu/arm920t/start.S

#ifndefCONFIG_SKip_LOWLEVEL_INIT

bl cpu_init_crit

#endif

如果没有定义CONFIG_SKIP_LOWLEVEL_INIT就跳转cpu_init_crit函数执行,该函数进行了一些底层的初始化,比如内存。因为下面我们直接将u-boot下载到内存中运行,如果在内存中运行的同时再初始化内存,那么内存中的数据代码会遭到破坏。

所以我们在配置文件tq2440.h中定义该宏

#defineCONFIG_SKIP_LOWLEVEL_INIT

修改一下顶层Makefile:

202CROSS_COMPILE?=arm-linux-

ARCH就不用我们手动配置了,因为在执行maketq2440_config时,会解析boards.cfg文件,得到ARCH的值。

pengdl@debian:~/work/tq2440/u-boot-2014.04$maketq2440_config

编译完成生成可执行二进制文件u—boot.bin,开发板启动原有好的u-boot

将u-boot.bin下载到SDRAM的0x32000000地址,然后go0x32000000运行

EmbedSky>tftp0x32000000u-boot.bin

(注意:在新版本的u-boot中,进行代码重定位relocate之前就已经在board_init_f中调用了全局性的代码,这些全局性的代码并不是位置无关的,所以这里需要将u-boot直接下载到它的链接地址处,防止程序跑飞)

dm9000i/o:0x20000300,id:0x90000a46

MAC:0a:1b:2c:3d:4e:5f

TFTPfromserver192.168.1.8;ourIPaddressis192.168.1.6

Filename'u-boot.bin'.

Loadaddress:0x32000000

Loading:checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

T###########

done

Bytestransferred=153844(258f4hex)

EmbedSky>go0x32000000

(注意:必须与刚才tftp下载到的地址相同)

##Startingapplicationat0x32000000...¡ø

U-Boot2014.04(Jun282014-23:11:32)

CPUID:32440001

FCLK:400MHz

HCLK:100MHz

PCLK:50MHz

DRAM:64MiB

WARNING:Cachesnotenabled

在tq2440.h中定义DEBUG宏

#defineDEBUG

EmbedSky>tftp0x32000000u-boot.bin;go0x32000000

dm9000i/o:0x20000300,id:0x90000a46

MAC:0a:1b:2c:3d:4e:5f

TFTPfromserver192.168.1.8;ourIPaddressis192.168.1.6

Filename'u-boot.bin'.

Loadaddress:0x32000000

Loading:checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

T############

done

Bytestransferred=168860(2939chex)

##Startingapplicationat0x32000000...¡ø

U-Boot2014.04(Jun292014-02:51:27)

U-Bootcode:32000000->320246BCBSS:->3202A0A4

CPUID:32440001

FCLK:400MHz

HCLK:100MHz

PCLK:50MHz

monitorlen:0002A0A4

ramsize:04000000

TLBtablefrom33ff0000to33ff4000

TopofRAMusableforU-Bootat:33ff0000

Reserving168kforU-Bootat:33fc5000

Reserving4160kformalloc()at:33bb5000

Reserving32BytesforBoardInfoat:33bb4fe0

Reserving160BytesforGlobalDataat:33bb4f40

NewStackPointeris:33bb4f30

RAMConfiguration:

Bank#0:3000000064MiB

relocationOffsetis:01fc5000

WARNING:Cachesnotenabled

monitorflashlen:0002939C

NowrunninginRAM-U-Bootat:33fc5000

经过加打印,问题定位在board.c中的board_init_r在调用mem_malloc_init函数时出了问题,他完成的操作是将malloc_start标识的malloc区域清零,这里malloc区域的大小是4MB+160KB,发现在清除到2MB多的时候程序就挂了。

这个问题的原因好没有找到,等待解决。目前临时的解决办法是将malloc区域的大小减小为2MB+160KB,做法是修改tq2440.h中,将

#defineCONFIG_SYS_MALLOC_LEN (4*1024*1024)

改为:

#defineCONFIG_SYS_MALLOC_LEN (2*1024*1024)

然后编译运行,打印信息如下:

U-Bootcode:32000000->320246BCBSS:->3202A0A4

CPUID:32440001

FCLK:400MHz

HCLK:100MHz

PCLK:50MHz

monitorlen:0002A0A4

ramsize:04000000

TLBtablefrom33ff0000to33ff4000

TopofRAMusableforU-Bootat:33ff0000

Reserving168kforU-Bootat:33fc5000

Reserving2112kformalloc()at:33db5000

Reserving32BytesforBoardInfoat:33db4fe0

Reserving160BytesforGlobalDataat:33db4f40

NewStackPointeris:33db4f30

RAMConfiguration:

Bank#0:3000000064MiB

relocationOffsetis:01fc5000

WARNING:Cachesnotenabled

monitorflashlen:0002939C

NowrunninginRAM-U-Bootat:33fc5000

Flash:fwcaddr00000000cmdf000f016bitx16bit

fwcaddr0000aaaacmdaa00aa16bitx16bit

fwcaddr00005554cmd55005516bitx16bit

fwcaddr0000aaaacmd90009016bitx16bit

fwcaddr00000000cmdf000f016bitx16bit

JEDECPROBE:ID1c22490

fwcaddr00000000cmdff00ff16bitx16bit

fwcaddr00000000cmd90009016bitx16bit

fwcaddr00000000cmdff00ff16bitx16bit

JEDECPROBE:ID16ea000

***failed***

###ERROR###PleaseRESETtheboard###

三、移植NORFLASH

第二步Flash:***failed***

###ERROR###PleaseRESETtheboard###

卡在这里不动了

搜索“Flash:”

pengdl@debian:~/work/tq2440/u-boot-2014.04$grep"Flash:"*-nR

......

arch/arm/lib/board.c:557:puts("Flash:");

.....

进入查看

puts("Flash:");

flash_size=flash_init();

if(flash_size>0){

#ifdefCONFIG_SYS_FLASH_CHECKSUM

print_size(flash_size,"");

/*

*ComputeandprintflashCRCifflashchecksumissetto'y'

*

*NOTE:MaybeweshouldaddsomeWATCHDOG_RESET()?XXX

*/

if(getenv_yesno("flashchecksum")==1){

printf("CRC:%08X",crc32(0,

(constunsignedchar*)CONFIG_SYS_FLASH_BASE,

flash_size));

}

putc('/n');

#else /*!CONFIG_SYS_FLASH_CHECKSUM*/

print_size(flash_size,"/n");

#endif/*CONFIG_SYS_FLASH_CHECKSUM*/

}else{

puts(failed);

hang();

}

failed在该文件中的定义如下

staticchar*failed="***failed***/n";

函数hang()在该文件中的定义如下

voidhang(void)

{

puts("###ERROR###PleaseRESETtheboard###/n");

for(;;);

}

说明是flash初始化失败

进入drivers/mtd/cfi_flash.c:flash_init函数

if(!flash_detect_legacy(cfi_flash_bank_addr(i),i))

flash_detect_legacy函数去探测flash

进入flash_detect_legacy函数

flash_read_jedec_ids(info);

debug("JEDECPROBE:ID%x%x%x/n",

info->manufacturer_id,

info->device_id,

info->device_id2);

if(jedec_flash_match(info,info->start[0]))

break;

else

unmap_physmem((void*)info->start[0],MAP_NOCACHE);

jedec_flash_match函数将读取到的flash信息与jedec_table进行匹配,如果匹配成功则填充flash_info,否则返回1,看来这里没有匹配成功,在drivers/mtd/cfi_flash.c:flash_detect_legacy函数去探测开发板的flash,打开调试信息的宏,将探测到的flash信息打印出来

#defineDEBUG(也可以加载tq2440.h中)

重新编译,开发板从NORFLASH启动,

EmbedSky>tftp0x32000000u-boot.bin;go0x32000000

dm9000i/o:0x20000300,id:0x90000a46

MAC:0a:1b:2c:3d:4e:5f

TFTPfromserver192.168.1.8;ourIPaddressis192.168.1.6

Filename'u-boot.bin'.

Loadaddress:0x32000000

Loading:checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

T############

done

Bytestransferred=168860(2939chex)

##Startingapplicationat0x32000000...

U-Boot2014.04(Jun292014-02:57:57)

U-Bootcode:32000000->320246BCBSS:->3202A0A4

CPUID:32440001

FCLK:400MHz

HCLK:100MHz

PCLK:50MHz

monitorlen:0002A0A4

ramsize:04000000

TLBtablefrom33ff0000to33ff4000

TopofRAMusableforU-Bootat:33ff0000

Reserving168kforU-Bootat:33fc5000

Reserving2112kformalloc()at:33db5000

Reserving32BytesforBoardInfoat:33db4fe0

Reserving160BytesforGlobalDataat:33db4f40

NewStackPointeris:33db4f30

RAMConfiguration:

Bank#0:3000000064MiB

relocationOffsetis:01fc5000

WARNING:Cachesnotenabled

monitorflashlen:0002939C

NowrunninginRAM-U-Bootat:33fc5000

Flash:fwcaddr00000000cmdf000f016bitx16bit

fwcaddr0000aaaacmdaa00aa16bitx16bit

fwcaddr00005554cmd55005516bitx16bit

fwcaddr0000aaaacmd90009016bitx16bit

fwcaddr00000000cmdf000f016bitx16bit

JEDECPROBE:ID1c22490

fwcaddr00000000cmdff00ff16bitx16bit

fwcaddr00000000cmd90009016bitx16bit

fwcaddr00000000cmdff00ff16bitx16bit

JEDECPROBE:ID16ea000

***failed***

###ERROR###PleaseRESETtheboard###

根据debug("JEDECPROBE:ID%x%x%x/n",

info->manufacturer_id,

info->device_id,

info->device_id2);

可以知道已经探测到开发板的flash的厂家ID为0x1c,设备ID为0x2249

在jedec_table表中增加TQ2440开发板的NORFLASH(EN29LV160AB)内容

#ifdefCONFIG_SYS_FLASH_LEGACY_1024Kx16

{/*TQ2440EN29LV160AB*/

.mfr_id=0x1c, /*manufacturer_id*/

.dev_id=0x2249,/*device_id*/

.name="EONEN29LV160AB",

.uaddr={/*因为NORFLASH的ADDR0接到了S3C2440的ADDR1*/

[1]=MTD_UADDR_0x0555_0x02AA/*x16*/

},

.DevSize=SIZE_2MiB,

.CmdSet=P_ID_AMD_STD,

.NumEraseRegions=4,

.regions={

ERASEINFO(0x04000,1),

ERASEINFO(0x02000,2),

ERASEINFO(0x08000,1),

ERASEINFO(0x10000,31),

}

},

#endif

注释掉刚才打开的宏

drivers/mtd/cfi_flash.c

//#defineDEBUG

并在tq2440.h中定义CONFIG_SYS_FLASH_LEGACY_1024Kx16

//#defineCONFIG_SYS_FLASH_LEGACY_512Kx16

#defineCONFIG_SYS_FLASH_LEGACY_1024Kx16

重新编译u-boot,从NORFLASH启动开发板

EmbedSky>tftp0x32000000u-boot.bin;go0x32000000

dm9000i/o:0x20000300,id:0x90000a46

MAC:0a:1b:2c:3d:4e:5f

TFTPfromserver192.168.1.8;ourIPaddressis192.168.1.6

Filename'u-boot.bin'.

Loadaddress:0x32000000

Loading:checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

T###########

done

Bytestransferred=153568(257e0hex)

##Startingapplicationat0x32000000...¡ø

U-Boot2014.04(Jun292014-03:10:56)

CPUID:32440001

FCLK:400MHz

HCLK:100MHz

PCLK:50MHz

DRAM:64MiB

WARNING:Cachesnotenabled

Flash:ERROR:toomanyflashsectors

2MiB

***Warning-badCRC,usingdefaultenvironment

In:serial

Out:serial

Err:serial

Net:Noethernetfound.

TQ2440#

出现一个错误toomanyflashsectors

搜索toomanyflashsectors

pengdl@debian:~/work/tq2440/u-boot-2014.04$grep"toomanyflashsectors"*-nR

./drivers/mtd/jedec_flash.c:444: printf("ERROR:toomanyflashsectors/n");

查看代码

if(sect_cnt>=CONFIG_SYS_MAX_FLASH_SECT){

printf("ERROR:toomanyflashsectors/n");

break;

}

说明CONFIG_SYS_MAX_FLASH_SECT的值太小了,在配置文件tq2440.h修改该宏

#defineCONFIG_SYS_MAX_FLASH_SECT (35) //根据EN29LV160AB芯片手册

重新编译,从NORFLASH启动开发板

EmbedSky>tftp0x32000000u-boot.bin;go0x32000000

dm9000i/o:0x20000300,id:0x90000a46

MAC:0a:1b:2c:3d:4e:5f

TFTPfromserver192.168.1.8;ourIPaddressis192.168.1.6

Filename'u-boot.bin'.

Loadaddress:0x32000000

Loading:checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

T###########

done

Bytestransferred=153568(257e0hex)

##Startingapplicationat0x32000000...¡ø

U-Boot2014.04(Jun292014-03:12:36)

CPUID:32440001

FCLK:400MHz

HCLK:100MHz

PCLK:50MHz

DRAM:64MiB

WARNING:Cachesnotenabled

Flash:2MiB

***Warning-badCRC,usingdefaultenvironment

In:serial

Out:serial

Err:serial

Net:Noethernetfound.

TQ2440#

TQ2440#flinfo

Bank#1:EONEN29LV160ABflash(16x16)Size:2MBin35Sectors

AMDLegacycommandset,ManufacturerID:0x1C,DeviceID:0x2249

Erasetimeout:30000ms,writetimeout:100ms

SectorStartAddresses:

00000000RO00004000RO00006000RO00008000RO00010000RO

00020000RO00030000000400000005000000060000

00070000RO0008000000090000000A0000000B0000

000C0000000D0000000E0000000F000000100000

0011000000120000001300000014000000150000

00160000001700000018000000190000001A0000

001B0000001C0000001D0000001E0000001F0000

测试flash读写是否正常

读取0x32000000地址的0x10字节数据到0x0地址,然后比较两份数据是否相等

注意:从flinfo中可以看出0地址所在扇区是RO,要先解保护

TQ2440#protectoffall

Un-ProtectFlashBank#1

TQ2440#cp.b32000000010

CopytoFlash...done

TQ2440#cmp.b03200000010

Totalof16byte(s)werethesame

再来读

TQ2440#md.b3200000010

32000000:130000ea14f09fe514f09fe514f09fe5................

TQ2440#md.b010

00000000:130000ea14f09fe514f09fe514f09fe5................

读出的两份数据一样

至此NORFLASH移植完毕

四、移植网卡DM9000

网卡DM9000的驱动为drivers/net/dm9000x.c,我们需要将它编译进u-boot,查看drivers/net/Makefile

38COBJS-$(CONFIG_DRIVER_DM9000)+=dm9000x.o

如果定义了CONFIG_DRIVER_DM9000就将dm9000x.o编译进u-boot,在配置文件tq2440.h中定义该宏

#defineCONFIG_DRIVER_DM9000

在第一步已经经网卡CS8900的相关配置注释掉了

重新编译出错

dm9000x.c:Infunction'dm9000_outblk_8bit':

dm9000x.c:156:error:'DM9000_DATA'undeclared(firstuseinthisfunction)

DM9000_DATA没有定义,参考mini2440.h的配置如下

#defineCONFIG_DRIVER_DM9000

#defineCONFIG_DM9000_NO_SROM

(如果不设置这个宏,uboot会打印类似:

Warning:dm9000MACaddressesdon'tmatch:

AddressinSROMisff:ff:ff:ff:ff:ff

Addressinenvironmentis00:0c:29:2a:5c:a5

的信息)

#defineCONFIG_DM9000_BASE 0x20000000 //tq2440开发板的网卡dm9000接在S3C2440的bank4#defineDM9000_IO CONFIG_DM9000_BASE

#defineDM9000_DATA (CONFIG_DM9000_BASE+4) //tq2440开发板的网卡dm9000的cmd引脚接在S3C2440的ADDR2

打开之前第一步暂时注释掉的宏

#defineCONFIG_CMD_PING

重新编译,从NORFLASH启动u-boot

EmbedSky>tftp0x32000000u-boot.bin;go0x32000000

dm9000i/o:0x20000300,id:0x90000a46

MAC:0a:1b:2c:3d:4e:5f

TFTPfromserver192.168.1.8;ourIPaddressis192.168.1.6

Filename'u-boot.bin'.

Loadaddress:0x32000000

Loading:checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

T###########

done

Bytestransferred=154592(25be0hex)

##Startingapplicationat0x32000000...¡ø

U-Boot2014.04(Jun292014-03:16:30)

CPUID:32440001

FCLK:400MHz

HCLK:100MHz

PCLK:50MHz

DRAM:64MiB

WARNING:Cachesnotenabled

Flash:2MiB

***Warning-badCRC,usingdefaultenvironment

In:serial

Out:serial

Err:serial

Net:Noethernetfound.

TQ2440#

没有找到网路

搜索Net:

pengdl@debian:~/work/tq2440/u-boot-2014.04$grep"Net:"*-nR

......

arch/arm/lib/board.c:662:puts("Net:");

......

查看单板文件board.c

puts("Net:");

eth_initialize(gd->bd);

进入net/eth.c:eth_initialize函数

if(board_eth_init(bis)<0)

进入board/tq2440/tq2440.c:board_eth_init函数

修改如下

intboard_eth_init(bd_t*bis)

{

intrc=0;

#ifdefCONFIG_CS8900

rc=cs8900_initialize(0,CONFIG_CS8900_BASE);

#endif

#ifdefCONFIG_DRIVER_DM9000

rc=dm9000_initialize(bis);

#endif

returnrc;

}

重新编译,从NORFLASH启动u-boot

EmbedSky>tftp0x32000000u-boot.bin;go0x32000000

dm9000i/o:0x20000300,id:0x90000a46

MAC:0a:1b:2c:3d:4e:5f

TFTPfromserver192.168.1.8;ourIPaddressis192.168.1.6

Filename'u-boot.bin'.

Loadaddress:0x32000000

Loading:checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

T###########

done

Bytestransferred=160268(2720chex)

##Startingapplicationat0x32000000...¡ø

U-Boot2014.04(Jun292014-03:20:16)

CPUID:32440001

FCLK:400MHz

HCLK:100MHz

PCLK:50MHz

DRAM:64MiB

WARNING:Cachesnotenabled

Flash:2MiB

***Warning-badCRC,usingdefaultenvironment

In:serial

Out:serial

Err:serial

Net:dm9000

TQ2440#setethaddr00:12:34:56:ab:cd 设置mac地址

TQ2440#setipaddr192.168.1.6 设置开发板IP地址

TQ2440#setserverip192.168.1.8 设置tftp服务器IP地址

TQ2440#ping192.168.1.8 ping主机

dm9000i/o:0x20000000,id:0x90000a46

DM9000:runningin16bitmode

MAC:00:12:34:56:ab:cd

couldnotestablishlink

Usingdm9000device

host192.168.1.8isalive

TQ2440#tftpboot31000000u-boot.bin 下载文件

dm9000i/o:0x20000000,id:0x90000a46

DM9000:runningin16bitmode

MAC:00:12:34:56:ab:cd

couldnotestablishlink

Usingdm9000device

TFTPfromserver192.168.1.8;ourIPaddressis192.168.1.6

Filename'u-boot.bin'.

Loadaddress:0x31000000

Loading:##############

1.8MiB/s

done

Bytestransferred=198364(306dchex)

注意到新版u-boot在用tftp下载时会打印出下载速度,另外上面出现了一个错误couldnotestablishlink

pengdl@debian:~/work/tq2440/u-boot-2014.04$grep"couldnotestablishlink"*-nR

./drivers/net/dm9000x.c:376: printf("couldnotestablishlink/n");

查看代码并修改

#if0

i=0;

while(!(dm9000_phy_read(1)&0x20)){ /*autonegationcompletebit*/

udelay(1000);

i++;

if(i==10000){

printf("couldnotestablishlink/n");

return0;

}

}

#endif

重新编译,从NORFLASH重启开发板

EmbedSky>tftp0x32000000u-boot.bin;go0x32000000

dm9000i/o:0x20000300,id:0x90000a46

MAC:0a:1b:2c:3d:4e:5f

TFTPfromserver192.168.1.8;ourIPaddressis192.168.1.6

Filename'u-boot.bin'.

Loadaddress:0x32000000

Loading:checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

checksumbad

T###########

done

Bytestransferred=160140(2718chex)

##Startingapplicationat0x32000000...¡ø

U-Boot2014.04(Jun292014-03:25:30)

CPUID:32440001

FCLK:400MHz

HCLK:100MHz

PCLK:50MHz

DRAM:64MiB

WARNING:Cachesnotenabled

Flash:2MiB

***Warning-badCRC,usingdefaultenvironment

In:serial

Out:serial

Err:serial

Net:dm9000

现在重新下载刚才的u-boot.bin

TQ2440#tftp0x30000000u-boot.bin

dm9000i/o:0x20000000,id:0x90000a46

DM9000:runningin16bitmode

MAC:ff:ff:ff:ff:ff:ff

WARNING:BadMACaddress(uninitializedEEPROM?)

Operatingat100Mfullduplexmode

Usingdm9000device

TFTPfromserver192.168.1.8;ourIPaddressis192.168.1.6

Filename'u-boot.bin'.

Loadaddress:0x30000000

Loading:T###########

30.3KiB/s

done

Bytestransferred=160140(2718chex)

刚才的错误解决了

至此网卡DM9000移植完毕

五、支持NANDFLASH读写

修改配置文件include/configs/tq2440.h打开之前注释掉的NAND相关的宏

#defineCONFIG_CMD_NAND

编译出错

s3c2410_nand.c:Infunction's3c2410_hwcontrol':

s3c2410_nand.c:57:warning:implicitdeclarationoffunction's3c2410_get_base_nand'

s3c2410_nand.c:57:warning:initializationmakespointerfromintegerwithoutacast

s3c2410_nand.c:72:error:dereferencingpointertoincompletetype

s3c2410_nand.c:72:error:dereferencingpointertoincompletetype

s3c2410_nand.c:75:error:dereferencingpointertoincompletetype

s3c2410_nand.c:75:error:dereferencingpointertoincompletetype

查看代码

structs3c2410_nand*nand=s3c2410_get_base_nand();

structs3c2410_nand的定义

#ifdefCONFIG_S3C2410

/*NANDFLASH(seeS3C24

上一篇:文件操作

下一篇:rsync安装配置

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表