arm9uboot移植.docx

上传人:b****6 文档编号:14007939 上传时间:2023-06-20 格式:DOCX 页数:16 大小:43.69KB
下载 相关 举报
arm9uboot移植.docx_第1页
第1页 / 共16页
arm9uboot移植.docx_第2页
第2页 / 共16页
arm9uboot移植.docx_第3页
第3页 / 共16页
arm9uboot移植.docx_第4页
第4页 / 共16页
arm9uboot移植.docx_第5页
第5页 / 共16页
arm9uboot移植.docx_第6页
第6页 / 共16页
arm9uboot移植.docx_第7页
第7页 / 共16页
arm9uboot移植.docx_第8页
第8页 / 共16页
arm9uboot移植.docx_第9页
第9页 / 共16页
arm9uboot移植.docx_第10页
第10页 / 共16页
arm9uboot移植.docx_第11页
第11页 / 共16页
arm9uboot移植.docx_第12页
第12页 / 共16页
arm9uboot移植.docx_第13页
第13页 / 共16页
arm9uboot移植.docx_第14页
第14页 / 共16页
arm9uboot移植.docx_第15页
第15页 / 共16页
arm9uboot移植.docx_第16页
第16页 / 共16页
亲,该文档总共16页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

arm9uboot移植.docx

《arm9uboot移植.docx》由会员分享,可在线阅读,更多相关《arm9uboot移植.docx(16页珍藏版)》请在冰点文库上搜索。

arm9uboot移植.docx

arm9uboot移植

Uboot移植

 

目录

目录I

1.uboot移植1

1.1.4.3.2版本交叉编译工具1

1.2.加入atmel芯片支持1

1.3.增加对大页nandflash支持2

1.4.修改ether.c增加网络支持7

1.5.修改启动命令和网络参数设置7

1.6.加快断开网络时系统启动速度8

1.7.编译uboot8

1.uboot移植

EP63平台uboot1.2.0挂载用户文件系统yaffs2时存在bug,挂载的镜像内容为空,只能采用从ramdisk文件系统中复制用户文件的方式。

该bug的主要原因是移植uboot1.2.0增加对nandflash读写时不支持大页nandflash。

而uboot1.2.0对大页nandflash支持的资料比较少,鉴于此移植uboot1.3.4,增加对大页nandflash的正确读写。

支持更多的命令,如支持nandcrube、上下键盘命令等。

1.1.4.3.2版本交叉编译工具

uboot1.2.0选用3.4.1版本的arm-linux-gcc编译,uboot1.3.4选用4.3.2版本的编译。

否则编译通不过。

修改/etc/bashrc,注释掉3.4.1版本的交叉编译器,增加4.3.2版本的交叉器。

下载arm-linux-gcc-4.3.2.tgz然后在根目录下解压。

解压后把4.3.2的交叉编译路径加入环境变量如下:

PATH=$PATH:

/usr/local/arm/4.3.2/bin

#PATH=$PATH:

/usr/local/arm/3.4.1/bin

使刚才的修改生效source/etc/bashrc。

这样修改后就不需要重启系统,4.3.2版本的交叉编译工具就可以生效。

1.2.加入atmel芯片支持

下载uboot源码和补丁:

root@emboard:

/xiaoyj/uboot#ls

u-boot-1.3.4-exp.3.diff 

u-boot-1.3.4.tar.bz

解压打入atmel芯片补丁

root@emboard:

/xiaoyj/uboot#tar-xjvfu-boot-1.3.4.tar.bz2

root@emboard:

/xiaoyj/uboot#ls

u-boot-1.3.4 u-boot-1.3.4-exp.3.diff u-boot-1.3.4.tar.bz2

进入u-boot-1.3.4 目录:

将补丁复制到u-boot-1.3.4 目录里:

root@emboard:

/xiaoyj/uboot/u-boot-1.3.4#cp../u-boot-1.3.4-exp.3.diff

打入atmel的补丁并清除以前的配置选项:

root@emboard:

/xiaoyj/uboot/u-boot-1.3.4#catu-boot-1.3.4-exp.3.diff|patch-p1

root@emboard:

/xiaoyj/uboot/u-boot-1.3.4#makedistclean

采用从nandflash启动,增加nandflash配置选项:

root@emboard:

/xiaoyj/uboot/u-boot-1.3.4#makeat91sam9260ek_nandflash_config

...withenvironmentvariableinNANDFLASH

Configuringforat91sam9260ekboard...

1.3.增加对大页nandflash支持

修改u-boot-1.3.4/commn/cmd_nand.c

在第12行,#include之后增加读写yaffs配置

#include

#ifndefCFG_NAND_WRITE_YAFFS//addedbegin

#defineCFG_NAND_WRITE_YAFFS

#endif//addedend

然后增加yaffs2文件系统读写支持,关键是了解yaffs2中64bytesOOB区中的数据组织结构:

1)OOB最前端的2bytes为0xFF0xFF,用于标识为非坏块。

2)每256bytes的数据需要3bytes的ECC校验,因此2K的数据需要24bytes的ECC校验。

修改如下:

else

printf("offset0x%lx,size0x%x\n",*off,*size);

