嵌入式Linux開發(fā)環(huán)境的搭建之:U-Boot移植
(9)提供nandflash相關宏定義(include/configs/fs2410.h),具體參考源碼。
(10)加入NandFlash設備(include/linux/mtd/nand_ids.h)
staticstructnand_flash_devnand_flash_ids[]=
{
......
{SamsungKM29N16000,NAND_MFR_SAMSUNG,0x64,21,1,2,0x1000,0},
{SamsungK9F1208U0M,NAND_MFR_SAMSUNG,0x76,26,0,3,0x4000,0},
{Samsungunknown4Mb,NAND_MFR_SAMSUNG,0x6b,22,0,2,0x2000,0},
......
{NULL,}
};
(11)設置NandFlash環(huán)境(common/env_nand.c)
intnand_legacy_rw(structnand_chip*nand,intcmd,
size_tstart,size_tlen,
size_t*retlen,u_char*buf);
externstructnand_chipnand_dev_desc[CFG_MAX_NAND_DEVICE];
externintnand_legacy_erase(structnand_chip*nand,
size_tofs,size_tlen,intclean);
/*infoforNANDchips,definedindrivers/nand/nand.c*/
externnand_info_tnand_info[CFG_MAX_NAND_DEVICE];
......
#else/*!CFG_ENV_OFFSET_REDUND*/
intsaveenv(void)
{
ulongtotal;
intret=0;
puts(ErasingNand...);
if(nand_legacy_erase(nand_dev_desc+0,
CFG_ENV_OFFSET,CFG_ENV_SIZE,0))
{
return1;
}
puts(WritingtoNand...);
total=CFG_ENV_SIZE;
ret=nand_legacy_rw(nand_dev_desc+0,0x00|0x02,CFG_ENV_OFFSET,
CFG_ENV_SIZE,total,(u_char*)env_ptr);
if(ret||total!=CFG_ENV_SIZE)
{
return1;
}
puts(donen);
returnret;
......
#else/*!CFG_ENV_OFFSET_REDUND*/
voidenv_relocate_spec(void)
{
#if!defined(ENV_IS_EMBEDDED)
ulongtotal;
intret;
total=CFG_ENV_SIZE;
ret=nand_legacy_rw(nand_dev_desc+0,0x01|0x02,CFG_ENV_OFFSET,
CFG_ENV_SIZE,total,(u_char*)env_ptr);
c語言相關文章:c語言教程
linux相關文章:linux教程
評論