前回、中国移動 RAX3000Mで有効化したSSHを通じて、現行版OpenWrtファームウェアへの入れ替えに挑戦します。
お手本にする記事
NAND版、eMMC版という2つの異なるストレージ仕様が存在するRAX3000Mで、中華テック系でポピュラーなImmoralWrtではなく、OpenWrt謹製ファームウェアをNAND版へ書き込んでいるこちらの記事をお手本に作業を進めます(鳴謝!)。
OpenWrtファームウェアの調達
OpenWrtのRAX3000M情報ページに記載のあった、MediaTek Filogic向けファームウェアイメージ一覧ページにて、以下の4つのファイルをダウンロード。
|
1 2 3 4 5 |
$ ls -l 7,340,032 byte openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-initramfs-recovery.itb # INITRAMFS 1,006,233 byte openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-bl31-uboot.fip # FIP 226,141 byte openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-preloader.bin # BL2 10,486,064 byte openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-squashfs-sysupgrade.itb # SYSUPGRADE |
Ubuntu 22.04にtftpdの構築
次に、作業用Ubuntu PCにtftpサーバを構築。前回とは違うPCなので、またパッケージのインストールから。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$ sudo apt install tftpd-hpa 以下のパッケージが新たにインストールされます: tftpd-hpa アップグレード: 0 個、新規インストール: 1 個、削除: 0 個、保留: 1 個。 39.5 kB のアーカイブを取得する必要があります。 この操作後に追加で 116 kB のディスク容量が消費されます。 取得:1 http://hk.archive.ubuntu.com/ubuntu noble/main amd64 tftpd-hpa amd64 5.2+20150808-1.4build1 [39.5 kB] 39.5 kB を 5秒 で取得しました (7,816 B/s) 以前に未選択のパッケージ tftpd-hpa を選択しています。 (データベースを読み込んでいます ... 現在 283630 個のファイルとディレクトリがインストールされています。) .../tftpd-hpa_5.2+20150808-1.4build1_amd64.deb を展開する準備をしています ... tftpd-hpa (5.2+20150808-1.4build1) を展開しています... tftpd-hpa (5.2+20150808-1.4build1) を設定しています ... man-db (2.12.0-4build2) のトリガを処理しています ... |
設定ファイル /etc/default/tftpd-hpa を編集。
|
1 2 3 4 5 6 7 |
# /etc/default/tftpd-hpa TFTP_USERNAME="tftp" TFTP_DIRECTORY="/srv/tftp" TFTP_ADDRESS=":69" #TFTP_OPTIONS="--secure" # コメントアウト TFTP_OPTIONS="-s -c -v" # 追加 |
tftpルートディレクトリ /srv/tftp/ の所有権を変更します。
|
1 2 3 4 5 6 |
$ ls -l /srv/ drwxr-xr-x 2 root nogroup 4096 Dec 11 12:38 tftp $ sudo chown tftp /srv/tftp $ ls -l /srv/ drwxr-xr-x 2 tftp nogroup 4096 Dec 11 12:38 tftp |
tftpサーバサービスを再起動。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$ sudo systemctl restart tftpd-hpa.service $ systemctl status tftpd-hpa.service ● tftpd-hpa.service - LSB: HPA's tftp server Loaded: loaded (/etc/init.d/tftpd-hpa; generated) Active: active (running) since Wed 2024-12-11 12:40:05 HKT; 2s ago Docs: man:systemd-sysv-generator(8) Process: 19963 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=0/SUCCESS) Tasks: 1 (limit: 14166) Memory: 232.0K (peak: 1.3M) CPU: 13ms CGroup: /system.slice/tftpd-hpa.service └─19971 /usr/sbin/in.tftpd --listen --user tftp --address :69 --secure /srv/tftp Dec 11 12:40:05 VPCSA26GGK systemd[1]: Starting tftpd-hpa.service - LSB: HPA's tftp server... Dec 11 12:40:05 VPCSA26GGK tftpd-hpa[19963]: * Starting HPA's tftpd in.tftpd Dec 11 12:40:05 VPCSA26GGK tftpd-hpa[19963]: ...done. Dec 11 12:40:05 VPCSA26GGK systemd[1]: Started tftpd-hpa.service - LSB: HPA's tftp server. |
そして、先ほどダウンロードした4つのファイルのうち、 ...initramfs-recovery.itb と記載のあるファイルを、そのファイル名からバージョン番号の部分を除去した上で、tftpルートディレクトリ /srv/tftp/ へ配置します。
|
1 2 |
$ ls -l /srv/tftp -rw-r--r-- 1 root root 7340032 Dec 11 13:06 openwrt-mediatek-filogic-cmcc_rax3000m-initramfs-recovery.itb |
現在のMTDをバックアップ
作業PCの下準備が終わったので、SSHでRAX3000Mに入って現在のMTD構成を確認。ファームウェア入れ替え前に、これらを全てddコマンドでファイルに書き出してバックアップします。
|
1 2 3 4 5 6 7 8 9 10 11 |
root@RAX3000M:~# cat /proc/mtd dev: size erasesize name mtd0: 08000000 00020000 "spi0.0" mtd1: 00100000 00020000 "BL2" mtd2: 00080000 00020000 "u-boot-env" mtd3: 00200000 00020000 "Factory" mtd4: 00200000 00020000 "FIP" mtd5: 03d00000 00020000 "ubi" mtd6: 02500000 00020000 "plugins" mtd7: 00800000 00020000 "fwk" mtd8: 00800000 00020000 "fwk2" |
まずは少しサイズの大きい mtd0 を /tmp へ吸い出して圧縮、scpで作業PCへ転送します。
|
1 2 3 4 5 6 7 8 9 |
root@RAX3000M:~# dd if=/dev/mtd0 | gzip >/tmp/mtd0_spi0.0.bin.gz 262144+0 records in 262144+0 records out root@RAX3000M:~# ls -l /tmp/*.gz -rw-r--r-- 1 root root 51246851 Dec 10 17:09 mtd0_spi0.0.bin.gz root@RAX3000M:~# scp /tmp/mtd0_spi0.0.bin.gz user@192.168.10.170:~/Downloads/cmcc/ mtd0_spi0.0.bin.gz 100% 49MB 24.4MB/s 00:02 root@RAX3000M:~# rm /tmp/mtd0_spi0.0.bin.gz |
残りは大したサイズではないので、一気にファイルへ書き出して、scpでまとめて転送します。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
root@RAX3000M:~# dd if=/dev/mtd1 of=/tmp/mtd1_BL2.bin 2048+0 records in 2048+0 records out root@RAX3000M:~# dd if=/dev/mtd2 of=/tmp/mtd2_u-boot-env.bin 1024+0 records in 1024+0 records out root@RAX3000M:~# dd if=/dev/mtd3 of=/tmp/mtd3_Factory.bin 4096+0 records in 4096+0 records out root@RAX3000M:~# dd if=/dev/mtd4 of=/tmp/mtd4_FIP.bin 4096+0 records in 4096+0 records out root@RAX3000M:~# dd if=/dev/mtd5 of=/tmp/mtd5_ubi.bin 124928+0 records in 124928+0 records out root@RAX3000M:~# dd if=/dev/mtd6 of=/tmp/mtd6_plugins.bin 75776+0 records in 75776+0 records out root@RAX3000M:~# dd if=/dev/mtd7 of=/tmp/mtd7_fwk.bin 16384+0 records in 16384+0 records out root@RAX3000M:~# dd if=/dev/mtd8 of=/tmp/mtd8_fwk2.bin 16384+0 records in 16384+0 records out root@RAX3000M:~# ls -l /tmp/*.bin -rw-r--r-- 1 root root 1048576 Dec 10 17:19 /tmp/mtd1_BL2.bin -rw-r--r-- 1 root root 524288 Dec 10 17:19 /tmp/mtd2_u-boot-env.bin -rw-r--r-- 1 root root 2097152 Dec 10 17:19 /tmp/mtd3_Factory.bin -rw-r--r-- 1 root root 2097152 Dec 10 17:20 /tmp/mtd4_FIP.bin -rw-r--r-- 1 root root 63963136 Dec 10 17:20 /tmp/mtd5_ubi.bin -rw-r--r-- 1 root root 38797312 Dec 10 17:21 /tmp/mtd6_plugins.bin -rw-r--r-- 1 root root 8388608 Dec 10 17:21 /tmp/mtd7_fwk.bin -rw-r--r-- 1 root root 8388608 Dec 10 17:22 /tmp/mtd8_fwk2.bin root@RAX3000M:~# scp /tmp/mtd*.bin user@192.168.10.170:~/Downloads/cmcc/ mtd1_BL2.bin 100% 1024KB 1.0MB/s 00:00 mtd2_u-boot-env.bin 100% 512KB 512.0KB/s 00:00 mtd3_Factory.bin 100% 2048KB 2.0MB/s 00:00 mtd4_FIP.bin 100% 2048KB 2.0MB/s 00:00 mtd5_ubi.bin 100% 61MB 30.5MB/s 00:02 mtd6_plugins.bin 100% 37MB 18.5MB/s 00:02 mtd7_fwk.bin 100% 8192KB 8.0MB/s 00:00 mtd8_fwk2.bin 100% 8192KB 8.0MB/s 00:00 root@RAX3000M:~# rm -f /tmp/mtd*.bin |
BL2とFIP(uboot)の書き込み
そのまま、作業Ubuntu PCにある ...preloader.bin (BL2)と、 ...uboot.fip (FIP)をUbuntu PCからscpで引っ張ってきます。正しくコピーできているかをハッシュで確認。
|
1 2 3 4 5 6 7 8 9 10 11 |
root@RAX3000M:~# scp user@192.168.10.170:~/Downloads/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-bl31-uboot.fip /tmp/ openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-bl31-uboot.fip 100% 983KB 982.7KB/s 00:00 root@RAX3000M:~# scp user@192.168.10.170:~/Downloads/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-preloader.bin /tmp/ openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-preloader.bin 100% 221KB 220.8KB/s 00:00 root@RAX3000M:~# ls -l /tmp/open* -rw-r--r-- 1 root root 1006233 Dec 10 19:36 /tmp/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-bl31-uboot.fip -rw-r--r-- 1 root root 226141 Dec 10 19:37 /tmp/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-preloader.bin root@RAX3000M:~# sha256sum /tmp/open* b4a0c5662c4ff7db16b435f46ba845c5a50b053684dbc0d65a41c964a36383f3 /tmp/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-bl31-uboot.fip 9f505abc0df8ff06df6f15635226be3e4d85397108de3c1165716cb783611176 /tmp/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-preloader.bin |
これから書き込むMTDを消去しようとするも、BL2は蹴られてしまうのはH3C Magic NX30 Proの時と同じ。
|
1 2 3 4 5 6 7 |
root@RAX3000M:~# mtd erase BL2 Could not open mtd device: BL2 Could not open mtd device: BL2 root@RAX3000M:~# mtd erase FIP Unlocking FIP ... Erasing FIP ... |
そのままBL2は触らずにFIPを書き換え、これは成功。
|
1 2 3 4 5 |
root@RAX3000M:~# mtd write /tmp/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-bl31-uboot.fip FIP Unlocking FIP ... Writing from /tmp/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-bl31-uboot.fip to FIP ... root@RAX3000M:~# exit |
initramfsとsysupgradeのインストール
作業用Ubuntu PCを静的IPアドレス 192.168.1.254/24 へ変更したら、RAX3000Mの電源を抜き差しして再起動を促します。
再起動後、 192.168.1.1/24 になったRAX3000Mからtftpサーバに対して、 initramfs ファイルのリクエストがあるのを確認(tftpサーバへのアクセスがさっぱり無い場合は、ファイアウォールでポートが塞がれていないか確認)。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$ systemctl status tftpd-hpa.service● tftpd-hpa.service - LSB: HPA's tftp server Loaded: loaded (/etc/init.d/tftpd-hpa; generated) Active: active (running) since Wed 2024-12-11 13:04:46 HKT; 41min ago Docs: man:systemd-sysv-generator(8) Tasks: 1 (limit: 14166) Memory: 244.0K (peak: 1.6M) CPU: 169ms CGroup: /system.slice/tftpd-hpa.service └─20607 /usr/sbin/in.tftpd --listen --user tftp --address :69 -s -c -v /srv/tftp Dec 11 13:04:46 VPCSA26GGK systemd[1]: Starting tftpd-hpa.service - LSB: HPA's tftp server... Dec 11 13:04:46 VPCSA26GGK tftpd-hpa[20599]: * Starting HPA's tftpd in.tftpd Dec 11 13:04:46 VPCSA26GGK tftpd-hpa[20599]: ...done. Dec 11 13:04:46 VPCSA26GGK systemd[1]: Started tftpd-hpa.service - LSB: HPA's tftp server. Dec 11 13:45:26 VPCSA26GGK in.tftpd[22214]: RRQ from 192.168.1.1 filename openwrt-mediatek-filogic-cmcc_rax3000m-initramfs-recovery.itb |
しばらく待ってから、 192.168.1.1/24 になったRAX3000MへSSHで入り、作業用Ubuntu PCから ...sysupgrade.itb ファイルを引っ張り出して、そのまま実行します。
|
1 2 3 4 5 6 7 8 9 10 11 12 |
$ ssh root@192.168.1.1 root@OpenWrt:~# scp user@192.168.1.254:~/Downloads/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-squashfs-sysupgrade.itb /tmp/ openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-squashfs-sysupgrade.itb 100% 10MB 10.0MB/s 00:00 root@OpenWrt:~# ls -l /tmp/open* -rw-r--r-- 1 root root 10486064 Sep 23 12:43 /tmp/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-squashfs-sysupgrade.itb root@OpenWrt:~# sysupgrade -F -n /tmp/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-squashfs-sysupgrade.itb Mon Sep 23 12:53:02 UTC 2024 upgrade: Commencing upgrade. Closing all shell sessions. Command failed: Connection failed root@OpenWrt:~# Connection to 192.168.1.1 closed by remote host. Connection to 192.168.1.1 closed. |
実行後、RAX3000Mは自動再起動するので、セッションが切れたらコマンド実行完了の合図。
BL2の書き込みに再チャレンジ
再起動後、RAX3000MのWANポートを既存のLANに繋いでインターネットへの疎通を確保。その上でSSHで再び入り、パッケージリストの更新と一括アップデートを実行。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
root@OpenWrt:~# opkg update root@OpenWrt:~# opkg list-upgradable | cut -f 1 -d ' ' | xargs -r opkg upgrade Configuring luci-app-opkg.Configuring luci-base. Configuring luci-mod-system. Configuring luci-theme-bootstrap. Configuring luci-mod-status. Configuring wireless-regdb. Configuring luci-app-firewall. Configuring luci-proto-ipv6. Configuring luci-mod-network. Configuring luci-mod-admin-full. Configuring luci-proto-ppp. Configuring luci-light. Configuring luci-ssl. Configuring luci. |
先ほど書き込み操作に失敗したBL2のロックを解除を試みます。
|
1 2 3 4 5 6 7 8 9 |
root@OpenWrt:~# opkg install kmod-mtd-rw Installing kmod-mtd-rw (5.15.167+git-20160214-2) to root... Downloading https://downloads.openwrt.org/releases/23.05.5/targets/mediatek/filogic/packages/kmod-mtd-rw_5.15.167%2bgit-20160214-2_aarch64_cortex-a53.ipk Configuring kmod-mtd-rw. root@OpenWrt:~#opkg list kmod-mtd-rw kmod-mtd-rw - 5.15.167+git-20160214-2 - A kernel module that temporarily makes all MTD partitions writeable. root@OpenWrt:~# insmod /lib/modules/$(uname -r)/mtd-rw.ko i_want_a_brick=1 |
MTDの構成を確認の上、BL2の中身を消去してみます。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
root@OpenWrt:~# cat /proc/mtd dev: size erasesize name mtd0: 07200000 00020000 "ubi" mtd1: 00200000 00020000 "fip" mtd2: 00200000 00020000 "factory" mtd3: 00080000 00020000 "u-boot-env" mtd4: 00100000 00020000 "bl2" root@OpenWrt:~# dmesg | grep mtd-rw [ 587.978400] mtd-rw: mtd1: setting writeable flag [ 587.983026] mtd-rw: mtd2: setting writeable flag [ 587.987665] mtd-rw: mtd4: setting writeable flag root@OpenWrt:~# mtd erase bl2 Unlocking bl2 ... Erasing bl2 ... |
BL2が書き込み可能なことが確認できたので、作業用PCから ...preloader.bin (BL2)ファイルを再度引っ張ってきて、書き込みます。
|
1 2 3 4 5 6 7 8 9 10 |
root@OpenWrt:~# scp user@192.168.1.254:~/Downloads/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-preloader.bin /tmp/ openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-preloader.bin 100% 221KB 220.8KB/s 00:00 root@OpenWrt:~# ls -l /tmp/open* -rw-r--r-- 1 root root 226141 Dec 11 06:21 /tmp/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-preloader.bin root@OpenWrt:~# mtd write /tmp/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-preloader.bin bl2 Unlocking bl2 ... Writing from /tmp/openwrt-23.05.5-mediatek-filogic-cmcc_rax3000m-nand-preloader.bin to bl2 ... root@OpenWrt:~# reboot |
書き込み成功したら、デバイスを再起動して作業完了(なお、このBL2は書き換えなくてもOpenWrtの動作に支障ないのでお好みで)。
OpenWrt 23.05.5初期状態の確認
あらためて、コンソールからシステムの状態を確認します。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 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 |
$ ssh root@192.168.1.1 BusyBox v1.36.1 (2024-09-23 12:34:46 UTC) built-in shell (ash) _______ ________ __ | |.-----.-----.-----.| | | |.----.| |_ | - || _ | -__| || | | || _|| _| |_______|| __|_____|__|__||________||__| |____| |__| W I R E L E S S F R E E D O M ----------------------------------------------------- OpenWrt 23.05.5, r24106-10cc5fcd00 ----------------------------------------------------- === WARNING! ===================================== There is no root password defined on this device! Use the "passwd" command to set up a new password in order to prevent unauthorized SSH logins. -------------------------------------------------- root@OpenWrt:~# uname -a Linux OpenWrt 5.15.167 #0 SMP Mon Sep 23 12:34:46 2024 aarch64 GNU/Linux root@OpenWrt:~# cat /etc/os-release NAME="OpenWrt" VERSION="23.05.5" ID="openwrt" ID_LIKE="lede openwrt" PRETTY_NAME="OpenWrt 23.05.5" VERSION_ID="23.05.5" HOME_URL="https://openwrt.org/" BUG_URL="https://bugs.openwrt.org/" SUPPORT_URL="https://forum.openwrt.org/" BUILD_ID="r24106-10cc5fcd00" OPENWRT_BOARD="mediatek/filogic" OPENWRT_ARCH="aarch64_cortex-a53" OPENWRT_TAINTS="" OPENWRT_DEVICE_MANUFACTURER="OpenWrt" OPENWRT_DEVICE_MANUFACTURER_URL="https://openwrt.org/" OPENWRT_DEVICE_PRODUCT="Generic" OPENWRT_DEVICE_REVISION="v0" OPENWRT_RELEASE="OpenWrt 23.05.5 r24106-10cc5fcd00" root@OpenWrt:~# df -h Filesystem Size Used Available Use% Mounted on /dev/root 5.0M 5.0M 0 100% /rom tmpfs 243.6M 64.0K 243.5M 0% /tmp /dev/ubi0_3 86.0M 684.0K 80.9M 1% /overlay overlayfs:/overlay 86.0M 684.0K 80.9M 1% / tmpfs 512.0K 0 512.0K 0% /dev root@OpenWrt:~# free -h total used free shared buff/cache available Mem: 498912 78960 398300 64 21652 384520 Swap: 0 0 0 oot@OpenWrt:~# cat /proc/cpuinfo processor : 0 BogoMIPS : 26.00 Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4 processor : 1 BogoMIPS : 26.00 Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4 |
ブラウザからLuCIへアクセス、RAMがH3C Magic NX30 Proに対して倍増の512MBなので余裕たっぷり。
WirelessはNX30 Proと同じMT7981なので、変わり映え無し。
OpenWrt 23.05.5へ無事に入れ替え終わったところで今回はここまで。このデバイスも既存LAN環境のアクセスポイントとして使いたいので、次回はルータのアクセスポイント化(Dumb AP)へと続きます。




