OpenWRT 刷机步骤

系统固件分为三种

  1. factory 从默认固件刷OpenWRT时使用,即第一次刷第三方固件时使用
  2. sysupgrade 已经刷OpenWRT了,需要更新版本时使用
  3. tftp 设备刷故障了,使用tftp方式恢复时,需要特别使用这个固件

刷机方式有二种

  1. mtd
mtd -e linux -r write gargoyle_1.3.14-ar71xx-wzr-hp-g300nh-squashfs-sysupgrade.bin linux
mtd -r write openwrt-ar71xx-wzr-hp-g300nh-squashfs-sysupgrade.bin linux
  1. sysupgrade
sysupgrade -v /tmp/openwrt-ar71xx-generic-wzr-hp-ag300h-squashfs-sysupgrade.bin

Installation Procedure

  1. Change firmware name
    修改openwrt-ar71xx-wzr-hp-g300nh-squashfs-sysupgrade.bin为1.bin,方便文件传输和操作
    本地运行HFS HTTP Server,指向目录到bin文件

  2. upload firmware
    cd /tmp
    wget http://172.16.230.132/1.bin

  3. Write firmware
    mtd -r write 1.bin firmware

    官方操作文档需要将文件写入到linux下:
    mtd -r write openwrt-ar71xx-wzr-hp-g300nh-squashfs-sysupgrade.bin linux
    但实际操作时可能没有,则需要自己去检查:
    cat /proc/mtd

  4. Real Case
    操作实例:

    root@Gargoyle:~# cd /tmp/
    root@Gargoyle:/tmp# wget http://172.16.230.132/1.bin
    Connecting to 172.16.230.132 (172.16.230.132:80)
    1.bin                100% |*******************************|  2880k  0:00:00 ETA
    root@Gargoyle:/tmp#
    
    root@Gargoyle:/tmp# mtd -r write 1.bin linux
    Could not open mtd device: linux
    Can't open device for writing!
    root@Gargoyle:/tmp# mtd -e linux -r write 1.bin linux
    Could not open mtd device: linux
    Can't open device for writing!
    root@Gargoyle:/tmp# cat /proc/mtd
    dev:    size   erasesize  name
    mtd0: 01000000 00010000 "spi0.0"
    mtd1: 01000000 00010000 "spi0.1"
    mtd2: 00040000 00010000 "u-boot"
    mtd3: 00010000 00010000 "u-boot-env"
    mtd4: 00010000 00010000 "art"
    mtd5: 00100000 00010000 "kernel"
    mtd6: 01e90000 00010000 "rootfs"
    mtd7: 018f0000 00010000 "rootfs_data"
    mtd8: 00010000 00010000 "user_property"
    mtd9: 01f90000 00010000 "firmware"
    root@Gargoyle:/tmp# mtd -r write 1.bin firmware
    Unlocking firmware ...
    
    Writing from 1.bin to firmware ...
    Rebooting ...
  1. Setup
    刷机完成后,无线信号默认是不开启的(刷成砖的场景除外),需要连接网线到LAN进行配置。
    Gargoyle 默认密码:root/password
    (1) 配置自定义端口号
    https: 3911
    ssh: 3912
    (2)配置LED
    Vim /etc/config/system
config 'led' 'Wan'
        option 'name' 'Wan'
        option 'sysfs' 'buffalo:green:router'
        option 'trigger' 'netdev'
        option 'dev' 'pppoe-wan'
        option 'mode' 'link'

config 'led' 'Diag'
        option 'name' 'Diag'
        option 'sysfs' 'buffalo:red:diag'
        option 'trigger' 'none'
        option 'default' '0'

config 'led' 'Wlan'
        option 'name' 'Wlan'
        option 'sysfs' 'ath9k-phy0'
        option 'trigger' 'netdev'
        option 'dev' 'wlan0'
        option 'mode' 'link'
    原文作者:mst7
    原文地址: https://www.jianshu.com/p/51b725a3dfc5
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