• «
  • 1
  • 2
  • »
  • Pages: 1/2     Go
主题 : Nand layout for 1GB SLC, 2GB/4GB MLC nand 复制链接 | 浏览器收藏 | 打印
Cya,Reggie.
级别: 侠客
UID: 81867
精华: 1
发帖: 68
金钱: 390 两
威望: 78 点
贡献值: 1 点
综合积分: 156 分
注册时间: 2012-11-14
最后登录: 2014-10-30
楼主  发表于: 2013-05-01 10:27

 Nand layout for 1GB SLC, 2GB/4GB MLC nand

管理提醒: 本帖被 xoom 设置为精华(2013-05-02)
Hi Everyone, I thought I'd take some time to dump some information from the nand driver for the mini210/tiny210 range of boards.

I've only dumped information for mini210S boards that have 1GB slc, 2GB or 4GB mlc nand onboard, however, the tiny210v2 boards use 2GB mlc nand so this information should be valid for those boards too.  The information was dumped from the following chips:
1GB SLC = K9K8G08U0A
2GB MLC = K9GAG08U0F
4GB MLC = K9GBG08U0A

If your mini/tiny210 board chip has one of these chips on it then the information below is valid.

Here is the information I dumped into the kernel boot logs from the nand driver:


4GB MLC log

