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

ok6410 uboot nandflash移植

时间:2015-07-07 17:01:38      阅读:284      评论:0      收藏:0      [点我收藏+]

标签:ok6410   uboot   nandflash   

1.4  Nandflash移植

先解决上面的错误,修改arch/arm/cpu/arm1176/s3c64xx/timer.c

static ulong timer_load_val;修改为 DECLARE_GLOBAL_DATA_PTR;

删除下面的两个定义:

/* Internal tick units */

/* Last decremneter snapshot */

static unsigned long lastdec;

/* Monotonic incrementing timer */

static unsigned long long timestamp;

接着把:

        timers->TCFG0 =PRESCALER << 8;

        if (timer_load_val == 0) {

                timer_load_val =get_PCLK() / PRESCALER * (100 / 4); /* 100s */

                timers->TCFG1 =(timers->TCFG1 & ~0xf0000) | 0x20000;

        }

修改为:

        timers->TCFG0 =PRESCALER << 8;

 

        gd->timer_rate_hz =get_PCLK() / PRESCALER * (100 / 4); /* 100s */

        timers->TCFG1 = (timers->TCFG1& ~0xf0000) | 0x20000;

将lastdec = timers->TCNTB4 = timer_load_val;修改为:

gd->lastinc = timers->TCNTB4 = gd->timer_rate_hz;

将timestamp = 0;修改为gd->timer_reset_value = 0;

将unsigned long long get_ticks(void)

{

        ulong now = read_timer();

 

        if (lastdec >= now) {

                /* normal mode */

                timestamp +=lastdec - now;

        } else {

                /* we have anoverflow ... */

                timestamp +=lastdec + timer_load_val - now;

        }

        lastdec = now;

 

        return timestamp;

}

修改为:

unsigned long long get_ticks(void)

{

        ulong now = read_timer();

 

        if (gd->lastinc >=now) {

                /* normal mode */

               gd->timer_reset_value += gd->lastinc - now;

        } else {

                /* we have anoverflow ... */

               gd->timer_reset_value += gd->lastinc + gd->timer_rate_hz - now;

        }

        gd->lastinc = now;

 

        returngd->timer_reset_value;

}

将ulong get_tbclk(void)

{

        /* We overrun in 100s */

        return(ulong)(timer_load_val / 100);

}

 

ulong get_timer_masked(void)

{

        unsigned long long res =get_ticks();

        do_div (res,(timer_load_val / (100 * CONFIG_SYS_HZ)));

        return res;

}

修改为:

ulong get_tbclk(void)

{

        /* We overrun in 100s */

        return(ulong)(gd->timer_rate_hz / 100);

}

 

ulong get_timer_masked(void)

{

        unsigned long long res =get_ticks();

        //do_div (res,(timer_load_val / (100 * CONFIG_SYS_HZ)));

        return res;

}

修改nand_spl/board/samsung/ok6410/ok6410_nand_spl.c将

void board_init_f(unsigned long bootflag)

{

       relocate_code(CONFIG_SYS_TEXT_BASE - TOTAL_MALLOC_LEN, NULL,

                       CONFIG_SYS_TEXT_BASE);

}

改为:

void board_init_f(unsigned long bootflag)

{

        relocate_code(8*1024,NULL,

                       CONFIG_SYS_TEXT_BASE);

}

修改bl1的配置大小:nand_spl/board/samsung/ok6410/config.mk

# PAD_TO used to generate a 4kByte binary needed for the combined image

# -> PAD_TO = CONFIG_SYS_TEXT_BASE + 4096

PAD_TO  := $(shell expr$$[$(CONFIG_SYS_TEXT_BASE) + 4096])

修改为

# PAD_TO used to generate a 8kByte binary needed for the combined image

# -> PAD_TO = CONFIG_SYS_TEXT_BASE + 8192

PAD_TO  := $(shell expr$(CONFIG_SYS_TEXT_BASE) + 8192)

重新编译烧写:

技术分享

Nandflash的初始化过程如下:

board_init_rànand_initànand_init_chipàboard_nand_initànand_scanà

nand_scan_identànand_scan_tailànand_register

在drivers/mtd/nand/nand_ids.c文件中定义了连个数组:nand_flash_ids[]和nand_manuf_ids[]。

添加ok6410 nandflash型号:

        /* 16 Gigabit */

        {"NAND 2GiB 1,8V8-bit",        0xA5, 0, 2048, 0,LP_OPTIONS},

        {"NAND 2GiB 3,3V8-bit",        0xD5, 0, 2048, 0,LP_OPTIONS},

        {"NAND 2GiB 3,3V8-bit",        0x38, 4096, 2048,4096*128, LP_OPTIONS},

        {"NAND 2GiB 1,8V16-bit",       0xB5, 0, 2048, 0,LP_OPTIONS16},

        {"NAND 2GiB 3,3V16-bit",       0xC5, 0, 2048, 0,LP_OPTIONS16},

每个字段的含义如下:注意  IDcode需要自己测。

Name. ID code, pagesize, chipsize in MegaByte, eraseblock size, options

重新编译烧写:

技术分享

这里nandflash是使用的4位ecc校验,有兴趣的可以自己实现8位ecc校验,6410是支持8位ecc的。

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

ok6410 uboot nandflash移植

标签:ok6410   uboot   nandflash   

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

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