Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
OSC 2019 Tokyo/Spring Aterm & OpenWrt
Search
musashino205
February 23, 2019
Technology
990
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
OSC 2019 Tokyo/Spring Aterm & OpenWrt
musashino205
February 23, 2019
More Decks by musashino205
See All by musashino205
OSC2025_Tokyo-Fall_RecentOpenWrt
musashino205
0
110
OSC2019-TokyoFall_OpenWrt-and-Monitoring
musashino205
0
180
tokaido-lug-201909-yokohama
musashino205
0
130
tokaido-lug-201812-yokohama
musashino205
0
350
OSC 2018 Tokyo/Fall OpenWrt
musashino205
0
420
tokaido-lug_201807-yokohama
musashino205
0
500
OSC2018-Tokyo/Spring_OpenWrt
musashino205
0
330
TokaidoLUG-201712_Router
musashino205
0
350
Other Decks in Technology
See All in Technology
OPENLOGI Company Profile for engineer
hr01
1
74k
それでも、技術なブログを書く理由 #kichijojipm / Why I Still Write Tech Blogs Even Now
shinkufencer
0
330
AI時代のPlaywright活用(システムテストを自動化する ー 実行エンジンにPla ywrightを選んだ理由)
ynisqa1988
2
930
AI Coding Agent時代のcdk-nagガードレール 〜組織ルールを強制CIで守り抜く設計の挑戦〜
mhrtech
3
510
人とエージェントが高め合う協業設計
kintotechdev
0
750
AI Native なプロダクト組織の立ち上げ方 : 生産性 100 倍への挑戦
mikesorae
0
1.2k
ファミコンでPHPを動かす / PHP on the Famicom
tomzoh
2
600
AmplifyHostingConstructからSSRフレームワークのためのホスティング設計を考察する/amplify-hosting-construct
fossamagna
1
300
生成AI×AWS CDK×AWS FISで"振り返れる"ミニGameDayをつくろう
yoshimi0227
2
530
【公開用】AI_Dev_Ex2026_AI_登壇資料
matsuritechnologies
PRO
1
470
穢れた技術選定について
watany
19
6.1k
書籍セキュアAPIについて
riiimparm
0
210
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Designing Powerful Visuals for Engaging Learning
tmiket
1
460
Discover your Explorer Soul
emna__ayadi
2
1.2k
Thoughts on Productivity
jonyablonski
76
5.3k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.8k
Deep Space Network (abreviated)
tonyrice
0
230
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.9k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
Ethics towards AI in product and experience design
skipperchong
2
330
Transcript
None
HN: 武蔵野 / 大破 ◦ musashino_205 ◦ musashino205 @mstdn.maud.io
◦ 詳細はWebで https://大破.net/ 今年の目標 願望 ◦ 就職したい
法律面での注意 ◦ 市販のルータにサードパーティー製ファームウェアをインス トールして電波を出す場合、 技適表示が無効となる “改造” に該当する場合がある ◦
原則として搭載されている無線機能は使用せず、有線機とし て使用する 法律を守って楽しいHackを!
エンドユーザー視点: ◦ (ルータを中心とした) 組込デバイス向けLinuxディストリ ビューション お役御免になったルータを再活用 中古ルータで安価にネットワーク構築
etc...
開発者視点: ◦ 組込デバイス向け開発環境 Cross-Compile用toolchain (gcc, musl, ...) のダウンロード、
コンパイル、構築 Kernelのコンパイル Rootfs (squashfs, ext4, その他)作成 デバイス毎に適したファームウェア生成 etc... デバイスを選択後、 “make” 一発で全部やってくれる SoCベンダ等のSDKでOpenWrtを利用したものがチラホラ
最近サポートを投げ込んだ機種 (OSC 2018 Tokyo/Fall以降) ◦ BUFFALO WXR-2533DHP ◦
ELECOM WRC-1750GHBK2-I/C 2018年内滑り込み(12/31 21:38) ◦ I-O DATA WN-AG300DGR WN-AC1600DGR WN-AC1167GR ◦ NEC WG800HP
Aterm シリーズ
ハード/ソフト構成は主に3系統(把握してる範囲) ◦ 共通点: パスワードがガチガチ BootloaderとKernel両方 ハックが厳しい →
Atermはサードパーティ製ファームウェアは厳しい、 という認識が多い 1 2 3 SoC Qualcomm, QCA Realtek QCA, Atheros Bootloader U-Boot Realtek Bootcode original? OS Linux Linux NetBSD
1つ目の系統 ◦ SoC(把握している範囲): Qualcomm IPQ8064 Qualcomm Atheros
QCA9563 いずれもOpenWrtでサポート済み ◦ 全体的に家庭向けでは一般的な構成 ◦ ハイエンド帯, 旧ミドルレンジ帯 WG800HP WG2600HPx WG800HP, WG2600HPはOpenWrtでサポート済 1 SoC Qualcomm, QCA Bootloader U-Boot OS Linux
2つ目の系統 ◦ SoC: Realtek RTL81xx (Lexra/MIPS) OpenWrtでは未サポート
◦ 現行ローエンド/ミドルレンジ帯に多い WF800HP WG1200HPx WG1800HP3 HP/HP2はQCA WG1900HPx etc... 2 SoC Realtek Bootloader Realtek Bootcode OS Linux
3つ目の系統 ◦ SoC: Atheros AR7xxx Atheros AR9xxx
Qualcomm Atheros QCA955x OpenWrtでサポート済 ◦ 家庭向けルータとしてはあまり見ない ソフトウェア構成 BootloaderはNECオリジナルと思われるもの ◦ 旧型機に(とても)多い WR4100N WR8750N WG600HP WG1400HP 他いっぱい 3 SoC QCA, Atheros Bootloader original ? OS NetBSD
None
3つ目の系統の機種 仕様 Model WR8750N WR9500N WG600HP SoC Atheros
AR9344 RAM DDR2 128MB Flash 8MB 16MB 8MB WAN/LAN 1000Mbps x1 / 1000Mbps x4 WLAN AR9382 AR9380 AR9382 USB USB 2.0 Type-A x1 Bootloader original ? OS NetBSD based
OpenWrtを動かすにあたっての課題 ◦ 解決済み Bootloader, Kernelのパスワードが不明 Bootloaderは5chにヒント
Bootloaderが必要とするファームのフォーマットが不明 やもり氏 (@yamori813) から教わった(感謝) ファームヘッダのchecksum算出方法が不明 やもり氏から近い算出方法を頂き、弄っていたら確実そうな?算出方 法を見つけた OpenWrtブート中にリセットされ再起動される WatchDogが原因、カウントを最大値に設定してからOpenWrt ブート開始
NECのBootloaderが受け付けてくれるファームのヘッダ ◦ バイナリHACK – Qiita https://qiita.com/yamori813/items/8dccf20843f31c57ccd3 ◦ Aterm
WR8750N(進捗報告) – 鉄PCブログ https://tetsupc.wordpress.com/2019/01/21/aterm- wr8750n%EF%BC%88%E9%80%B2%E6%8D%97%E5%A0%B1%E5%91%8A%EF%BC%89/ 0x0 – 0x3 0x4 – 0x7 0x8 – 0xB 0xC – 0xF 0x00 データ種別 フラグ データ長 ヘッダ長 チェックサム 0x10 ロード アドレス エントリ ポイント 0x20 データ本体
ヘッダ内チェックサム算出方法(大体確実?) ◦ データを偶数サイズにpaddingして、チェックサム部を 0x00000000 で埋めたヘッダをデータに付加し で算出、4桁の前後2桁を入れ替えて後ろに0000を付ける ◦ 例:
“771f” --(入替)--> “1f77” チェックサム: 1F770000 $ dd if=fw.bin ibs=4 skip=1 2> /dev/null | od -A n -t u2 | tr -s ' ' '¥n' | awk '{s+=$0}END{printf "%04x", 0xffff-(s%0x100000000)%0xffff}' 771f
オリジナルのBootloaderからOpenWrtをブート ◦ Flashには書き込まず、TFTPでRAMにロードして直接ブート IPL:HARD-RESET memory test ... ok flinstall
OK boot version: 1.0.0 PKG "Orthos-HP" CPU "Atheros/AR9344" Revision 212.1 CLOCK 560.0 MHz HEAP MEMORY 262144 bytes Boot:InitFilesystem welcome to boot console Password: boot> tftpd phy0.1: "Atheros/AR8327(SW)" phy0.0: "Atheros/AR8327(phy)" active ch:0 tftpd start 192.168.0.1 boot> start tftp load openwrt-ath79-tiny-nec_wr8750n-i end tftp load length = 3439548 start memory load ... memory load complete begin : 0x80060000 length : 3439524 startup: 0x80060000 boot begin : 0x80060000 length : 3439524 startup: 0x80060000 option: 0x0 (右へ) OpenWrt kernel loader for AR7XXX/AR9XXX Copyright (C) 2011 Gabor Juhos Decompressing kernel... done! Starting kernel at 80060000... [ 0.000000] Linux version 4.14.98 (
[email protected]
) (gcc version 7.4.0 (OpenWrt GCC 7.4.0 r0+9245-e163387b7a)) #0 Tue Feb 12 07:50:40 2019 [ 0.000000] bootconsole [early0] enabled [ 0.000000] CPU0 revision is: 0001974c (MIPS 74Kc) [ 0.000000] MIPS: machine is NEC Aterm WR8750N [ 0.000000] SoC: Atheros AR9344 rev 1 [ 0.000000] Determined physical RAM map: [ 0.000000] memory: 08000000 @ 00000000 (usable) [ 0.000000] Initrd not found or empty - disabling initrd [ 0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes. [ 0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes [ 0.000000] Zone ranges: [ 0.000000] Normal [mem 0x0000000000000000-0x0000000007ffffff] [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000000000000-0x0000000007ffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000000000000- 0x0000000007ffffff] [ 0.000000] random: get_random_bytes called from 0x8045972c with crng_init=0 [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 32512 [ 0.000000] Kernel command line: console=ttyS0,9600 rootfstype=squashfs,jffs2 ... (この後も続く)
Flash内からのOpenWrtブートは厳しそう ◦ Firmware領域で独特なファイルシステムが形成されている ※ ファームウェアのサイズ内0x10000毎に挿入されている OpenWrtでこのFSを再現するのは厳しそう (WR8750N ファームウェア領域)
$ busybox hexdump -n 128 -C -v mtd2_os-image.bin 00000000 46 69 72 6d 77 61 72 65 00 ff ff ff ff ff ff ff |Firmware........| <- ※ 00000010 00 00 00 00 00 35 9f 94 30 53 46 54 ff ff ff ff |.....5..0SFT....| <- ※ 00000020 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| <- ※ 00000030 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| <- ※ 00000040 55 53 42 20 41 54 45 52 4d 57 4c 33 30 35 30 00 |USB ATERMWL3050.| <- ファーム本体 00000050 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| start 00000060 00 00 ff ff 00 00 01 42 00 00 00 18 68 09 00 00 |.......B....h...| 00000070 00 00 00 00 00 00 00 00 56 45 52 53 49 4f 4e 3a |........VERSION:| 00000080
U-Bootに置き換え ◦ pepe2k/u-boot_modを利用 U-Boot 1.1.4ベース https://github.com/pepe2k/u-boot_mod ◦
Aterm用フォーク: musashino-build/u-boot_mod https://github.com/musashino-build/u-boot_mod ◦ Cross-Compile用toolchain (gcc等) はOpenWrtのもの を利用 ◦ Windows 10のWSLでもコンパイルでき、動作した ◦ NECのBootloaderから専用のOpenWrtをブートして踏み台 にし、U-Bootへの置き換えとU-Boot用OpenWrtファーム の書き込みを行う
Flash内からブート (U-Boot) *************************************** * U-Boot 1.1.4-398303cd-clean * * Build:
2019-01-26 * *************************************** BOARD: NEC Aterm WR8750N SOC: AR9344 rev. 1 CPU: MIPS 74Kc RAM: 128 MB DDR2 32-bit CL3-4-4-10 FLASH: 8 MB Macronix MX25L64 PCIe: 168C:0030 MAC: 1C:B1:7F:00:A5:00 CLOCKS: CPU/RAM/AHB/SPI/REF 550/400/200/ 25/ 40 MHz Hit any key to stop booting: 0 Booting image from 0x9F040000... Image name: MIPS OpenWrt Linux-4.14.95 Build date: 2019-01-25 10:38:20 UTC Architecture: MIPS OS/image type: Linux Kernel Compression: LZMA Data size: 1.3 MB (1377507 bytes) Load address: 0x80060000 Entry point: 0x80060000 Header CRC... OK! Data CRC... skipped Uncompressing Kernel... OK! Starting kernel... (右へ) [ 0.000000] Linux version 4.14.95 (
[email protected]
) (gcc version 7.4.0 (OpenWrt GCC 7.4.0 r0+9120-bad68ff519)) #0 Fri Jan 25 10:38:20 2019 [ 0.000000] bootconsole [early0] enabled [ 0.000000] CPU0 revision is: 0001974c (MIPS 74Kc) [ 0.000000] MIPS: machine is NEC Aterm WR8750N [ 0.000000] SoC: Atheros AR9344 rev 1 [ 0.000000] Determined physical RAM map: [ 0.000000] memory: 08000000 @ 00000000 (usable) [ 0.000000] Initrd not found or empty - disabling initrd [ 0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes. [ 0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes [ 0.000000] Zone ranges: [ 0.000000] Normal [mem 0x0000000000000000-0x0000000007ffffff] [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000000000000-0x0000000007ffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff] [ 0.000000] random: get_random_bytes called from 0x8045972c with crng_init=0 [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 32512 [ 0.000000] Kernel command line: console=ttyS0,9600 rootfstype=squashfs,jffs2 ... (省略) BusyBox v1.30.0 () built-in shell (ash) _______ ________ __ | |.-----.-----.-----.| | | |.----.| |_ | - || _ | -__| || | | || _|| _| |_______|| __|_____|__|__||________||__| |____| |__| W I R E L E S S F R E E D O M ----------------------------------------------------- OpenWrt SNAPSHOT, r0+9135-d6efa74437 ----------------------------------------------------- root@OpenWrt:/#
ほぼ動作OK ◦ 現状、U-Bootへ置き換えることでルータとしては問題無く動作 今後の課題 ◦ SoCのUSB機能の初期化が完全ではない (Full-Speedまで)
OpenWrt内のUSB phyドライバ実装に抜けがある Kernel moduleの知識が無いので現状回避策により対処 Bugレポート投げる予定 ◦ USBポートの認識タイミングが遅い SoCと物理ポートの間に挟まるHubチップのRESETラインに、SoC ではなく無線チップ (AR938x) のGPIOが接続されている → 無線ドライバがロードされるまでLOWのまま、Hubが機能しな い (Reset状態) (たぶん)U-Bootで対処する必要がある
ブース出展してます ◦ openwrt.jp (仮) 5階 508 教室
今回の内容まとめ(ブログ記事) ◦ Aterm WR8750N(進捗報告) – 鉄PCブログ ◦ Aterm WR8750N/WR9500N/WG600HP(進捗報告2) – 鉄PCブログ スライドよりも詳細な内容をまとめています