[    0.997933] S3C NAND Driver, (c) 2008 Samsung Electronics
[    0.998458] s3c-nand: ID bytes  ec  d7  94  7a  54  43  ec  d7  
[    1.004047]
[    1.005785] S3C NAND Driver is using hardware ECC.
[    1.010610] NAND device: Manufacturer ID: 0xec, Chip ID: 0xd7 (Samsung NAND 4GiB 3,3V 8-bit)
[    1.018985] Creating 5 MTD partitions on "s5pv210-nand":
[    1.024261] 0x0000000c0000-0x000000100000 : "misc"
[    1.030145] 0x000000100000-0x000000600000 : "recovery"
[    1.035644] 0x000000600000-0x000000b00000 : "kernel"
[    1.040958] 0x000000b00000-0x000000e00000 : "ramdisk"
[    1.045379] 0x000000e00000-0x000100000000 : "system"
[    1.706875] Nand oob info:   Dumping the nand ecc layout positions
[    1.706928]
[    1.706943] 40, 41, 42, 43, 44, 45, 46, 47, 48,
[    1.706993] 49, 50, 51, 52, 53, 54, 55, 56,
[    1.707039] 57, 58, 59, 60, 61, 62, 63, 64,
[    1.707085] 65, 66, 67, 68, 69, 70, 71, 72,
[    1.709397] 73, 74, 75, 76, 77, 78, 79, 80,
[    1.713643] 81, 82, 83, 84, 85, 86, 87, 88,
[    1.717890] 89, 90, 91, 92, 93, 94, 95, 96,
[    1.722155] 97, 89, 99, 100, 101, 102, 103, 104,
[    1.726815] 105, 106, 107, 108, 109, 110, 111, 112,
[    1.731755] 113, 114, 115, 116, 117, 118, 119, 120,
[    1.736694] 121, 122, 123, 124, 125, 126, 127, 128,
[    1.741634] 129, 130, 131, 132, 133, 134, 135, 136,
[    1.746573] 137, 138, 139, 140, 141, 142, 143, 144,
[    1.751513] 145, 146, 147, 148, 149, 150, 151, 152,
[    1.756452] 153, 154, 155, 156, 157, 158, 159, 160,
[    1.761391] 161, 162, 163, 164, 165, 166, 167, 168,
[    1.766331] 169, 170, 171, 172, 173, 174, 175, 176,
[    1.771270] 177, 178, 179, 180, 181, 182, 183, 184,
[    1.776210] 185, 186, 187, 188, 189, 190, 191, 192,
[    1.781149] 193, 194, 195, 196, 197, 198, 199, 200,
[    1.786089] 201, 202, 203, 204, 205, 206, 207, 208,
[    1.791028] 209, 210, 211, 212, 213, 214, 215, 216,
[    1.795967] 217, 218, 219, 220, 221, 222, 223, 224,
[    1.800907] 225, 226, 227, 228, 229, 230, 231, 232,
[    1.805846] 233, 234, 235, 236, 237, 238, 239, 240,
[    1.810786] 241, 242, 243, 244, 245, 246, 247, 248,
[    1.815725] 249, 250, 251, 252, 253, 254, 255, 256,
[    1.820664] 257, 258, 259, 260, 261, 262, 263, 264,
[    1.825604] 265, 266, 267, 268, 269, 270, 271, 272,
[    1.830543] 273, 274, 275, 276, 277, 278, 279, 280,
[    1.835483] 281, 282, 283, 284, 285, 286, 287, 288,
[    1.840422] 289, 290, 291, 292, 293, 294, 295, 296,
[    1.845362] 297, 298, 299, 300, 301, 302, 303, 304,
[    1.850301] 305, 306, 307, 308, 309, 310, 311, 312,
[    1.855241] 313, 314, 315, 316, 317, 318, 319, 320,
[    1.860180] 321, 322, 323, 324, 325, 326, 327, 328,
[    1.865119] 329, 330, 331, 332, 333, 334, 335, 336,
[    1.870059] 337, 338, 339, 340, 341, 342, 343, 344,
[    1.874998] 345, 346, 347, 348, 349, 350, 351, 352,
[    1.879938] 353, 354, 355, 356, 357, 358, 359, 360,
[    1.884877] 361, 362, 363, 364, 365, 366, 367, 368,
[    1.889817] 369, 370, 371, 372, 373, 374, 375, 376,
[    1.894756] 377, 378, 379, 380, 381, 382, 383, 384,
[    1.899695] 385, 386, 387, 388, 389, 390, 391, 392,
[    1.904635] 393, 394, 395, 396, 397, 398, 399, 400,
[    1.909574] 401, 402, 403, 404, 405, 406, 407, 408,
[    1.914514] 409, 410, 411, 412, 413, 414, 415, 416,
[    1.919453] 417, 418, 419, 420, 421, 422, 423, 424,
[    1.924392] 425, 426, 427, 428, 429, 430, 431, 432,
[    1.929332] 433, 434, 435, 436, 437, 438, 439, 440,
[    1.934271] 441, 442, 443, 444, 445, 446, 447, 448,
[    1.939211] 449, 450, 451, 452, 453, 454, 455, 456,
[    1.944150] 457, 458, 459, 460, 461, 462, 463, 464,
[    1.949090] 465, 466, 467, 468, 469, 470, 471, 472,
[    1.954029] 473, 474, 475, 476, 477, 478, 479, 480,
[    1.958969] 481, 482, 483, 484, 485, 486, 487,
[    1.963475] Dumping the nand ecc layout
[    1.967302] .eccbytes 448
[    1.969975] .oobfree offset 4
[    1.973019] .oobfree length 32
[    1.976127] ecc bytes  28
[    1.978825] ecc size 512
[    1.981416] badblockbits 4
[    1.984198] chip->pagemask 524287
[    1.987577] mtd->oobsize 640
[    1.990512] chip->ecc.steps 16
[    1.993643] mtd->writesize 8192
[    1.996841] chip->ecc.total 448

2GB MLC log

