0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

MT7621をopenocdでいじってみた

Last updated at Posted at 2025-02-04

MT7621を使ったルーターでZ-LOADERで止められないモジュールがあったので、openocdでいじってみました。

環境はEl Capitanのopenocd 0.10です。USBの安定度とスピートでMacがいいです。

JTAGのピンを立てます。自分は半田ごてがぼろいので、ミニドリルで穴を開けてます。

MacからターゲットにCH340とFT232Hで接続します。

openocdでFTを使うためにはkextをunloadしてしまうので、シリアルは別のチップにする必要があります。

MT7621JTAG.png

Macは1階にあって作業は2階でしてるので、sshで入って操作します。

誰かやってるかと思ってネットで検索してみたら、本家のレポジトリがありました。

mt7621のディレクトリの中でFTの設定とmt7621.cfgでopenocdを立ち上げて、readme.txtの通りやったらu-bootが起動しました。

U-Boot 2023.04-rc5-10922-g897d634a98 (Apr 01 2023 - 18:47:12 +0800)

CPU:   MediaTek MT7621A ver 1, eco 3
Boot:  DDR3, NAND 2K+64
Clock: CPU: 880MHz, DDR: 1200MT/s, Bus: 220MHz, XTAL: 40MHz
Model: MediaTek MT7621 RFB (SPI-NOR)
DRAM:  128 MiB
Core:  39 devices, 18 uclasses, devicetree: separate
MMC:   mmc@1e130000: 0
Loading Environment from nowhere... OK
Net:   
Warning: eth@1e100000 (eth0) using random MAC address - 56:7d:15:52:26:4f
eth0: eth@1e100000
=> 

元のボーレートが57600なので設定前に115200に変える必要があります。

u-bootを起動しても元のnandの内容が変更されることはありません。

snorの方を試しましたがこのターゲットではnandの方が正しいです。

nandの方も起動してみました。

U-Boot 2023.04-rc5-10922-g897d634a98 (Apr 01 2023 - 18:49:26 +0800)

CPU:   MediaTek MT7621A ver 1, eco 3
Boot:  DDR3, NAND 2K+64
Clock: CPU: 880MHz, DDR: 1200MT/s, Bus: 220MHz, XTAL: 40MHz
Model: MediaTek MT7621 RFB (NAND)
DRAM:  128 MiB
Core:  36 devices, 15 uclasses, devicetree: separate
NAND:  128 MiB
MMC:   
Loading Environment from nowhere... OK
Net:   
Warning: eth@1e100000 (eth0) using random MAC address - 0a:30:0c:1f:e1:95
eth0: eth@1e100000
=>

openocdにはMT7621のnandドライバーは無いのでこのu-bootで操作するのが良いです。

nandのブートローダーをバックアップしてみます。

パーティションは以下のようになっています。

[    2.792000] 0x000000000000-0x000007f80000 : "ALL"
[    2.804000] 0x000000000000-0x000000100000 : "Bootloader"
[    2.816000] 0x000000100000-0x000000200000 : "Ubootenv"
[    2.824000] 0x000000200000-0x000000300000 : "Factory"
[    2.836000] 0x000000400000-0x000003600000 : "firmware"
[    2.848000] 0x00000058296a-0x000003600000 : "rootfs"
[    2.892000] 0x000003600000-0x000003700000 : "Config"
[    2.904000] 0x000003700000-0x000006900000 : "firmware_2"
[    2.916000] 0x000006900000-0x000006a00000 : "Config_2"
[    2.928000] 0x000006a00000-0x000006b00000 : "persist"
[    2.936000] 0x000006b00000-0x000006c00000 : "idmkey"
[    2.948000] 0x000006c00000-0x000007f80000 : "Backup"
[    2.960000] 0x000000300000-0x000000400000 : "SecondBoot"

u-bootで先頭の4Mをいったんメモリにコピーします。

=> nand read 0x81000000 0 0x400000

NAND read: device 0 offset 0x0, size 0x400000
 4194304 bytes read: OK

openocdでhaltして、ファイルに落とします。

> dump_image dump.bin 0x81000000 0x400000
dumped 4194304 bytes in 1829.527832s (2.239 KiB/s)

4Mで30分。結構時間がかかります。

Z-LOADERを止められるようにします。

=> nand read 0x81000000 0x200000 0x10000

NAND read: device 0 offset 0x200000, size 0x10000
 65536 bytes read: OK
=> mw.b 8100fe75 1
=> nand erase 0x200000 0x10000

NAND erase: device 0 offset 0x200000, size 0x10000
Erasing at 0x200000 -- 100% complete.
OK
=> nand write 0x81000000 0x200000 0x10000

NAND write: device 0 offset 0x200000, size 0x10000
 65536 bytes written: OK

止められるようになりました。

Z-LOADER V1.28 | 08/06/2018 14:37:44


..Hit ESC key to stop autoboot: 1
ZLB> 
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?