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

📄 loader-8bit.c

📁 S3C6410 Startup Code,包括nand和onenand2种启动代码
💻 C
字号:
/**************************************************************************************
* 
*	Project Name : S3C6410 Validation
*
*	Copyright 2006 by Samsung Electronics, Inc.
*	All rights reserved.
*
*	Project Description :
*		This software is only for validating functions of the S3C6410.
*		Anybody can use this software without our permission.
*  
*--------------------------------------------------------------------------------------
* 
*	File Name : 6410loader-8bit.c
*  
*	File Description : This file implements the functons for Nand Booting.
*
*	Author : Heemyung.noh
*	Dept. : AP Development Team
*	Created Date : 2007/02/02
*	Version : 0.1 
* 
*	History
*	- Created(Heemyung.noh 2007/02/02)
*  
**************************************************************************************/

#include "def.h"
#include "option.h"
#include "sfr6410.h"
#include "System.h"
#include "sysc.h"
#include "Nand.h"


// Normal NAND :	1page = 256B or 512B, 1block = 32pages, total ? blocks..
// Advanced NAND :	1page = 1K or 2KB, 1block = 64pages, total ? blocks..


#define	OS_IMAGE_SIZE 0x20			// block quantity for USB monitor (block number)
//#define OS_IMAGE_SIZE 0x800		// block quantity for WinCE : 32Mbyte(page=512B), 
#define	OS_START_ADDR_OFFSET (0x00000000)

#define DOWNLOAD_ADDRESS (_DRAM_BaseAddress+OS_START_ADDR_OFFSET)

void Check_SleepKey(void);
void (*run)(void)=(void (*)(void))(DOWNLOAD_ADDRESS);
volatile unsigned char *downPt;

extern int Uart_puts( const char *s);
extern void DisplayLED(u8 data);
extern void InitLED(void);
extern void Uart_Init(unsigned int pclk,unsigned int baud);

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

	InitLED();
	DisplayLED(0x9);
	
	SYSC_GetClkInform();
	Uart_Init(0,115200);
	
	Uart_puts("\n\nNAND booting.....\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);	

	SYSTEM_EnableICache();

#if (NAND_TYPE == NORMAL_8BIT)
	page_size = 32;
#elif (NAND_TYPE == ADVANCED_8BIT)
	page_size = 64;
#elif (NAND_TYPE == MLC_8BIT)
	page_size = 128;
#endif
	
									   
	NF8_Init();
								   
	while(blockcopy_count<OS_IMAGE_SIZE)	    
	{
		block++;
		if(!NF8_IsBadBlock(block)) continue;    //  Skip bad block
		blockcopy_count++;

		for(i=0;i<page_size;i++)   // Read 32 page
		{
			if(!NF8_ReadPage(block, i, (unsigned char *)downPt))   //1
			{   
		           
				DisplayLED(0x2);   // real ECC Error
				while(1);
			}
#if (NAND_TYPE == NORMAL_8BIT)
			downPt += 512;	    // Next page
#elif (NAND_TYPE == ADVANCED_8BIT)
			downPt += 2048;	    // Next page
#elif (NAND_TYPE == MLC_8BIT)
			downPt += 2048;	    // Next page
#endif			
		}
		
	}
	DisplayLED(0x3);
	
	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 + -