U-Boot移植:
系統(tǒng):Ubuntu 12.04
開發(fā)板:JZ2440
虛擬機:VM10.04
U-Boot:U-BOOT-1.1.6
步驟:
1、解壓U-BOOT-1.1.6
tar jxvf U-BOOT-1.1.6.tar.bz2
2、同時支持S3C2410和S3C2440:
(1)、新建一個開發(fā)板的相應(yīng)目錄和文件
在board目錄下將smdk2410復(fù)制為100ask24x0,并將board/100ask24x0/smdk2410.c改名為100ask24x0.c,再將include/configs/smdk2410.h復(fù)制為100ask24x0.h
修改兩個Makefile:
1)、在頂層Makefile中增加如個兩行:
100ask24x0_config :unconfig
@$(MKCONFIG) $(@:_config=) arm arm920t 100ask24x0 NULL s3c24x0
2)、在board/100ask24x0/Makefile中修改如下:
COBJS:= smdk2410.o flash.o
改為
COBJS:= 100ask24x0.o flash.o
3、修改SDRAM的配置
SDRAM的初始化在U-Boot的第一階段完成,在board/100ask24x0/lowlevel_init.S中,由于開發(fā)板的HCLK都為100mhz,需該REFCNT寄存器的值。修改如下:
#define REFCNT0x1113
改為
#define REFCNT0x4f4
4、增加對S3C2440的支持
2440的時鐘計算公式、NAND操作和2410不太一樣。
對于2440開發(fā)板,將FCLK設(shè)為400MHz,分頻比為FCLK:HCLK:PCLK=1:4:8。
首先修改board/100ask24x0/100ask24x0.c中的board_init函數(shù):
#define S3C2440_MPLL_400MHZ((0x5c<<12)|(0x02<<4)|(0x01))
#define S3C2440_UPLL_48MHZ((0x38<<12)|(0x02<<4)|(0x02))
#define S3C2440_CLKDIV0x05
#define S3C2410_MPLL_200MHZ((0x5c<<12)|(0x04<<4)|(0x00))
#define S3C2410_UPLL_48MHZ((0x28<<12)|(0x01<<4)|(0x02))
#define S3C2410_CLKDIV0x03
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__("mrcp15, 0, r1, c1, c0, 0n"
"orrr1, r1, #0xc0000000n"
"mcrp15, 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__("mrcp15, 0, r1, c1, c0, 0n"
"orrr1, r1, #0xc0000000n"
"mcrp15, 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;
}
5、修改系統(tǒng)時鐘
在U-Boot的第二階段,設(shè)置串口波特率時需要獲得系統(tǒng)時鐘,lib_arm/board.c中,start_armboot函數(shù)調(diào)用serial_init函數(shù)初始化時會調(diào)用get_PCLK函數(shù)。
在cpu/arm920t/s3c24x0/speed.c中修改:
首先,在程序開頭增加一行DECLARE_GLOBAL_DATA_PTR;,這樣才可以使用gd變量。
S3C2410和S3C2440的MPLL,UPLL計算公式不一樣,所以修改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));
}
由于分頻系數(shù)的設(shè)置方法也不一樣,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_UCLK(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-