博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
u-boot2009,norflash移植
阅读量:6517 次
发布时间:2019-06-24

本文共 3742 字,大约阅读时间需要 12 分钟。

  1. 开发板的配置文件fl2440.h/include/configs/fl2440.h)修改配置

    /*-------------------------------------------------------------------

    * FLASH and environment organization

    */

    #define CONFIG_SYS_MONITOR_BASE TEXT_BASE

    #define FLASH_BASE0_PRELIM PHYS_FLASH_1

    #define CONFIG_SYS_FLASH_PROTECTION 1

    #define CFG_MAX_FLASH_BANKS 1

    #define CONFIG_SYS_FLASH_SIZE 0x00400000

    #define CONFIG_SYS_MAX_FLASH_SECT 32

     

    #if 0

    #define CONFIG_AMD_LV400 1 /* uncomment this if you have a LV400 flash */

    #define CONFIG_AMD_LV800 1 /* uncomment this if you have a LV800 flash */

    #endif

     

    #define CONFIG_ENV_IS_IN_FLASH 1

    #define CONFIG_ENV_SIZE 0x20000

    #define CONFIG_ENV_OFFSET 0x40000

    /*----------------------------------------------------------------*/

     

  2. 把开发板目录下flash.c文件替换成下面的/board/cmi/下面的flash.c文件,然后删除这个write_short函数的申明和定义、删除write_buff函数。替换成下面的两个函数

     

    /*

    * Copy memory to flash, returns:

    * 0 - OK

    * 1 - write timeout

    * 2 - Flash not erased

    * 4 - Flash not identified

    */

    int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)

    {

    ulong cp, wp;

    ushort data;

    int l;

    int i, rc;

    wp = (addr & ~1);

     

    if ((l = addr - wp) != 0)

    {

    data = 0;

    for (i=0, cp=wp; i<l; ++i, ++cp) {

    data = (data >> 8) | (*(uchar *)cp << 8);

    }

    for (; i<2 && cnt>0; ++i) {

    data = (data >> 8) | (*src++ << 8);

    --cnt;

    ++cp;

    }

    for (; cnt==0 && i<2; ++i, ++cp) {

    data = (data >> 8) | (*(uchar *)cp << 8);

    }

    if ((rc = write_word(info, wp, data)) != 0) {

    return (rc);

    }

    wp += 2;

    }

     

    while (cnt >= 2) {

    data = *((vu_short*)src);

    if ((rc = write_word(info, wp, data)) != 0) {

    return (rc);

    }

    src += 2;

    wp += 2;

    cnt -= 2;

    }

    if (cnt == 0) {

    return ERR_OK;

    }

     

    data = 0;

    for (i=0, cp=wp; i<2 && cnt>0; ++i, ++cp) {

    data = (data >> 8) | (*src++ << 8);

    --cnt;

    }

    for (; i<2; ++i, ++cp) {

    data = (data >> 8) | (*(uchar *)cp << 8);

    }

    return write_word(info, wp, data);

    }

    /*

    * Write 16 bit (short) to flash

    */

     

    static int write_word (flash_info_t *info, ulong dest, ushort data)

    {

    vu_short *addr = (vu_short *)dest, val;

    int rc = ERR_OK;

    int flag;

     

     

    if ((*addr & data) != data)

    return ERR_NOT_ERASED;

     

    flag = disable_interrupts();

    *addr = 0x50;

    *addr = 0x40;

    *addr = data;

    reset_timer_masked();

    while(((val = *addr) & 0x80) != 0x80)

    {

    if (get_timer_masked() > CONFIG_SYS_FLASH_WRITE_TOUT) {

    rc = ERR_TIMOUT;

     

    *addr = 0xB0;

    goto outahere;

    }

    }

    if(val & 0x1A) {

    printf("nFlash write error x at address lxn",

    (int)val, (unsigned long)dest);

    if(val & (1<<3)) {

    printf("Voltage range error.n");

    rc = ERR_PROG_ERROR;

    goto outahere;

    }

    if(val & (1<<1)) {

    printf("Device protect error.n");

    rc = ERR_PROTECTED;

    goto outahere;

    }

    if(val & (1<<4)) {

    printf("Programming error.n");

    rc = ERR_PROG_ERROR;

    goto outahere;

    }

    rc = ERR_PROG_ERROR;

    goto outahere;

    }

    outahere:

     

    *addr = 0xFF;

    if (flag)

    enable_interrupts();

    return rc;

    }

     

    1. 修改board/fl2440/flash.c中函数申明:
      static ulong flash_get_size (vu_short *addr, flash_info_t *info);
      //static int write_short (flash_info_t *info, ulong dest, ushort data);
      static int write_word (flash_info_t *info, ulong dest, ushort data);
      static void flash_get_offsets (ulong base, flash_info_t *info);
      1. 开发板的配置文件flash.h/include/flash.h)修改配置

     

    #define FLASH_28F320J3D 0x00C0        /* INTEL 28F320J3A ( 32M = 128K x 32)    */

    #define FLASH_28F640J3D 0x00C2        /* INTEL 28F640J3A ( 64M = 128K x 64)    */

    #define FLASH_28F128J3D 0x00C4        /* INTEL 28F128J3A (128M = 128K x 128)    */

    #define FLASH_28F256J3D 0x00C6        /* INTEL 28F256J3A (256M = 128K x 256)    */

    (原来是a)

     

    #define INTEL_ID_28F320J3D 0x00160016    /* 32M = 128K x 32    */

    #define INTEL_ID_28F640J3D 0x00170017    /* 64M = 128K x 64    */

    #define INTEL_ID_28F128J3D 0x00180018    /* 128M = 128K x 128    */

     

    以及将/board/fl2440/flash.c 中涉及的这两项修改。

        

  3. 修改flash.c文件中的一个宏定义:
    把:
    #define FLASH_BLOCK_SIZE        0x00010000
    改为:
    #define FLASH_BLOCK_SIZE        0x00020000

转载于:https://www.cnblogs.com/zcmaker/archive/2012/11/23/2784319.html

你可能感兴趣的文章
shell 批量修改gif文件为jpg文件
查看>>
我的友情链接
查看>>
Elasticsearch5.2.0部署过程的坑
查看>>
LaTeX - 笛卡尔叶形线
查看>>
网络爬虫-Python
查看>>
使用Jmeter测试Dubbo接口
查看>>
vi 删除以什么为开头的行
查看>>
[转载] 杜拉拉升职记——24 教会徒弟饿死师傅
查看>>
查看并修改Linux主机名命令hostname
查看>>
基于Web的网上书店的设计与开发
查看>>
hbase中的Bloom filter
查看>>
Centos7相关
查看>>
大学生就业不难谁难
查看>>
AfxGetApp()和GetSafeHwnd()
查看>>
再谈HTTP 方法:GET和POST对比
查看>>
输入输出和死锁
查看>>
[转载] 七龙珠第一部——第087话 雅木茶对抗天津饭
查看>>
Django
查看>>
lvm基本操作(扩展和缩减)
查看>>
Docker 教程
查看>>