开发环境:
开发板 FriendlyARM Tiny6410
主机 CentOS release 6.4 (Final)
参考:
http://www.cnblogs.com/plinx/archive/2013/03/15/2960925.html
http://www.cnblogs.com/plinx/archive/2013/04/11/2963823.html
http://www.cnblogs.com/plinx/archive/2013/04/13/3015851.html
http://wenku.baidu.com/view/a4d3f5320b4c2e3f572763d5.html
u-boot的2010.03版本最接近三星定制的s3c-u-boot-1.1.6版本,所以选此版本尝试移植。对于arm11架构的芯片,u-boot-2010.03仅支持6400,我们可以复制并修改6400的相关文件,使u-boot支持6410。
1.获得源码
到http://ftp.denx.de/pub/u-boot/下载u-boot-2010.03.tar.bz2,解压。
2.首次编译
在u-boot根目录配置并编译
make smdk6400_config
make
编译成功,在u-boot根目录下生成的u-boot.bin即为u-boot镜像。
3.文件添加
make clean
3.1)board目录
cd board/samsung/
mkdir smdk6410
cp smdk6400/* smdk6410/
cd smdk6410
mv smdk6400.c smdk6410.c
将目录下所有文件中的。
查找board/samsung/smdk6410目录下含有“6400”的文件,将这些文件中的“6400”替换成“6410”。vim下的替换命令是“:%s/6400/6410/g”。
[root@tanghuimin smdk6410]# find . -name '*' | xargs grep '6400'
./Makefile:COBJS-y := smdk6400.o
./lowlevel_init.S:#include
./lowlevel_init.S: /* r1 = physical address of s3c6400_cpu_resume function */
./lowlevel_init.S: /* Jump to kernel (sleep-s3c6400.S) */
./lowlevel_init.S: * seem to make much sense on S3C6400.
./lowlevel_init.S:#ifndef CONFIG_S3C6400
./lowlevel_init.S:#elif !defined(CONFIG_S3C6400)
./lowlevel_init.S: /* According to 661558um_S3C6400X_rev10.pdf 0x20 is reserved */
./lowlevel_init.S: * NAND Interface init for SMDK6400
./lowlevel_init.S: * MMU Table for SMDK6400
./config.mk:# SAMSUNG SMDK6400 board with mDirac3 (ARM1176) cpu
./config.mk:# On SMDK6400 we use the 64 MB SDRAM bank at
./smdk6410.c:#include
./smdk6410.c: printf('Board: SMDK6400n');
./smdk6410.c:ulong virt_to_phy_smdk6400(ulong addr)
[root@tanghuimin smdk6410]#
3.2)cpu目录
查找cpu/arm1176目录下含有“6400”的文件,将这些文件中的“6400”替换成“6410”。vim下的替换命令是“:%s/6400/6410/g”。
[root@tanghuimin arm1176]# pwd
/home/thm/u-boot/u-boot-2010.03/cpu/arm1176
[root@tanghuimin arm1176]#
[root@tanghuimin arm1176]# find . -name '*' | xargs grep '6400'
./s3c64xx/Makefile:COBJS-$(CONFIG_S3C6400) += cpu_init.o speed.o
./s3c64xx/timer.c:#include
./s3c64xx/speed.c:#include
./s3c64xx/speed.c: * Bit 7 exists on s3c6410, and not on s3c6400, it is reserved on
./s3c64xx/speed.c: * s3c6400 and is always 0, and it is indeed running in ASYNC mode
./s3c64xx/speed.c: printf('nCPU: S3C6400@%luMHzn', get_ARMCLK() / 1000000);
./s3c64xx/reset.S:#include
./s3c64xx/cpu_init.S: * Originates from Samsung's u-boot 1.1.6 port to S3C6400 / SMDK6400
./s3c64xx/cpu_init.S:#include
./.depend: /home/thm/u-boot/u-boot-2010.03/include/configs/smdk6400.h
./.depend: /home/thm/u-boot/u-boot-2010.03/include/asm/arch/s3c6400.h
./.depend: /home/thm/u-boot/u-boot-2010.03/include/configs/smdk6400.h
./.depend: /home/thm/u-boot/u-boot-2010.03/include/asm/arch/s3c6400.h
./start.S: * armboot - Startup Code for S3C6400/ARM1176 CPU-core
./start.S:#include
./cpu.c:#include
3.3)nand_spl目录
cd nand_spl/board/samsung/
mkdir smdk6410
cp smdk6400/* smdk6410/
cd smdk6410
查找nand_spl/board/samsung/smdk6410目录下含有“6400”的文件,将这些文件中的“6400”替换成“6410”。vim下的替换命令是“:%s/6400/6410/g”。
[root@tanghuimin smdk6410]# pwd
/home/thm/u-boot/u-boot-2010.03/nand_spl/board/samsung/smdk6410
[root@tanghuimin smdk6410]#
[root@tanghuimin smdk6410]# find . -name '*'| xargs grep '6400'
./Makefile: @ln -s $(TOPDIR)/board/samsung/smdk6400/lowlevel_init.S $@
./lowlevel_init.S:#include
./lowlevel_init.S: /* r1 = physical address of s3c6400_cpu_resume function */
./lowlevel_init.S: /* Jump to kernel (sleep-s3c6400.S) */
./lowlevel_init.S: * seem to make much sense on S3C6400.
./lowlevel_init.S:#ifndef CONFIG_S3C6400
./lowlevel_init.S:#elif !defined(CONFIG_S3C6400)
./lowlevel_init.S: /* According to 661558um_S3C6400X_rev10.pdf 0x20 is reserved */
./lowlevel_init.S: * NAND Interface init for SMDK6400
./lowlevel_init.S: * MMU Table for SMDK6400
./s3c64xx.c:#include
./config.mk:# Samsung S3C64xx Reference Platform (smdk6400) board
[root@tanghuimin smdk6410]#
3.4)添加头文件smdk6410.h
cd include/configs
cp smdk6400.h smdk6410.h
vim smdk6410.h
:%s/6400/6410/g
3.5)添加头文件s3c6410.h
cd include/asm-arm/arch-s3c64xx/
cp s3c6400.h s3c6410.h
vim s3c6410.h
:%s/6400/6410/g
并且修改
#include 's3c64x0.h'
为
#include './asm/arch/s3c64x0.h'
3.6)修改根目录下mkconfig
if [ '$2' = 'arm' ] ; then
rm -f asm-$2/proc
ln -s ${LNPREFIX}proc-armv asm-$2/proc
fi
if [ '$1' = 'smdk6410' ]; then
rm -f regs.h
ln -s asm-$2/arch/s3c6410.h regs.h
fi
3.7)修改根目录下Makefile
搜索6400可以看到smdk6400的配置项,复制smdk6400的配置项并把6400改为6410。
#########################################################################
## ARM1176 Systems
#########################################################################
smdk6400_noUSB_config
smdk6400_config : unconfig
@mkdir -p $(obj)include $(obj)board/samsung/smdk6400
@mkdir -p $(obj)nand_spl/board/samsung/smdk6400
@echo '#define CONFIG_NAND_U_BOOT' > $(obj)include/config.h
@if [ -z '$(findstring smdk6400_noUSB_config,$@)' ]; then
echo 'RAM_TEXT = 0x57e00000' >> $(obj)board/samsung/smdk6400/config.tmp;
$(MKCONFIG) $(@:_config=) arm arm1176 smdk6400 samsung s3c64xx;
else
echo 'RAM_TEXT = 0xc7e00000' >> $(obj)board/samsung/smdk6400/config.tmp;
$(MKCONFIG) $(@:_noUSB_config=) arm arm1176 smdk6400 samsung s3c64xx;
fi
@echo 'CONFIG_NAND_U_BOOT = y' >> $(obj)include/config.mk
smdk6410_noUSB_config
smdk6410_config : unconfig
@mkdir -p $(obj)include $(obj)board/samsung/smdk6410
@mkdir -p $(obj)nand_spl/board/samsung/smdk6410
@echo '#define CONFIG_NAND_U_BOOT' > $(obj)include/config.h
@if [ -z '$(findstring smdk6410_noUSB_config,$@)' ]; then
echo 'RAM_TEXT = 0x57e00000' >> $(obj)board/samsung/smdk6410/config.tmp;
$(MKCONFIG) $(@:_config=) arm arm1176 smdk6410 samsung s3c64xx;
else
echo 'RAM_TEXT = 0xc7e00000' >> $(obj)board/samsung/smdk6410/config.tmp;
$(MKCONFIG) $(@:_noUSB_config=) arm arm1176 smdk6410 samsung s3c64xx;
fi
@echo 'CONFIG_NAND_U_BOOT = y' >> $(obj)include/config.mk
3.8)配置编译
make smdk6410_config
make
可以编译成功。
4.文件修改
4.1)cpu/arm1176/start.S
4.1.1)将如下红色代码段注释掉,添加“mcr p15,0,r0,c1,c0,0”。
#ifndef CONFIG_NAND_SPL
/*
* flush v4 I/D caches
*/
mov r0, #0
mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */
mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */
/*
* disable MMU stuff and caches
*/
mrc p15, 0, r0, c1, c0, 0
bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS)
bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM)
orr r0, r0, #0x00000002 @ set bit 2 (A) Align
orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache
/* Prepare to disable the MMU */
adr r1, mmu_disable_phys
/* We presume we're within the first 1024 bytes */
and r1, r1, #0x3fc
ldr r2, _TEXT_PHY_BASE
ldr r3, =0xfff00000
and r2, r2, r3
orr r2, r2, r1
b mmu_disable
.align 5
/* Run in a single cache-line */
mmu_disable:
mcr p15, 0, r0, c1, c0, 0
nop
nop
mov pc, r2
#endif
修改后的代码如下:
#ifndef CONFIG_NAND_SPL
/*
* flush v4 I/D caches
*/
mov r0, #0
mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */
mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */