码迷,mamicode.com
首页 > 其他好文 > 详细

OK6410 uboot移植之sd启动

时间:2015-07-07 17:05:36      阅读:544      评论:0      收藏:0      [点我收藏+]

标签:ok6410   uboot   sd   

1  uboot移植

1.1  移植准备工作

1.1.1 安装交叉编译工具链

版本:arm-linux-gcc 4.4.1

环境:ubuntu14.04.01LTS

 

1.1.2建立OK6410配置项

从官网下载u-boot-2012.10.tar.bz2,由于uboot支持的smdk6400单板与我们的板子OK6410最相似,所以修改是基于smdk6400进行的,初步修改uboot建立OK6410配置项。

详细修改过程如下:

进入u-boot-2012.10顶层目录,在board/Samsung目录下,新建一个ok6410文件夹,把smdk6400下的所有文件拷贝到ok6410下面。将smdk6400.c改为ok6410.c,将smdk6400_nand_spl.c改为ok6410_nand_spl.c。修改ok6410文件夹下的Makefile:将COBJS-y := smdk6400.o改为COBJS-y := ok6410.o。

在nand_spl/board/samsung下,新建一个ok6410文件夹,把smdk6400下的所有文件拷贝到ok6410下面。修改ok6410文件夹下的Makefile:COBJS   = nand_boot.o nand_ecc.o s3c64xx.osmdk6400_nand_spl.o nand_base.o改为COBJS  = nand_boot.o nand_ecc.o s3c64xx.o ok6410_nand_spl.o nand_base.o;@ln -s$(TOPDIR)/board/samsung/smdk6400/lowlevel_init.S $@改为@ln -s $(TOPDIR)/board/samsung/ok6410/lowlevel_init.S$@;$(obj)smdk6400_nand_spl.c:

        @rm -f $@

        @ln -s$(TOPDIR)/board/samsung/smdk6400/smdk6400_nand_spl.c $@改为$(obj)ok6410_nand_spl.c:

        @rm -f $@

        @ln -s$(TOPDIR)/board/samsung/ok6410/ok6410_nand_spl.c $@

在include/configs文件夹下,修改板子配置文件。将smdk6400.h拷贝一份为ok6410.h。修改ok6410.h将CONFIG_S3C6400改为CONFIG_S3C6410,CONFIG_SMDK6400改为CONFIG_OK6400。

在arch/arm/include/asm/arch-s3c64xx文件夹下,将s3c6400.h拷贝一份为s3c6410.h并修改#ifndef __S3C6400_H__为#ifndef __S3C6410_H__;修改

#define __S3C6400_H__为#define __S3C6410_H__。

进入arch/arm/cpu/arm1176/s3c64xx,打开Makefile,将CONFIG_S3C6400修改为CONFIG_S3C6410。

进入board/samsung/ok6410,打开ok6410.c和lowlevel_init.S;

进入arch/arm/cpu/arm1176/s3c64xx,打开cpu_init.S、reset.S、speed.c和timer.c;

进入/drivers/mtd/nand,打开s3c64xx.c;

进入/drivers/serial,打开s3c64xx.c;

进入/drivers/usb/host,打开s3c64xx-hcd;

将上面文件中的#include <asm/arch/s3c6400.h>改为#include <asm/arch/s3c6410.h>

修改uboot顶层的Makefile,修改编译工具:将CROSS_COMPILE ?改为CROSS_COMPILE ?= arm-linux-

在下面代码处添加#########################################################################

## 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 "#defineCONFIG_NAND_U_BOOT" > $(obj)include/config.h

        @echo"CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk

        @if [ -z"$(findstring smdk6400_noUSB_config,$@)" ]; then                       \

                echo"RAM_TEXT = 0x57e00000" >>$(obj)board/samsung/smdk6400/config.tmp;\

        else                                                                            \

                echo"RAM_TEXT = 0xc7e00000" >>$(obj)board/samsung/smdk6400/config.tmp;\

        fi

        @$(MKCONFIG) smdk6400 armarm1176 smdk6400 samsung s3c64xx

        @echo"CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk

 

#########################################################################

ok6410配置项:

#########################################################################

## ARM1176 Systems

#########################################################################

ok6410_noUSB_config     \

ok6410_config   :       unconfig

        @mkdir -p $(obj)include$(obj)board/samsung/ok6410

        @mkdir -p$(obj)nand_spl/board/samsung/ok6410

        @echo "#defineCONFIG_NAND_U_BOOT" > $(obj)include/config.h

        @echo"CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk

        @if [ -z"$(findstring ok6410_noUSB_config,$@)" ]; then                 \

                echo"RAM_TEXT = 0x57e00000" >>$(obj)board/samsung/ok6410/config.tmp;\

        else                                                                            \

                echo"RAM_TEXT = 0xc7e00000" >>$(obj)board/samsung/ok6410/config.tmp;\

        fi

        @$(MKCONFIG) ok6410 armarm1176 ok6410 samsung s3c64xx

        @echo "CONFIG_NAND_U_BOOT= y" >> $(obj)include/config.mk

 

#########################################################################

此时,如果没操作错误的话,执行make ok6410_config就可以建立ok6410的配置了。执行成功信息如下:

warning: Please migrate to boards.cfg. Failure to do so will

         mean removal of yourboard in the next release.

 

Configuring for ok6410 board...

执行make也编译成功。

 

1.2硬件初始化

从start.S文件开始一路跟踪,修改代码。

1.2.1 led配置和时钟修改

ok6410led接到GPM端口,修改board/samsung/ok6410/lowlevel.S

        /* LED on only #8 */

        ldr     r0, =ELFIN_GPIO_BASE

        ldr     r1, =0x55540000

        str     r1, [r0, #GPNCON_OFFSET]

        ldr     r1, =0x55555555

        str     r1, [r0, #GPNPUD_OFFSET]

        ldr     r1, =0xf000

        str     r1, [r0, #GPNDAT_OFFSET]

修改为:

        /* LED on only #8 */

        ldr    r0, =ELFIN_GPIO_BASE

        ldr     r1, =0x1111

        str     r1, [r0, #GPMCON_OFFSET]

        ldr     r1, =0x555

        str     r1, [r0, #GPMPUD_OFFSET]

        ldr     r1, =0x3

        str     r1, [r0, #GPMDAT_OFFSET]

时钟初始化部分smdk6400和ok6410还是有区别的:

        /* FOUT of EPLL is 96MHz*/

        ldr     r1, =0x200203

        str     r1, [r0, #EPLL_CON0_OFFSET]

        ldr     r1, =0x0

        str     r1, [r0, #EPLL_CON1_OFFSET]

修改为:

        /* FOUT of EPLL is 96MHz*/

        ldr     r1, =0x80200203

        str     r1, [r0, #EPLL_CON0_OFFSET]

        ldr     r1, =0x0

        str     r1, [r0, #EPLL_CON1_OFFSET]

将#ifndef CONFIG_S3C6400改为#ifndef CONFIG_S3C6410

修改 mmu_table:(ok6410 SDRAM为256M)

        /* 128MB for SDRAM0xC0000000 -> 0x50000000 */

        .set __base, 0x500

        .rept 0xC80 - 0xC00

        FL_SECTION_ENTRY __base,3, 0, 1, 1

        .set __base, __base + 1

        .endr

 

        /* access is not allowed.*/

        .rept 0x1000 - 0xc80

        .word 0x00000000

        .endr

修改为:

        /* 256MB for SDRAM0xD0000000 -> 0x50000000 */

        .set __base, 0x500

        .rept 0xD00 - 0xC00

        FL_SECTION_ENTRY __base,3, 0, 1, 1

        .set __base, __base + 1

        .endr

 

        /* access is not allowed.*/

        .rept 0x1000 - 0xD00

        .word 0x00000000

        .endr

修改板子配置文件include/configs/ok6410.h

修改板子机器id为1626(与内核里的机器id一致):

/*

 * Architecture magic and machinetype

 */

#define CONFIG_MACH_TYPE               1270

改为#define CONFIG_MACH_TYPE                1626

#define CONFIG_SYS_PROMPT              "SMDK6400 # "修改为#define CONFIG_SYS_PROMPT               "lavender # "

因为PCLK=50MHz所以将#define CONFIG_SYS_HZ                   1000修改为

#define CONFIG_SYS_HZ                  1562500

修改内存大小:

#define PHYS_SDRAM_1_SIZE       0x08000000      /* 128 MB in Bank #1    */

改为

#define PHYS_SDRAM_1_SIZE       0x10000000      /* 256 MB in Bank #1    */

修改CONFIG_IDENT_STRING 为#define CONFIG_IDENT_STRING     " for lavender"

修改CONFIG_ENV_OFFSET 为#define CONFIG_ENV_OFFSET    0x0080000

将如下代码:

#define CONFIG_SYS_NAND_U_BOOT_OFFS    (4 * 1024)      /* Offset to RAMU-Boot image */

#define CONFIG_SYS_NAND_U_BOOT_SIZE    (252 * 1024)    /* Size of RAMU-Boot image   */

修改为:

#define CONFIG_SYS_NAND_U_BOOT_OFFS    (16 * 1024)     /* Offset to RAMU-Boot image */

#define CONFIG_SYS_NAND_U_BOOT_SIZE    (496 * 1024)    /* Size of RAMU-Boot image   *

接下来根据K9F2G08U0A手册,修改Nandflash配置:

将/* NAND chip page size          */

#define CONFIG_SYS_NAND_PAGE_SIZE      2048

/* NAND chip block size         */

#define CONFIG_SYS_NAND_BLOCK_SIZE     (128 * 1024)

/* NAND chip page per block count */

#define CONFIG_SYS_NAND_PAGE_COUNT     64

/* Location of the bad-block label */

#define CONFIG_SYS_NAND_BAD_BLOCK_POS  0

/* Extra address cycle for > 128MiB */

#define CONFIG_SYS_NAND_5_ADDR_CYCLE

修改为:

/* NAND chip page size          */

#define CONFIG_SYS_NAND_PAGE_SIZE      4096

/* NAND chip block size         */

#define CONFIG_SYS_NAND_BLOCK_SIZE     (512 * 1024)

/* NAND chip page per block count */

#define CONFIG_SYS_NAND_PAGE_COUNT     128

/* Location of the bad-block label */

#define CONFIG_SYS_NAND_BAD_BLOCK_POS  0

/* Extra address cycle for > 128MiB */

#define CONFIG_SYS_NAND_5_ADDR_CYCLE

 

1.3   使uboot支持SD启动

根据三星s3c6410IROM启动手册,在arch/arm/cpu/arm1176/s3c64xx/目录下新建mmcboot.c文件。文件内容见相关附件。

1.3.1 修改配置文件ok6410.h添加CONFIG_BOOT_SD宏,支持SD卡启动

/* Boot configuration (define only one of next 3) */

#define CONFIG_BOOT_SD  /* supportsd boot */

#define CONFIG_BOOT_NAND

1.3.2 修改Makefile(arch/arm/cpu/arm1176/s3c64xx),增加mmcboot.c的编译。

COBJS-$(CONFIG_S3C6410) += cpu_init.o speed.o

COBJS-$(CONFIG_BOOT_SD) += mmcboot.o

COBJS-y += timer.o

1.3.3  在start.S中调用sd启动函数

/* Set stackpointer in internal RAM to call board_init_f */

#if defined(CONFIG_BOOT_SD) && !defined(CONFIG_NAND_SPL)

call_board_init_f:

        ldr     sp, =(CONFIG_SYS_INIT_SP_ADDR)

        bl      BootCopyMMCtoMem

        bic     sp, sp, #7 /* 8-byte alignment for ABIcompliance */

        ldr     r0,=0x00000000

        ldr     pc, =board_init_f

#else

        bic     sp, sp, #7

        ldr     r0,=0x0

        bl      board_init_f

#endif

1.3.4 修改链接脚本(board/samsung/ok6410/u-boot-nand.lds),确保添加的sd启动函数位于uboot的前8k。

        .text      :

        {

         arch/arm/cpu/arm1176/start.o (.text)

          board/samsung/ok6410/libok6410.o(.text)

          *(.text)

        }

编译烧写:可以用在linux用dd命令烧写,也可以用我从网上下载的烧写工具SD_Writer。

结果如下:

技术分享

Flash错误,ok6410没有Flash存储器直接定位代码,去掉这部分即可。

在arch/arm/lib/board.c文件下找到:

                puts(failed);

                hang();

修改为:

                puts("noFlash devices!\n");

                //hang();

重新编译烧写:

技术分享


技术分享

版权声明:本文为博主原创文章,未经博主允许不得转载。

OK6410 uboot移植之sd启动

标签:ok6410   uboot   sd   

原文地址:http://blog.csdn.net/u010346967/article/details/46789841

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!