[    0.997921] S3C NAND Driver, (c) 2008 Samsung Electronics
[    0.998459] s3c-nand: ID bytes  ec  d5  94  76  54  43  ec  d5  
[    1.004046]
[    1.005784] S3C NAND Driver is using hardware ECC.
[    1.010611] NAND device: Manufacturer ID: 0xec, Chip ID: 0xd5 (Samsung NAND 2GiB 3,3V 8-bit)
[    1.018982] Creating 5 MTD partitions on "s5pv210-nand":
[    1.024260] 0x0000000c0000-0x000000100000 : "misc"
[    1.030141] 0x000000100000-0x000000600000 : "recovery"
[    1.035885] 0x000000600000-0x000000b00000 : "kernel"
[    1.040751] 0x000000b00000-0x000000e00000 : "ramdisk"
[    1.045386] 0x000000e00000-0x000080000000 : "system"
[    1.379992] Nand oob info:   Dumping the nand ecc layout positions
[    1.380046]
[    1.380061] 40, 41, 42, 43, 44, 45, 46, 47, 48,
[    1.380112] 49, 50, 51, 52, 53, 54, 55, 56,
[    1.380157] 57, 58, 59, 60, 61, 62, 63, 64,
[    1.380203] 65, 66, 67, 68, 69, 70, 71, 72,
[    1.382511] 73, 74, 75, 76, 77, 78, 79, 80,
[    1.386757] 81, 82, 83, 84, 85, 86, 87, 88,
[    1.391003] 89, 90, 91, 92, 93, 94, 95, 96,
[    1.395249] 97, 89, 99, 100, 101, 102, 103, 104,
[    1.399929] 105, 106, 107, 108, 109, 110, 111, 112,
[    1.404868] 113, 114, 115, 116, 117, 118, 119, 120,
[    1.409807] 121, 122, 123, 124, 125, 126, 127, 128,
[    1.414747] 129, 130, 131, 132, 133, 134, 135, 136,
[    1.419686] 137, 138, 139, 140, 141, 142, 143, 144,
[    1.424626] 145, 146, 147, 148, 149, 150, 151, 152,
[    1.429565] 153, 154, 155, 156, 157, 158, 159, 160,
[    1.434505] 161, 162, 163, 164, 165, 166, 167, 168,
[    1.439444] 169, 170, 171, 172, 173, 174, 175, 176,
[    1.444383] 177, 178, 179, 180, 181, 182, 183, 184,
[    1.449323] 185, 186, 187, 188, 189, 190, 191, 192,
[    1.454262] 193, 194, 195, 196, 197, 198, 199, 200,
[    1.459202] 201, 202, 203, 204, 205, 206, 207, 208,
[    1.464141] 209, 210, 211, 212, 213, 214, 215, 216,
[    1.469081] 217, 218, 219, 220, 221, 222, 223, 224,
[    1.474020] 225, 226, 227, 228, 229, 230, 231, 232,
[    1.478959] 233, 234, 235, 236, 237, 238, 239, 240,
[    1.483899] 241, 242, 243, 244, 245, 246, 247, 248,
[    1.488838] 249, 250, 251, 252, 253, 254, 255, 256,
[    1.493778] 257, 258, 259, 260, 261, 262, 263, 264,
[    1.498717] 265, 266, 267, 268, 269, 270, 271, 272,
[    1.503657] 273, 274, 275, 276, 277, 278, 279, 280,
[    1.508596] 281, 282, 283, 284, 285, 286, 287, 288,
[    1.513536] 289, 290, 291, 292, 293, 294, 295, 296,
[    1.518475] 297, 298, 299, 300, 301, 302, 303, 304,
[    1.523414] 305, 306, 307, 308, 309, 310, 311, 312,
[    1.528354] 313, 314, 315, 316, 317, 318, 319, 320,
[    1.533293] 321, 322, 323, 324, 325, 326, 327, 328,
[    1.538233] 329, 330, 331, 332, 333, 334, 335, 336,
[    1.543172] 337, 338, 339, 340, 341, 342, 343, 344,
[    1.548112] 345, 346, 347, 348, 349, 350, 351, 352,
[    1.553051] 353, 354, 355, 356, 357, 358, 359, 360,
[    1.557990] 361, 362, 363, 364, 365, 366, 367, 368,
[    1.562930] 369, 370, 371, 372, 373, 374, 375, 376,
[    1.567869] 377, 378, 379, 380, 381, 382, 383, 384,
[    1.572809] 385, 386, 387, 388, 389, 390, 391, 392,
[    1.577748] 393, 394, 395, 396, 397, 398, 399, 400,
[    1.582688] 401, 402, 403, 404, 405, 406, 407, 408,
[    1.587627] 409, 410, 411, 412, 413, 414, 415, 416,
[    1.592567] 417, 418, 419, 420, 421, 422, 423, 424,
[    1.597506] 425, 426, 427, 428, 429, 430, 431, 432,
[    1.602446] 433, 434, 435, 436, 437, 438, 439, 440,
[    1.607385] 441, 442, 443, 444, 445, 446, 447, 448,
[    1.612324] 449, 450, 451, 452, 453, 454, 455, 456,
[    1.617275] 457, 458, 459, 460, 461, 462, 463, 464,
[    1.622214] 465, 466, 467, 468, 469, 470, 471, 472,
[    1.627154] 473, 474, 475, 476, 477, 478, 479, 480,
[    1.632082] 481, 482, 483, 484, 485, 486, 487,
[    1.636588] Dumping the nand ecc layout
[    1.640415] .eccbytes 448
[    1.643099] .oobfree offset 4
[    1.646121] .oobfree length 32
[    1.649251] ecc bytes  28
[    1.651927] ecc size 512
[    1.654553] badblockbits 4
[    1.657313] chip->pagemask 262143
[    1.660679] mtd->oobsize 512
[    1.663637] chip->ecc.steps 16
[    1.666745] mtd->writesize 8192
[    1.669966] chip->ecc.total 448

