wiki:TipAndDoc/Hardware/WZR-HP-AG300H

Version 1 (modified by mitty, 12 years ago) (diff)

--

  • 注意: 非純正ファームウェアで無線を使うと(日本では)電波法違反になる可能性がある。
  • see also Linux/OpenWRT

reference

  • matsuk_start_xmit: WZR-HP-AG300HにDD-WRT / OpenWrtをインストールする

    DD-WRTと比べると運用方法も一気に難易度があがります。自分で全部manageしたいという方にしかおすすめできません。

    • T8 トルクスドライバー
    • マイナスドライバー (筐体ひっぺがし用)
    • TTLレベルのシリアル接続ができるケーブル (秋月のFT232RLとか)
    • はんだ、はんだごて、銅線とか。ようははんだづけしなきゃならんです。
    • 後述するが、純正ファームウェアからWebUI経由で適用出来る

binary

Official Firm

  1. $ sudo ifconfig eth0:1 192.168.11.2
  2. $ sudo arp -s 192.168.11.1 02:aa:bb:cc:dd:20
  3. $ tftp 192.168.11.1
    tftp> binary
    tftp> put wzrhpag300h-172
    Sent 20467964 bytes in 26.5 seconds
    
  • DIAG LED(赤)が点滅すれば成功
  • リセットボタン
    • 純正ファームウェアでも、DD-WRTのデフォルト状態でも動作する
    • OpenWRTではsquashfsを使った上で、スクリプトを設置しないと動作しない

transfer firmware with tftp

  • see TFTPを使用してインストールする

    訳注) 日本版のAG300Hは標準状態では、OpenWrtファームウェアイメージをtftp経由でアップロードを行っても無視されますので、まずはじめにこちらを参照してブートローダの設定変更を行ってください。

    • 純正ファームへの書き戻しは、「setenv accept_open_rt_fmt 1」なしでも可能
    • それ以外は、setenv無しには無理な模様
      • mitty@ubuntu64:~/OpenWRT$ tftp 192.168.11.1
        tftp> binary
        tftp> put openwrt-ar71xx-generic-wzr-hp-ag300h-squashfs-tftp.bin
        Sent 2555940 bytes in 17.1 seconds
        tftp>
        
      • 変化しない
  • mitty@ubuntu64:~/OpenWRT$ sudo ifconfig eth0:1 192.168.11.2
  • mitty@ubuntu64:~/OpenWRT$ sudo arp -s 192.168.11.1 02:aa:bb:cc:dd:20
  • mitty@ubuntu64:~$ ifconfig eth0:1
    eth0:1    Link encap:Ethernet  HWaddr 00:0c:29:a3:81:7f
              inet addr:192.168.11.2  Bcast:192.168.11.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
    
  • mitty@ubuntu64:~$ arp -n
    Address                  HWtype  HWaddress           Flags Mask            Iface
    192.168.11.1             ether   02:aa:bb:cc:dd:20   CM                    eth0
    
  • mitty@ubuntu64:~/OpenWRT$ tftp 192.168.11.1 -m binary -c put openwrt-ar71xx-generic-wzr-hp-ag300h-squashfs-tftp.bin
    usage: tftp host-name [port]
    
    • wikiのコマンドラインではうまくいかなかった
  • mitty@ubuntu64:~/OpenWRT$ tftp 192.168.11.1
    tftp> put openwrt-ar71xx-generic-wzr-hp-ag300h-squashfs-tftp.bin
    Sent 2575462 bytes in 16.6 seconds
    
    • しかし、上でも述べたように適用されない

