天嵌 ARM开发社区

 找回密码
 注册
查看: 1901|回复: 1

求教Uboot: start address not on sector boundary

[复制链接]
相逢的日子 发表于 2011-9-17 16:19:03 | 显示全部楼层 |阅读模式
求教大侠们一个问题啊,我手头有一个TQ2400开发板,刚移植了uboot,修改了flash.h和flash.c,nor flash是EN29LV160AB,nand flash没动
烧录到norflash之后执行saveenv,提示start address not on sector boundary,请问这是未配置nand flash还是nor flash设置错误的原因啊,有何修改良策啊!谢谢大家的指点!


我移植Nor Flash参照了如下的帖子:



/*-----------------------------------------------------------------------
* FLASH and environment organization
*/
#if 0    //注释掉下面两个类型的Nor Flash设置,因为不是我们所使用的型号
#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_SYS_MAX_FLASH_BANKS 1  /* max number of memory banks */

#ifdef CONFIG_AMD_LV800
#define PHYS_FLASH_SIZE            0x00100000  /* 1MB */
#define CONFIG_SYS_MAX_FLASH_SECT  (19)        /* max number of sectors on one chip */
#define CONFIG_ENV_ADDR            (CONFIG_SYS_FLASH_BASE + 0x0F0000) /* addr of environment */
#endif
#ifdef CONFIG_AMD_LV400
#define PHYS_FLASH_SIZE            0x00080000  /* 512KB */
#define CONFIG_SYS_MAX_FLASH_SECT  (11)        /* max number of sectors on one chip */
#define CONFIG_ENV_ADDR            (CONFIG_SYS_FLASH_BASE + 0x070000) /* addr of environment */
#endif

//第175行添加如下内容

#define CONFIG_EON_29LV160AB     1        //添加TQ2440开发板Nor Flash设置
#define PHYS_FLASH_SIZE            0x200000 //我们开发板的Nor Flash是2M
#define CONFIG_SYS_MAX_FLASH_SECT  (35)     //根据EN29LV160AB的芯片手册描述,共35个扇区
#define CONFIG_ENV_ADDR            (CONFIG_SYS_FLASH_BASE + 0x80000) //暂设置环境变量的首地址为0x80000 //在256K处放uboot参数

5、添加Norflash的information

vi include/flash.h



第181行添加

#define EON_ID_LV160AB   0x22492249

6、修改norflash的驱动,在u-boot中对Nor Flash的操作分别有初始化、擦除和写入,所以我们主要修改与硬件密切相关的三个函数flash_init、flash_erase、write_hword。

vi board/samsung/smdk2440/flash.c

由-One 8-Kword, two 4-Kword, one 16-Kword,and thirty-one 32-Kword sectors(word mode)

可知主要扇区大小为32k,so修改第31行

#define MAIN_SECT_SIZE     0x8000  //定义为32k,主要扇区的大小

#define MEM_FLASH_ADDR1  (*(volatile u16 *)(CONFIG_SYS_FLASH_BASE + (0x00000555 << 1)))
#define MEM_FLASH_ADDR2  (*(volatile u16 *)(CONFIG_SYS_FLASH_BASE + (0x000002AA << 1)))

由于我们是把norflash连接到了s3c2440的bank0上,因此norflash中的地址相对于s3c2440来说基址为0x00000000,即CONFIG_SYS_FLASH_BASE  = 0。
而之所以又把norflash中的地址向左移一位(即乘以2),是因为我们是把s3c2440的ADDR1连接到了norflash的A0上的缘故。

由数据手册可知EN29LV160AB第0扇区大小为8K,第1、2为4K,第3为16K,后面31扇区为32K。前面4个扇区加起来刚好是主要扇区的大小 = 32K, 所以修改87行下如下

for (j = 0; j < flash_info.sector_count; j++)
{
    if (j <= 3)
   {
        /* 1st one is 8 KB */
       if (j == 0)
      {
             flash_info.start[j] = flashbase + 0;
      }

      /* 2nd and 3rd are both 4 KB */
      if ((j == 1) || (j == 2))
     {
           flash_info.start[j] = flashbase + 0x2000 + (j - 1) * 0x1000;
     }

     /* 4th 16 KB */
     if (j == 3)
    {
           flash_info.start[j] = flashbase + 0x4000;
     }
}
else
{
       flash_info.start[j] = flashbase + (j - 3) * MAIN_SECT_SIZE;
}
}
size += flash_info.size;



修改flash_print_info,添加EN29LV160AB相关信息如下:

switch (info->flash_id & FLASH_VENDMASK) {
case (AMD_MANUFACT & FLASH_VENDMASK):
  printf ("AMD: ");
  break;
case (EON_MANUFACT & FLASH_VENDMASK):
  printf ("EON: ");
  break;
default:
  printf ("Unknown Vendor ");
  break;
}

switch (info->flash_id & FLASH_TYPEMASK) {
case (AMD_ID_LV400B & FLASH_TYPEMASK):
  printf ("1x Amd29LV400BB (4Mbit)\n");
  break;
case (AMD_ID_LV800B & FLASH_TYPEMASK):
  printf ("1x Amd29LV800BB (8Mbit)\n");
  break;
case (EON_ID_LV160AB & FLASH_TYPEMASK):
  printf ("1x EN29LV160AB (16Mbit)\n");
  break;

default:
  printf ("Unknown Chip Type\n");
  goto Done;
  break;
}

修改int flash_erase (flash_info_t * info, int s_first, int s_last)

if ((info->flash_id & FLASH_VENDMASK) !=
     (EON_MANUFACT & FLASH_VENDMASK)) {
  return ERR_UNKNOWN_FLASH_VENDOR;

7、至此,uboot关于Norflash已经移植好

make distclean

make smdk2440_config

make即可生成u-boot.bin

下载到板子的Norflash,在命令台输入saveenv即可

[SMDK2440]# saveenv

Saving Environment to Flash...

Un-Protected 2 sectors

Erasing Flash...Erasing sector 19 ... ok.

Erasing sector 20 ... ok.

Erased 2 sectors

Writing to Flash... done

Protected 2 sectors

[SMDK2440]# flinfo


Bank # 1: EON: 1x EN29LV160AB (16Mbit)

  Size: 2 MB in 35 Sectors

  Sector Start Addresses:

    00000000 (RO) 00002000 (RO) 00003000 (RO) 00004000 (RO) 00008000 (RO)

    00010000 (RO) 00018000 (RO) 00020000      00028000      00030000     

    00038000      00040000      00048000      00050000      00058000     

    00060000      00068000      00070000      00078000      00080000     

    00088000      00090000      00098000      000A0000      000A8000     

    000B0000      000B8000      000C0000      000C8000      000D0000     

    000D8000      000E0000      000E8000      000F0000      000F8000     

[SMDK2440]#



但是我照着做结果却是start address not on sector boundary
谢谢大家的指点!
亚瑟王 发表于 2011-10-17 16:10:31 | 显示全部楼层
你下载的地址不是Nand Flash的整块的头,而是中间的,由于的操作在u-boot中对Nand Flash来讲是不合法的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-5-3 11:26 , Processed in 1.062500 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表