1GB SLC log

[    0.997944] S3C NAND Driver, (c) 2008 Samsung Electronics
[    0.998453] s3c-nand: ID bytes  ec  d3  51  95  58  ec  ec  d3  
[    1.004039]
[    1.005776] S3C NAND Driver is using hardware ECC.
[    1.010602] NAND device: Manufacturer ID: 0xec, Chip ID: 0xd3 (Samsung NAND 1GiB 3,3V 8-bit)
[    1.018975] Creating 5 MTD partitions on "s5pv210-nand":
[    1.024254] 0x0000000c0000-0x000000100000 : "misc"
[    1.030009] 0x000000100000-0x000000600000 : "recovery"
[    1.035888] 0x000000600000-0x000000b00000 : "kernel"
[    1.040825] 0x000000b00000-0x000000e00000 : "ramdisk"
[    1.045433] 0x000000e00000-0x000040000000 : "system"
[    1.228976] Nand oob info:   Dumping the nand ecc layout positions
[    1.229029]
[    1.229044] 40, 41, 42, 43, 44, 45, 46, 47, 48,
[    1.229094] 49, 50, 51, 52, 53, 54, 55,
[    1.229135] Dumping the nand ecc layout
[    1.229168] .eccbytes 16
[    1.229191] .oobfree offset 2
[    1.232102] .oobfree length 38
[    1.235266] ecc bytes  4
[    1.237851] ecc size 512
[    1.240421] badblockbits 8
[    1.243209] chip->pagemask 524287
[    1.246574] mtd->oobsize 64
[    1.249453] chip->ecc.steps 4
[    1.252497] mtd->writesize 2048
[    1.255673] chip->ecc.total 16


Understanding the dumped information.

The information above has been dumped from the s3c_nand.c driver as the kernel initialises the drivers, this allows us to analyse the oob layout of the nand chip, there are other extra bits of information but we're really only interested in the nand_ecclayout information, once we have that we can compare it to the known ecc layouts in the s3c_nand.c file, such as s3c_nand_oob_128.

If we take the 1GB SLC nand as an example, these lines give us all the information we need:

[    1.228976] Nand oob info:   Dumping the nand ecc layout positions
[    1.229029]
[    1.229044] 40, 41, 42, 43, 44, 45, 46, 47, 48,
[    1.229094] 49, 50, 51, 52, 53, 54, 55,
[    1.229135] Dumping the nand ecc layout
[    1.229168] .eccbytes 16
[    1.229191] .oobfree offset 2
[    1.232102] .oobfree length 38

lines 1.229044 and 1.229094 give us the .eccpos of:
        40, 41, 42, 43, 44, 45, 46, 47,
        48, 49, 50, 51, 52, 53, 54, 55
        
line 1.229168 gives us the .eccbytes:
16

The next 2 lines give us the oobfree offset and length of:
2
38

If we put that all together in the order of the nand_ecclayout struct we get:
.eccbytes 16
.eccpos 40, 41, 42, 43, 44, 45, 46, 47,
        48, 49, 50, 51, 52, 53, 54, 55
oobfree
.offset 2
.length 38