deploy with WebUI

  • official firm (ファームウェアを更新する) -> buffalo_to_ddwrt_webflash-MULTI.bin
    • OK -> DD-WRT化
  • official firm (ファームウェアを更新する) -> openwrt-ar71xx-generic-wzr-hp-ag300h-squashfs-factory.bin
    • OK -> OpenWRT化(squashfs)
    • 基礎的な機能(telnetd, sshd)しか導入されない
  • official firm (ファームウェアを更新する) -> openwrt-ar71xx-generic-wzr-hp-ag300h-jffs2-factory.bin
    • OK -> OpenWRT化(jffs2)
    • 基礎的な機能(telnetd, sshd)しか導入されない
    • jffs2なので、リセット機能(firstboot)がうまく動かない(?)
  • DD-WRT (Admin. > Firm. Upgrade) -> openwrt-ar71xx-generic-wzr-hp-ag300h-squashfs-*.bin
    • NG

OpenWRT

jffs2

  • root@OpenWrt:/# df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    rootfs                   31296      2936     28360   9% /
    /dev/root                31296      2936     28360   9% /
    tmpfs                    63320        60     63260   0% /tmp
    tmpfs                      512         0       512   0% /dev
    
  • root@OpenWrt:/# mount
    rootfs on / type rootfs (rw)
    /dev/root on / type jffs2 (rw,noatime)
    proc on /proc type proc (rw,noatime)
    sysfs on /sys type sysfs (rw,noatime)
    tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
    tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755)
    devpts on /dev/pts type devpts (rw,noatime,mode=600)
    debugfs on /sys/kernel/debug type debugfs (rw,relatime)
    none on /proc/bus/usb type usbfs (rw,relatime)
    

reset function

  • root@OpenWrt:~# mkdir -p /etc/hotplug.d/button
  • root@OpenWrt:~# vim /etc/hotplug.d/button/buttons
    #!/bin/sh
    logger $BUTTON
    logger $ACTION
    
  • root@OpenWrt:~# opkg update
  • root@OpenWrt:~# opkg install wget
  • root@OpenWrt:~# uci add system button
    cfg055d81
    
  • root@OpenWrt:~# uci set system.@button[-1].button=reset
  • root@OpenWrt:~# uci set system.@button[-1].action=released
  • root@OpenWrt:~# uci set system.@button[-1].handler="firstboot && reboot"
  • root@OpenWrt:~# uci set system.@button[-1].min=5
  • root@OpenWrt:~# uci set system.@button[-1].max=10
  • root@OpenWrt:~# uci commit system
  • root@OpenWrt:~# uci export system.button
    package system
    
    config system
            option hostname 'OpenWrt'
            option timezone 'UTC'
    
    config timeserver 'ntp'
            list server '0.openwrt.pool.ntp.org'
            list server '1.openwrt.pool.ntp.org'
            list server '2.openwrt.pool.ntp.org'
            list server '3.openwrt.pool.ntp.org'
            option enable_server '0'
    
    config button
            option button 'reset'
            option action 'released'
            option handler 'firstboot && reboot'
            option min '5'
            option max '10'
    
  • 以下のようにより簡単なスクリプトも試してみたが、動作しない
  • root@OpenWrt:~# vim /etc/hotplug.d/button/10-button
    #!/bin/sh
    
    [ "$ACTION" = "released" -a "$BUTTON" = "reset" ] && {
            logger -t button-hotplug Button: $BUTTON / Action: $ACTION
            firstboot && reboot
    }
    
  • firstbootコマンド自体がうまく動かない模様
  • root@OpenWrt:~# firstboot
    firstboot has already been run
    jffs2 partition is mounted, only resetting files
    MTD partition not found.
    
  • root@OpenWrt:~# echo $?
    1
    

