⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2443loader-8bit.c

📁 S3C2443的读Nand程序
💻 C
字号:
/************************************************
 * NAME    : 24loader-8bit.c
 * DESC    : 
 * History : 2005.09.23 ver 0.0
 * rev0.1  : 2005.09.23
************************************************/

//#include <stdlib.h>
//#include <string.h>
#include "def.h"
#include "option.h"
#include "2443addr.h"
#include "System.h"
#include "Console.h"
#include "MmuCache.h"
#include "Nand.h"

//#include "mmu.h"

#define	OS_IMAGE_SIZE 0x100			//	block quantity for USB monitor. : 64Kbyte
#define	OS_START_ADDR_OFFSET (0x00000000)

#define DOWNLOAD_ADDRESS (_RAM_STARTADDRESS+OS_START_ADDR_OFFSET)
//#define DOWNLOAD_ADDRESS (_NONCACHE_STARTADDRESS+OS_START_ADDR_OFFSET) //for debugging

void Check_SleepKey(void);

void (*run)(void)=(void (*)(void))(DOWNLOAD_ADDRESS);

volatile unsigned char *downPt;

int main(void)
{
    //main start
	register int i, block, blockcopy_count;



	Init_LED();
	Led_Display(0x9);

	SystemCLK();


	Console();

	(*(volatile unsigned char *)0x50004020)='$';


   /*******************************/
   /*		Cause of Boot-up	   */
   /*******************************/
    //Check_SleepKey(); // Check the cause of Boot-up(Watchdog /Soft Reset / Power on reset / Sleep wakeup.....) 
	

	block=0;
   	blockcopy_count=0;

	downPt=(unsigned char *)(DOWNLOAD_ADDRESS);	
	Led_Display(0x5);
	MMU_EnableICache();
	

	NF8_Init();



	while(blockcopy_count<OS_IMAGE_SIZE)	    
	{
		block++;
	//	if(!NF8_IsBadBlock(block)) continue;    //  Skip bad block
		blockcopy_count++;

		for(i=0;i<32;i++)   // Read 32 page
		{
			if(!NF8_ReadPage(block, i, (unsigned char *)downPt))   //1
			{   
		           
				Led_Display(0x2);   // real ECC Error
				while(1);
			}
			downPt += 512;	    // Next page
		}
		
	}
	Led_Display(0x3);
	
	(*(volatile unsigned char *)0x50004020)='*';


	run();
}


#if 0
 void Check_SleepKey(void)
{
	if( rRSTSTAT & (1<<0) )
	{
		Uart_puts("Power-on Reset\n");
	}

	else if( rRSTSTAT & (1<<2) )
	{
		Uart_puts("\nWatch-dog Reset\n\n");
		if(SRAMKey_Run==0)
			return;
		run=(void (*)(void))SRAMKey_Run;
		MMU_DisableICache();
		run();
	}
	else if( rRSTSTAT & (1<<3) )//Sleep mode wake-up
	{
		Uart_puts("\nSLEEP mode Wake-up\n\n");

		if(SRAMKey_Run==0)
			return;
		run=(void (*)(void))SRAMKey_Run;
		MMU_DisableICache();
		run();
	}
	else if( rRSTSTAT & (1<<4) )
	{
		Uart_puts("\nEsleep mode Wake-up\n\n");
		if(SRAMKey_Run==0)
			return;
		run=(void (*)(void))SRAMKey_Run;
		MMU_DisableICache();
		run();
	}
	else if( rRSTSTAT & (1<<5) )
	{
		Uart_puts("\nSoft Reset\n\n");
		if(SRAMKey_Run==0)
			return;
		run=(void (*)(void))SRAMKey_Run;
		MMU_DisableICache();
		run();
	}
}

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -