全文预览

最小bootloader的实现,完整源代码

上传者:随心@流浪 |  格式:doc  |  页数:36 |  大小:0KB

文档介绍
ND_BLOCK_MASK)||(size&NAND_BLOCK_MASK)){return-1;/*invalidalignment*/}NAND_CHIP_ENABLE;for(i=start_addr;i<(start_addr+size);){/*READ0*/NAND_CLEAR_RB;NFCMD=0;/*WriteAddress*/NFADDR=i&0xff;NFADDR=(i>>9)&0xff;NFADDR=(i>>17)&0xff;NFADDR=(i>>25)&0xff;NAND_DETECT_RB;for(j=0;j<NAND_SECTOR_SIZE;j++,i++){*buf=(NFDATA&0xff);buf++;}}NAND_CHIP_DISABLE;return0;}intNandErase(unsignedlongstart_addr){if(start_addr&NAND_BLOCK_MASK){return-1;/*invalidalignment*/}NAND_CHIP_ENABLE;NAND_CLEAR_RB;NFCMD=0x60;NFADDR=(start_addr>>9)&0xff;NFADDR=(start_addr>>17)&0xff;NFADDR=(start_addr>>25)&0xff;NFCMD=0xd0;NAND_DETECT_RB;uart_printf("Erase0x%x\r",start_addr);NAND_CHIP_DISABLE;return0;}intnand_write_ll(unsignedchar*buf,unsignedlongstart_addr,intsize){inti,j,k;if((start_addr&NAND_BLOCK_MASK)||(size&NAND_BLOCK_MASK)){

收藏

分享

举报
下载此文档