squashfs

  • root@OpenWrt:/# df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    rootfs                   29824       852     28972   3% /
    /dev/root                 1536      1536         0 100% /rom
    tmpfs                    63320        64     63256   0% /tmp
    tmpfs                      512         0       512   0% /dev
    root                     63320        32     63288   0% /tmp/root
    overlayfs:/tmp/root      63320        32     63288   0% /tmp/root
    /dev/mtdblock7           29824       852     28972   3% /overlay
    overlayfs:/overlay       29824       852     28972   3% /
    
  • root@OpenWrt:/# mount
    rootfs on / type rootfs (rw)
    /dev/root on /rom type squashfs (ro,relatime)
    proc on /proc type proc (rw,noatime)
    sysfs on /sys type sysfs (rw,noatime)
    tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
    tmpfs on /dev type tmpfs (rw,noatime,size=512k,mode=755)
    devpts on /dev/pts type devpts (rw,noatime,mode=600)
    root on /tmp/root type tmpfs (rw,noatime,mode=755)
    overlayfs:/tmp/root on /tmp/root type overlayfs (ro,noatime,lowerdir=/,upperdir=
    /tmp/root)
    debugfs on /sys/kernel/debug type debugfs (rw,relatime)
    none on /proc/bus/usb type usbfs (rw,relatime)
    /dev/mtdblock7 on /overlay type jffs2 (rw,noatime)
    overlayfs:/overlay on / type overlayfs (rw,noatime,lowerdir=/,upperdir=/overlay)
    

reset function

  • 正常に動作する
  • root@OpenWrt:~# firstboot && reboot
    firstboot has already been run
    jffs2 partition is mounted, only resetting files
    root@OpenWrt:~# Connection to 192.168.1.1 closed by remote host.
    
  • root@OpenWrt:~# mkdir -p /etc/hotplug.d/button
  • root@OpenWrt:~# vim /etc/hotplug.d/button/10-button
    #!/bin/sh
    
    [ "$ACTION" = "released" -a "$BUTTON" = "reset" ] && {
            logger -t button-hotplug Button: $BUTTON / Action: $ACTION
            firstboot && reboot
    }
    
  • 期待通り動く…が、完全に初期状態に戻るため、opkgでインストールしたものなども消えてしまう
    • -> reset用スクリプトも消える

uhttpd

  • root@OpenWrt:~# opkg update
  • root@OpenWrt:~# opkg install luci
  • root@OpenWrt:~# /etc/init.d/uhttpd enable
  • root@OpenWrt:~# uci export uhttpd
    package uhttpd
    
    config uhttpd 'main'
            list listen_http '0.0.0.0:80'
            list listen_https '0.0.0.0:443'
            option home '/www'
            option rfc1918_filter '1'
            option cert '/etc/uhttpd.crt'
            option key '/etc/uhttpd.key'
            option cgi_prefix '/cgi-bin'
            option script_timeout '60'
            option network_timeout '30'
            option tcp_keepalive '1'
    
    config cert 'px5g'
            option days '730'
            option bits '1024'
            option country 'DE'
            option state 'Berlin'
            option location 'Berlin'
            option commonname 'OpenWrt'
    
  • root@OpenWrt:~# /etc/init.d/uhttpd start
  • root@OpenWrt:~# opkg update
  • root@OpenWrt:~# opkg install luci-ssl
  • root@OpenWrt:~# /etc/init.d/uhttpd restart
    Generating RSA private key, 1024 bit long modulus
    Generating selfsigned certificate with subject 'C=DE;ST=Berlin;L=Berlin;CN=OpenWrt;' and validity 2012-05-08 13:30:09-2014-05-08 13:30:09
    
  • root@OpenWrt:~# opkg install luci-i18n-japanese

useradd / sudo

  • install sudo, shadow via webUI
    • opkg install でももちろん可
  • suコマンドは存在しない模様
  • root@ag300h:~# mkdir /home
  • root@ag300h:~# useradd -m -s /bin/bash mitty
  • root@ag300h:~# visudo
    mitty ALL=NOPASSWD: ALL
    
  • root@ag300h:~# vim /etc/shadow
    mitty:!:15468::::::
    
    • パスワードログインを不可能にする
  • mitty@ag300h:~$ sudo chmod o-rwx /etc/shadow
  • mitty@ag300h:~$ sudo chmod o-rwx /etc/shadow-
  • mitty@ag300h:~$ sudo chmod o-rwx /etc/uhttpd.*
    • 一般ユーザでも見れる状態になってしまっている

Attachments (10)

Download all attachments as: .zip