一. 准备工作
1. 软硬件
主 机:VMWare--ubuntu 10.10
开发板:TQ2440--128MB Nand, Kernel:3.4.0
编译器:EABI-4.3.3_EmbedSky_20091210.tar.bz2
u-boot:u-boot-2012.07.tar.bz2
2. 工具链,解压EABI-4.3.3_EmbedSky_20091210.tar.bz2到/opt目录
root@ubuntu:~/uboot# ls /opt/EmbedSky/
4.3.3/ crosstools_3.4.5_softfloat/
3. 这次移植是以smdk2410为模版,所以首先要删除多余的目录
//a. 删除arch下除arm以外的所有目录
root@ubuntu:~/uboot/u-boot-2012.07/arch# find . -maxdepth 1 -type d | grep -v arm | xargs rm -rf
//b. arm/cpu下除arm920t以外的所有目录
root@ubuntu:~/uboot/u-boot-2012.07/arch/arm/cpu# find . -maxdepth 1 -type d | grep -v arm920t |xargs rm -rf
//c. arch/arm/cpu/arm920t 录下除s3c24x0以外的所有目录
root@ubuntu:~/uboot/u-boot-2012.07/arch/arm/cpu/arm920t# find . -maxdepth 1 -type d | grep -v s3c24x0 | xargs rm -rf
//d. arch/arm/include/asm下除arch-s3c24x0以外的所有arch-xxxx, proc目录不能删
root@ubuntu:~/uboot/u-boot-2012.07/include/asm# find . -maxdepth 1 -type d | grep -v arch-s3c24x0 | grep -v proc | xargs rm -rf
//e. 删除include/configs目录下除smdk2410.h文件以外的所有头文件
root@ubuntu:~/uboot/u-boot-2012.07/include/configs# ls | grep -v smdk2410.h | xargs rm -rf
//f. 去掉board下多余的目录
root@ubuntu:~/uboot/u-boot-2012.07/board# find . -maxdepth 1 -type d | grep -v samsung | xargs rm -rf
root@ubuntu:~/uboot/u-boot-2012.07/board/samsung# find . -maxdepth 1 -type d | grep -v smdk2410 | xargs rm -rf
4. 生成内存可运行的u-boot
a. 修改Makefile
-
156 ifeq ($(HOSTARCH),$(ARCH))
-
157 CROSS_COMPILE ?=
-
158 endif
-
159
-
160 CROSS_COMPILE ?= /opt/EmbedSky/crosstools_3.4.5_softfloat/gcc-3.4.5-glibc-2.3.6/arm-linux/bin/arm-linux-
b. 修改链接地址 board/samsung/smdk2410/config.mk
-
#烧到板子上TEXT_BASE=0x33d80000
-
25 TEXT_BASE = 0x33d80000
-
#仿真器调试TEXT_BASE=0x33000000
-
26 #TEXT_BASE = 0x33000000
-
#为什么要选这个呢? 因其只要在内存中就可以了,但是因为TQ2440有一个选项
-
[7] Download Program (uCOS-II or TQ2440_Test) to SDRAM and Run it
-
写到内存的0x33000000并运行,这样编出u-boot.bin后,直接写到内存就可以运行了,非常方便.
c.编译,直接用smdk2410的,比较省事
-
make smdk2410_config
-
make
二. 可以从nand_flash启动的u-boot
2.1 初始化内存
修改board/samsung/smdk2410/lowlevel_init.S
L54 #define B1_BWSCON (DW32) > #define B1_BWSCON (DW16)
L58 #define B5_BWSCON (DW16) > #define B5_BWSCON (DW8)
L126 #define REFCNT 1113 > #define REFCNT 0x4F4
2.2 初始化clock_controler ,并将u-boot代码复制到TEXT_BASE处
修改 arch/arm/cpu/arm920t/start.S
/*注掉这一段*/
#if 0
/* FCLK:HCLK:PCLK = 1:2:4 */
/* default FCLK is 120 MHz ! */
ldr r0, =CLKDIVN
mov r1, #3
str r1, [r0]
#endif
#endif /* CONFIG_S3C24X0 */
/*
* we do sys-critical inits only at reboot,
* not when booting from ram!
*/
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
#if 1
bl cpu_init_crit
#endif
#endif
/*把栈初始化提前,因为下面要调用C函数*/
/* Set up the stack */
stack_setup:
ldr r0, _TEXT_BASE /* upper 128 KiB: relocated uboot */
sub r0, r0, #CONFIG_SYS_MALLOC_LEN /* malloc area */
sub r0, r0, #CONFIG_SYS_GBL_DATA_SIZE /* bdinfo */
#ifdef CONFIG_USE_IRQ
sub r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)
#endif
sub sp, r0, #12 /* leave 3 words for abort-stack */
bl clock_init /*调用clock_init,初始化clock*/
bl my_nand_init /*调用my_nand_init,进行nand flash初始化*/
#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 clear_bss
ldr r2, _armboot_start
ldr r3, _bss_start
sub r2, r3, r2 /* r2 <- size of armboot */
#if 1
bl my_nand_read_page /*调用my_nand_read_page,将u-boot从nand复制到TEXT_BASE处*/
#else
add r2, r0, r2 /* r2 <- source end address */
copy_loop:
ldmia r0!, {r3-r10} /* copy from source address [r0] */
stmia r1!, {r3-r10} /* copy to target address [r1] */
cmp r0, r2 /* until source end addreee [r2] */
ble copy_loop
#endif
#endif /* CONFIG_SKIP_RELOCATE_UBOOT */
2.3
a. 在board/samsung/smdk2410目录下建文件boot_init.c,完成初始化clock_controler ,并将u-boot代码复制到TEXT_BASE处的实际操作
b. 在arch/arm/include/asm/arch-s3c24x0/s3c24x0.h中
struct s3c24x0_clock_power {
u32 LOCKTIME;
u32 MPLLCON;
u32 UPLLCON;
u32 CLKCON;
u32 CLKSLOW;
u32 CLKDIVN;
u32 CAMDIVN; /*增加*/
};
b. 同时在board/samsung/smdk2410/Makefile中
COBJS := smdk2410.o flash.o boot_init.o
c.在arch/arm/cpu/arm920t/u-boot.lds中,将lowlevel_init.o和boot_init.o链接到前4K.
.text :
{
arch/arm/cpu/arm920t/start.o (.text) board/samsung/smdk2410/lowlevel_init.o (.text)
board/samsung/smdk2410/boot_init.o (.text) *(.text)
2.4 为了使u-boot启动后打印点东东,还需要修改arch/arm/cpu/arm920t/s3c24x0/speed.c
speed.c.txt (下载后改名为speed.c,替换以前的arch/arm/cpu/arm920t/s3c24x0/speed.c)
2.5. 最后写到内存0x33000000处还需要
a. 修改arch/arm/cpu/arm920t/start.S文件
161 #if 0
162 bl cpu_init_crit
163 #endif
b.修改 board/samsung/smdk2410/config.mk
25 #TEXT_BASE = 0x33d80000
26 TEXT_BASE = 0x33000000
2.6 make后写到内存中.
[参考文章]
阅读(2237) | 评论(0) | 转发(0) |