加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ok6410 uboot nandflash移植

发布时间:2020-12-15 20:09:21 所属栏目:百科 来源:网络整理
导读: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 l

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,

???????????????????????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,2048,LP_OPTIONS},

??????? {"NAND 2GiB 3,3V8-bit",??????? 0xD5,??????? 0x38,4096,4096*128,

??????? {"NAND 2GiB 1,8V16-bit",?????? 0xB5,LP_OPTIONS16},3V16-bit",?????? 0xC5,

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

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

重新编译烧写:


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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读