结合:移植最新uboot的总结
参考:u-boot2012.04.01移植到mini2440
u-boot-2012.04.01流程以及移植说明:
从新制作一个单板:
复制u-boot-2012.04.01/board/samsung目录下的:smdk2410文件夹为smdk2440
复制u-boot-2012.04.01/include/configs目录下的:smdk2410.h文件为smdk2440.h
在u-boot-2012.04.01/boards.cfg文件下复制65行,修改boards.cfg:
仿照
smdk2410 arm arm920t - samsung s3c24x0
添加:
smdk2440 arm arm920t - samsung s3c24x0
然后重新配置一下:make smdk2440_config
然后重新编译一下:make
1、设置管理模式:
//
// set the cpu to SVC32 mode
//
mrs r0, cpsr
bic r0, r0, #0x1f
orr r0, r0, #0xd3
msr cpsr, r0
2、关看门狗:
// turn off the watchdog //
# if defined(CONFIG_S3C2400)
# define pWTCON 0x15300000
# define INTMSK 0x14400008 // Interrupt-Controller base addresses //
# define CLKdivN 0x14800014 // clock divisor register //
#else
# define pWTCON 0x53000000
# define INTMSK 0x4A000008 // Interrupt-Controller base addresses //
# define INTSUBMSK 0x4A00001C
# define CLKdivN 0x4C000014 // clock divisor register //
# endif
ldr r0, =pWTCON
mov r1, #0x0
str r1, [r0]
3、屏蔽中断:
//
// mask all IRQs by setting all bits in the INTMR - default
//
mov r1, #0xffffffff
ldr r0, =INTMSK
str r1, [r0]
# if defined(CONFIG_S3C2410)
ldr r1, =0x3ff
ldr r0, =INTSUBMSK
str r1, [r0]
# endif
4、设置时钟:
//先屏蔽系统原有的时钟设置-修改board_init_f:
init_sequence
board_early_init_f
// to reduce PLL lock time, adjust the LOCKTIME register //
//writel(0xFFFFFF, &clk_power->locktime);
// configure MPLL //
//writel((M_Mdiv < 12) + (M_Pdiv < 4) + M_Sdiv,
// &clk_power->mpllcon);
#define S3C2440_MPLL_200MHZ ((0x5c<12)|(0x01<4)|(0x02))
#define S3C2440_MPLL_400MHZ ((0x5c<12)|(0x01<4)|(0x01))
// 设置时钟 //
ldr r0, =0x4c000014
mov r1, #0x05
str r1, [r0]
// 如果HdivN非0,CPU的总线模式应该从“fast bus mode”变为“asynchronous bus mode” //
mrc p15, 0, r1, c1, c0, 0 // 读出控制寄存器 //
orr r1, r1, #0xc0000000 // 设置为“asynchronous bus mode” //
mcr p15, 0, r1, c1, c0, 0 // 写入控制寄存器 //
ldr r0, =0x4c000004
ldr r1, =S3C2440_MPLL_400MHZ
str r1, [r0]
// 启动ICACHE //
mrc p15, 0, r0, c1, c0, 0 @ read control reg
orr r0, r0, #(1<12)
mcr p15, 0, r0, c1, c0, 0 @ write it back
5、设置SDRAM:
bl cpu_init_crit
...........
bl lowlevel_init
修改lowlevel_init中为:
.long 0x22011110 //BWSCON
.long 0x00000700 //BANKCON0
.long 0x00000700 //BANKCON1
.long 0x00000700 //BANKCON2
.long 0x00000700 //BANKCON3
.long 0x00000740 //BANKCON4
.long 0x00000700 //BANKCON5
.long 0x00018005 //BANKCON6
.long 0x00018005 //BANKCON7
.long 00x008C04F4 //REFRESH
.long 00x000000B1 //BANKSIZE
.long 00x00000030 //MRSRB6
.long 00x00000030 //MRSRB7
6、初始化nand flash、重定位、清楚BSS段:
bl nand_init_ll
参考"毕业班第1课"的start.S, init.c(nand flash初始化、读写等操作)来修改代码
把init.c放入board/samsung/smdk2440目录,修改init.c文件主要是加上static,
修改u-boot链接地址CONFIG_SYS_TEXT_BASE为0x33f00000,u-boot.bin文件太大,0x33f80000不够放
//修改u-boot-2012.04.01\u-boot-2012.04.01\board\samsung\smdk2440\Makefile:
COBJS := smdk2410.o init.o //COBJS表示C文件生成的.o文件
//修改链接脚本,把start.S, init.c, lowlevel.S等文件放在最前面
//(u-boot-2012.04.01\u-boot-2012.04.01\arch\arm\cpu\u-boot.lds):
增加:board/samsung/smdk2440/libsmdk2440.o (.text)
{
__image_copy_start = .;
CPUDIR/start.o (.text)
board/samsung/smdk2440/libsmdk2440.o (.text)
*(.text)
}
bl copy_code_to_sdram_ll //重定位
bl clear_bss_ll //清除BSS
注意:详细