移植u-boot 1.1.6到TQ2440開發(fā)板-第二階段
移植u-boot 1.1.6到TQ2440開發(fā)板-第二階段
增加uboot對TQ2440的代碼支持
第一步:修改 SDRAM 配置,修改u-boot-1.1.6/board/TQ2440目錄lowlevel_init.S文件
第54行
#define B1_BWSCON
#define B2_BWSCON
#define B3_BWSCON
#define B4_BWSCON
#define B5_BWSCON
#define B6_BWSCON
#define B7_BWSCON
第126行
#define REFCNT
第二步:時鐘設(shè)置,S3c2440 的時鐘計算公式和 s3c2410 不一樣,對于 s3c2440 開發(fā)板,將 PCLK 設(shè)為
400Mhz ,分頻比為 FCLK:HCLK:PCLK=1:4:8,有2種設(shè)定方法,我們使用簡單的一種。
1、首先屏蔽原來 s3c2410 的時鐘設(shè)置,修改 u-boot-1.1.6/cpu/arm920t/ 目錄下 start.S 文件 148 行如下:
#if 0
#endif
2、修改 u-boot-1.1.6/cpu/arm920t/start.S ,將 stack_setup子程序搬到 relocate 子程序之前,因?yàn)樗{(diào)用的 clock_init 函數(shù)需要用到堆棧。
stack_setup:
#ifdef CONFIG_USE_IRQ
#endif
bl
#ifndef CONFIG_SKIP_RELOCATE_UBOOT
relocate:
3、編寫clock_init函數(shù),board/TQ2440 目錄下建議一個名為 boot_init.c 的文件,編寫 colck_init 函數(shù),同時加上一些聲明和延時子函數(shù)
#include
#include
#define GSTATUS1
static inline void delay (unsigned long loops)
{
__asm__ volatile ("1: n"
"subs %0, %1, #1 n"
"bne 1b":"=r" (loops):"0" (loops));
}
#define S3C2440_MPLL_400MHZ
#define S3C2440_MPLL_200MHZ ((0x5c<<12)|(0x01<<4)|(0x02))
#define S3C2440_MPLL_100MHZ ((0x5c<<12)|(0x01<<4)|(0x03))
#define S3C2440_UPLL_96MHZ ((0x38<<12)|(0x02<<4)|(0x01))
#define S3C2440_UPLL_48MHZ ((0x38<<12)|(0x02<<4)|(0x02))
#define S3C2440_CLKDIV (0x05) // | (1<<3))
#define S3C2440_CLKDIV188 0x04
#define S3C2440_CAMDIVN188 ((0<<8)|(1<<9))
#define S3C2410_MPLL_200MHZ
#define S3C2410_UPLL_48MHZ ((0x28<<12)|(0x01<<4)|(0x02))
#define S3C2410_CLKDIV 0x03
void clock_init(void)
{
S3C24X0_CLOCK_POWER *clk_power = (S3C24X0_CLOCK_POWER *)0x4C000000;
if ((GSTATUS1 == 0x32410000)|| (GSTATUS1 == 0x32410002))
{
clk_power- >CLKDIVN = S3C2410_CLKDIV;
__asm__("mrc
"orr r1,r1, #0xc0000000 n"
11
"mcr p15, 0, r1, c1, c0, 0 n"
:::"r1"
);
clk_power- >LOCKTIME = 0xFFFFFFFF;
clk_power- >UPLLCON = S3C2410_UPLL_48MHZ;
delay (4000);
clk_power- >MPLLCON = S3C2410_MPLL_200MHZ;
delay (8000);
}
else
{
clk_power- >CLKDIVN = S3C2440_CLKDIV;
__asm__("mrc
"orr r1,r1, #0xc0000000 n"
"mcr p15, 0, r1, c1, c0, 0 n"
:::"r1"
);
clk_power- >LOCKTIME = 0xFFFFFFFF;
clk_power- >UPLLCON = S3C2440_UPLL_48MHZ;
delay (4000);
clk_power- >MPLLCON = S3C2440_MPLL_400MHZ;
delay (8000);
}
}
4、修改u-boot-1.1.6/board/TQ2440/TQ2440.c 文件中的 board_init 函數(shù)
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 = 0x00055555;
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 = 0xFF94FFBA;
gpio- >GPGUP = 0x0000FFEF;
gpio- >GPGDAT = gpio- >GPGDAT & (~(1<<4)) | (1<<4);
gpio- >GPHCON = 0x002AFAAA;
gpio- >GPHUP = 0x000007FF;
if ((gpio- >GSTATUS1 == 0x32410000) || (gpio- >GSTATUS1 == 0x32410002))
{
gd- >bd- >bi_arch_number = MACH_TYPE_SMDK2410;
}
else
{
gd- >bd- >bi_arch_number = MACH_TYPE_S3C2440;
}
gd- >bd- >bi_boot_params = 0x30000100;
icache_enable();
dcache_enable();
return 0;
}
5、修改u-boot-1.1.6/board/TQ2440的Makefile
COBJS
并在 board/dong2440/u - boot.lds 文件中 35 行添加如下內(nèi)容:
.text
{
cpu/arm920t/start.o
board/TQ2440/boot_init.o
*(.text)
}
以增加對 boot_init.o 的連接。
其它inclu de/s3c24x0.h ,cpu/arm920t/s3c24x0/speed.c
第三步:make
最后 make 一下,沒有錯誤,加載到內(nèi)存中運(yùn)行正常。我的運(yùn)行結(jié)果如下:
U- Boot 1.1.6 (Sep 4 2010
DRAM: 64 MB
Flash: 512 kB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
SMDK2410 # ?
?
autoscr - run script from m emory
base
u - boot 中的提示符“ SMDK2410 #” 可以在/include/configs/dong2440.h 中修改成自己喜歡的
提示符,操作如下:#define
評論