return0;

}

之后,第159行增加如下代码:

#ifdefCFG_NAND_WRITE_YAFFS/////////xiaoyjaddedbegin

/*

*WriteayaffsfilesystemimagetoNAND.

*

*Ifyaffsflagis1,thentheimageisassumedtohavebeen

*generatedbyyaffs2/utils/mkyaffsimage.c,andonly

*512Bblock+16BOOBNANDissupportedusingtheYAFFS1OOBlayout.

*

*Otherwise,theimageisassumedtohavebeengeneratedby

*yaffs2/utils/mkyaffs2image.cwithSergeyKubushyn'spatchapplied

*andsupportslarger2KBblock+64BOOBNAND.

*

*OnlyMTDgeneratedECCissupported.

*

*Looselybasedonmtd/util/nandwrite.c.

*/

staticstructnand_oobinfoyaffs1_oobinfo={

.useecc=MTD_NANDECC_AUTOPLACE,

.eccbytes=6,

.eccpos={0,1,2,3,6,7},

.oobfree={{8,8}},

};

staticstructnand_oobinfoyaffs2_oobinfo={

.useecc=MTD_NANDECC_AUTOPLACE,

.eccbytes=24,

.eccpos={

40,41,42,43,44,45,46,47,

48,49,50,51,52,53,54,55,

56,57,58,59,60,61,62,63},

.oobfree={{2,38}}

};

staticunsignedcharffchars[]={

0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,

0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,/*16*/

0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,

0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,/*32*/

0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,

0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,/*48*/

0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,

0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,/*64*/

};

staticintnand_write_yaffs(nand_info_t*nand,ulongoff,size_t*size,u_char*image,intyaffs)

{

intimglen,pagelen;

u_char*imgptr,*oobptr;

intret;

size_tretlen;

inti;

structnand_oobinfoold_oobinfo;

imglen=*size;

imgptr=image;

*size=0;

/*Makesuredevicepagesizesarevalid*/

if((yaffs==1&&!

(nand->oobsize==16&&nand->oobblock==512))||

(yaffs==2&&!

(nand->oobsize==64&&nand->oobblock==2048))){

printf("Unsupportedflashlayout\n");

return1;

}

/*updateoobinfoforyaffs*/

old_oobinfo=nand->oobinfo;

nand->oobinfo=yaffs==1?

yaffs1_oobinfo:

yaffs2_oobinfo;

/*Check,ifimageispagealigned*/

pagelen=nand->oobblock+nand->oobsize;

if((off%nand->erasesize)!

=0||(imglen%pagelen)!

=0){

printf("Inputimageisnotpagealigned\n");

gotocloseall;

}

/*Check,iflengthfitsintodevice*/

if(((imglen/pagelen)*nand->oobblock)>(nand->size-off)){

printf("Inputimagedoesnotfitintodevice");

gotocloseall;

}

/*Getdatafrominputandwritetothedevice*/

while(imglen>0&&(offsize)){

/*ifstartoferaseblock,checkforbadblock*/

if(off%nand->erasesize==0&&(nand->block_isbad)(nand,off)){

printf("Badblockat0x%08lx,willbeskipped\n",off);

off+=nand->erasesize;

continue;

}

oobptr=imgptr+nand->oobblock;

/*WriteOOBdatafirst,aseccwillbeplacedinthere*/

memset(ffchars,0xff,nand->oobsize);

if(1==yaffs){

ffchars[15]=oobptr[12];

ffchars[14]=oobptr[11];

ffchars[13]=oobptr[7]&0x3f;

ffchars[13]|=(oobptr[4]==0?

0:

0x40);

ffchars[13]|=(oobptr[5]=='Y'?

0:

0x80);

ffchars[12]=oobptr[6];

ffchars[11]=oobptr[3];

ffchars[10]=oobptr[2];

ffchars[9]=oobptr[1];

ffchars[8]=oobptr[0];

}else

memcpy(ffchars+((nand->oobinfo).oobfree)[0][0],oobptr,((nand->oobinfo).oobfree)[0][1]);

ret=(nand->write_oob)(nand,off,nand->oobsize,&retlen,ffchars);

if(ret!

=0){

printf("\nNANDOOBwriteerror%datblock0x%08lx\n",ret,off);

gotocloseall;

}

/*WriteoutthePagedata*/

ret=(nand->write)(nand,off,nand->oobblock,&retlen,imgptr);

if(ret!

=0){

printf("\nNANDwriteerror%datblock0x%08lx\n",ret,off);

gotocloseall;

}

imgptr+=pagelen;

imglen-=pagelen;

off+=nand->oobblock;

}

closeall:

nand->oobinfo=old_oobinfo;

*size=imgptr-image;

if(imglen>0){

printf("Datadidnotfitintodevice,duetobadblocks\n");

return1;

}

return0;

}

#endif/*CFG_NAND_WRITE_YAFFS*////////////xiaoyjaddedend

修改第421行,修正在执行nandscrub命令擦除nandflash时异常退出的bug。

