U-boot源码结构
图片来自韦东山的《嵌入式linux应用开发完全手册》
U-boot下载地址:ftp://ftp.denx.de/pub/u-boot/
交叉编译工具链 3.3.2
U-boot移植
1.新建一个fl2440开发板目录和文件
①在board目录下新建fl2440目录,讲smdk2410目录下的文件复制到fl2440目录下,并将board/fl2440/smdk2410.c重命名为fl2440.c
②修改u-boot-1.1.6目录下Makefile文件
smdk2410_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t smdk2410 NULL s3c24x0
后面加上
fl2410_config : unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t fl2410 NULL s3c24x0
然后在board/fl2440/Makefile中修改
COBJS := smdk2410.o flash.o 为 COBJS := fl2440.o flash.o
2.修改SDRAM的配置
①修改board/fl2440/lowlevel_init.s文件中的126行
#define REFCNT 0x4f4
②
修改board/fl2440/fl2440.c中的board_init函数,即替换掉整个函数board_init包括它本身的所有语句。
#define S3C2440_MPLL_400MHZ ((0x7f<<12)|(0x02<<4)|(0x01))
#define S3C2440_UPLL_48MHZ ((0x38<<12)|(0x02<<4)|(0x02))
#define S3C2440_CLKDIV 0x05
#define S3C2410_MPLL_200MHZ ((0x5c<<12)|(0x04<<4)|(0x00))
#define S3C2410_UPLL_48MHZ ((0x28<<12)|(0x01<<4)|(0x02))
#define S3C2410_CLKDIV 0x03
int board_init (void)
{
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
gpio->GPACON = 0x007FFFFF;
gpio->GPBCON = 0x00044555;
gpio->GPBUP = 0x000007FF;
gpio->GPCCON = 0xAAAAAAAA;
gpio->GPCUP = 0x0000FFFF;
gpio->GPDCON = 0xAAAAAAAA;
gpio->GPDUP = 0x0000FFFF;
gpio->GPECON = 0xAAAAAAAA;
gpio->GPEUP = 0x0000FFFF;
gpio->GPFCON = 0x000055AA;
gpio->GPFUP = 0x000000FF;
gpio->GPGCON = 0xFF95FFBA;
gpio->GPGUP = 0x0000FFFF;
gpio->GPHCON = 0x002AFAAA;
gpio->GPHUP = 0x000007FF;
if ((gpio->GSTATUS1 == 0x32410000) || (gpio->GSTATUS1 == 0x32410002))
{
clk_power->CLKDIVN = S3C2410_CLKDIV;
__asm__( "mrc p15, 0, r1, c1, c0, 0n"
"orr r1, r1, #0xc0000000n"
"mcr p15, 0, r1, c1, c0, 0n"
:::"r1"
);
clk_power->LOCKTIME = 0xFFFFFF;
clk_power->MPLLCON = S3C2410_MPLL_200MHZ;
delay (4000);
clk_power->UPLLCON = S3C2410_UPLL_48MHZ;
delay (8000);
gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
}
else
{
clk_power->CLKDIVN = S3C2440_CLKDIV;
__asm__( "mrc p15, 0, r1, c1, c0, 0n"
"orr r1, r1, #0xc0000000n"
"mcr p15, 0, r1, c1, c0, 0n"
:::"r1"
);
clk_power->LOCKTIME = 0xFFFFFF;
clk_power->MPLLCON = S3C2440_MPLL_400MHZ;
delay (4000);
clk_power->UPLLCON = S3C2440_UPLL_48MHZ;
delay (8000);
gd->bd->bi_arch_number = MACH_TYPE_S3C2440;
}
gd->bd->bi_boot_params = 0x30000100;
icache_enable();
dcache_enable();
return 0;
}
③S3C2410和S3C2440的MPLL,UPLL计算公式不一样,所以get_PLLCLK函数也需要修改
在cpu/arm920t/s3c24X0/speed.c中修改:
修改get_PLLCLK函数:
static ulong get_PLLCLK(int pllreg)
{
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
ulong r, m, p, s;
if (pllreg == MPLL)
r = clk_power->MPLLCON;
else if (pllreg == UPLL)
r = clk_power->UPLLCON;
else
hang();
m = ((r & 0xFF000) >> 12) + 8;
p = ((r & 0x003F0) >> 4) + 2;
s = r & 0x3;
if (gd->bd->bi_arch_number == MACH_TYPE_SMDK2410)
return((CONFIG_SYS_CLK_FREQ * m) / (p << s));
else
return((CONFIG_SYS_CLK_FREQ * m * 2) / (p << s));
}
即在get_PLLCLK函数下加入上面的红色字体。
修改get_HCLK, get_PCLK(直接粘贴下面代码,来把这个两个函数覆盖掉):
#define S3C2440_CLKDIVN_PDIVN (1<<0)
#define S3C2440_CLKDIVN_HDIVN_MASK (3<<1)
#define S3C2440_CLKDIVN_HDIVN_1 (0<<1)
#define S3C2440_CLKDIVN_HDIVN_2 (1<<1)
#define S3C2440_CLKDIVN_HDIVN_4_8 (2<<1)
#define S3C2440_CLKDIVN_HDIVN_3_6 (3<<1)
#define S3C2440_CLKDIVN_ LK (1<<3)
#define S3C2440_CAMDIVN_CAMCLK_MASK (0xf<<0)
#define S3C2440_CAMDIVN_CAMCLK_SEL (1<<4)
#define S3C2440_CAMDIVN_HCLK3_HALF (1<<8)
#define S3C2440_CAMDIVN_HCLK4_HALF (1<<9)
#define S3C2440_CAMDIVN_DVSEN (1<<12)
ulong get_HCLK(void)
{
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
unsigned long clkdiv;
unsigned long camdiv;
int hdiv = 1;
if (gd->bd->bi_arch_number == MACH_TYPE_SMDK2410)
return((clk_power->CLKDIVN & 0x2) ? get_FCLK()/2 : get_FCLK());
else
{
clkdiv = clk_power->CLKDIVN;
camdiv = clk_power->CAMDIVN;
switch (clkdiv & S3C2440_CLKDIVN_HDIVN_MASK) {
case S3C2440_CLKDIVN_HDIVN_1:
hdiv = 1;
break;
case S3C2440_CLKDIVN_HDIVN_2:
hdiv = 2;
break;
case S3C2440_CLKDIVN_HDIVN_4_8:
hdiv = (camdiv & S3C2440_CAMDIVN_HCLK4_HALF) ? 8 : 4;
break;
case S3C2440_CLKDIVN_HDIVN_3_6:
hdiv = (camdiv & S3C2440_CAMDIVN_HCLK3_HALF) ? 6 : 3;
break;
}
return get_FCLK() / hdiv;
}
}
ulong get_PCLK(void)
{
S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
unsigned long clkdiv;
unsigned long camdiv;
int hdiv = 1;
if (gd->bd->bi_arch_number == MACH_TYPE_SMDK2410)
return((clk_power->CLKDIVN & 0x1) ? get_HCLK()/2 : get_HCLK());
else
{
clkdiv = clk_power->CLKDIVN;
camdiv = clk_power->CAMDIVN;
switch (clkdiv & S3C2440_CLKDIVN_HDIVN_MASK) {
case S3C2440_CLKDIVN_HDIVN_1:
hdiv = 1;
break;
case S3C2440_CLKDIVN_HDIVN_2:
hdiv = 2;
break;
case S3C2440_CLKDIVN_HDIVN_4_8:
hdiv = (camdiv & S3C2440_CAMDIVN_HCLK4_HALF) ? 8 : 4;
break;
case S3C2440_CLKDIVN_HDIVN_3_6:
hdiv = (camdiv & S3C2440_CAMDIVN_HCLK3_HALF) ? 6 : 3;
break;
}
return get_FCLK() / hdiv / ((clkdiv & S3C2440_CLKDIVN_PDIVN)? 2:1);
}
}
重新执行make fl2440_config make all 生成u-boot.bin,由于还没有增加NAND Flash的支持,所以可烧入NOR Flash中运行
在make all时会出现错误:没有CAMDIVN
这个要在include/s3c24x0.h头文件中定义,在129行S3C24X0_CLOCK_POWER结构体中增加:S3C24X0_REG32 CAMDIVN;
现在执行 make fl2440_config 和 make all生成U-Boot.bin就可以烧入norflash了。
相关文章