◆ OpenWrt の trunk 版(r36853) を Planex MZK-W300NH2 用にビルドしてみました(対策編)
前回の記事の続きです。
※ 本記事の対象は、OpenWrt のリビジョン r36853 のソースコードです。 BARRIER BREAKER リリースに向けた 開発途上である trunk ブランチなのでこれからどんどん変わって適用できなくなる可能性があります。
※ trunk 版は開発途中です。何がおきるかわかりません。MZK-W300NH2 にシリアル接続ができることは必須と考えたほうがよいでしょう。前回も今回もシリアル接続できることを前提として書いています。シリアル接続については以前書いた記事「PLANEX MZK-W300NH2 とのシリアル接続とブートログ」などを参考にしてください。
※ビルド環境の構築、ファームの入れ替え方などは、カテゴリ「openwrt」の過去記事を参考にしてください。
firmware パーティションから自動で kernel と rootfs を切り出してくれる処理が mtdpart.c にあるのですが、kernel の認識に失敗しています。これが、OpenWrt のブートでカーネルパニックを起こしている理由です。
認識できない理由は、れ@さんがコメントしてくれたように、MZK-W300NH2 では Edimax ヘッダを追加しているのに、そのことへの考慮がされていないことです。
そこで、Edimax ヘッダ分をずらして読み出す処理を追加します。
以下に、mtdpart.c へのパッチファイルを用意しました。
http://ranosgrant.cocolog-nifty.com/openwrt-trunk-r36853/0212-mtd_fix_edimax_header.patch
*** a/drivers/mtd/mtdpart.c 2013-06-06 05:26:55.646489841 +0900 --- b/drivers/mtd/mtdpart.c 2013-06-06 06:02:18.427481167 +0900 *************** *** 899,904 **** --- 899,912 ---- }; split_partitions[0].size = find_uimage_size(mtd, part->offset); + if (!split_partitions[0].size) { + unsigned long uimage_size; + + uimage_size = find_uimage_size(mtd, part->offset + 0x14); + if (uimage_size) { + split_partitions[0].size = uimage_size + 0x14; + } + } if (!split_partitions[0].size) { split_partitions[0].size = find_squashfs_offset(mtd, part->offset); if (!split_partitions[0].size) {
■ビルド方法
以下、作業ディレクトリが ~/openwrt/trunk と仮定して書いています。
ビルドに必要なパッケージのインストールなど OS 側の準備が出来ているという前提です。
1) 今回の対策パッチファイルを置きます。
cd ~/openwrt/trunk/target/linux/ramips/patches-3.8
wget http://ranosgrant.cocolog-nifty.com/openwrt-trunk-r36853/0212-mtd_fix_edimax_header.patch
2) すでにビルドをしている場合は、コンパイル済のオブジェクトを削除します
cd ~/openwrt/trunk
make clean
3) ビルドしてください
cd ~/openwrt/trunk
make menuconfig (未実施の場合)
以下を指定します:
[Target System]: Ralink RT288x/RT3xxx
[Subtarget]: RT3x5x/RT5350 based boards
make (「make V=99 2>&1 | tee build.log」がオススメ)
ファームウェアは、~/openwrt/trunk/bin/ramips/openwrt-ramips-rt305x-mzk-w300nh2-squashfs-factory.bin にできます。
■ブート
ファーム入れ替え後の一度目のログインで以下のコマンドを実施してゴミ掃除しておきます。
mtd -r erase rootfs_data
オプション -r を付けているのでコマンドの終了時に自動でリブートされます。
以下、リブート時のブートログです。(OpenWrt のバナーが出る前にリターンキーを押しています)
赤字のところで kernel と rootfs が認識できているメッセージが出ています。バウンダリがどうこうといわれていますが readonly で使うところなので問題ありません。
U-Boot 1.1.3 (Nov 25 2008 - 16:46:30)
Board: Ralink APSoC DRAM: 16 MB
relocate_code Pointer at: 80fa8000
****************************
Init GPIO Pin****************************
flash_protect ON: from 0xBFC00000 to 0xBFC26213
protect on 0
protect on 1
protect on 2
protect on 3
protect on 4
protect on 5
protect on 6
protect on 7
protect on 8
protect on 9
flash_protect ON: from 0xBFC30000 to 0xBFC3FFFF
protect on 10
============================================
Ralink UBoot Version: 3.1
--------------------------------------------
ASIC 3052_MP1 (MAC to GigaMAC Mode)
DRAM COMPONENT: 64Mbits
DRAM BUS: 32BIT
Total memory: 16 MBytes
Flash: 4 MBytes
Date:Nov 25 2008 Time:16:46:30
============================================
icache: sets:256, ways:4, linesz:32 ,total:32768
dcache: sets:128, ways:4, linesz:32 ,total:16384
##### The CPU freq = 384 MHZ ####
SDRAM bus set to 32 bit
SDRAM size =16 Mbytes
Please choose the operation:
0: Load ucos code to SDRAM via TFTP Client.
1: Load system code to SDRAM via TFTP.
2: Load system code then write to Flash via TFTP.
3: Boot system code via Flash (default).
4: Entr boot command line interface.
9: Load Boot Loader code then write to Flash via TFTP.
0
3: System Boot system code via Flash.
## Booting image at bfc50000 ...
Bad Magic Number,43535953
Image Name: MIPS OpenWrt Linux-3.8.13
Created: 2013-06-07 14:29:37 UTC
System Control Status = 0x01040000
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 954429 Bytes = 932.1 kB
Load Address: 80000000
Entry Point: 80000000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
No initrd
## Transferring control to Linux (at address 80000000) ...
## Giving linux memsize in MB, 16
Starting kernel ...
[ 0.000000] Linux version 3.8.13 (lubun@lubun) (gcc version 4.6.4 (OpenWrt/Linaro GCC 4.6-2012.12 r36852) ) #1 Fri Jun 7 23:27:40 JST 2013
[ 0.000000] SoC Type: Ralink RT3052 id:1 rev:3
[ 0.000000] bootconsole [early0] enabled
[ 0.000000] CPU revision is: 0001964c (MIPS 24KEc)
[ 0.000000] MIPS: machine is Planex MZK-W300NH2
[ 0.000000] Determined physical RAM map:
[ 0.000000] memory: 01000000 @ 00000000 (usable)
[ 0.000000] Initrd not found or empty - disabling initrd
[ 0.000000] Zone ranges:
[ 0.000000] Normal [mem 0x00000000-0x00ffffff]
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x00000000-0x00ffffff]
[ 0.000000] Primary instruction cache 32kB, VIPT, 4-way, linesize 32 bytes.
[ 0.000000] Primary data cache 16kB, 4-way, VIPT, no aliases, linesize 32 bytes
[ 0.000000] Built 1 zonelists in Zone order, mobility grouping off. Total pages: 4064
[ 0.000000] Kernel command line: console=ttyS0,57600 rootfstype=squashfs,jffs2
[ 0.000000] PID hash table entries: 64 (order: -4, 256 bytes)
[ 0.000000] Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
[ 0.000000] Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
[ 0.000000] __ex_table already sorted, skipping sort
[ 0.000000] Writing ErrCtl register=00071960
[ 0.000000] Readback ErrCtl register=00071960
[ 0.000000] Memory: 13184k/16384k available (2084k kernel code, 3200k reserved, 509k data, 220k init, 0k highmem)
[ 0.000000] SLUB: Genslabs=9, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[ 0.000000] NR_IRQS:128
[ 0.000000] CPU Clock: 384MHz
[ 0.000000] Calibrating delay loop... 255.59 BogoMIPS (lpj=1277952)
[ 0.070000] pid_max: default: 32768 minimum: 301
[ 0.080000] Mount-cache hash table entries: 512
[ 0.090000] NET: Registered protocol family 16
[ 0.120000] bio: create slab <bio-0> at 0
[ 0.130000] rt2880_gpio 10000600.gpio: registering 24 gpios
[ 0.140000] Switching to clocksource MIPS
[ 0.150000] NET: Registered protocol family 2
[ 0.160000] TCP established hash table entries: 512 (order: 0, 4096 bytes)
[ 0.170000] TCP bind hash table entries: 512 (order: -1, 2048 bytes)
[ 0.190000] TCP: Hash tables configured (established 512 bind 512)
[ 0.200000] TCP: reno registered
[ 0.210000] UDP hash table entries: 256 (order: 0, 4096 bytes)
[ 0.220000] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[ 0.230000] NET: Registered protocol family 1
[ 0.240000] rt-timer 10000100.timer: maximum frequncy is 7812Hz
[ 0.280000] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 0.290000] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[ 0.310000] msgmni has been set to 25
[ 0.320000] io scheduler noop registered
[ 0.330000] io scheduler deadline registered (default)
[ 0.340000] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[ 0.350000] 10000c00.uartlite: ttyS0 at MMIO 0x10000c00 (irq = 20) is a 16550A
[ 0.370000] console [ttyS0] enabled, bootconsole disabled
[ 0.370000] console [ttyS0] enabled, bootconsole disabled
[ 0.390000] 1f000000.cfi: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x0000c2 Chip ID 0x0022a8
[ 0.410000] Amd/Fujitsu Extended Query Table at 0x0040
[ 0.420000] Amd/Fujitsu Extended Query version 1.1.
[ 0.430000] number of CFI chips: 1
[ 0.440000] 5 ofpart partitions found on MTD device 1f000000.cfi
[ 0.450000] Creating 5 MTD partitions on "1f000000.cfi":
[ 0.460000] 0x000000000000-0x000000030000 : "u-boot"
[ 0.480000] 0x000000030000-0x000000040000 : "u-boot-env"
[ 0.490000] 0x000000040000-0x000000050000 : "factory"
[ 0.500000] 0x0000003e0000-0x000000400000 : "cimage"
[ 0.520000] 0x000000050000-0x0000003e0000 : "firmware"
[ 0.530000] found squashfs behind kernel
[ 0.540000] Creating 2 MTD partitions on "1f000000.cfi":
[ 0.550000] 0x000000050000-0x000000139091 : "kernel"
[ 0.560000] mtd: partition "kernel" must either start or end on erase block boundary or be smaller than an erase block -- forcing read-only
[ 0.590000] 0x000000139091-0x0000003e0000 : "rootfs"
[ 0.600000] mtd: partition "rootfs" must either start or end on erase block boundary or be smaller than an erase block -- forcing read-only
[ 0.620000] mtd: partition "rootfs" set to be root filesystem
[ 0.640000] mtd: partition "rootfs_data" created automatically, ofs=2E0000, len=100000
[ 0.650000] 0x0000002e0000-0x0000003e0000 : "rootfs_data"
[ 0.670000] rt305x-esw 10110000.esw: link changed 0x08
[ 0.680000] eth0: done loading
[ 0.690000] TCP: cubic registered
[ 0.700000] NET: Registered protocol family 17
[ 0.710000] 8021q: 802.1Q VLAN Support v1.8
[ 0.720000] VFS: Mounted root (squashfs filesystem) readonly on device 31:6.
[ 0.740000] Freeing unused kernel memory: 220k freed
[ 3.000000] input: gpio-keys-polled.2 as /devices/gpio-keys-polled.2/input/input0
[ 3.080000] Button Hotplug driver version 0.4.1
- preinit -
Press the [f] key and hit [enter] to enter failsafe mode
- regular preinit -
[ 6.490000] jffs2: notice: (406) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
switching to jffs2
- init -
Please press Enter to activate this console. [ 7.910000] compat-drivers backport release: compat-drivers-2013-03-28-5
[ 7.930000] Backport based on wireless-testing.git master-2013-04-16
[ 7.940000] compat.git: wireless-testing.git
[ 8.100000] cfg80211: Calling CRDA to update world regulatory domain
[ 8.110000] cfg80211: World regulatory domain updated:
[ 8.120000] cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
[ 8.130000] cfg80211: (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[ 8.150000] cfg80211: (2457000 KHz - 2482000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
[ 8.170000] cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
[ 8.180000] cfg80211: (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[ 8.200000] cfg80211: (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
[ 8.810000] NET: Registered protocol family 10
[ 9.180000] usbcore: registered new interface driver usbfs
[ 9.200000] usbcore: registered new interface driver hub
[ 9.210000] usbcore: registered new device driver usb
[ 9.580000] rt2800_wmac 10180000.wmac: failed to load eeprom property
[ 9.590000] phy0 -> rt2x00lib_request_eeprom_file: Info - Loading EEPROM data from 'soc_wmac.eeprom'.
[ 17.900000] phy0 -> rt2x00_set_rt: Info - RT chipset 2872, rev 0200 detected
[ 17.920000] phy0 -> rt2x00_set_rf: Info - RF chipset 0008 detected
[ 18.070000] PPP generic driver version 2.4.2
[ 18.230000] ip_tables: (C) 2000-2006 Netfilter Core Team
[ 18.490000] xt_time: kernel timezone is -0000
[ 18.540000] NET: Registered protocol family 24
[ 18.570000] nf_conntrack version 0.5.0 (209 buckets, 836 max)
[ 18.880000] ip6_tables: (C) 2000-2006 Netfilter Core Team
[ 19.080000] dwc_otg: version 2.72a 24-JUN-2008
[ 26.150000] device eth0.1 entered promiscuous mode
[ 26.160000] device eth0 entered promiscuous mode
[ 26.170000] br-lan: port 1(eth0.1) entered forwarding state
[ 26.180000] br-lan: port 1(eth0.1) entered forwarding state
[ 27.400000] IPv6: ADDRCONF(NETDEV_CHANGE): eth0.1: link becomes ready
[ 28.180000] br-lan: port 1(eth0.1) entered forwarding state
[ 28.440000] ralink-wdt: timeout value 60 must be 0 < timeout <= 33, using 30
BusyBox v1.19.4 (2013-06-07 23:07:54 JST) built-in shell (ash)
Enter 'help' for a list of built-in commands.
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
BARRIER BREAKER (Bleeding Edge, r36852)
-----------------------------------------------------
* 1/2 oz Galliano Pour all ingredients into
* 4 oz cold Coffee an irish coffee mug filled
* 1 1/2 oz Dark Rum with crushed ice. Stir.
* 2 tsp. Creme de Cacao
-----------------------------------------------------
root@OpenWrt:/#
リブート後に /etc/config/network を見ると以下があり、lan 側ポート、つまり「1」~「4」のポートに接続すればIP アドレス 192.168.1.1 で telnet でつながります。
config switch option name 'switch0' option reset '1' option enable_vlan '1' config switch_vlan option device 'switch0' option vlan '1' option ports '0 1 2 3 6t' config interface 'lan' option ifname 'eth0.1' option type 'bridge' option proto 'static' option ipaddr '192.168.1.1' option netmask '255.255.255.0' option ip6assign '60'
最近のコメント