if(scrub){

#if0/////////////////////changedbegin

puts("Warning:

"

"scruboptionwilleraseallfactoryset"

"badblocks!

\n"

""

"Thereisnoreliablewaytorecoverthem.\n"

""

"Usethiscommandonlyfortestingpurposes"

"ifyou\n"

""

"aresureofwhatyouaredoing!

\n"

"\nReallyscrubthisNANDflash?

\n");

if(getc()=='y'&&getc()=='\r'){

opts.scrub=1;

}else{

puts("scrubaborted\n");

return-1;

}

#else

puts("Warning:

"

"scruboptionwilleraseallfactoryset"

"badblocks!

\n"

""

"Thereisnoreliablewaytorecoverthem.\n"

""

"Usethiscommandonlyfortestingpurposes"

"ifyou\n"

""

"aresureofwhatyouaredoing!

\n"

"\nReallyscrubthisNANDflash?

\n"

"\n\n-->y<--\n\n");

opts.scrub=1;

#endif//////////////////changededend

}

修改第316行,采用大页nandflash,2KBblock+64BOOBNAND方式。

intquiet=0;

#endif

#ifdefCFG_NAND_WRITE_YAFFS//////addedbegin

intyaffs=0;/*1=512Bblock+64OOBNAND,0=2048+64NAND*/

#endif////////addedend

修改第518行,增加yaffs读写。

ret=nand_write_opts(nand,&opts);

}

#ifdefCFG_NAND_WRITE_YAFFS///////////addedbegin

}elseif(!

read&&s!

=NULL&&0==strncmp(s,".yaffs",6)){

if(s[6]=='1')

yaffs=1;

elseif(s[6]=='2'||s[6]=='\0')

yaffs=2;

if(yaffs)

ret=nand_write_yaffs(nand,off,&size,(u_char*)addr,yaffs);

#endif///////////addedend

修改第1116行,在uboot处增加nandwrite.yaffs2命令以支持烧写yaffs2。

"nandwrite[.jffs2]addroffsize-read/write`size'bytesstarting\n"

"atoffset`off'to/frommemoryaddress`addr'\n"

#ifdefCFG_NAND_WRITE_YAFFS//////////addedbegin

"nandwrite[.yaffs[1]]addroffsize-read/write`size'bytesstarting\n"

"atoffset`off'tomemoryaddress`addr'[yaffs1oryaffs2format]\n"

#endif////////////addedend

1.4.修改ether.c增加网络支持

默认情况下,uboot1.3.4网络不通,是因为网络初始化时没有打开网络连接,网络不通则yaffs2文件系统没法下载。

修改\u-boot-1.3.4\cpu\arm926ejs\at91sam9\ether.c第33行,使初始化网络状态为打开网络链接。

//macb_eth_initialize(0,(void*)AT91_BASE_EMAC,0x00);

macb_eth_initialize(0,(void*)AT91_BASE_EMAC,0x01);

1.5.修改启动命令和网络参数设置

根据SDRAM地址、内核分区情况和本地电脑ip设置修改\u-boot-1.3.4\include\configs\at91sam9260ek.h中第165行

注释掉如下代码:

#defineCONFIG_BOOTCOMMAND"nandread0x220000000xA00000x200000;bootm"

#defineCONFIG_BOOTARGS"console=ttyS0,115200"\

"root=/dev/mtdblock5"\

"mtdparts=at91_nand:

128k(bootstrap)ro,"\

"256k(uboot)ro,128k(env1)ro,"\

"128k(env2)ro,2M(linux),-(root)"\

"rwrootfstype=jffs2"

增加如下代码:

#defineCONFIG_BOOTCOMMAND"nandread0x220000000x1000000x200000;\

nandread0x231000000x4000000x600000;bootm0x22000000"

#if0

#defineCONFIG_BOOTARGS"64Mconsole=ttyS0,115200"\

"initrd0x23100000,6000000"\

"root=/dev/ram0rw"

#endif

#defineCONFIG_IPADDR192.168.100.101

#defineCONFIG_ETHADDR12:

34:

56:

78:

90:

AB

#defineCONFIG_SERVERIP192.168.100.102

#defineCONFIG_NETMASK255.255.255.0

#defineCONFIG_GATEWAYIP192.168.100.255

1.6.加快断开网络时系统启动速度

在网络断开的情况下,系统会不断的搜索是否有网络到达,约5秒后才退出搜索网络,大大降低了系统启动速度。

修改u-boot-1.3.4\drivers\net\macb.c注释掉第304到311行,增加一个延时函数,具体修改如下:

#if0/////changedbegin

for(i=0;i

status=macb_mdio_read(macb,MII_BMSR);

if(status&BMSR_ANEGCOMPLETE)

break;

udelay(100);

}

#endif

udelay(100*1000);

udelay(100*1000);

status=macb_mdio_read(macb,MII_BMSR);//////changedend

if(status&BMSR_ANEGCOMPLETE)

printf("%s:

Autonegotiationcomplete\n",netdev->name);

无网络连接时,延时0.2秒之后就退出搜索网络,启动下一进程。

1.7.编译uboot

root@emboard:

/xiaoyj/uboot/u-boot-1.3.4#make

这样就可以编译出u-boot.bin,烧写到板子即可。

启动信息如下:

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2