void nand_demo() { int (*OS_Entry)(void *); unsigned int offset; int blockno; int blockstart; int blockend; int page; enable_nand(); blockstart=0x20000/0x4000; blockend=blockstart+(0x170000/0x4000); offset=0x31000000; for(blockno=blockstart;blockno<(blockend+1);blockno++) { for(page=0;page<32;page++) { NAND_ReadPage(blockno,page,offset); offset = offset + 512; } } clean_cache(); putstr("OS read successfully\r\n"); putstr("Press any key to continue\r\n"); getchar(); OS_Entry=(int *)0x31000000; OS_Entry(1); }
void main(void) { register nBlock; register nPage; register nBadBlocks; volatile unsigned char *pBuf; // Set up copy section (initialized globals). // // NOTE: after this call, globals become valid. // SetupCopySection(pTOC); // Enable the ICache. //System_EnableICache(); // I-Cache was already enabled in startup.s // Set up all GPIO ports for LED. //Port_Init(); //Led_Display(0xf); // UART Initialize #if UART_DEBUG Uart_Init(); Uart_SendString("\r\nWinCE 6.0 Steploader for SMDK6410\r\n"); // Initialize the NAND flash interface. Uart_SendString("NAND Initialize\n\r"); #endif g_bLargeBlock = NAND_Init(); // Copy image from NAND flash to RAM. pBuf = (unsigned char *)LOAD_ADDRESS_PHYSICAL; nBadBlocks = 0; //Led_Display(0x4); for (nPage = LOAD_IMAGE_PAGE_OFFSET; nPage < (LOAD_IMAGE_PAGE_OFFSET + LOAD_IMAGE_PAGE_COUNT) ; nPage++) { //Led_Display(0x1); nBlock = ((nPage / NAND_PAGES_PER_BLOCK) + nBadBlocks); if (!NAND_ReadPage(nBlock, (nPage % NAND_PAGES_PER_BLOCK), pBuf)) { if ((nPage % NAND_PAGES_PER_BLOCK) != 0) { //Led_Display(0x9); // real ECC Error. #if UART_DEBUG Uart_SendString("ECC Error.\r\n"); #endif while(1) { // Spin forever... } } // ECC error on a block boundary is (likely) a bad block - retry the page 0 read on the next block. nBadBlocks++; nPage--; continue; } pBuf += NAND_BYTES_PER_PAGE; } //Led_Display(0x6); #if UART_DEBUG Uart_SendString("Launch Eboot...\n\r"); #endif ((PFN_IMAGE_LAUNCH)(LOAD_ADDRESS_PHYSICAL))(); }