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

📄 2410loader.c

📁 2410 nand boot load!(4K DRAM) 0地址开始运行
💻 C
字号:
/************************************************
 * NAME    : 2410loader.C			*
 * DESC    : 					*
 * History : 2002.02.25 ver 0.0			*
************************************************/

#include "option.h"
#include "def.h"
#include "2410addr.h"
#include "2410slib.h"
#include "2410lib.h"
#include "2410addr.h"
#include "k9s1208.h"
#include "register.h"

#define DOWNLOAD_ADDRESS _RAM_STARTADDRESS
#define BOOT_IMAGE_SIZE 5 
#define MEM_OFFSET    0x01000000

void (*run)(void)=(void (*)(void))(DOWNLOAD_ADDRESS+MEM_OFFSET);
void Port_Init(void);
void Led_Display(int);
void Delay(int);

volatile unsigned char *downPt;

void T4_Start(void);
void T4_Stop(void);
//char *hex2char(int val);


int main(int argc,char **argv)
{
	int i,j;

	MMU_EnableICache();

	ChangeClockDivider(1,1);	    // 1:2:4
	ChangeMPllValue(M_MDIV,M_PDIV,M_SDIV);  //Fin=12MHz FCLK=200MHz

	Port_Init();

	Uart_Init(PCLK, 115200);

	downPt=(unsigned char *)(DOWNLOAD_ADDRESS+MEM_OFFSET);

	NF_Init();

	/*********************************************************
	 *  off(led4)  off(led3) off(led2) on(led1)
	 ********************************************************/

	Led_Display(1);


	//    T4_Start();

	j=0;
	while(j<(BOOT_IMAGE_SIZE))	    // Read 1~90 block(2.4M) for Linux image
	{
		j++;

		for(i=0;i<32;i++)   // Read 32 page
		{
			Led_Display(2);
			if(!NF_ReadPage(j, i, (U8 *)downPt))  //(U32 block,U32 page,U8 *buffer)
			{
				if(i!=0)
				{
					Led_Display(0x8);   // real ECC Error
				}
				break;		    // ECC error is considered as a bad block.
			}
			downPt += 512;	    // Next page
			Led_Display(4);
		}

	}


	//  T4_Stop();

	Uart_SendString("\nNand Bootloader(ADAM) 1.0.1 \n");
	Uart_SendString(  "Loading ARMBOOT\n");
	run();
	Uart_SendString("\n\nNOT RETURN\n");
	return 0;
}


void T4_Start(void)
{
#if 0
    	Uart_SendString("--------------------------------------------------\n");
    Uart_SendString("Linux S3C2410 NAND Boot Start\n");
    Uart_SendString("OS Image start from SMC Block 1\n");    
    Uart_SendString("and copy OS Image from SMC to SDRAM at 0x30f00000\n");
    Uart_SendString("             by SW.LEE hitchcar@sec.samsung.com  \n");
#endif

    rTCFG0=0xff00; /* Prescaler 1 */
    rTCFG1=(0x3<<16); //T4=16/256
    rTCNTB4=0xffff;
    rTCON=(1<<22)|(1<<21);  // Auto reload &  Manual update
    rTCON=(1<<22)|(1<<20);  // Auto reload &  Start T4
}


void T4_Stop(void)
{
    int cnt;
    rTCON=(1<<22)|(0<<20);  //Stop T4
    cnt=0xffff-rTCNTO4;
 
#if 0    
    Uart_SendString("NAND Boot End\n");
    Uart_SendString("Boot time=nTCNT*82uS. nTCNT=0x");
    Uart_SendString(hex2char((cnt&0xf000)>>12));
    Uart_SendString(hex2char((cnt&0x0f00)>>8));
    Uart_SendString(hex2char((cnt&0x00f0)>>4));
    Uart_SendString(hex2char((cnt&0x000f)>>0));    	
    Uart_SendString("\n\n");
#endif


}

#if 0
char *hex2char(int val)
{
    static char str[2];
    str[1]='\0';	
    if(val<=9)str[0]='0'+val;
    else str[0]=('a'+val-10);
    return str;
}

#endif

⌨️ 快捷键说明

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