Chinaunix首页 | 论坛 | 博客
  • 博客访问: 875960
  • 博文数量: 149
  • 博客积分: 3671
  • 博客等级: 中校
  • 技术积分: 1701
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-03 16:52
文章分类

全部博文(149)

文章存档

2011年(57)

2010年(92)

分类: 嵌入式

2010-08-11 11:32:35

3步:支持nandboot2440相关修改(蓝色为修改部分)

1、修改/cpu/arm920t/start.S

1) 关闭AT91RM9200使用的LED代码。

#include

#include

#if defined(CONFIG_AT91RM9200DK)

#include /*这是针对AT91RM9200DK开发板的。*/

#endif

......

/*

* the actual start code

*/

start_code:

/*

* set the cpu to SVC32 mode

*/

mrs r0,cpsr

bic r0,r0,#0x1f

orr r0,r0,#0xd3

msr cpsr,r0

#if defined(CONFIG_AT91RM9200DK)

bl coloured_LED_init

bl red_LED_on

#endif


2) 修改寄存器地址定义

#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)|| defined(CONFIG_S3C2440)

/* turn off the watchdog */

#if defined(CONFIG_S3C2400)

#define pWTCON 0x15300000

#define INTMSK 0x14400008 /* Interupt-Controller base addresses */

#define CLKDIVN 0x14800014 /* clock divisor register */

#else

#define pWTCON 0x53000000

#define INTMSK 0x4A000008 /* Interupt-Controller base addresses */

#define INTSUBMSK 0x4A00001C

#define CLKDIVN 0x4C000014 /* clock divisor register */

#endif

#define CLK_CTL_BASE 0x4C000000

#define MDIV_405 0x7f << 12

#define PSDIV_405 0x21

#define MDIV_200 0xa1 << 12

#define PSDIV_200 0x31


3) 修改中断禁止部分


#if defined(CONFIG_S3C2410)

ldr r1, =0x3ff /*根据2410芯片手册,INTSUBMSK11位可用*/

ldr r0, =INTSUBMSK

str r1, [r0]

#endif

#if defined(CONFIG_S3C2440)

ldr r1, =0x7fff /*根据2440芯片手册,INTSUBMSK15位可用*/

ldr r0, =INTSUBMSK

str r1, [r0]

#endif


4) 修改时钟设置(2440的主频为405MHz。)


# if defined(CONFIG_S3C2440)

/* FCLK:HCLK:PCLK = 1:4:8 */

ldr r0, =CLKDIVN

mov r1, #5

str r1, [r0]

mrc p15, 0, r1, c1, c0, 0 /*read ctrl register */

orr r1, r1, #0xc0000000 /*Asynchronous */

mcr p15, 0, r1, c1, c0, 0 /*write ctrl register */

/*now, CPU clock is 405.00 Mhz */

mov r1, #CLK_CTL_BASE /* */

mov r2, #MDIV_405 /* mpll_405mhz */

add r2, r2, #PSDIV_405 /* mpll_405mhz */

