主题 : Barebox for tiny 210 - step 10 MLC NAND 复制链接 | 浏览器收藏 | 打印
级别: 侠客
UID: 54261
精华: 9
发帖: 43
金钱: 665 两
威望: 133 点
贡献值: 9 点
综合积分: 266 分
注册时间: 2011-08-27
最后登录: 2014-08-08
楼主  发表于: 2013-05-09 12:20

 Barebox for tiny 210 - step 10 MLC NAND

管理提醒: 本帖被 xoom 执行加亮操作(2013-05-09)
友善之臂210群不给力啊,偶尔想偷懒问个问题,基本都没人解答...

返回学习汇总贴
0.开始之前:
    (1) MTD框架下NAND驱动并不难,只要注意和内核使用相同的ECC算法(1/4/8/12/16位ECC)和存储格式(ecc_layout)。这篇帖子2楼介绍了如何探测的ECC算法和存储格式,K9GAG08U0F的探测结果
[    1.498393] Nand oob info:   Dumping the nand ecc layout positions
[    1.498445]
[    1.498460] 36, 37, 38, 39, 40, 41, 42, 43, 44,
[    1.498510] 45, 46, 47, 48, 49, 50, 51, 52,
[    1.498556] 53, 54, 55, 56, 57, 58, 59, 60,
[    1.498602] 61, 62, 63, 64, 65, 66, 67, 68,
[    1.500913] 69, 70, 71, 72, 73, 74, 75, 76,
[    1.505160] 77, 78, 79, 80, 81, 82, 83, 84,
[    1.509406] 85, 86, 87, 88, 89, 90, 91, 92,
[    1.513652] 93, 94, 95, 96, 97, 98, 99, 100,
[    1.517985] 101, 102, 103, 104, 105, 106, 107, 108,
[    1.522924] 109, 110, 111, 112, 113, 114, 115, 116,
[    1.527863] 117, 118, 119, 120, 121, 122, 123, 124,
[    1.532803] 125, 126, 127, 128, 129, 130, 131, 132,
[    1.537742] 133, 134, 135, 136, 137, 138, 139, 140,
[    1.542682] 141, 142, 143, 144, 145, 146, 147, 148,
[    1.547621] 149, 150, 151, 152, 153, 154, 155, 156,
[    1.552561] 157, 158, 159, 160, 161, 162, 163, 164,
[    1.556546] 165, 166, 167, 168, 169, 170, 171, 172,
[    1.561486] 173, 174, 175, 176, 177, 178, 179, 180,
[    1.566425] 181, 182, 183, 184, 185, 186, 187, 188,
[    1.571365] 189, 190, 191, 192, 193, 194, 195, 196,
[    1.576304] 197, 198, 199, 200, 201, 202, 203, 204,
[    1.581244] 205, 206, 207, 208, 209, 210, 211, 212,
[    1.586183] 213, 214, 215, 216, 217, 218, 219, 220,
[    1.591122] 221, 222, 223, 224, 225, 226, 227, 228,
[    1.596062] 229, 230, 231, 232, 233, 234, 235, 236,
[    1.601001] 237, 238, 239, 240, 241, 242, 243, 244,
[    1.605941] 245, 246, 247, 248, 249, 250, 251, 252,
[    1.610880] 253, 254, 255, 256, 257, 258, 259, 260,
[    1.615819] 261, 262, 263, 264, 265, 266, 267, 268,
[    1.620759] 269, 270, 271, 272, 273, 274, 275, 276,
[    1.625698] 277, 278, 279, 280, 281, 282, 283, 284,
[    1.630638] 285, 286, 287, 288, 289, 290, 291, 292,
[    1.635580] 293, 294, 295, 296, 297, 298, 299, 300,
[    1.640517] 301, 302, 303, 304, 305, 306, 307, 308,
[    1.645456] 309, 310, 311, 312, 313, 314, 315, 316,
[    1.650395] 317, 318, 319, 320, 321, 322, 323, 324,
[    1.655335] 325, 326, 327, 328, 329, 330, 331, 332,
[    1.660274] 333, 334, 335, 336, 337, 338, 339, 340,
[    1.665214] 341, 342, 343, 344, 345, 346, 347, 348,
[    1.670153] 349, 350, 351, 352, 353, 354, 355, 356,
[    1.675093] 357, 358, 359, 360, 361, 362, 363, 364,
[    1.680032] 365, 366, 367, 368, 369, 370, 371, 372,
[    1.684972] 373, 374, 375, 376, 377, 378, 379, 380,
[    1.689911] 381, 382, 383, 384, 385, 386, 387, 388,
[    1.694851] 389, 390, 391, 392, 393, 394, 395, 396,
[    1.699790] 397, 398, 399, 400, 401, 402, 403, 404,
[    1.704730] 405, 406, 407, 408, 409, 410, 411, 412,
[    1.709669] 413, 414, 415, 416, 417, 418, 419, 420,
[    1.714620] 421, 422, 423, 424, 425, 426, 427, 428,
[    1.719559] 429, 430, 431, 432, 433, 434, 435, 436,
[    1.724498] 437, 438, 439, 440, 441, 442, 443, 444,
[    1.729426] 445, 446, 447, 448, 449, 450, 451, 452,
[    1.734366] 453, 454, 455, 456, 457, 458, 459, 460,
[    1.739305] 461, 462, 463, 464, 465, 466, 467, 468,
[    1.744245] 469, 470, 471, 472, 473, 474, 475, 476,
[    1.749184] 477, 478, 479, 480, 481, 482, 483,
[    1.753690] Dumping the nand ecc layout
[    1.757515] .eccbytes 448
[    1.760204] .oobfree offset 4
[    1.763223] .oobfree length 32
[    1.766354] ecc bytes  28
[    1.769029] ecc size 512
[    1.771640] badblockbits 4
[    1.774402] chip->pagemask 262143
[    1.777796] mtd->oobsize 512
[    1.780739] chip->ecc.steps 16
[    1.783847] mtd->writesize 8192
[    1.787065] chip->ecc.total 448
    (2) 同样道理,NAND BOOT的难处在于搞清楚iROM采用的ECC算法和存储格式。按照友善用户手册将superboot写入NAND,然后用nanddump或其他工具显示superboot在NAND中的存储格式
