移植u-boot-1.1.6之NOR的支持

u-boot-1.1.6里面默认配置文件里面支持的nor型号是

1 #if 0
2 #define CONFIG_AMD_LV400    1    /* uncomment this if you have a LV400 flash */
3 #endif
4 #define CONFIG_AMD_LV800    1    /* uncomment this if you have a LV800 flash */

而我们使用的nor flash不是LV400/LV800;

我们使用的芯片是MX29LV160DB,但是uboot里面没有,而有相近的AM29LV040B,这是需要借助数据手册仿写一个
MX29LV160DB特性有:
大小:2M
位数:16位
扇区数目:4个

已经有的配置: 在jedec_flash.c里面
{
  .mfr_id = (u16)AMD_MANUFACT,
  .dev_id = AM29LV040B,
  .name = "AMD AM29LV040B",
  .uaddr = {
  [0] = MTD_UADDR_0x0555_0x02AA /* x8 */
  },
  .DevSize = SIZE_512KiB,
  .CmdSet = P_ID_AMD_STD,
  .NumEraseRegions= 1,
  .regions = {
  ERASEINFO(0x10000,8),
  }
  }


以上各种参数说明:
  struct amd_flash_info {
  const __u16 mfr_id;
  const __u16 dev_id;
  const char *name;
  const int DevSize;
  const int NumEraseRegions;
  const int CmdSet;
  const __u8 uaddr[4]; /* unlock addrs for 8, 16, 32, 64 */
  const ulong regions[6];
  };

我们修改为:

 1 {
 2         .mfr_id        = MANUFACTURER_AMD,   //制造商
 3         .dev_id        = AM29LV160DB,        //型号
 4         .name        = "AMD AM29LV160DB",    //名字
 5         .uaddr        = {
 6             [0] = MTD_UADDR_0x0AAA_0x0555,  /* x8 */
 7             [1] = MTD_UADDR_0x0555_0x02AA   /* x16 */  输出对应指令,翻阅数据手册
 8         },
 9         .DevSize    = SIZE_2MiB,         //大小
10         .CmdSet        = P_ID_AMD_STD,   
11         .NumEraseRegions= 4,              //分区数目
12         .regions    = {                  //分区列表,参看nor数据手册
13             ERASEINFO(0x04000,1),
14             ERASEINFO(0x02000,2),
15             ERASEINFO(0x08000,1),
16             ERASEINFO(0x10000,31)
17         }
18     }

现在回顾nor flash的调用过程:

board.c里面调用flash_init ();

flash_init ();

  cfi_flash.c   //注意,正常情形使用flash.c,不过因为flash.c里面没有我们需要的型号,所以应该在flash.c所在目录下的Makefile里面去掉flash.o

  flash_detect_legacy

    flash_read_jedec_ids       //制造商

    jedec_flash_match

      jedec_table  //在芯片table里面匹配有无支持的NOR flash

  flash_get_size

原文地址:https://www.cnblogs.com/hulig7/p/4746912.html