So we can now compare those values to the nand_ecclayout objects that start on line 141 in s3c_nand.c, we can see that .eccbytes is 4, this doesn't match ours, so it's not s3c_nand_oob_16, lets check s3c_nand_oob_64 next:
/* Nand flash oob definition for SLC 2k page size */
static struct nand_ecclayout s3c_nand_oob_64 = {
    .eccbytes = 16,
    .eccpos = {
        40, 41, 42, 43, 44, 45, 46, 47,
        48, 49, 50, 51, 52, 53, 54, 55
    },
    .oobfree = {
        {
        .offset = 2,
        .length = 38
        }
    }
};

I know, it's very obvious just by looking, our 1GB SLC nand chip has 2K page size and everything matches what I dumped from the driver.

So what to do for the 2GB/4GB MLC nand chips?  It doesn't really matter which one you look at, they both have the same ecc_layout but if you check all of the layouts in s3c_nand.c you won't find a match. The good news is that you can make your own :-)

static struct nand_ecclayout s3c_nand_oob_mlc_512 = {
    .eccbytes = 448,
    .eccpos = {
         40,  41,  42,  43,  44,  45,  46,  47,
         48,  49,  50,  51,  52,  53,  54,  55,
         56,  57,  58,  59,  60,  61,  62,  63,
         64,  65,  66,  67,  68,  69,  70,  71,
         72,  73,  74,  75,  76,  77,  78,  79,
         80,  81,  82,  83,  84,  85,  86,  87,
         88,  89,  90,  91,  92,  93,  94,  95,
         96,  97,  89,  99, 100, 101, 102, 103,
        104, 105, 106, 107, 108, 109, 110, 111,
        112, 113, 114, 115, 116, 117, 118, 119,
        120, 121, 122, 123, 124, 125, 126, 127,
        128, 129, 130, 131, 132, 133, 134, 135,
        136, 137, 138, 139, 140, 141, 142, 143,
        144, 145, 146, 147, 148, 149, 150, 151,
        152, 153, 154, 155, 156, 157, 158, 159,
        160, 161, 162, 163, 164, 165, 166, 167,
        168, 169, 170, 171, 172, 173, 174, 175,
        176, 177, 178, 179, 180, 181, 182, 183,
        184, 185, 186, 187, 188, 189, 190, 191,
        192, 193, 194, 195, 196, 197, 198, 199,
        200, 201, 202, 203, 204, 205, 206, 207,
        208, 209, 210, 211, 212, 213, 214, 215,
        216, 217, 218, 219, 220, 221, 222, 223,
        224, 225, 226, 227, 228, 229, 230, 231,
        232, 233, 234, 235, 236, 237, 238, 239,
        240, 241, 242, 243, 244, 245, 246, 247,
        248, 249, 250, 251, 252, 253, 254, 255,
        256, 257, 258, 259, 260, 261, 262, 263,
        264, 265, 266, 267, 268, 269, 270, 271,
        272, 273, 274, 275, 276, 277, 278, 279,
        280, 281, 282, 283, 284, 285, 286, 287,
        288, 289, 290, 291, 292, 293, 294, 295,
        296, 297, 298, 299, 300, 301, 302, 303,
        304, 305, 306, 307, 308, 309, 310, 311,
        312, 313, 314, 315, 316, 317, 318, 319,
        320, 321, 322, 323, 324, 325, 326, 327,
        328, 329, 330, 331, 332, 333, 334, 335,
        336, 337, 338, 339, 340, 341, 342, 343,
        344, 345, 346, 347, 348, 349, 350, 351,
        352, 353, 354, 355, 356, 357, 358, 359,
        360, 361, 362, 363, 364, 365, 366, 367,
        368, 369, 370, 371, 372, 373, 374, 375,
        376, 377, 378, 379, 380, 381, 382, 383,
        384, 385, 386, 387, 388, 389, 390, 391,
        392, 393, 394, 395, 396, 397, 398, 399,
        400, 401, 402, 403, 404, 405, 406, 407,
        408, 409, 410, 411, 412, 413, 414, 415,
        416, 417, 418, 419, 420, 421, 422, 423,
        424, 425, 426, 427, 428, 429, 430, 431,
        432, 433, 434, 435, 436, 437, 438, 439,
        440, 441, 442, 443, 444, 445, 446, 447,
        448, 449, 450, 451, 452, 453, 454, 455,
        456, 457, 458, 459, 460, 461, 462, 463,
        464, 465, 466, 467, 468, 469, 470, 471,
        472, 473, 474, 475, 476, 477, 478, 479,
        480, 481, 482, 483, 484, 485, 486, 487 },
    .oobfree = {
        {.offset = 4,
         .length = 32 }
         }
};