本部分内容设定了隐藏,需要回复后才能看到

    (3) 掌握 Barebox for tiny 210 - step 9

1.编译
    (1) 更新源码到对应版本
        cd ~/s5pv210/github/loader/barebox && git checkout 72773edd34b97b7e2e1a6932dbaa10a2d95ae246
    (2) 配置编译
        cp arch/arm/configs/friendlyarm_tiny210_defconfig .config
        make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig
                禁用System Type  --->S3C Features  --->[ ] Booting from NAND
        make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- && cp barebox.s5p barebox.sd
        编译生成的barebox.s5p,重命名为barebox.sd,这个版本适合SD卡启动,专门用于向NAND写入barebox
        make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig
                启用System Type  --->S3C Features  --->[*] Booting from NAND
        make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- && sudo cp barebox.s5p /srv/tftp/
        编译生成的barebox.s5p,放到tftp根目录下,这个版本适合NAND启动
2.运行
        亲自在Tiny210(256MB SLC)和Tiny210-V2(2G MLC)上测试通过
        将SD版本烧写到SD卡        sudo dd if=./barebox.sd of=/dev/sdb bs=512 seek=1
        从SD卡启动单板,三秒内按任意键中断autoboot
        从FTP取NAND版本,烧写到nand.barebox分区        erase /dev/nand0.barebox.bb & cp /mnt/tftp/barebox.s5p /dev/nand0.barebox.bb
        从NAND启动单板,barebox正常启动
        写入内核和根文件系统,启动并确认文件系统正常工作
3.源码分析
    不贴代码,感兴趣的建议看github commit记录
    (1) 调整barebox及bareboxenv分区大小为1MB,因为K9GAG08U0F块大小为1MB
    (2) 修改nanddump命令以支持mtdraw/mtdoob设备
    (3) 调整mtdraw/mtdoob写缓冲长度
    (4) 修改nand_base.c以支持512/640字节oob区
    (5) 新增适用于MLC的ecc_layout结构,16位HWECC算法,以及写页函数
    (6) 新增适用于MLC NAND BOOT的写页函数
    (7) NAND引导时根据OM_STAT寄存器判断NAND页大小
4.继续之前
        Tiny210-v2偶尔出现Barebox无法启动的问题,怀疑是因为s3c_nand_load_image读NAND未使用ECC导致
        NAND启动版本无法升级bootloader,怎么办?!
        测试4G MLC NAND
[ 此帖被mei5150在2013-05-09 20:08重新编辑 ]
级别: 新手上路
UID: 65147
精华: 0
发帖: 33
金钱: 165 两
威望: 33 点
贡献值: 0 点
综合积分: 66 分
注册时间: 2012-03-14
最后登录: 2013-08-13
1楼  发表于: 2013-05-10 11:11
xuexixuexi