友善开发板移植uboot-2010.03

来源:互联网 发布:公安民警网络答题 编辑:程序博客网 时间:2024/05/16 09:21

一、硬件资源
CPU:S3C6410 ARM1176 run at 533Mhz,up to 677Mhz
FLASH:K9F2G08U 256M*8bit
DDR/SDRAM:K4X2G323PD-8GD8 256M(64M*32)
二、移植第一步
1、下载:u-boot-2010.03.tar.bz2
http://ftp.denx.de/pub/u-boot/
解压:

#tar jxvf u-boot-2010.03.tar.bz2#cd  u-boot-2010.03/board/samsung

2、建立tiny6410文件夹
mkdir tiny6410
3、6410和6400资源差不多,所以以6400代码作为模版

#cp -rf smdk6400/* tiny6410 //将6400下所有的代码复制到tiny6400目录下#cd tiny6410#mv smdk6400.c  tiny6410.c  //将smdk6400.c改名为tiny6410.c

4、修改tiny6410文件夹Makefile的第31行为
31 COBJS-y := tiny6410.o
5、建立tiny6410头文件

#cd ../../../include/configs#cp -rf smdk6400.h  tiny6410.h

6、修改U-boot根目录下Makefile文件
指定交叉环境(163行):CROSS_COMPILE ?=arm-linux-
找到smdk6400配置项(3316行),复制一段修改为tiny6410配置项,将smdk6400全改为tiny6410,如下:
注意:空格位应为一个tab键,否则会出错。

tiny6410_noUSB_config   \tiny6410_config :   unconfig    @mkdir -p $(obj)include $(obj)board/samsung/tiny6410    @mkdir -p $(obj)nand_spl/board/samsung/tiny6410    @echo "#define CONFIG_NAND_U_BOOT" > $(obj)include/config.h    @if [ -z "$(findstring tiny6410_noUSB_config,$@)" ]; then          \        echo "RAM_TEXT = 0x57e00000" >> $(obj)board/samsung/tiny6410/config.tmp;\        $(MKCONFIG) $(@:_config=) arm arm1176 tiny6410 samsung s3c64xx;     \    else                                        \        echo "RAM_TEXT = 0xc7e00000" >> $(obj)board/samsung/tiny6410/config.tmp;\        $(MKCONFIG) $(@:_noUSB_config=) arm arm1176 tiny6410 samsung s3c64xx;   \    fi    @echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk

其中:
arm: CPU的架构
arm1176:CPU的类型
tiny6410:对应在board目录下建立新的开发板项目目录
samsung:新开发板项目的上级目录,如直接在board下建立新的开发板项目,此处应为NULL
s3c64xx:CPU的型号
7、测试编译新建的tiny6410开发板项目

#make  tiny6410_config  (出现:Configuring for tiny6410 board...表正确,否则重新配置。#make编译后没有错误,且根目录生成u-boot.bin文件,表示u-boot移植第一步成功

参考:http://blog.sina.com.cn/s/blog_79abea8a01012ruj.html
二、移植第二步
1、修改u-boot第一个要运行的程序位于:cpu/arm1176/start.S
在dsable MMU中(大约166行):
添加一行:mcr p15, 0, r0, c1, c0, 0

    /*     * 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    mcr p15, 0, r0, c1, c0, 0

在bl lowlevel_init之后添加如下代码,主要用于判断是从nandflash启动还是ram中启动:

/* when we already run in ram, we don't need to relocate U-Boot.     * and actually, memory controller must be configured before U-Boot     * is running in ram.     */    ldr r0, =0xff000fff    bic r1, pc, r0      /* r0 <- current base addr of code */    ldr r2, _TEXT_BASE      /* r1 <- original base addr in ram */    bic r2, r2, r0      /* r0 <- current base addr of code */    cmp     r1, r2                  /* compare r0, r1                  */    beq     after_copy      /* r0 == r1 then skip flash copy   */

如果没有完成copy,则接下来应该copy_from_nand,那么在beq after_copy后面添加:

 #ifdef CONFIG_BOOT_NAND mov r0, #0x1000 bl copy_from_nand#endif

如果完成则会跳过这段代码,直接进入after_copy。
2、那么在u-boot-2010.03\cpu\arm1176下建立一个nand_cp.c,为了方便,我们可以直接从u-boot-1.1.6\cpu\s3c64xx下拷贝过来使用。
修改该目录下的Makefile,添加如下:
COBJS = cpu.o nand_cp.o
3、回到Start.S,在
- #ifdef CONFIG_ENABLE_MMU
- .globl theLastJump
之前添加如下代码:

/* * copy U-Boot to SDRAM and jump to ram (from NAND or OneNAND) * r0: size to be compared * Load 1'st 2blocks to RAM because U-boot's size is larger than 1block(128k) size */    .globl copy_from_nandcopy_from_nand:    mov r10, lr     /* save return address */    mov r9, r0    /* get ready to call C functions */    ldr sp, _TEXT_PHY_BASE  /* setup temp stack pointer */    sub sp, sp, #12    mov fp, #0          /* no previous frame, so fp=0 */    mov r9, #0x1000    bl  copy_uboot_to_ram3:  tst     r0, #0x0    bne copy_failed    ldr r0, =0x0c000000    ldr r1, _TEXT_PHY_BASE1:  ldr r3, [r0], #4    ldr r4, [r1], #4    teq r3, r4    bne compare_failed  /* not matched */    subs    r9, r9, #4    bne 1b4:  mov lr, r10     /* all is OK */    mov pc, lrcopy_failed:    nop         /* copy from nand failed */    b   copy_failedcompare_failed:    nop         /* compare failed */    b   compare_failed

4、接着修改6410的头文件,进入include\configs,打开tiny6410.h

#if !defined(CONFIG_NAND_SPL) && (TEXT_BASE >= 0xc0000000)#define CONFIG_ENABLE_MMU#endif

下方添加:

#ifdef CONFIG_ENABLE_MMU#define virt_to_phys(x) virt_to_phy_smdk6410(x)#else#define virt_to_phys(x) (x)#endif

接着修改:

#define CONFIG_SYS_PROMPT       "SMDK6400 # 

表示命令行的名称,我这里改为tiny6410#
然后确定板载SDRAM的大小,我们这里使用的是256M的SDRAM所以修改如下:

#define PHYS_SDRAM_1_SIZE   0x10000000#define CFG_MEMTEST_END     MEMORY_BASE_ADDRESS + 0xfe00000 

当为128M的SDRAM时,应修改为:

 #define PHYS_SDRAM_1_SIZE 0x08000000 #define CFG_MEMTEST_END        MEMORY_BASE_ADDRESS + 0x7e00000 

另一方面机器号的确定,6410我们修改如下:

#define MACH_TYPE       1626

时间修改:

 //#define CONFIG_SYS_HZ 1000 // at PCLK 50MHz#define CONFIG_SYS_HZ 1562500
0 0
原创粉丝点击