分类: LINUX
2013-05-01 21:26:00
原文地址:uboot 在mini2440上的移植(一) 作者:xinyuwuxian
分类: LINUX
移植环境说明
1,主机环境:VMare下RHEL5
2,编译器:arm-linux-gcc v4.4.3
3,开发板:mini2440,2M nor flash,256M nand flash(自改,原64M),NEC屏。
4,u-boot版本:u-boot-2009.08
参考说明:
(1)本篇文章参考了 Linux公社网站()
原文链接:http:///Linux/2011-05/35982.htm
向作者singleboy表示感谢!
(2)也参考了Tekkaman Ninja的blog文章,http://blog.chinaunix.net/space.php?uid=20543672&do=blog&cuid=2085154,一并表示感谢!
移植步骤:
1.1,了解u-boot目录结构和启动流程,请参考U-Boot启动过程分析
【1】目录结构
【2】启动流程
1.2,建立mini2440开发板文件并编译测试
【1】定位到board,在其目录下建立gy目录,将board/sansung目录下的smdk2410内的所有内容复制到gy目录下,将其重命名为mini2440。
#mkdir -p board/gy/mini2440
#cp -arf ./samsung/smdk2410/* gy/mini2440
【2】打开mini2440目录,将smdk2410.c重命名为mini2440.c,
#cd gy/mini2440/
#mv smdk2410.c mini2440.c
【3】用gedit Makefile定位到28行
include $(TOPDIR)/config.mk
LIB = $(obj)lib$(BOARD).a
COBJS := mini2440.o flash.o
SOBJS := lowlevel_init.o
然后保存。
【4】在根目录下定位到include/configs,将smdk2410.h复制并粘贴到当前目录下,将其重命名为mini2440.h。
#cd include/configs/
#cp ./smdk2410.h ./mini2440.h
【5】根目录下,用gedit Makefile文件,然后搜索smdk2410,定位到2997行,找到下列语句
smdk2410_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 samsung s3c24x0
然后将其复制并粘贴到其下面,并修改成如下语句
mini2440_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t mini2440 gy s3c24x0
*注意:编译选项格式的第二行要用Tab键开始,否则编译会出错。
*说明:
arm :CPU的架构(ARCH);
arm920t:CPU的类型;
mini2440 :开发板型号,对应于board/gy/mini2440目录;
gy:开发者或经销商,对应于board/gy目录;
s3c24x0:SOC定义。
在163行,做如下修改:
CROSS_COMPILE ?= arm-linux- //指定交叉编译器为arm-linux-gcc
【6】编译测试
打开终端,进入到u-boot-2009.08根目录下执行
[root@localhost u-boot-2009.08-2]# make clean
[root@localhost u-boot-2009.08-2]# make mini2440_config
Configuring for mini2440 board...
[root@localhost u-boot-2009.08-2]# make
... .... .... ....
board.c:127: error: inline function 'coloured_LED_init' cannot be declared weak
board.c:129: error: inline function 'red_LED_on' cannot be declared weak
board.c:131: error: inline function 'red_LED_off' cannot be declared weak
board.c:133: error: inline function 'green_LED_on' cannot be declared weak
board.c:135: error: inline function 'green_LED_off' cannot be declared weak
board.c:137: error: inline function 'yellow_LED_on' cannot be declared weak
board.c:139: error: inline function 'yellow_LED_off' cannot be declared weak
board.c:141: error: inline function 'blue_LED_on' cannot be declared weak
board.c:143: error: inline function 'blue_LED_off' cannot be declared weak
make[1]: *** [board.o] 错误 1
make[1]: Leaving directory `/root/workspace/u-boot-2009.08/lib_arm'
make: *** [lib_arm/libarm.a] 错误 2
[root@localhost u-boot-2009.08-2]#
出现错误,内嵌函数不能被声明为weak属性,gedit lib_arm/board.c,定位到127行开始,将其注释掉,修改后结果如下:
#if 0
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")));
void inline __blue_LED_on(void) {}
void inline blue_LED_on(void)__attribute__((weak, alias("__blue_LED_on")));
void inline __blue_LED_off(void) {}
void inline blue_LED_off(void)__attribute__((weak, alias("__blue_LED_off")));
#endif
[root@localhost u-boot-2009.08-2]# make clean
[root@localhost u-boot-2009.08-2]# make
... ...
/home/guoqian/4-2-4/u-boot-2009.08-2/cpu/arm920t/start.S:117: undefined reference to `coloured_LED_init'
/home/guoqian/4-2-4/u-boot-2009.08-2/cpu/arm920t/start.S:118: undefined reference to `red_LED_on'
make: *** [u-boot] Error 1
出现错误coloured_LED_init'未定义。gedit cpu/arm920t/start.S,搜索“coloured_LED_init”定位到117行,找到如下代码:
bl coloured_LED_init
bl red_LED_on
这两行是AT91RM9200DK开发板的LED初始化,注释掉
//bl coloured_LED_init
//bl red_LED_on
然后执行清除、编译命令
[root@localhost u-boot-2009.08-2]# make clean
[root@localhost u-boot-2009.08-2]# make
... ...
arm-linux-objcopy -O srec u-boot u-boot.srec
arm-linux-objcopy --gap-fill=0xff -O binary u-boot u-boot.bin
[root@localhost u-boot-2009.08]#
编译通过。
1.3,根据启动流程修改或添加基本的u-boot源码,使其能够在内存中启动
【1】增加对S3C2440一些寄存器的支持,添加中断禁止部分和时钟设置部分
用gedit cpu/arm920t/start.S,定位到134行附近,如下代码
#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)
/* turn off the watchdog */
由于2410和2440的寄存器及地址大部分是一致的,所以这里就直接在2410的基础上再加上对2440的支持即可,修改后代码如下:
# if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
/* turn off the watchdog */
#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410)
/* 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
... ...
# if defined(CONFIG_S3C2410)
ldr r1, =0x3ff
ldr r0, =INTSUBMSK
str r1, [r0]
# endif
# if defined(CONFIG_S3C2440)//添加s3c2440的中断禁止部分
ldr r1, =0x7fff //根据2440芯片手册,INTSUBMSK寄存器有15位可用
ldr r0, =INTSUBMSK
str r1, [r0]
# endif
# if defined(CONFIG_S3C2440) //添加s3c2440的时钟部分
#define MPLLCON 0x4C000004 //系统主频配置寄存器基地址
#define UPLLCON 0x4C000008 //USB时钟频率配置寄存器基地址
ldr r0, =CLKDIVN //设置分频系数FCLK:HCLK:PCLK = 1:4:8
mov r1, #5
str r1, [r0]
ldr r0, =MPLLCON //设置系统主频为405MHz
ldr r1, =0x7F021 //这个值参考芯片手册“PLL VALUE SELECTION TABLE”部分
str r1, [r0]
ldr r0, =UPLLCON //设置USB时钟频率为48MHz
ldr r1, =0x38022 //这个值参考芯片手册“PLL VALUE SELECTION TABLE”部分
str r1, [r0]
# else //其他开发板的时钟部分
/* FCLK:HCLK:PCLK = 1:2:4 */
/* default FCLK is 202.8 MHz ! */
ldr r0, =CLKDIVN
mov r1, #3
str r1, [r0]
ldr r0, =MPLLCON //设置系统主频为202.8MHz
ldr r1, =0xa1031 //这个值参考芯片手册“PLL VALUE SELECTION TABLE”部分
str r1, [r0]
# endif
#endif /* CONFIG_S3C2400 || CONFIG_S3C2410 || CONFIG_S3C2440 */
【2】S3C2440的时钟部分除了在start.S中添加外,还要分别在board/samsung/mini2440/mini2440.c和cpu/arm920t/s3c24x0/speed.c中修改或添加部分代码。
(1)用gedit board/gy/mini2440/mini2440.c (gedit board/samsung/mini2440/mini2440.c),定位到33行,修改或添加如下内容:
//设置主频和USB时钟频率参数与start.S中的一致
#define FCLK_SPEED 2 //设置默认等于2
#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 */
#define M_MDIV 0xA1
#define M_PDIV 0x3
#define M_SDIV 0x1
#elif FCLK_SPEED==2 /* Fout = 405MHz */
#define M_MDIV 0x7F //这三个值根据S3C2440芯片手册“PLL VALUE SELECTION TABLE”部分进行设置
#define M_PDIV 0x2
#define M_SDIV 0x1
#endif
#define USB_CLOCK 2 //设置默认等于2
#if USB_CLOCK==0
#define U_M_MDIV 0xA1
#define U_M_PDIV 0x3
#define U_M_SDIV 0x1
#elif USB_CLOCK==1
#define U_M_MDIV 0x48
#define U_M_PDIV 0x3
#define U_M_SDIV 0x2
#elif USB_CLOCK==2 /* Fout = 48MHz */
#define U_M_MDIV 0x38 //这三个值根据S3C2440芯片手册“PLL VALUE SELECTION TABLE”部分进行设置
#define U_M_PDIV 0x2
#define U_M_SDIV 0x2
#endif
(2)用gedit cpu/arm920t/s3c24x0/speed.c,定位到70行加入如下代码
1.
m = ((r & 0xFF000) >> 12) + 8;
p = ((r & 0x003F0) >> 4) + 2;
s = r & 0x3;
//根据设置的分频系数FCLK:HCLK:PCLK = 1:4:8修改获取时钟频率的函数
#if defined(CONFIG_S3C2440)
if(pllreg == MPLL)//参考S3C2440芯片手册上的公式:PLL=(2 * m * Fin)/(p * 2s)
return((CONFIG_SYS_CLK_FREQ * m * 2) / (p << s));
//else if (pllreg == UPLL) //warning: control reaches end of non-void function
#endif
return((CONFIG_SYS_CLK_FREQ * m) / (p << s));
为什么要再返回时加一个判断呢?因为在2440中MPLL的时钟为UPLL时钟的2倍,在s3c2440的数据手册里的227页这样写到MPLL和UPLL的计算方法
MPLL Control Register
Mpll = (2 * m * Fin) / (p * 2s)
m = (MDIV + 8), p = (PDIV + 2), s = SDIV
UPLL Control Register
Upll = (m * Fin) / (p * 2s)
m = (MDIV + 8), p = (PDIV + 2), s = SDIV
这个就是修改此函数的缘由。
2.于S3C2410和S3C2440的设置方法也不一样,所以get_HCLK函数也需要修改:
87行:
/* return HCLK frequency */
ulong get_HCLK(void)
{
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
#if defined(CONFIG_S3C2440)
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());
#else
return((clk_power->CLKDIVN & 0x2) ? get_FCLK()/2 : get_FCLK());
#endif
}
这里用到了将在include/s3c24x0.h文件里所添加的CAMDIVN 项,因为这一项的值决定了我们的时钟配置。
这样修改的原因是在s3c2440的数据手册的231页有这样一段话:
CLOCK DIVIDER CONTROL (CLKDIVN) REGISTER
Register Address R/W Description Reset Value
CLKDIVN 0x4C000014 R/W Clock divider control register 0x00000000
CLKDIVN Bit Description
DIVN_UPLL [3] UCLK select register(UCLK must be 48MHz for USB)
0:UCLK = UPLL clock
1:UCLK = UPLL clock / 2
Set to 0, when UPLL clock is set as 48Mhz
Set to 1. when UPLL clock is set as 96Mhz.
HDIVN [2:1] 00 : HCLK = FCLK/1.
01 : HCLK = FCLK/2.
10 : HCLK = FCLK/4 when CAMDIVN[9] = 0.
HCLK= FCLK/8 when CAMDIVN[9] = 1.
11 : HCLK = FCLK/3 when CAMDIVN[8] = 0.
HCLK = FCLK/6 when CAMDIVN[8] = 1.
PDIVN [0] 0: PCLK has the clock same as the HCLK/1.
1: PCLK has the clock same as the HCLK/2.
我们到底应该返回FCLK的几分之一在这里就有秒数,其中必须根据HDIVN 的值与CAMDIVN的值来判断。
【3】加入LED进度指示,增加控制台显示信息
作用是显示代码进度,对 Debug 有帮助。
(1)代码在跳转到第二阶段代码start_armboot 函数前亮起LED1, gedit cpu/arm920t/start.S,定位到240行附近,修改如下:
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)
//根据mini2440原理图可知LED分别由S3C2440的PB5、6、7、8口来控制,
//以下是PB端口寄存器基地址(查2440的DataSheet得知)
#define GPBCON 0x56000010
#define GPBDAT 0x56000014
#define GPBUP 0x56000018
//以下对寄存器的操作参照S3C2440的DataSheet进行操作
ldr r0, =GPBUP
ldr r1, =0x7FF //即:二进制11111111111,关闭PB口上拉
str r1, [r0]
ldr r0, =GPBCON //配置PB5、6、7、8为输出口,对应PBCON寄存器的第10-17位
ldr r1, =0x154FD //即:二进制010101010011111101
str r1, [r0]
ldr r0, =GPBDAT
ldr r1, =0x1C0 //即:二进制111000000,PB5设为低电平,6、7、8为高电平
str r1, [r0]
#endif
//此段代码使u-boot启动后,开发板上的LED1被点亮,而LED2、LED3、LED4不亮
_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_init函数初始化时的点亮LED2,修改如下:
gedit board/gy/mini2440/mini2440.c,定位到100行附近,修改如下:
/* 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 = 0xFFFFFFFF;
gpio->GPDCON = 0xAAAAAAAA;
gpio->GPDUP = 0xFFFFFFFF;
gpio->GPECON = 0xAAAAAAAA;
gpio->GPEUP = 0x0000FFFF;
gpio->GPFCON = 0x000055AA;
gpio->GPFUP = 0x000000FF;
gpio->GPGCON = 0xFF95FFBA;
gpio->GPGUP = 0x0000FFFF;
gpio->GPHCON = 0x0016FAAA;
gpio->GPHUP = 0x000007FF;
gpio->EXTINT0=0x22222222;
gpio->EXTINT1=0x22222222;
gpio->EXTINT2=0x22222222;
/* arch number of SMDK2410-Board */
gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
/* adress of boot parameters */
gd->bd->bi_boot_params = 0x30000100;
#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 ;
gd->bd->bi_arch_number = MACH_TYPE_MINI2440;
#endif
icache_enable();
dcache_enable();
#if defined(CONFIG_MINI2440_LED)
gpio->GPBDAT = 0x00000181;//GPB0=buzzer(1 on)
#endif
return 0;
}
int dram_init (void)
{
gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
return 0;
}
(3)在初始化console后点亮LED3,进入命令行之前点亮LED4。
gedit lib_arm/board.c,定位到52行,修改如下:
#include
#include
#include
#include
#ifdef CONFIG_DRIVER_SMC91111
定位到171行附近:修改如下:
static int display_banner (void)
{
#if defined(CONFIG_MINI2440_LED)
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
gpio->GPBDAT = 0x101; // LED3 on
#endif
printf ("\n\n%s\n\n", version_string);
printf (" modified by gy (robinfit01@163.com)\n"); //display on serial console
printf (" Love Linux and pore 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);
}
定位到314行附近:修改如下:
#if defined(CONFIG_VFD) || defined(CONFIG_LCD)
unsigned long addr;
#endif
#if defined(CONFIG_MINI2440_LED)
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
#endif
/* Pointer is writable since we allocated a register for it */
gd = (gd_t*)(_armboot_start - CONFIG_SYS_MALLOC_LEN - sizeof(gd_t));
/* compiler optimization barrier needed for GCC >= 3.4 */
__asm__ __volatile__("": : :"memory");
定位到479行附近,修改如下:
#if defined(CONFIG_RESET_PHY_R)
debug ("Reset Ethernet PHY\n");
reset_phy();
#endif
#endif
#if defined(CONFIG_MINI2440_LED)
gpio->GPBDAT = 0x00; //4LED all on
#endif
/* main_loop() can return to retry autoboot, if so just run it again. */
for (;;) {
main_loop ();
}
【4】如果这时进行编译,是不能通过的,对于S3C2440,很多代码是借用S3C2410 的,所以要在所有条件编译中有CONFIG_S3C2410 的地方添CONFIG_S3C2440,这样这些代码才会编译进来。一个简单的方法就是在代码中搜索出所有的CONFIG_S3C2410,并根据实际情况修改。但要注意不是所有的2410的寄存器都和2440兼容,还必须根据两个芯片的不同来分布做出修改,比如PLL的操作代码和NAND Flash Controller的操作代码。现分别修改如下:
(1) gedit include/common.h,定位到496行,修改结果如下:
#ifdef CONFIG_4xx
ulong get_OPB_freq (void);
ulong get_PCI_freq (void);
#endif
#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440) || \
defined(CONFIG_LH7A40X) || defined(CONFIG_S3C6400)
ulong get_FCLK (void);
ulong get_HCLK (void);
(2) gedit include/s3c24x0.h文件,分别定位到85、95、99、110、148、404行,将
#ifdef CONFIG_S3C2410改为
//gy
#if defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440)
然后在下面结构中加入2440 的NAND FLASH 的数据结构成员CAMDIVN定义(第128行附近):
/* 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;
这个结构是用来封装时钟寄存器的,我们要在其中增加一项CAMDIVN寄存器是2410所没有的,而2440在配置时钟的时候又必须用到,看名字我们就知道是用来配置CAMERA时钟的,也就是配置摄像头的时钟的。
加入Nand flash寄存器定义(第160行附近):
#if defined(CONFIG_S3C2410)
/* NAND FLASH (see S3C2410 manual chapter 6) */
typedef struct {
S3C24X0_REG32 NFCONF;
S3C24X0_REG32 NFCMD;
S3C24X0_REG32 NFADDR;
S3C24X0_REG32 NFDATA;
S3C24X0_REG32 NFSTAT;
S3C24X0_REG32 NFECC;
} /*__attribute__((__packed__))*/ S3C2410_NAND;
#endif
#if defined (CONFIG_S3C2440)
/* NAND FLASH (see S3C2440 manual chapter 6) */
typedef struct {
S3C24X0_REG32 NFCONF;
S3C24X0_REG32 NFCONT;
S3C24X0_REG32 NFCMD;
S3C24X0_REG32 NFADDR;
S3C24X0_REG32 NFDATA;
S3C24X0_REG32 NFMECCD0;
S3C24X0_REG32 NFMECCD1;
S3C24X0_REG32 NFSECCD;
S3C24X0_REG32 NFSTAT;
S3C24X0_REG32 NFESTAT0;
S3C24X0_REG32 NFESTAT1;
S3C24X0_REG32 NFMECC0;
S3C24X0_REG32 NFMECC1;
S3C24X0_REG32 NFSECC;
S3C24X0_REG32 NFSBLK;
S3C24X0_REG32 NFEBLK;
} /*__attribute__((__packed__))*/ S3C2410_NAND;
#endif
(3) gedit cpu/arm920t/s3c24x0/interrupts.c文件,定位到第36行作如下修改:
#if defined(CONFIG_S3C2400)
#include
#elif defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440)
#include
#endif
(4) gedit cpu/arm920t/s3c24x0/timer.c文件分别定位到33行和37行,修改如下:
#include
#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440) || defined(CONFIG_TRAB)
#if defined(CONFIG_S3C2400)
#include
#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
#include
#endif
在180行添加:
#if defined(CONFIG_SMDK2400) || defined(CONFIG_TRAB)
tbclk = timer_load_val * 100;
#elif defined(CONFIG_SBC2410X) || \
defined(CONFIG_SMDK2410) || \
defined(CONFIG_MINI2440) || \
defined(CONFIG_VCMA9)
tbclk = CONFIG_SYS_HZ;
#else
# error "tbclk not configured"
#endif
(5) gedit cpu/arm920t/s3c24x0/speed.c,分别定位到33行和37行,修改如下:
#include
#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440) || defined(CONFIG_TRAB)
#if defined(CONFIG_S3C2400)
#include
#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
#include
#endif
(6) gedit cpu/arm920t/s3c24x0/usb.c文件,定位到第27、31行:
#if defined(CONFIG_USB_OHCI_NEW) && defined(CONFIG_SYS_USB_OHCI_CPU_INIT)
# if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
#if defined(CONFIG_S3C2400)
# include
#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
# include
#endif
(7) gedit drivers/serial/serial_s3c24x0.c,定位到24行,修改如下:
#include
#if defined(CONFIG_S3C2400) || defined(CONFIG_TRAB)
#include
#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
#include
#endif
(8) gedit drivers/rtc/s3c24x0_rtc.c文件,定位到第35行:
#if defined(CONFIG_S3C2400)
#include
#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
#include
#endif
(9) gedit drivers/i2c/s3c24x0_i2c.c文件,定位到32行:
#include
#if defined(CONFIG_S3C2400)
#include
#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)
#include
#endif
#include
再分别定位到第63、82、139、147、171行:将#ifdef CONFIG_S3C2410 改为红色部分
#if defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440) //gy
return (gpio->GPEDAT & 0x8000) >> 15;
#endif
... ...
#if defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440) //#ifdef CONFIG_S3C2410
gpio->GPEDAT = (gpio->GPEDAT & ~0x4000) | (x&1) << 14;
#endif
... ...
#if defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440) //modified by gy#ifdef CONFIG_S3C2410
ulong old_gpecon = gpio->GPECON;
... ...
#if defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440) //#ifdef CONFIG_S3C2410
/* set I2CSDA and I2CSCL (GPE15, GPE14) to GPIO */
gpio->GPECON = (gpio->GPECON & ~0xF0000000) | 0x10000000;
#endif
... ...
/* restore pin functions */
#if defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440) //#ifdef CONFIG_S3C2410
gpio->GPECON = old_gpecon;
#endif
【5】用gedit include/configs/mini2440.h头文件,在36行添加CONFIG_S3C2440宏,修改后代码如下所示
#define CONFIG_ARM920T 1 /* This is an ARM920T Core */
//#define CONFIG_S3C2410 1 /* in a SAMSUNG S3C2410 SoC */
//#define CONFIG_SMDK2410 1 /* on a SAMSUNG SMDK2410 Board */
#define CONFIG_S3C2440 1 /* in a SAMSUNG S3C2440 SoC */
#define CONFIG_MINI2440 1 /* on a SAMSUNG MINI2440 Board */
#define CONFIG_MINI2440_LED 1 /* mini2440 led on/off */
/* input clock of PLL */
#define CONFIG_SYS_CLK_FREQ 12000000/* the SMDK2410 has 12MHz input clock */
【6】为了能够让u-boot.bin下载到内存中运行,需要注释掉CPU和DRAM初始化部分
(注意:我们使用supervivi进行下载时已经对CPU、RAM进行了初始化,所以我们在u-boot中要屏蔽掉对CPU、RAM的初始化)
用gedit cpu/arm920t/start.S,定位到201行
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
bl cpu_init_crit
#endif
将其注释掉,屏蔽u-boot对CPU、RAM的初始化
//#ifndef CONFIG_SKIP_LOWLEVEL_INIT
//bl cpu_init_crit
//#endif
1.3重新编译,运行测试
[root@localhost u-boot-2009.08-2]# make clean
Generating include/autoconf.mk
[root@localhost u-boot-2009.08-2]# make mini2440_config
[root@localhost u-boot-2009.08-2]# make
... ...
编译完成之后,利用mini2440自带的supervivi将根目录u-boot-2009.08-2下的u-boot.bin文件下载到DRAM中运行测试。确认开发板与主机之间的串口线和usb线已经正确连接,给开发板上电,在suppervivi启动完成后,在与开发板相连的终端中执行如下命令:
##### FriendlyARM BIOS 2.0 for 2440 #####
[x] format NAND FLASH for Linux
[v] Download vivi
[k] Download linux kernel
[y] Download root_yaffs image
[a] Absolute User Application
[n] Download Nboot for WinCE
[l] Download WinCE boot-logo
[w] Download WinCE NK.bin
[d] Download & Run
[z] Download zImage into RAM
[g] Boot linux from RAM
[f] Format the nand flash
[b] Boot the system
[s] Set the boot parameters
[u] Backup NAND Flash to HOST through USB(upload)
[r] Restore NAND Flash from HOST through USB
[q] Goto shell of vivi
[i] Version: 0945-2K
Enter your selection: d
Clear the free memory
USB host is connected. Waiting a download.
Now, Downloading [ADDRESS:31000000h,TOTAL:100090]
RECEIVED FILE SIZE: 100090 (97KB/S, 1S)
ownloaded file at 0x30000000, size = 100080 bytes
U-Boot 2009.08 (Jul 25 2011 - 06:03:18)
modified by gy (robinfit01@163.com)
Love Linux and pore forever!!
DRAM: 64 MB
Flash: 512 kB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
SMDK2410 #
到此可以看到u-boot的版本和编译时间U-Boot 2009.08 (Jul 25 2011 - 06:03:18),以及还未修改的提示符SMDK2410 #。同时还可以看到开发板上的四个LED全亮,有关Warning ...相关的告警信息,将在下一节解决。
接下来将进入u-boot的第二阶段,为u-boot-2009.08增加norflash支持。