This ecc layout is valid for the 2GB mlc nand and the 4GB mlc nand chips, however, it's not particularly useful without the 16bit ecc functions in the driver.

If you want to know which level of ecc the nand driver is using, look for the line(s) with chip->ecc.steps in them, you can see that the 1GB slc nand has chip->ecc.steps 4, the 2GB and 4GB mlc has chip->ecc.steps 16, so the SLC nand is using 4bit ecc and the mlc nand is using 16bit ecc.

You can get the pagesize, from mtd->writesize, it's 2048 (2KB) for the 1GB slc and 8192 (8KB) for the 2GB/4GB mlc nand.

You can get the oob size from mtd->oobsize for the 1GB slc it's 64 bytes, for the 2GB mlc  it's 512 bytes, for the 4GB mlc it's actually 640 bytes, however, don't let this confuse you, the ecclayout should be set for

You might also want to know what the erase block size is, you can get that from linux:
cat /sys/class/mtd/mtd4/erasesize
131072 (bytes) = 128KB for 1GB SLC nand

for the 2GB/4GB MLC nand, the erase block size is 1MB.
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5407
金钱: 40120 两
威望: 17929 点
贡献值: 71 点
综合积分: 11054 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2013-05-01 10:50
Thanks for sharing. That's very useful.
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 侠客
UID: 54261
精华: 9
发帖: 43
金钱: 665 两
威望: 133 点
贡献值: 9 点
综合积分: 266 分
注册时间: 2011-08-27
最后登录: 2014-08-08
2楼  发表于: 2013-05-01 19:57
cool, thanks for sharing!
级别: 新手上路
UID: 21909
精华: 0
发帖: 22
金钱: 110 两
威望: 22 点
贡献值: 0 点
综合积分: 44 分
注册时间: 2010-05-23
最后登录: 2016-01-22
3楼  发表于: 2013-05-06 08:39
thanks for sharing!
级别: 侠客
UID: 86171
精华: 0
发帖: 104
金钱: 520 两
威望: 104 点
贡献值: 0 点
综合积分: 208 分
注册时间: 2013-01-14
最后登录: 2015-11-16
4楼  发表于: 2013-05-07 08:48
thanks for sharing!
级别: 禁止发言
UID: 100097
精华: 0
发帖: 34
金钱: 195 两
威望: 39 点
贡献值: 0 点
综合积分: 68 分
注册时间: 2014-01-20
最后登录: 2014-09-22
5楼  发表于: 2014-05-26 13:44
用户被禁言,该主题自动屏蔽!
级别: 新手上路
UID: 106342
精华: 0
发帖: 25
金钱: 125 两
威望: 25 点
贡献值: 0 点
综合积分: 50 分
注册时间: 2014-07-21
最后登录: 2017-02-19
6楼  发表于: 2015-08-21 16:29
干嘛都说英文,让没过CET4的情何以堪。。。
级别: 风云使者
UID: 39598
精华: 0
发帖: 2713
金钱: 84685 两
威望: 16937 点
贡献值: 0 点
综合积分: 5426 分
注册时间: 2011-03-10
最后登录: 2017-07-08
7楼  发表于: 2017-07-06 23:00
oh!magat!!!
级别: 风云使者
UID: 133552
精华: 0
发帖: 2682
金钱: 13410 两
威望: 2682 点
贡献值: 0 点
综合积分: 5364 分
注册时间: 2017-07-06
最后登录: 2017-07-11
8楼  发表于: 2017-07-07 03:53
日出而作,日落而写作。
级别: 风云使者
UID: 133551
精华: 0
发帖: 2689
金钱: 13445 两
威望: 2689 点
贡献值: 0 点
综合积分: 5378 分
注册时间: 2017-07-06
最后登录: 2017-07-08
9楼  发表于: 2017-07-07 07:08
顶!!!!!!!!!!
  • «
  • 1
  • 2
  • »
  • Pages: 1/2     Go