微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > UBOOT和bootloader的关系

UBOOT和bootloader的关系

时间:11-21 来源:互联网 点击:

RESET();

_WR(0x555,0xaa);

_WR(0x2aa,0x55);

_WR(0x555,0x90);

manId=_RD(0x0);

_WR(0x555,0xaa);

_WR(0x2aa,0x55);

_WR(0x555,0x90);

devId=_RD(0x1);

_RESET();

printf("flashn");

printf("Manufacture ID=%4x(0x0004), Device ID(0x22c4)=%4xn",manId,devId);

if(manId!=0x0004 && devId!=0x22c4){

printf("flash check faliluren");

return 0;

}else{

for (i=0; i < CFG_MAX_FLASH_BANKS; ++i){

flash_info[i].flash_id=FLASH_AM160T;//In fact it is fujitu,I only dont want to

//modify common files

}

}

// Setup offsets //

flash_get_offsets (CFG_FLASH_BASE, &flash_info[0]);

// zhangyy comment

#if CFG_MONITOR_BASE >= CFG_FLASH_BASE

//onitor protection ON by default

flash_protect(FLAG_PROTECT_SET,

CFG_MONITOR_BASE,

CFG_MONITOR_BASE+monitor_flash_len-1,

&flash_info[0]);

#endif

//

flash_info[0].size =PHYS_FLASH_SIZE;

return (PHYS_FLASH_SIZE);

}

flash_init 完成初始化部分,这里的主要目的是检验flash 的型号是否正确。

int flash_erase (flash_info_t *info, int s_first, int s_last)

{

volatile unsigned char *addr = (volatile unsigned char *)(info->start[0]);

int flag, prot, sect, l_sect;

//ulong start, now, last;

u32 targetAddr;

u32 targetSize;

//zyy note:It is required and cant be omitted//

rNCACHBE0=( (0x2000000>>12)<16 )|(0>>12); //flash area(Bank0) must be non-cachable

area.

rSYSCFG=rSYSCFG & (~0x8); //write buffer has to be off for proper timing.

if ((s_first < 0) || (s_first > s_last)) {

if (info->flash_id == FLASH_UNKNOWN) {

printf ("- missingn");

} else {

printf ("- no sectors to erasen");

}

return 1;

}

if ((info->flash_id == FLASH_UNKNOWN) ||

(info->flash_id > FLASH_AMD_COMP)) {

printf ("Cant erase unknown flash type - abortedn");

return 1;

}

prot = 0;

for (sect=s_first; sect<=s_last; ++sect) {

if (info->protect[sect]) {

prot++;

}

}

if (prot) {

printf ("- Warning: %d protected sectors will not be erased!n",

prot);

} else {

printf ("n");

}

l_sect = -1;

// Disable interrupts which might cause a timeout here //

flag = disable_interrupts();

// Start erase on unprotected sectors //

for (sect = s_first; sect<=s_last; sect++) {

if (info->protect[sect] == 0) { // not protected //

targetAddr=0x10000*sect;

if(targetAddr<0x1F0000)

targetSize=0x10000;

else if(targetAddr<0x1F8000)

targetSize=0x8000;

else if(targetAddr<0x1FC000)

targetSize=0x2000;

else

targetSize=0x4000;

F29LV160_EraseSector(targetAddr);

l_sect = sect;

if(!BlankCheck(targetAddr, targetSize))

printf("BlankCheck Errorn");

}

}

// re-enable interrupts if necessary //

if (flag)

enable_interrupts();

// wait at least 80us - lets wait 1 ms //

udelay (1000);

//

*We wait for the last triggered sector

//

if (l_sect < 0)

goto DONE;

DONE:

printf (" donen");

return 0;

}

int BlankCheck(int targetAddr,int targetSize)

{

int i,j;

for(i=0;i{

j=*((u16 *)(i+targetAddr));

if( j!=0xffff)

{

printf("E:%x=%xn",(i+targetAddr),j);

return 0;

}

}

return 1;

}

flash_erase 擦除flash,BlankCheck 则检查该部分内容是否擦除成功。

//-----------------------------------------------------------------------

*Write a word to Flash, returns:

* 0 - OK

* 1 - write timeout

* 2 - Flash not erased

//

static int write_word (flash_info_t *info, ulong dest, ulong data)

{

volatile u16 *tempPt;

//zhangyy note:because of compatiblity of function,I use low & hi//

u16 low = data & 0xffff;

u16 high = (data >> 16) & 0xffff;

low=swap_16(low);

high=swap_16(high);

tempPt=(volatile u16 *)dest;

_WR(0x555,0xaa);

_WR(0x2aa,0x55);

_WR(0x555,0xa0);

*tempPt=high;

_WAIT();

_WR(0x555,0xaa);

_WR(0x2aa,0x55);

_WR(0x555,0xa0);

*(tempPt+1)=low;

_WAIT();

return 0;

}

wirte_word 则想flash 里面写入unsigned long 类型的data,因为flash 一次只能写入16bits,所以这里分两次写入。

免费参加,名额有限!2005DVTF;MP3 U盘礼物...

zlei 发表于 2005-1-16 12:33 ARM 论坛 ←返回版面

MPC8xx的U-Boot移植体会(ZT)

BOOT LOADER(引导装载器),是用于初始化目标板硬件,给嵌入式操作系统提供板上硬件资源信息,并进一

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top