三、【s3c2440移植u-boot-2016-11】 识别Nor Flash

(一)解决u-boot读取完DRAM后卡死

1、修改common/board_f.c
diff -urN u-boot-2016.11/common/board_f.c u-boot-2016.11_s3c2440/common/board_f.c
--- u-boot-2016.11/common/board_f.c 2016-11-15 00:27:11.000000000 +0800
+++ u-boot-2016.11_s3c2440/common/board_f.c 2018-06-15 16:26:03.283161976 +0800
@@ -517,8 +517,9 @@
     * reserve memory for U-Boot code, data & bss
     * round down to next 4 kB limit
     */
-   gd->relocaddr -= gd->mon_len;
-   gd->relocaddr &= ~(4096 - 1);
+   //gd->relocaddr -= gd->mon_len;
+   //gd->relocaddr &= ~(4096 - 1);
+   gd->relocaddr = (unsigned int)_start;
 #ifdef CONFIG_E500
    /* round down to next 64 kB limit so that IVPR stays aligned */
    gd->relocaddr &= ~(65536 - 1);
2、烧写u-boot.bin到Nor Flash或Nand Flash上
book@ubuntu:~/u-boot-2016.11$ ./auto_run.sh  

这里写图片描述

(二)查看Nor Flash信息

1、分析flash_init的过程
drivers/mtd/cfi_flash.c  
    flash_init  
        flash_detect_legacy(cfi_flash_bank_addr(i)  
            jedec_flash_match(info, info->start[0])  
                jedec_table(这里面就有许多Flash的一些信息,比如:厂家ID、设备ID、容量等)  
2、修改drivers/mtd/cfi_flash.c,使其打印出调试信息
diff -urN u-boot-2016.11/drivers/mtd/cfi_flash.c u-boot-2016.11_s3c2440/drivers/mtd/cfi_flash.c
--- u-boot-2016.11/drivers/mtd/cfi_flash.c  2016-11-15 00:27:11.000000000 +0800
+++ u-boot-2016.11_s3c2440/drivers/mtd/cfi_flash.c  2018-06-15 16:45:39.679161976 +0800
@@ -30,6 +30,9 @@
 #include <mtd/cfi_flash.h>
 #include <watchdog.h>

+#define DEBUG 1
+#define _DEBUG 1
+
 /*
  * This file implements a Common Flash Interface (CFI) driver for
  * U-Boot.
3、烧写u-boot.bin到NOR Flash上启动
book@ubuntu:~/u-boot-2016.11$ ./auto_run.sh

这里写图片描述
可以看出我的NOR Flash 厂家ID:c2、设备ID:2249,查看jedec_flash.c文件发现在jedec_table数组里面是没有的该型号的Nor Flash信息

(三)u-boot识别Nor Flash

1、修改drivers/mtd/jedec_flash.c增加MTLV160DB这款Nor Flash信息

大家要知道清楚自己的开发板所用到的Nor Flash型号并相应进行一小部分修改就可以了

diff -urN u-boot-2016.11/drivers/mtd/jedec_flash.c u-boot-2016.11_s3c2440/drivers/mtd/jedec_flash.c
--- u-boot-2016.11/drivers/mtd/jedec_flash.c    2016-11-15 00:27:11.000000000 +0800
+++ u-boot-2016.11_s3c2440/drivers/mtd/jedec_flash.c    2018-06-15 17:01:46.951161976 +0800
@@ -57,6 +57,8 @@

 /* MXIC */
 #define MX29LV040  0x004F
+#define MTLV160DB  0X2249
+

 /* WINBOND */
 #define W39L040A   0x00D6
@@ -401,6 +403,25 @@
        }
    },
 #endif
+   /* JZ2440v3使用的MTLV160DB */
+   {
+       .mfr_id     = (u16)MX_MANUFACT, /* 厂家ID */
+       .dev_id     = MTLV160DB,        /* 设备ID */
+       .name       = "MXIC MTLV160DB",
+       .uaddr      = { /* NOR flash看到解锁地址 */
+           [1] = MTD_UADDR_0x0555_0x02AA /* x16 */
+       },
+       .DevSize    = SIZE_2MiB,        /* 总大小 */
+       .CmdSet     = P_ID_AMD_STD,
+       .NumEraseRegions= 4,
+       .regions    = {
+           ERASEINFO(16*1024, 1),
+           ERASEINFO(8*1024, 2),
+           ERASEINFO(32*1024, 1),
+           ERASEINFO(64*1024, 31),
+       }
+   },
+
 };

 static inline void fill_info(flash_info_t *info, const struct amd_flash_info *jedec_entry, ulong base)
2、烧写u-boot.bin到Nor Flash上启动
book@ubuntu:~/u-boot-2016.11$ ./auto_run.sh  

这里写图片描述
可以看到已经可以成功识别到2MB大小的Nor Flash了,但还存在错误信息ERROR: too many flash sectors

3、修改include/configs/smdk2440.h
diff -urN u-boot-2016.11/include/configs/smdk2440.h u-boot-2016.11_s3c2440/include/configs/smdk2440.h
--- u-boot-2016.11/include/configs/smdk2440.h   2018-06-15 16:28:35.839161976 +0800
+++ u-boot-2016.11_s3c2440/include/configs/smdk2440.h   2018-06-15 17:17:26.087161976 +0800
@@ -135,7 +135,7 @@

 #define CONFIG_SYS_MAX_FLASH_BANKS 1
 #define CONFIG_SYS_FLASH_BANKS_LIST     { CONFIG_SYS_FLASH_BASE }
-#define CONFIG_SYS_MAX_FLASH_SECT  (19)
+#define CONFIG_SYS_MAX_FLASH_SECT  (128)

 #define CONFIG_ENV_ADDR            (CONFIG_SYS_FLASH_BASE + 0x070000)
 #define CONFIG_ENV_IS_IN_FLASH
4、修改drivers/mtd/cfi_flash.c关闭调试信息
diff -urN u-boot-2016.11/drivers/mtd/cfi_flash.c u-boot-2016.11_s3c2440/drivers/mtd/cfi_flash.c
--- u-boot-2016.11/drivers/mtd/cfi_flash.c  2018-06-15 17:02:57.551161976 +0800
+++ u-boot-2016.11_s3c2440/drivers/mtd/cfi_flash.c  2018-06-15 17:17:50.607161976 +0800
@@ -30,8 +30,8 @@
 #include <mtd/cfi_flash.h>
 #include <watchdog.h>

-#define DEBUG 1
-#define _DEBUG 1
+//#define DEBUG 1
+//#define _DEBUG 1

 /*
  * This file implements a Common Flash Interface (CFI) driver for
5、重新烧写u-boot.bin到Nor Flash上
book@ubuntu:~/u-boot-2016.11$ ./auto_run.sh

这里写图片描述
到此已经成功识别到Nor Flash为2MB

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值