str r2, [r1, #0x04] /* MPLLCON */

#else

/* FCLK:HCLK:PCLK = 1:2:4 */

ldr r0, =CLKDIVN

mov r1, #3

str r1, [r0]

mrc p15, 0, r1, c1, c0, 0 /*read ctrl register */

orr r1, r1, #0xc0000000 /*Asynchronous */

mcr p15, 0, r1, c1, c0, 0 /*write ctrl register */

/*now, CPU clock is 202.8 Mhz */

mov r1, #CLK_CTL_BASE /* */

mov r2, #MDIV_200 /* mpll_200mhz */

add r2, r2, #PSDIV_200 /* mpll_200mhz */

str r2, [r1, #0x04]

# endif

#endif /* CONFIG_S3C2400 || CONFIG_S3C2410|| CONFIG_S3C2440 */


5) 将从Nor Flash启动改成从NAND Flash启动。


在以下UBoot的重定向语句段(作用是将u-boot的源代码从nor flashsdram): (我将红色部分删除了)


#ifndef CONFIG_AT91RM9200

#ifndef CONFIG_SKIP_RELOCATE_UBOOT

relocate: /* relocate U-Boot to RAM */

adr r0, _start /* r0 <- current position of code */

ldr r1, _TEXT_BASE /* test if we run from flash or RAM */

cmp r0, r1 /* don't reloc during debug */

beq stack_setup

ldr r2, _armboot_start

ldr r3, _bss_start

sub r2, r3, r2 /* r2 <- size of armboot */

add r2, r0, r2 /* r2 <- source end address*/

copy_loop:

ldmia {r3-r10} /* copy from source address [r0] */

stmia {r3-r10} /* copy to target address [r1] */

cmp r0, r2 /* until source end addreee [r2] */

ble copy_loop

/************ NAND_BOOT************************************/

#ifdef CONFIG_S3C2440_NAND_BOOT

#define NAND_CTL_BASE 0x4E000000

/* Offset */

#define oNFCONF 0x00

#define oNFCONT 0x04

#define oNFCMD 0x08

#define oNFSTAT 0x20

#define LENGTH_UBOOT 0x60000


@ reset NAND


mov r1, #NAND_CTL_BASE

ldr r2, =( (7<<12)|(7<<8)|(7<<4)|(0<<0) )

str r2, [r1, #oNFCONF]

ldr r2, [r1, #oNFCONF]


ldr r2, =( (1<<4)|(0<<1)|(1<<0) ) @ Active low CE Control

str r2, [r1, #oNFCONT]

ldr r2, [r1, #oNFCONT]


ldr r2, =(0x6) @ RnB Clear

str r2, [r1, #oNFSTAT]

ldr r2, [r1, #oNFSTAT]


mov r2, #0xff @ RESET command

strb r2, [r1, #oNFCMD]


mov r3, #0 @ wait


nand1:


add r3, r3, #0x1

cmp r3, #0xa

blt nand1

nand2:

ldr r2, [r1, #oNFSTAT] @ wait ready

tst r2, #0x4

beq nand2

ldr r2, [r1, #oNFCONT]

orr r2, r2, #0x2 @ Flash Memory Chip Disable

str r2, [r1, #oNFCONT]

@ get read to call C functions (for nand_read())

ldr sp, DW_STACK_START @ setup stack pointer

mov fp, #0 @ no previous frame, so fp=0

@ copy U-Boot to RAM

ldr r0, =TEXT_BASE

mov r1, #0x0

mov r2, #LENGTH_UBOOT

bl nand_read_ll

tst r0, #0x0

beq ok_nand_read

bad_nand_read:

loop2:

b loop2 @ infinite loop

ok_nand_read:

@ verify

mov r0, #0

ldr r1, =TEXT_BASE

mov r2, #0x400 @ 4 bytes * 1024 = 4K-bytes


go_next:


ldr r3, [r0], #4

ldr r4, [r1], #4

teq r3, r4

bne notmatch

subs r2, r2, #4

beq stack_setup

bne go_next

notmatch:

loop3:

b loop3 @ infinite loop

#endif

#ifdef CONFIG_S3C2410_NAND_BOOT

#define NAND_CTL_BASE 0x4E000000

/* Offset */

#define oNFCONF 0x00

#define oNFCMD 0x04

#define oNFSTAT 0x10

#define LENGTH_UBOOT 0x40000

@ reset NAND

mov r1, #NAND_CTL_BASE

ldr r2, =0xf830 @ initial value

str r2, [r1, #oNFCONF]

ldr r2, [r1, #oNFCONF]

bic r2, r2, #0x800 @ enable chip

str r2, [r1, #oNFCONF]

mov r2, #0xff @ RESET command

strb r2, [r1, #oNFCMD]

mov r3, #0 @ wait

nand1:

add r3, r3, #0x1

cmp r3, #0xa

blt nand1


nand2:


ldr r2, [r1, #oNFSTAT] @ wait ready

tst r2, #0x1

beq nand2


ldr r2, [r1, #oNFCONF]

orr r2, r2, #0x800 @ disable chip

str r2, [r1, #oNFCONF]


@ get read to call C functions (for nand_read())


ldr sp, DW_STACK_START @ setup stack pointer

mov fp, #0 @ no previous frame, so fp=0


@ copy U-Boot to RAM


ldr r0, =TEXT_BASE

mov r1, #0x0

mov r2, #LENGTH_UBOOT

bl nand_read_ll

tst r0, #0x0

beq ok_nand_read


bad_nand_read:


loop2:


b loop2 @ infinite loop


ok_nand_read:


@ verify

mov r0, #0

ldr r1, =TEXT_BASE

mov r2, #0x400 @ 4 bytes * 1024 = 4K-bytes


go_next:


ldr r3, [r0], #4

ldr r4, [r1], #4

teq r3, r4

bne notmatch

subs r2, r2, #4

beq stack_setup

bne go_next


notmatch:


loop3:


b loop3 @ infinite loop


#endif

#endif /* CONFIG_SKIP_RELOCATE_UBOOT */


在 “ _start_armboot: .word start_armboot ” 后加入:


#define STACK_BASE 0x33f00000

#define STACK_SIZE 0x10000

.align 2

DW_STACK_START: .word STACK_BASE+STACK_SIZE-4


6),最后增加LED点亮的操作


作用是显示代码进度,Debug 有帮助。代码在跳转到第二阶段代码 start_armboot

数前会亮起一个 LED 灯。(还记得前面有调用 C 语言的 nand_read_ll 函数吧,初始化堆栈

的定义就在此)


clbss_l:str r2, [r0] /* clear loop... */


add r0, r0, #4

cmp r0, r1

ble clbss_l

ldr pc, _start_armboot


#if defined(CONFIG_MINI2440_LED)

#define GPIO_CTL_BASE 0x56000000

#define oGPIO_B 0x10

#define oGPIO_CON 0x0

/* R/W, Configures the pins of the port */

#define oGPIO_DAT 0x4

#define oGPIO_UP 0x8

/* R/W, Pull-up disable register */

mov r1, #GPIO_CTL_BASE

add r1, r1, #oGPIO_B

ldr r2, =0x295551

str r2, [r1, #oGPIO_CON]

mov r2, #0xff

str r2, [r1, #oGPIO_UP]

ldr r2, =0x1c1

str r2, [r1, #oGPIO_DAT]

#endif

_start_armboot: .word start_armboot

#define STACK_BASE 0x33f00000

#define STACK_SIZE 0x10000

.align 2

DW_STACK_START:.word STACK_BASE+STACK_SIZE-4


2、 在board/mini2440加入NAND Flash读取函数(start.S中需要的nand_read_ll函数)文件nand_read.c


==================================================================


/*

* nand_read.c: Simple NAND read functions for booting from NAND

*

* This is used by cpu/arm920/start.S assembler code,

* and the board-specific linker script must make sure this

* file is linked within the first 4kB of NAND flash.

*

* Taken from GPLv2 licensed vivi bootloader,

* Copyright (C) 2002 MIZI Research, Inc.

*

* Author: Hwang, Chideok

* Date : $Date: 2004/02/04 10:37:37 $

*

* u-boot integration and bad-block skipping (C) 2006 by OpenMoko, Inc.

* Author: Harald Welte

*/

#include

#include

#define __REGb(x) (*(volatile unsigned char *)(x))

#define __REGw(x) (*(volatile unsigned short *)(x))

#define __REGi(x) (*(volatile unsigned int *)(x))

#define NF_BASE 0x4e000000

#if defined(CONFIG_S3C2410)

#define NFCONF __REGi(NF_BASE + 0x0)

#define NFCMD __REGb(NF_BASE + 0x4)

#define NFADDR __REGb(NF_BASE + 0x8)

#define NFDATA __REGb(NF_BASE + 0xc)

#define NFSTAT __REGb(NF_BASE + 0x10)

#define NFSTAT_BUSY 1

#define nand_select() (NFCONF &= ~0x800)

#define nand_deselect() (NFCONF |= 0x800)

#define nand_clear_RnB() do {} while (0)

#elif defined(CONFIG_S3C2440) || defined(CONFIG_S3C2442)

#define NFCONF __REGi(NF_BASE + 0x0)

#define NFCONT __REGi(NF_BASE + 0x4)

#define NFCMD __REGb(NF_BASE + 0x8)

#define NFADDR __REGb(NF_BASE + 0xc)

#define NFDATA __REGb(NF_BASE + 0x10)

#define NFDATA16 __REGw(NF_BASE + 0x10)

#define NFSTAT __REGb(NF_BASE + 0x20)

#define NFSTAT_BUSY 1

#define nand_select() (NFCONT &= ~(1 << 1))

#define nand_deselect() (NFCONT |= (1 << 1))

#define nand_clear_RnB() (NFSTAT |= (1 << 2))

#endif

static inline void nand_wait(void)

{

int i;

while (!(NFSTAT & NFSTAT_BUSY))

for (i=0; i<10; i++);

}

struct boot_nand_t {

int page_size;

int block_size;

int bad_block_offset;

// unsigned long size;

};


#if 0

#if defined(CONFIG_S3C2410) || defined(CONFIG_MINI2440)

/* configuration for 2410 with 512byte sized flash */

#define NAND_PAGE_SIZE 512

#define BAD_BLOCK_OFFSET 5

#define NAND_BLOCK_MASK (NAND_PAGE_SIZE - 1)


#define NAND_BLOCK_SIZE 0x4000

#else

/* configuration for 2440 with 2048byte sized flash */

#define NAND_5_ADDR_CYCLE

#define NAND_PAGE_SIZE 2048

#define BAD_BLOCK_OFFSET NAND_PAGE_SIZE

#define NAND_BLOCK_MASK (NAND_PAGE_SIZE - 1)

#define NAND_BLOCK_SIZE (NAND_PAGE_SIZE * 64)

#endif

/* compile time failure in case of an invalid configuration */

#if defined(CONFIG_S3C2410) && (NAND_PAGE_SIZE != 512)

#error "S3C2410 does not support nand page size != 512"

#endif

#endif

static int is_bad_block(struct boot_nand_t * nand, unsigned long i)

{

unsigned char data;

unsigned long page_num;

nand_clear_RnB();

if (nand->page_size == 512) {

NFCMD = NAND_CMD_READOOB; /* 0x50 */

NFADDR = nand->bad_block_offset & 0xf;

NFADDR = (i >> 9) & 0xff;

NFADDR = (i >> 17) & 0xff;

NFADDR = (i >> 25) & 0xff;

} else if (nand->page_size == 2048) {

page_num = i >> 11; /* addr / 2048 */

NFCMD = NAND_CMD_READ0;

NFADDR = nand->bad_block_offset & 0xff;

NFADDR = (nand->bad_block_offset >> 8) & 0xff;

NFADDR = page_num & 0xff;

NFADDR = (page_num >> 8) & 0xff;

NFADDR = (page_num >> 16) & 0xff;

NFCMD = NAND_CMD_READSTART;

} else {

return -1;

}

nand_wait();


data = (NFDATA & 0xff);

if (data != 0xff)

return 1;

return 0;

}

static int nand_read_page_ll(struct boot_nand_t * nand, unsigned char *buf, unsigned long addr)

{

unsigned short *ptr16 = (unsigned short *)buf;

unsigned int i, page_num;

nand_clear_RnB();

NFCMD = NAND_CMD_READ0;

if (nand->page_size == 512) {

/* Write Address */

NFADDR = addr & 0xff;

NFADDR = (addr >> 9) & 0xff;

NFADDR = (addr >> 17) & 0xff;

NFADDR = (addr >> 25) & 0xff;

} else if (nand->page_size == 2048) {

page_num = addr >> 11; /* addr / 2048 */

/* Write Address */

NFADDR = 0;

NFADDR = 0;

NFADDR = page_num & 0xff;

NFADDR = (page_num >> 8) & 0xff;

NFADDR = (page_num >> 16) & 0xff;

NFCMD = NAND_CMD_READSTART;

} else {

return -1;

}

nand_wait();

#if defined(CONFIG_S3C2410)

for (i = 0; i < nand->page_size; i++) {

*buf = (NFDATA & 0xff);

buf++;

}

#elif defined(CONFIG_S3C2440) || defined(CONFIG_S3C2442)

for (i = 0; i < (nand->page_size>>1); i++) {

*ptr16 = NFDATA16;

ptr16++;

}

#endif

return nand->page_size;

}

static unsigned short nand_read_id()

{

unsigned short res = 0;

NFCMD = NAND_CMD_READID;

NFADDR = 0;

res = NFDATA;

res = (res << 8) | NFDATA;

return res;

}

extern unsigned int dynpart_size[];

/* low level nand read function */

int nand_read_ll(unsigned char *buf, unsigned long start_addr, int size)

{

int i, j;

unsigned short nand_id;

struct boot_nand_t nand;

/* chip Enable */

nand_select();

nand_clear_RnB();

for (i = 0; i < 10; i++)

;

nand_id = nand_read_id();

if (0) { /* dirty little hack to detect if nand id is misread */

unsigned short * nid = (unsigned short *)0x31fffff0;

*nid = nand_id;

}

if (nand_id == 0xec76 || /* Samsung K91208 */

nand_id == 0xad76 ) { /*Hynix HY27US08121A*/

nand.page_size = 512;

nand.block_size = 16 * 1024;

nand.bad_block_offset = 5;

// nand.size = 0x4000000;

} else if (nand_id == 0xecf1 || /* Samsung K9F1G08U0B */

nand_id == 0xecda || /* Samsung K9F2G08U0B */

nand_id == 0xecd3 ) { /* Samsung K9K8G08 */

nand.page_size = 2048;

nand.block_size = 128 * 1024;

nand.bad_block_offset = nand.page_size;

// nand.size = 0x8000000;

} else {

return -1; // hang

}

if ((start_addr & (nand.block_size-1)) || (size & ((nand.block_size-1))))

return -1; /* invalid alignment */

for (i=start_addr; i < (start_addr + size);) {

#ifdef CONFIG_S3C2410_NAND_SKIP_BAD

if (i & (nand.block_size-1)== 0) {

if (is_bad_block(&nand, i) ||

is_bad_block(&nand, i + nand.page_size)) {

/* Bad block */

i += nand.block_size;

size += nand.block_size;

continue;

}

}

#endif

j = nand_read_page_ll(&nand, buf, i);

i += j;

buf += j;

}

/* chip Disable */

nand_deselect();

return 0;

}


==============================================================


记得修改board/mini2440/Makefile文件,nand_read.c编译进u-boot


OBJS := mini2440.o nand_read.o flash.o


3、修改board/mini2440/lowlevel_init.S文件


/* REFRESH parameter */

#define REFEN 0x1 /* Refresh enable */

#define TREFMD 0x0 /* CBR(CAS before RAS)/Auto refresh */

#define Trc 0x3 /* 7clk */

#define Tchr 0x2 /* 3clk */

#if defined(CONFIG_S3C2440)

#define Trp 0x2 /* 4clk */

#define REFCNT 1012

#else

#define Trp 0x0 /* 2clk */

#define REFCNT 0x0459

#endif


4、 修改/board/mini2440/mini2440.c


修改其对GPIOPLL的配置(请参阅开发板的硬件说明和芯片手册);并针对LCD显示部分和nand flash驱动添加相应的代码: ......

#include

#include

#include

#if defined(CONFIG_CMD_NAND)

#include

#endif

DECLARE_GLOBAL_DATA_PTR;

#define FCLK_SPEED 1

#if FCLK_SPEED==0 /* Fout = 203MHz, Fin = 12MHz for Audio */

#define M_MDIV 0xC3

#define M_PDIV 0x4

#define M_SDIV 0x1

#elif FCLK_SPEED==1 /* Fout = 202.8MHz */

#if defined(CONFIG_S3C2410)

/* Fout = 202.8MHz */

#define M_MDIV 0xA1

#define M_PDIV 0x3

#define M_SDIV 0x1

#endif

#if defined(CONFIG_S3C2440)

/* Fout = 405MHz */

#define M_MDIV 0x7f

#define M_PDIV 0x2

#define M_SDIV 0x1

#endif

#endif


#define USB_CLOCK 1

#if USB_CLOCK==0

#define U_M_MDIV 0xA1

#define U_M_PDIV 0x3

#define U_M_SDIV 0x1

#elif USB_CLOCK==1

#if defined(CONFIG_S3C2410)

#define U_M_MDIV 0x48

#define U_M_PDIV 0x3

#endif

#if defined(CONFIG_S3C2440)

#define U_M_MDIV 0x38

#define U_M_PDIV 0x2

#endif

#define U_M_SDIV 0x2

#endif

......

为连接LED和蜂鸣器的GPIO修改配置寄存器:


int board_init (void):

./* set up the I/O ports */

gpio->GPACON = 0x007FFFFF;

#if defined(CONFIG_MINI2440)

gpio->GPBCON = 0x00295551;

#else

gpio->GPBCON = 0x00044555;

#endif

gpio->GPBUP = 0x000007FF;

gpio->GPCCON = 0xAAAAAAAA;

gpio->GPCUP = 0x0000FFFF;

gpio->GPCUP = 0xFFFFFFFF;

gpio->GPDCON = 0xAAAAAAAA;

gpio->GPDUP = 0x0000FFFF;

gpio->GPECON = 0xAAAAAAAA;

gpio->GPDUP = 0xFFFFFFFF;

gpio->GPECON = 0xAAAAAAAA;

gpio->GPEUP = 0x0000FFFF;

gpio->GPFCON = 0x000055AA;

gpio->GPFUP = 0x000000FF;

gpio->GPGCON = 0xFF95FFBA;

gpio->GPGUP = 0x0000FFFF;

gpio->GPHCON = 0x002AFAAA;

gpio->GPHUP = 0x000007FF;

为引导linux 内核,修改开发板的类型代码:


int board_init (void):

......

#if defined(CONFIG_S3C2410)

/* arch number of SMDK2410-Board */

gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;

#endif

#if defined(CONFIG_S3C2440)

/* arch number of S3C2440-Board */

gd->bd->bi_arch_number = MACH_TYPE_S3C2440 ;

#endif


......为使int board_init (void)设置完成后,LED1LED2同时亮起,蜂鸣器继续鸣叫,在int board_init (void)的最后添加: ......

icache_enable();

dcache_enable();

#if defined(CONFIG_MINI2440_LED)

gpio->GPBDAT = 0x00000181;

#endif

return 0;

}


5、最后,修改board/mini2440/u-boot.lds文件,在


cpu/arm920t/start.o (.text)

后加上

board/2440/lowlevel_init.o (.text)

board/2440/nand_read.o (.text)


6,当我将生成的uboot.bin烧到nandflash时,启动开发板,串口不能输出启动信息,通过网上查找资料发现没有定义ubootuboot_ram_base


include/configs/mini2440.h的最后添加如下代码:

/*

* Nandflash Boot

*/

#define CONFIG_S3C2440_NAND_BOOT 1

#define UBOOT_RAM_BASE 0x33f80000


4阶段 修改适合S3C2440的程序

1、修改include/configs/mini2440.h
#define CONFIG_S3C2410 1 /* in a SAMSUNG S3C2410 SoC */
改为:
#define CONFIG_S3C2440 1


2
、将/include/common.h中的
#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_LH7A40X)
改为:
#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_LH7A40X) || defined(CONFIG_S3C2440)

3、修改/include/s3c24x0.h,将文件中所有的
#ifdef CONFIG_S3C2410
改为:
#if defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440)


还有nand 的处理:

/* NAND FLASH (see S3C2410 manual chapter 6) */
typedef struct {
S3C24X0_REG32 NFCONF;
#if defined(CONFIG_S3C2440) //modified for 2440
S3C24X0_REG32 NFCONT;
#endif
S3C24X0_REG32 NFCMD;
S3C24X0_REG32 NFADDR;
S3C24X0_REG32 NFDATA;
S3C24X0_REG32 NFSTAT;
S3C24X0_REG32 NFECC;
} /*__attribute__((__packed__))*/ S3C2410_NAND;


4
、将/cpu/arm920t/s3c24x0/interrupts.c中的
#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB)
修改为:
#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB) || defined (CONFIG_S3C2440)

#elif defined(CONFIG_S3C2410)
改为:
#elif defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440)


5
、将/cpu/arm920t/s3c24x0/serial.c文件中的
#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB)
改为:
#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB) || defined (CONFIG_S3C2440)

#elif defined(CONFIG_S3C2410)
改为:
#elif defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440)
将函数static int serial_init_dev(const int dev_index)中的
uart->UFCON = 0x07;
改为:
uart->UFCON = 0x00;


6
、将/cpu/arm920t/s3c24x0/speed.c中的
#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB)
改为:
#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB) || defined (CONFIG_S3C2440)

#elif defined(CONFIG_S3C2410)
改为:
#elif defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440)
static ulong get_PLLCLK(int pllreg)中的
m = ((r & 0xFF000) >> 12) + 8;

p = ((r & 0x003F0) >> 4) + 2;
s = r & 0x3;
后面加上:
#if defined(CONFIG_S3C2440)
if (pllreg == MPLL)
return((CONFIG_SYS_CLK_FREQ * m * 2) / (p << s));

else if (pllreg == UPLL)
#endif

/* return HCLK frequency */
ulong get_HCLK(void)
{
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();

return((clk_power->CLKDIVN & 0x2) ? get_FCLK()/2 : get_FCLK());
}
改为:
/* return HCLK frequency */
ulong get_HCLK(void)
{
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();

if (clk_power->CLKDIVN & 0x6)
{
if ((clk_power->CLKDIVN & 0x6)==2) return(get_FCLK()/2);
if ((clk_power->CLKDIVN & 0x6)==6) return((clk_power->CAMDIVN & 0x100) ? get_FCLK()/6 : get_FCLK()/3);
if ((clk_power->CLKDIVN & 0x6)==4) return((clk_power->CAMDIVN & 0x200) ? get_FCLK()/8 : get_FCLK()/4);

return(get_FCLK());
}
else
return(get_FCLK());

}


7
/cpu/arm920t/s3c24x0/usb_ohci.c中的
#elif defined(CONFIG_S3C2410)
改为:
#elif defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440)


8、将drivers/rtc/s3c24x0_rtc.c中的
#elif defined(CONFIG_S3C2410)
改为:
#elif defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440)


9、需要在/include/s3c24x0.h文件中添加CAMDIVN定义,将
/* CLOCK & POWER MANAGEMENT (see S3C2400 manual chapter 6) */
/* (see S3C2410 manual chapter 7) */
typedef struct {
S3C24X0_REG32 LOCKTIME;
S3C24X0_REG32 MPLLCON;
S3C24X0_REG32 UPLLCON;
S3C24X0_REG32 CLKCON;
S3C24X0_REG32 CLKSLOW;
S3C24X0_REG32 CLKDIVN;
} /*__attribute__((__packed__))*/ S3C24X0_CLOCK_POWER;
改为:
/* CLOCK & POWER MANAGEMENT (see S3C2400 manual chapter 6) */
/* (see S3C2410 manual chapter 7) */
typedef struct {
S3C24X0_REG32 LOCKTIME;
S3C24X0_REG32 MPLLCON;
S3C24X0_REG32 UPLLCON;
S3C24X0_REG32 CLKCON;
S3C24X0_REG32 CLKSLOW;
S3C24X0_REG32 CLKDIVN;
#if defined (CONFIG_S3C2440)
S3C24X0_REG32 CAMDIVN;
#endif
} /*__attribute__((__packed__))*/ S3C24X0_CLOCK_POWER;


10,修改 lib_arm/board.c 文件

#include

#include

#include

#include

#if 0

/************************************************************************

* Coloured LED functionality

************************************************************************

* May be supplied by boards if desired

*/

void inline __coloured_LED_init (void) {}

void inline coloured_LED_init (void) __attribute__((weak, alias("__coloured_LED_init")));

void inline __red_LED_on (void) {}

void inline red_LED_on (void) __attribute__((weak, alias("__red_LED_on")));

void inline __red_LED_off(void) {}

void inline red_LED_off(void) __attribute__((weak, alias("__red_LED_off")));

void inline __green_LED_on(void) {}

void inline green_LED_on(void) __attribute__((weak, alias("__green_LED_on")));

void inline __green_LED_off(void) {}

void inline green_LED_off(void)__attribute__((weak, alias("__green_LED_off")));

void inline __yellow_LED_on(void) {}

void inline yellow_LED_on(void)__attribute__((weak, alias("__yellow_LED_on")));

void inline __yellow_LED_off(void) {}

void inline yellow_LED_off(void)__attribute__((weak, alias("__yellow_LED_off")));

#endif

static int display_banner (void)

{

printf ("\n\n%s\n\n", version_string);

// #if defined(CONFIG_MINI2440_LED)

// struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio();

// gpio->GPBDAT = 0x101;

// #endif

printf (" modified by Cyclone!\n");

printf (" Love Linux forever!!\n\n");

debug ("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n",

_armboot_start, _bss_start, _bss_end);

#ifdef CONFIG_MODEM_SUPPORT

debug ("Modem Support enabled\n");

#endif

#ifdef CONFIG_USE_IRQ

debug ("IRQ Stack: %08lx\n", IRQ_STACK_START);

debug ("FIQ Stack: %08lx\n", FIQ_STACK_START);

#endif

return (0);

}


到这里,make一下,把u-boot.bin烧到nand flash,重新启动,在串口工具上应该可以看到熟悉的

U-Boot 1.3.4 (Oct 9 2009 - 07:34:33)

DRAM: 64 MB

FlASH:


上面只是将uboot进行了简单的移植,后面还有相应的驱动要添加,移植中有些地方还不完善,欢迎大家指正!


阅读(2511) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~