|
本帖最后由 jiuweiljp 于 2023-9-9 12:06 编辑
一、前言:
之前发了一个帖子每台openwrt路由器都是编程器有网友提到大麦DW33D,发现这个配置不错,有NOR也有NAND Flash,内存也大256MB
闲鱼弄了一个非giga版的。
先说说这次为什么选用dw33d,因为4300v1 实在不适合,4300改造后虽然有双flash但nor flash只是作为u-boot用,系统只能运行在nand 上,
而4300 只有128MB memory,在文件操作用很容易溢出缓存,nana dump与write过程中要注意缓存的使用情况,如果缓存快满要清理(原帖提到过),
在清理缓存前要将载有系统的nand flash 换上去,不然就会报错。
dw33d呢就没有这个问题,系统运行在nor flash 上,nand 只作为rootfs_data 用,内存还大不少(256MB),还有16GB的TF卡,把程序放到TF卡上
运行静态编译的程序,热机换nand 没有报错情况。
二、硬件篇:
上次改造nand 编程座很痛苦,还容易弄坏网件4300 V1的焊盘,这次我就想了一个办法用FPC座加排线。
1、所需材料如下:
(1)、编程座
(2)、转接板
这个转接板我改造过,与上图的编程座针脚有点对不上,需要将插针解焊下来(较麻烦要小心保留焊盘),
在电路板反面焊上插针(厂家有心了,反面的焊盘能对上这个编程座),可参看完成后的照片。
在TB上也可买到空白电路板自己焊,FPC座焊接麻烦点,但不用解焊插针了。
(3)、24Pin排线
注意排线有两种(同面的和反面的),我这次用的是同面的。
(4)、FPC座
这种座也有两种,翻盖式与抽屉式,注意事项见图中的文字。
2、改造过程如下
(1)贴高温胶布
(2)脱焊NAND芯片,清理焊盘,焊盘留的焊锡一定要饱满(我这个就不太好),那个FPC座上路由的基板后,
针脚不能紧贴到焊盘上有很小的缝隙,如果焊盘留的锡不饱满还要加锡,特别容易连脚。
(3)不要拖焊
TB买的座质量太次了,温度高一点塑料就化了,拖焊容易弄坏FPC座及焊盘
(4)用点焊,且要固定FPC座
见下图我的焊盘坏了3个焊盘,还好这3个不用。注意:PFC座一定要固定在基板上,很重要。
另FPC座另外一边用胶固定,注意下使用的胶不能导电
(5)硬件完成图,注意事项见图
(二)软件篇
1、先说说原厂的U-boot吧,原厂的U-boot功能很齐全,但有个功能它如果发现你自己改了固件,在启动的时候
会将MTD7(backup,没错这个backup存储的就是原厂固件的备份),将你的固件恢复回到原厂,有个奇怪的现象恢复原厂后你用opkg安装的软件还在。
2、原厂的固件功能也很齐全,基本够用了,简单改下软件源可以自己安装opkg软件,但backup分区是锁定的,且没有暂时没有办法解锁。
但原厂的固件有个问题如果你的没有安装nand 或nand 坏了,那在启动过程中就会卡死。(我后来仔细排查了下原厂的固件只用mtd6 (在nand上)挂rootfs_data
而第三方opwenrt 会将 nor的部分区域也挂成rootfs_data,也就是说第三方固件会有2个rootfs_data)
- =========dw33d 原厂 启动
- 0x000000000000-0x000000040000 : "u-boot"
- 0x000000040000-0x000000050000 : "u-boot-env"
- 0x000000050000-0x000000e80000 : "rootfs"
- mtd: partition "rootfs" set to be root filesystem
- 0x000000e80000-0x000000ff0000 : "kernel"
- 0x000000ff0000-0x000001000000 : "art"
- 0x000000050000-0x000000fe0000 : "firmware"
- ath79-nand ath79-nand: AR71xx/AR9xxx Qualcomm-Atheros NAND FLash Controller driver, Version 1.0
- (c) 2010 Atheros Communications, Ltd.
- NAND device: Manufacturer ID: 0x2c, Chip ID: 0xf1 (Micron NAND 128MiB 3,3V 8-bit)
- Bad block table found at page 65472, version 0x01
- Bad block table found at page 65408, version 0x01
- 2 cmdlinepart partitions found on MTD device ath79-nand
- Creating 2 MTD partitions on "ath79-nand":
- 0x000000000000-0x000006000000 : "rootfs_data"
- 0x000006000000-0x000008000000 : "backup"
- >cat /proc/mtd (可以看到只有一个rootfs_data)
- dev: size erasesize name
- mtd0: 00040000 00010000 "u-boot"
- mtd1: 00010000 00010000 "u-boot-env"
- mtd2: 00e30000 00010000 "rootfs"
- mtd3: 00170000 00010000 "kernel"
- mtd4: 00010000 00010000 "art"
- mtd5: 00f90000 00010000 "firmware"
- mtd6: 06000000 00020000 "rootfs_data"
- mtd7: 02000000 00020000 "backup"
复制代码- ==========OpenWrt R8.1.11 启动 nor+nand flash
- [ 0.916110] 0x000000000000-0x000000040000 : "u-boot"
- [ 0.922662] 0x000000040000-0x000000050000 : "u-boot-env"
- [ 0.929651] 0x000000050000-0x000000e80000 : "rootfs"
- [ 0.935912] mtd: device 2 (rootfs) set to be root filesystem
- [ 0.941738] 1 squashfs-split partitions found on MTD device rootfs
- [ 0.948011] 0x000000950000-0x000000e80000 : "rootfs_data"
- [ 0.955141] 0x000000e80000-0x000000ff0000 : "kernel"
- [ 0.961792] 0x000000ff0000-0x000001000000 : "art"
- [ 0.968139] 0x000000050000-0x000000ff0000 : "firmware"
- [ 0.975786] nand: device found, Manufacturer ID: 0x01, Chip ID: 0xf1
- [ 0.982271] nand: AMD/Spansion NAND 128MiB 3,3V 8-bit
- [ 0.987395] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
- [ 0.995108] Scanning device for bad blocks
- [ 1.002349] Bad eraseblock 37 at 0x0000004a0000
- [ 1.007026] random: fast init done
- [ 1.054195] Bad eraseblock 586 at 0x000004940000
- [ 1.093755] 2 cmdlinepart partitions found on MTD device ar934x-nfc
- [ 1.100115] Creating 2 MTD partitions on "ar934x-nfc":
- [ 1.105331] 0x000000000000-0x000006000000 : "rootfs_data"
- [ 1.112537] 0x000006000000-0x000008000000 : "backup"
- >cat /proc/mtd (可以看到有二个rootfs_data)
- dev: size erasesize name
- mtd0: 00040000 00010000 "u-boot"
- mtd1: 00010000 00010000 "u-boot-env"
- mtd2: 00e30000 00010000 "rootfs"
- mtd3: 00530000 00010000 "rootfs_data"
- mtd4: 00170000 00010000 "kernel"
- mtd5: 00010000 00010000 "art"
- mtd6: 00fa0000 00010000 "firmware"
- mtd7: 06000000 00020000 "rootfs_data"
- mtd8: 02000000 00020000 "backup"
复制代码 不知道大家注意没有这两个固件nand控制器的驱动有点不同(ath79-nand,ar934x-nfc)不知道有什么区别,有谁知道望告知,谢!
3、因为原厂u-boot的问题还是刷breed吧,方法我就不说了,在原厂u-boot中用TTL可以刷,用解锁固件也也可以刷,方法见下文
大麦dw33d NAND固件安装方法和一些技巧
4、使用的固件也有一定要求因为要解锁mtd7(backup)所以版本不能低,
怎么用具体可看
不同官方或自制的openwrt版中刷uboot和art。
LEDE 17.01.0 以后的版本才有Kmod-mtd-rw插件,使用这个插件可以一次性解锁所有mtd。
在论坛找了半天找到一个合适的固件 ,其它文件名称中有nand字样的固件,虽然较多但我没有选用(这些固件可能在nand上运行系统)
(更新)大麦路由DW33D自编译Lean大openwrt R8.1.11固件
上面这个openwrt固件有点问题wifi 的5g模块(ath10K)启动加载很费时间,启动过程很漫长(300多秒才能完),估计有兼容的问题
我把这个固件中的5g模块去掉了(启动时间30秒)。
解锁mtd分区,安装kmod-mtd-rw插件要对核心版本及MD5值,该固件的核心版本是 4.9.138,与官方发行版本对不上,
但问题不大,能找到 kmod-mtd-rw_4.9.131的版本,强制安装就可以了
- opkg --nodeps install kmod-mtd-rw_4.9.131+git-20160214-1_mips_24kc.ipk
- 显示结果
- Installing kmod-mtd-rw (4.9.131+git-20160214-1) to root...
- Configuring kmod-mtd-rw.
复制代码- cp /lib/modules/4.9.131/* /lib/modules/4.9.138/.
复制代码- insmod mtd-rw.ko i_want_a_brick=1
- 显示结果
- [11947.837117] mtd-rw: mtd0: setting writeable flag
- [11947.841854] mtd-rw: mtd1: setting writeable flag
- [11947.846555] mtd-rw: mtd5: setting writeable flag
- [11947.849888] mtd-rw: mtd8: setting writeable flag
复制代码 可以看到所有mtd已经解锁了。
5、软件我使用的是buildroot 2020.2的正式版,这个buildroot是一款强大的toolchain,
我之前编译的4300 的u-boot就用的它(用的版本2009.11)。
在buildroot 中也有很多工具比如下面我要提到的mtd-utils(版本2.1.1),我做了静态编译。
拷贝到TF卡、u盘中就可以用,不需要任何库支持。
6、我发现在mtd-utils 中有nanddump nandwrite nandtest 不同的版本命令有所不同,
使用时要特别注意。
(1 )buildroot (版本2009.11)中的 nanddump (版本1.29)
- nanddump $Revision: 1.29 $
- Usage: nanddump [OPTIONS] MTD-device
- Dumps the contents of a nand mtd partition.
- --help display this help and exit
- --version output version information and exit
- -f file --file=file dump to file
- -i --ignoreerrors ignore errors
- -l length --length=length length
- -n --noecc read without error correction
- -o --omitoob omit oob data
- -b --omitbad omit bad blocks from the dump
- -p --prettyprint print nice (hexdump)
- -s addr --startaddress=addr start address
复制代码 (2)DW33D原厂固件用安装源nanddump (版本 1.31)
- nanddump 1.31
- Usage: nanddump [OPTIONS] MTD-device
- Dumps the contents of a nand mtd partition.
- --help Display this help and exit
- --version Output version information and exit
- --bb=METHOD Choose bad block handling method (see below).
- -a --forcebinary Force printing of binary data to tty
- -c --canonicalprint Print canonical Hex+ASCII dump
- -f file --file=file Dump to file
- -l length --length=length Length
- -n --noecc Read without error correction
- -o --omitoob Omit OOB data (default in next release)
- --oob Dump OOB data (current default)
- -p --prettyprint Print nice (hexdump)
- -q --quiet Don't display progress and status messages
- -s addr --startaddress=addr Start address
- --bb=METHOD, where METHOD can be `padbad', `dumpbad', or `skipbad':
- padbad: dump flash data, substituting 0xFF for any bad blocks (default)
- dumpbad: dump flash data, including any bad blocks
- skipbad: dump good data, completely skipping any bad blocks
- Deprecated options:
- The following options are being replaced by --bb=METHOD flags or being
- removed entirely. Do not continue to use these options.
- -b --omitbad Omit bad blocks from the dump (DEPRECATED)
- -N --noskipbad Read without bad block skipping
- Notes on --omitbad and --bb=skipbad:
- * `omitbad' and `skipbad' are very similar; we are deprecating `--omitbad'
- in favor of `--bb=skipbad'.
- * With either option, we stop dumping data when we encounter a bad block
- and resume dumping at the next good block. However, with `omitbad', we
- count the bad block as part of the total dump length, whereas with
- `skipbad', the bad block is skipped, that is, not counted toward the
- total dump length.
- Note on --oob, --omitoob:
- To make nanddump act more like an inverse to nandwrite, we are changing
- the default OOB behavior. In the next release, nanddump will not dump
- OOB data by default. We will leave both the `--omitoob' and `--oob'
- options, but to mirror nandwrite, the short option `-o' will then stand
- for `--oob', not `--omitoob'. Please adjust your usage accordingly.
复制代码 (3)buildroot (版本2020.2)中的 nanddump (版本2.1.1)
- nanddump (mtd-utils) 2.1.1
- Usage: nanddump [OPTIONS] MTD-device
- Dumps the contents of a nand mtd partition.
- -h --help Display this help and exit
- --version Output version information and exit
- --bb=METHOD Choose bad block handling method (see below).
- -a --forcebinary Force printing of binary data to tty
- -c --canonicalprint Print canonical Hex+ASCII dump
- -f file --file=file Dump to file
- -l length --length=length Length
- -n --noecc Read without error correction
- --omitoob Omit OOB data (default)
- -o --oob Dump OOB data
- -p --prettyprint Print nice (hexdump)
- -q --quiet Don't display progress and status messages
- -s addr --startaddress=addr Start address
- --skip-bad-blocks-to-start
- Skip bad blocks when seeking to the start address
- --bb=METHOD, where METHOD can be `padbad', `dumpbad', or `skipbad':
- padbad: dump flash data, substituting 0xFF for any bad blocks
- dumpbad: dump flash data, including any bad blocks
- skipbad: dump good data, completely skipping any bad blocks (default)
复制代码
7、 如果怀疑在启动的时候系统写nand,拷贝源nand芯片最好不要在启动前安装到弹跳座上(避免破坏原始nand的内容),
在固件启动完成后将源nand芯片热操作(带电操作)换上去。
这个只是怀疑,我后来简单测试了下这个固件启动时不对nand进行写操作,也就是说可以在冷机情况下换nand芯片,安全很多。
方法:用nanddump 读源nand芯片内容
- >./nanddump --bb=dumpbad -n -o -l 0x2000000 -f mtd7_32mb_noecc_oob_dumpbad /dev/mtd7
- Block size 131072, page size 2048, OOB size 64
- Dumping data starting at 0x00000000 and ending at 0x02000000...
复制代码 解释:使用非校验方式拷贝数据,坏块不跳过,拷贝oob数据,长度32MB(dw33d这个分区很大有96MB一般来说不用拷贝完全,个人随意吧)
这种方法可以避免使用5998的nand控制器的校验功能,在上一篇帖子中我采用这种方式,用网件wndr 4300 v1上可以救活使用arm cpu的机器。
注意事项:
请dump多次然后用md5sum比较下存盘md5值看是否相同,如果不同这个原片的品质就不太好,我测试用的一个芯片虽然没有坏区,但dump多次
有几次md5值就不同(当时有点担心是qca9558 nand驱动或 nand控制器的问题),后来换了一个品质好的芯片多次dump后比较值,就没问题了。
如果多次dump效果不理想,但我发现只要不是太烂的nand芯片肯定有几次md5值是相同的,采用哪个相同md5值的文件作为源文件吧。
:这个工具看来可以简单测试下芯片的质量,呵呵。
8、 然后擦除目标nand,有很多方法擦除,我也没有太仔细的比较。
- >mtd erase /dev/mtd7
- 系统命令(推荐)擦除时如果有坏块就跳过
- (执行完后所有的数据为FF)
复制代码- >./flash_erase /dev/mtd7 0x0 768
- 768 是96MB*1024/128KB=768
- 推荐使用该方法,也可以用 -N (不跳过坏块)过程中可以知道坏块的位置,例如:
- ./flash_erase -N /dev/mtd7 0x0 768
- Erasing 128 Kibyte [url=home.php?mod=space&uid=162986]@[/url] 4a0000 -- 4 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 37 (mtd7)
- error 5 (Input/output error)
- flash_erase: error!: /dev/mtd7: MTD Erase failure
- error 5 (Input/output error)
- Erasing 128 Kibyte @ 4940000 -- 76 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 586 (mtd7)
- error 5 (Input/output error)
- flash_erase: error!: /dev/mtd7: MTD Erase failure
- error 5 (Input/output error)
- Erasing 128 Kibyte @ 5fe0000 -- 100 % complete
- (执行完后所有的数据为FF)
复制代码- >./flash_erase -j /dev/mtd7 0x0 768
- 用jffs2格式化
- (执行完后数据区为FF,但每偏移0x20000处第一oob有数据变化)
复制代码- >./mtd_debug erase /dev/mtd7 0x0 0x6000000
- (执行完后所有的数据为FF,不推荐,好像有坏块就擦除不过去)
复制代码
8、nandwrite(写nand flash)
- >./nandwrite -n -o -m /dev/mtd7 mtd7_32mb_noecc_oob_dumpbad
复制代码 解释:使用非校验方式拷贝,并且文件带oob,如果有坏块就make它,
这种方法可以避免使用9558 nand控制器的ecc校验。也就是硬拷贝。
写完后在备份一次,然后比较两个文件是否相同
- >./nanddump --bb=dumpbad -n -o -l 0x2000000 -f mtd7_32mb_noecc_oob_dumpbad_cmp /dev/mtd7
- >cmp mtd7_32mb_noecc_oob_dumpbad mtd7_32mb_noecc_oob_dumpbad_cmp
- 或者用md5sum 比较也行
- >md5sum mtd7*
复制代码
9、最后介绍下nandtest这个命令,这个命令是测试nand用的。
这个命令有写数据能功能,所以在原nand 上一定不要使用这个命令,加-k参数也不行,会破坏oob。
我发现执行完成后 所有的数据为都有变化,包括oob
解释:-k 是保持测试完后nand的数据不发生改变
但我发现测试完后主体数据没有变化,但oob有变化,可能测试后重新校验了。
- >./nandtest -s -m /dev/mtd7
复制代码 这个是测试失败后标记坏块,非常有用的命令,新买的nand可以用它测试下。
小技巧:可以用这个命令在目标芯片上产生数据,然后多次dump比较md5值,如果相同,可以理解为这个芯片的品质不错,可以作为目标芯片用。
我参考了下面的文章,较详细,可看。
MTD应用学习札记
mtd-utils命令简介
技术文档
http://www.linux-mtd.infradead.org/doc/general.html
下载地址,回复可见
文件说明:
1、kmod-mtd-rw 让openwrt mtd所有分区能写的插件(4.9.131)
2、OpenWrtR8.1.11_firmware.rar 这是去除ath10K还安装了kmod-mtd-rw插件的固件,使用时只用载入模块就行了,我也安装了 nand-utils(版本2.0.2)
另外:系统密码password,非常有可能换nand芯片后,安装的kmod-mtd-rw模会丢失,自己再安装下吧,
并且kmod-ath10k这个模块会回来,opkg remove kmod-ath10k 删掉它就行了。
3、buildroot2020_2.tar.gz 是buildroot 静态编译的mtd-utils (版本2.1.1)
这个工具包内的工具很多(UBI工具也有,各位自己看吧),有空再介绍,这个工具只能在mips大端的cpu上用,MTK CPU的是MIPS 小端的,不能用。
另外坛友jspeng 编译的固件不错推荐下,文章地址如下
https://www.right.com.cn/forum/thread-4034857-1-1.html
========================
后记:breed的作者提到过Atheros 9344 与qca 9558 nand的校验算法相同,我用自己编译的4300 V1的u-boot文件,用DW33D
使用nandwrite -a (Use auto OOB layout)写进芯片,结果没有问题,4300 V1顺利启动到u-boot。
也测试过写的时候只使用 -n 参数故意不写oob 数据,4300 v1无法启动,这说明了9344启动U-boot也要读取ecc校验支持。
-----------------------------
这次采用的方法与上一帖相同,就是在硬件改造的地方,有点货(对大家的动手能力有点要求,但至少不用一根根焊漆包线了,漆包线焊接非常非常痛苦),
在TB上用了3个商家才弄齐了货。
软件部分就是自己静态编译了mtd-utils
-----------------------------
15楼有点内容,有空可看
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
评分
-
查看全部评分
|