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

📄 2460nand.cpp

📁 三星 s3c2460 从k9f1208u0m NAND FLASH BOOT系统 源代码
💻 CPP
字号:
//===================================================================
// NAME		: 2460NAND.cpp
// DESC		: NAND flash Boot Loader
// History	: 
// Revision	: Rev 0.2
// Updated  : 2004. 9. 2
//===================================================================
#include <stdio.h>
#include <stdlib.h>

#include "option.h"
#include "2460addr.h"
#include "2460lib.h"
#include "2460slib.h"
#include "k9s1208.h"


void Check_SleepKey(void);

/*-------------------- k9s1208 ----------------------
 
 1page = 528Bytes = (512+16)Byte
  1block = 528Bytes x 32pages
 1device = 528Bytes x 32pages x 4096blocks = 528Mbits
-------------------------------------------------*/

//#define	OS_IMAGE_SIZE 300		//block quantity for os image 

//#define	OS_IMAGE_SIZE 192		//block quantity for MBX image(3MByte)
//#define	OS_START_ADDR_OFFSET	(0x00200000)	//for OS

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

#define DOWNLOAD_ADDRESS (_RAM_STARTADDRESS+OS_START_ADDR_OFFSET)

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

volatile unsigned char *downPt;

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

	for(i=0;i<10000;i++);	//	Wait for PLL lock down.

	Init_LED();
	Led_Display(0x9);

	GlobalCLK();

	Uart_Init(0,115200);
	Uart_puts("\n\nNAND boot.\n");


   /*******************************/
   /*		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);	
	
	MMU_EnableICache();
	

	NF_Init();


	Led_Display(0x1);

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

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


 void Check_SleepKey(void)
{
	if( rRSTSTAT & (1<<0) )
	{
		Uart_puts("Power-on Reset\n");
	}
	else if( rRSTSTAT & (1<<1) )
	{
		Uart_puts("\nWarm Reset\n\n");
		if(SRAMKey_Run==0)
			return;
		run=(void (*)(void))SRAMKey_Run;
		MMU_DisableICache();
		run();
	}
	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("\nBattery Fault\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();
	}
}

⌨️ 快捷键说明

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