Rumah > Artikel > pangkalan data > 2.识别nandflash
kangear注:此文描述了u-boot中的分区 开启调试 修改wyh2440.h /* *debug enable */ #define DEBUG #define CONFIG_NAND_DEBUG 修改s3c2440_nand.c #if !defined(CONFIG_NAND_DEBUG) #undef debug #define debug(fmt,args...) #endif #define S3C2440_ADDR_N
kangear注:此文描述了u-boot中的分区
开启调试
修改wyh2440.h
/*
*debug enable
*/
#define DEBUG
#define CONFIG_NAND_DEBUG
修改s3c2440_nand.c
+#if !defined(CONFIG_NAND_DEBUG)
+#undef debug
+#define debug(fmt,args...)
+#endif
+#define S3C2440_ADDR_NALE 0x08
+#define S3C2440_ADDR_NCLE 0x0c
修改 s3c2440_hwcontrol 函数
static void s3c2440_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
{
struct nand_chip *chip = mtd->priv;
struct s3c2440_nand *nand = s3c2440_get_base_nand();
debug("hwcontrol(): 0x%02x 0x%02x\n", cmd, ctrl);
if (ctrl & NAND_CTRL_CHANGE) {
ulong IO_ADDR_W = (ulong)nand;
if (!(ctrl & NAND_CLE))
IO_ADDR_W |= S3C2440_ADDR_NCLE;
if (!(ctrl & NAND_ALE))
IO_ADDR_W |= S3C2440_ADDR_NALE;
if(cmd == NAND_CMD_NONE)
IO_ADDR_W = (ulong)&nand->nfdata;
chip->IO_ADDR_W = (void *)IO_ADDR_W;
/*
if (ctrl & NAND_NCE)
writel(readl(&nand->nfconf) & ~S3C2440_NFCONF_nFCE,
&nand->nfconf);
else
writel(readl(&nand->nfconf) | S3C2440_NFCONF_nFCE,
&nand->nfconf);
*/
}
if (cmd != NAND_CMD_NONE)
writeb(cmd, chip->IO_ADDR_W);
}
没完没了的hwcontrol() dev_ready打印信息
还是取消nand 的debug信息吧
/*#define CONFIG_NAND_DEBUG*/
make download go
U-Boot 2012.04.01 (Jul 03 2012 - 11:51:29)
U-Boot code: 30000000 -> 3006C274 BSS: -> 300AF944
CPUID: 32440001
FCLK: 400 MHz
HCLK: 100 MHz
PCLK: 50 MHz
monitor len: 000AF944
ramsize: 04000000
TLB table at: 33ff0000
Top of RAM usable for U-Boot at: 33ff0000
Reserving 702k for U-Boot at: 33f40000
Reserving 4096k for malloc() at: 33b40000
Reserving 36 Bytes for Board Info at: 33b3ffdc
Reserving 120 Bytes for Global Data at: 33b3ff64
New Stack Pointer is: 33b3ff58
RAM Configuration:
Bank #0: 30000000 64 MiB
relocation Offset is: 03f40000
WARNING: Caches not enabled
monitor flash len: 00074ADC
dram_bank_mmu_setup: bank: 0
Now running in RAM - U-Boot at: 33f40000
NAND: 256 MiB
*** Warning - bad CRC, using default environment
Destroy Hash Table: 33fadd70 table = (null)
Create Hash Table: N=75
INSERT: table 33fadd70, filled 1/79 rv 33b42a78 ==> name="bootdelay" value="5"
INSERT: table 33fadd70, filled 2/79 rv 33b429b8 ==> name="baudrate" value="115200"
INSERT: table 33fadd70, filled 3/79 rv 33b42988 ==> name="ipaddr" value="10.0.0.110"
INSERT: table 33fadd70, filled 4/79 rv 33b42a90 ==> name="serverip" value="10.0.0.1"
INSERT: table 33fadd70, filled 5/79 rv 33b42c1c ==> name="netmask" value="255.255.255.0"
INSERT: free(data = 33b42900)
INSERT: done
In: serial
Out: serial
Err: serial
Net: CS8900-0
### main_loop entered: bootdelay=5
### main_loop: bootcmd="
SMDK2410 #
SMDK2410 # nand info
Device 0: nand0, sector size 128 KiB
Page size 2048 b
OOB size 64 b
Erase size 131072 b
SMDK2410 # nand erase 0x640000 0x20000
测试nand 写入输入到offset 0x640000 size 为0x20000
NAND erase: device 0 offset 0x640000, size 0x20000
Erasing at 0x640000 -- 100% complete.
OK
SMDK2410 #
SMDK2410 # nand write 0x30000000 0x640000 0x20000
NAND write: device 0 offset 0x640000, size 0x20000
131072 bytes written: OK
SMDK2410 # md 30000000
30000000: ea000013 e59ff014 e59ff014 e59ff014 ................
30000010: e59ff014 e59ff014 e59ff014 e59ff014 ................
30000020: 30000200 30000260 300002c0 30000320 ...0`..0...0 ..0
30000030: 30000380 300003e0 30000440 deadbeef ...0...0@..0....
30000040: 30000000 0006c274 000af944 00074adc ...0t...D....J..
30000050: 0badc0de e10f0000 e3c0001f e38000d3 ................
30000060: e129f000 e3a00453 e3a01000 e5801000 ..).S...........
30000070: e3e01000 e59f040c e5801000 e59f1408 ................
30000080: e59f0408 e5801000 e59f0404 e3a01005 ................
30000090: e5801000 ee111f10 e3811103 ee011f10 ................
300000a0: eb000044 e59fd3ec e3cdd007 e3a00000 D...............
300000b0: eb000825 e1a04000 e1a05001 e1a06002 %....@...P...`..
300000c0: e1a0d004 e24f00cc e1500006 0a000022 ......O...P."...
300000d0: e1a01006 e51f3098 e0802003 e8b00600 .....0... ......
300000e0: e8a10600 e1500002 3afffffb e51f00b4 ......P....:....
300000f0: e0469000 e59fa0b8 e08aa000 e59f20a8 ..F.......... ..
SMDK2410 # nand dump 640000
Page 00640000 dump:
13 00 00 ea 14 f0 9f e5 14 f0 9f e5 14 f0 9f e5
14 f0 9f e5 14 f0 9f e5 14 f0 9f e5 14 f0 9f e5
00 02 00 30 60 02 00 30 c0 02 00 30 20 03 00 30
80 03 00 30 e0 03 00 30 40 04 00 30 ef be ad de
00 00 00 30 74 c2 06 00 44 f9 0a 00 dc 4a 07 00
de c0 ad 0b 00 00 0f e1 1f 00 c0 e3 d3 00 80 e3
00 f0 29 e1 53 04 a0 e3 00 10 a0 e3 00 10 80 e5
00 10 e0 e3 0c 04 9f e5 00 10 80 e5 08 14 9f e5
08 04 9f e5 00 10 80 e5 04 04 9f e5 05 10 a0 e3
00 10 80 e5 10 1f 11 ee 03 11 81 e3 10 1f 01 ee
44 00 00 eb ec d3 9f e5 07 d0 cd e3 00 00 a0 e3
25 08 00 eb 00 40 a0 e1 01 50 a0 e1 02 60 a0 e1
04 d0 a0 e1 cc 00 4f e2 06 00 50 e1 22 00 00 0a
06 10 a0 e1 98 30 1f e5 03 20 80 e0 00 06 b0 e8
00 06 a1 e8 02 00 50 e1 fb ff ff 3a b4 00 1f e5
00 90 46 e0 b8 a0 9f e5 00 a0 8a e0 a8 20 9f e5
00 20 82 e0 a4 30 9f e5 00 30 83 e0 00 00 92 e5
09 00 80 e0 04 10 92 e5 ff 70 01 e2 17 00 57 e3
07 00 00 0a 02 00 57 e3 00 00 00 0a 06 00 00 ea
21 12 a0 e1 01 10 8a e0 04 10 91 e5 09 10 81 e0
01 00 00 ea 00 10 90 e5 09 10 81 e0 00 10 80 e5
08 20 82 e2 03 00 52 e1 eb ff ff 3a 20 01 1f e5
20 11 1f e5 06 40 a0 e1 04 00 80 e0 04 10 81 e0
00 20 a0 e3 00 20 80 e5 04 00 80 e2 01 00 50 e1
fb ff ff 1a 7b 07 00 eb 7b 07 00 eb 14 00 9f e5
66 1f 4f e2 01 e0 80 e0 09 e0 8e e0 05 00 a0 e1
06 10 a0 e1 0e f0 a0 e1 4c 20 00 00 74 c2 06 00
0c 4a 07 00 0c 4a 07 00 00 00 a0 e3 17 0f 07 ee
17 0f 08 ee 10 0f 11 ee 23 0c c0 e3 87 00 c0 e3
02 00 80 e3 01 0a 80 e3 10 0f 01 ee 0e c0 a0 e1
0c e0 a0 e1 0e f0 a0 e1 00 00 a0 e1 00 00 a0 e1
00 00 a0 e1 00 00 a0 e1 00 00 a0 e1 00 00 a0 e1
b8 d1 1f e5 00 e0 8d e5 00 e0 4f e1 04 e0 8d e5
13 d0 a0 e3 0d f0 69 e1 0f e0 a0 e1 0e f0 b0 e1
48 d0 4d e2 ff 1f 8d e8 e0 21 1f e5 0c 00 92 e8
48 00 8d e2 34 50 8d e2 0e 10 a0 e1 0f 00 85 e8
0d 00 a0 e1 71 09 00 eb 00 00 a0 e1 00 00 a0 e1
00 00 a0 e1 00 00 a0 e1 00 00 a0 e1 00 00 a0 e1
18 d2 1f e5 00 e0 8d e5 00 e0 4f e1 04 e0 8d e5
13 d0 a0 e3 0d f0 69 e1 0f e0 a0 e1 0e f0 b0 e1
48 d0 4d e2 ff 1f 8d e8 40 22 1f e5 0c 00 92 e8
48 00 8d e2 34 50 8d e2 0e 10 a0 e1 0f 00 85 e8
0d 00 a0 e1 50 09 00 eb 00 00 a0 e1 00 00 a0 e1
00 00 a0 e1 00 00 a0 e1 00 00 a0 e1 00 00 a0 e1
78 d2 1f e5 00 e0 8d e5 00 e0 4f e1 04 e0 8d e5
13 d0 a0 e3 0d f0 69 e1 0f e0 a0 e1 0e f0 b0 e1
48 d0 4d e2 ff 1f 8d e8 a0 22 1f e5 0c 00 92 e8
48 00 8d e2 34 50 8d e2 0e 10 a0 e1 0f 00 85 e8
0d 00 a0 e1 2f 09 00 eb 00 00 a0 e1 00 00 a0 e1
00 00 a0 e1 00 00 a0 e1 00 00 a0 e1 00 00 a0 e1
d8 d2 1f e5 00 e0 8d e5 00 e0 4f e1 04 e0 8d e5
13 d0 a0 e3 0d f0 69 e1 0f e0 a0 e1 0e f0 b0 e1
48 d0 4d e2 ff 1f 8d e8 00 23 1f e5 0c 00 92 e8
48 00 8d e2 34 50 8d e2 0e 10 a0 e1 0f 00 85 e8
0d 00 a0 e1 0e 09 00 eb 00 00 a0 e1 00 00 a0 e1
00 00 a0 e1 00 00 a0 e1 00 00 a0 e1 00 00 a0 e1
38 d3 1f e5 00 e0 8d e5 00 e0 4f e1 04 e0 8d e5
13 d0 a0 e3 0d f0 69 e1 0f e0 a0 e1 0e f0 b0 e1
48 d0 4d e2 ff 1f 8d e8 60 23 1f e5 0c 00 92 e8
48 00 8d e2 34 50 8d e2 0e 10 a0 e1 0f 00 85 e8
0d 00 a0 e1 ed 08 00 eb 00 00 a0 e1 00 00 a0 e1
00 00 a0 e1 00 00 a0 e1 00 00 a0 e1 00 00 a0 e1
98 d3 1f e5 00 e0 8d e5 00 e0 4f e1 04 e0 8d e5
13 d0 a0 e3 0d f0 69 e1 0f e0 a0 e1 0e f0 b0 e1
48 d0 4d e2 ff 1f 8d e8 c0 23 1f e5 0c 00 92 e8
48 00 8d e2 34 50 8d e2 0e 10 a0 e1 0f 00 85 e8
0d 00 a0 e1 c3 08 00 eb 00 00 a0 e1 00 00 a0 e1
00 00 a0 e1 00 00 a0 e1 00 00 a0 e1 00 00 a0 e1
f8 d3 1f e5 00 e0 8d e5 00 e0 4f e1 04 e0 8d e5
13 d0 a0 e3 0d f0 69 e1 0f e0 a0 e1 0e f0 b0 e1
48 d0 4d e2 ff 1f 8d e8 20 24 1f e5 0c 00 92 e8
48 00 8d e2 34 50 8d e2 0e 10 a0 e1 0f 00 85 e8
0d 00 a0 e1 b4 08 00 eb 08 00 00 4a ff 7f 00 00
1c 00 00 4a 14 00 00 4c 80 ff ff 33 00 00 a0 e1
10 40 2d e9 4d 08 00 eb 20 09 00 eb 1d 09 00 eb
00 30 a0 e3 17 3f 07 ee 00 00 a0 e3 10 80 bd e8
30 40 2d e9 80 30 9f e5 24 d0 4d e2 00 10 93 e5
78 00 9f e5 d8 37 00 eb 47 00 00 eb 00 10 a0 e1
0d 00 a0 e1 76 28 01 eb 64 50 9f e5 00 20 a0 e1
46 10 a0 e3 05 00 a0 e1 cf 37 00 eb 40 00 00 eb
00 10 a0 e1 0d 00 a0 e1 6d 28 01 eb 48 10 a0 e3
00 20 a0 e1 05 00 a0 e1 c7 37 00 eb 5f 00 00 eb
00 10 a0 e1 0d 00 a0 e1 65 28 01 eb 50 10 a0 e3
00 20 a0 e1 05 00 a0 e1 bf 37 00 eb 0d 40 a0 e1
00 00 a0 e3 24 d0 8d e2 30 80 bd e8 b0 00 00 56
b5 99 05 30 c2 99 05 30 00 00 50 e3 10 40 2d e9
02 00 00 1a 7c 30 9f e5 00 30 93 e5 03 00 00 ea
01 00 50 e3 0d 00 00 1a 6c 30 9f e5 00 30 93 e5
03 20 a0 e1 3f 3e 03 e2 ff 1a 02 e2 23 32 a0 e1
21 16 a0 e1 02 30 83 e2 03 20 02 e2 00 00 50 e3
13 22 a0 e1 08 40 81 e2 07 00 00 1a 00 00 00 ea
a1 06 00 eb 02 10 a0 e1 30 00 9f e5 b9 54 01 eb
84 40 a0 e1 90 04 03 e0 04 00 00 ea 1c 30 9f e5
02 10 a0 e1 93 04 00 e0 b2 54 01 eb 00 30 a0 e1
03 00 a0 e1 10 80 bd e8 04 00 00 4c 08 00 00 4c
00 1b b7 00 01 00 a0 e3 d6 ff ff ea 00 00 a0 e3
d4 ff ff ea 8c 30 9f e5 10 40 2d e9 00 30 93 e5
06 40 03 e2 04 00 54 e3 08 00 00 0a 06 00 54 e3
10 00 00 0a 02 00 54 e3 01 00 00 0a 10 40 bd e8
f1 ff ff ea f0 ff ff eb a0 00 a0 e1 10 80 bd e8
54 30 9f e5 00 30 93 e5 02 0c 13 e3 02 00 00 0a
e9 ff ff eb a0 01 a0 e1 10 80 bd e8 e6 ff ff eb
20 01 a0 e1 10 80 bd e8 2c 30 9f e5 00 30 93 e5
01 0c 13 e3 03 00 00 0a df ff ff eb 04 10 a0 e1
88 54 01 eb 10 80 bd e8 db ff ff eb 03 10 a0 e3
84 54 01 eb 10 80 bd e8 14 00 00 4c 18 00 00 4c
20 30 9f e5 10 40 2d e9 00 30 93 e5 01 00 13 e3
02 00 00 0a d2 ff ff eb a0 00 a0 e1 10 80 bd e8
10 40 bd e8 ce ff ff ea 14 00 00 4c 5c 30 9f e5
00 30 93 e5 03 c8 a0 e1 30 30 98 e5 2c c8 a0 e1
0c 00 53 e1 08 00 a0 e1 05 00 00 3a 20 20 98 e5
30 30 98 e5 02 30 83 e0 03 30 6c e0 20 30 88 e5
06 00 00 ea 20 30 98 e5 30 20 98 e5 24 10 98 e5
03 20 82 e0 01 20 82 e0 02 20 6c e0 20 20 88 e5
30 c0 80 e5 00 10 a0 e3 20 00 90 e5 0e f0 a0 e1
40 00 00 51 fa 0f 50 e3 10 40 2d e9 00 10 a0 e1
07 00 00 3a fa 1f a0 e3 56 54 01 eb 24 20 98 e5
64 30 a0 e3 92 03 03 e0 fa 1f a0 e3 93 00 00 e0
04 00 00 ea 24 20 98 e5 64 30 a0 e3 92 03 03 e0
91 03 00 e0 20 10 9f e5 4a 54 01 eb 00 40 a0 e1
d1 ff ff eb 00 40 84 e0 cf ff ff eb 04 00 60 e0
00 00 50 e3 fb ff ff aa 10 80 bd e8 40 42 0f 00
10 40 2d e9 c8 ff ff eb fa 1f a0 e3 00 40 a0 e1
1c 00 98 e5 3b 54 01 eb 00 10 a0 e1 04 00 a0 e1
38 54 01 eb 10 80 bd e8 10 40 2d e9 00 40 a0 e1
f2 ff ff eb 00 00 64 e0 10 80 bd e8 70 40 2d e9
00 40 a0 e1 b8 ff ff eb fa 1f a0 e3 00 50 a0 e1
04 00 a0 e1 2b 54 01 eb 24 20 98 e5 64 30 a0 e3
OOB:
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
59 99 5b aa a9 6b a9 a5
9b fc c3 33 c3 30 33 3f
c0 f3 65 95 57 cc 3f cf
Command failed, result=1SMDK2410 #
SMDK2410 # nand read 31000000 640000 20000
NAND read: device 0 offset 0x640000, size 0x20000
131072 bytes read: OK
SMDK2410 # cmp 30000000 31000000 20000
word at 0x30020000 (0xe3a01030) != word at 0x31020000 (0xc5060008)
Total of 32768 words were the same
Command failed, result=1SMDK2410 #
正好0x20000个字的数据匹配
SMDK2410 # mtd
---mtdparts_init---
last_ids :
env_ids :
last_parts:
env_parts :
last_partition :
env_partition :
mtdids not defined, no default present
添加mtd分区
修改wyh2440.h
#define MTDIDS_DEFAULT "nand0=nandflash0"
#define MTDPARTS_DEFAULT "mtdparts=nandflash0:" \
"128k@0(spl),"/*offset 0x000000*/ \
"128k(env)," /*offset 0x020000*/ \
"1m(logo)," /*offset 0x040000*/ \
"1m(u-boot)," /*offset 0x140000*/ \
"4m(kernel)," /*offset 0x240000*/ \
"-(rootfs)" /*offset 0x640000*/
#define CONFIG_EXTRA_ENV_SETTINGS "mtdid=" MTDIDS_DEFAULT "\0" \
"mtdparts=" MTDPARTS_DEFAULT "\0"
make download go
SMDK2410 # mtd
---mtdparts_init---
last_ids :
env_ids :
last_parts:
env_parts : mtdparts=nandflash0:128k@0(spl),128k(env),1m(logo),1m(u-boot),4m(kernel),-(rootfs)
last_partition :
env_partition :
mtdids variable not defined, using default
---parse_mtdids---
mtdids = nand0=nandflash0
+ id nand0 268435456 bytes nandflash0
---parse_mtdparts---
mtdparts = mtdparts=nandflash0:128k@0(spl),128k(env),1m(logo),1m(u-boot),4m(kernel),-(rootfs)
--- current_save ---
hdelete: DELETE key "partition"
=> partition NULL
--- index partitions ---
hdelete: DELETE key "mtddevnum"
hdelete: DELETE key "mtddevname"
=> mtddevnum NULL
=> mtddevname NULL
===device_parse===
--- id_find_by_mtd_id: 'nandflash0' (len = 10)
entry: 'nandflash0' (len = 10)
dev type = 2 (nand), dev num = 0, mtd-id = nandflash0
parsing partitions 128k@0(spl),128k(env),1m(logo),1m(u-boot),4m(kernel),-(rootfs)
+ partition: name spl size 0x00020000 offset 0x00000000 mask flags 0
+ partition: name env size 0x00020000 offset 0xffffffff mask flags 0
+ partition: name logo size 0x00100000 offset 0xffffffff mask flags 0
+ partition: name u-boot size 0x00100000 offset 0xffffffff mask flags 0
+ partition: name kernel size 0x00400000 offset 0xffffffff mask flags 0
'-': remaining size assigned
+ partition: name rootfs size 0xffffffff offset 0xffffffff mask flags 0
total partitions: 6
part_sort_add: list empty
--- index partitions ---
hdelete: DELETE key "mtddevnum"
hdelete: DELETE key "mtddevname"
=> mtddevnum NULL
=> mtddevname NULL
--- index partitions ---
hdelete: DELETE key "mtddevnum"
hdelete: DELETE key "mtddevname"
=> mtddevnum NULL
=> mtddevname NULL
--- index partitions ---
hdelete: DELETE key "mtddevnum"
hdelete: DELETE key "mtddevname"
=> mtddevnum NULL
=> mtddevname NULL
--- index partitions ---
hdelete: DELETE key "mtddevnum"
hdelete: DELETE key "mtddevname"
=> mtddevnum NULL
=> mtddevname NULL
--- index partitions ---
hdelete: DELETE key "mtddevnum"
hdelete: DELETE key "mtddevname"
=> mtddevnum NULL
=> mtddevname NULL
--- index partitions ---
hdelete: DELETE key "mtddevnum"
hdelete: DELETE key "mtddevname"
=> mtddevnum NULL
=> mtddevname NULL
===
+ device: nand 0 nandflash0
--- current_save ---
=> partition nand0,0
--- index partitions ---
--- mtd_part_info: partition number 0 for device nand0 (nandflash0)
=> mtddevnum 0,
=> mtddevname spl
mtdparts_init: current_mtd_dev = nand0, current_mtd_partnum = 0
---list_partitions---
device nand0
#: name size offset mask_flags
0: spl 0x00020000 0x00000000 0
1: env 0x00020000 0x00020000 0
2: logo 0x00100000 0x00040000 0
3: u-boot 0x00100000 0x00140000 0
4: kernel 0x00400000 0x00240000 0
5: rootfs 0x0f9c0000 0x00640000 0
--- mtd_part_info: partition number 0 for device nand0 (nandflash0)
active partition: nand0,0 - (spl) 0x00020000 @ 0x00000000
defaults:
mtdids : nand0=nandflash0
mtdparts: mtdparts=nandflash0:128k@0(spl),128k(env),1m(logo),1m(u-boot),4m(kernel),-(rootfs)
SMDK2410 #
http://blog.163.com/yihui_wang/blog/static/1862154902012638928107/