20180130_jeffrey - silenceuncrio/diary GitHub Wiki

0910

review

0930

參考 開發OpenWrt路由器上LuCI的模塊

0945

想知道 mitrastar 怎麼透過 web ui 來做 firmware upgrade 可以 trace 以下

  • usr/lib/lua/luci/controller/admin/system.lua
    • entry({"admin", "system", "flashops"}, call("action_flashops"), _("Backup / Flash Firmware"), 70)
    • function action_flashops()

function action_flashops() 可知最終調用的是 /sbin/sysupgrade

看一下 sysupgrade 的使用方式

root@OpenWrt:/# sysupgrade
Usage: /sbin/sysupgrade [<upgrade-option>...] <image file or URL>
       /sbin/sysupgrade [-q] [-i] <backup-command> <file>

upgrade-option:
        -d <delay>   add a delay before rebooting
        -f <config>  restore configuration from .tar.gz (file or url)
        -i           interactive mode
        -c           attempt to preserve all changed files in /etc/
        -n           do not save configuration over reflash
        -T | --test
                     Verify image and config .tar.gz but do not actually flash.
        -F | --force
                     Flash image even if image checks fail, this is dangerous!
        -q           less verbose
        -v           more verbose
        -h | --help  display this help

backup-command:
        -b | --create-backup <file>
                     create .tar.gz of files specified in sysupgrade.conf
                     then exit. Does not flash an image. If file is '-',
                     i.e. stdout, verbosity is set to 0 (i.e. quiet).
        -r | --restore-backup <file>
                     restore a .tar.gz created with sysupgrade -b
                     then exit. Does not flash an image. If file is '-',
                     the archive is read from stdin.
        -l | --list-backup
                     list the files that would be backed up when calling
                     sysupgrade -b. Does not create a backup file.

1010

來試用 sysupgrade 看看

先透過 tftp 下載我們 proscend 的 image

root@OpenWrt:/tmp# tftp -g -r sysupgrade.bin 192.168.1.113
root@OpenWrt:/tmp# ls -al
drwxrwxrwt   13 root     root           440 Dec 27 16:15 .
drwxr-xr-x    1 root     root             0 Jan  1  1970 ..
...
-rw-r--r--    1 root     root      14680068 Dec 27 16:15 sysupgrade.bin

直接用最簡單的操作試試看

root@OpenWrt:/tmp# sysupgrade sysupgrade.bin
/sbin/sysupgrade: eval: line 1: opkg: not found
Saving config files...
shut down wifi
[ 1434.320000] MTPciPollTxRxEmpty
[ 1434.944000] AsicSetPreTbtt(): bss_idx=0, PreTBTT timeout = 0x0
[ 1434.956000] RTMPSetPiggyBack(912): Not support for HIF_MT yet!
[ 1434.972000] RT28xxPciAsicRadioOff(): Not support for HIF_MT yet!
[ 1434.984000] RTMPDrvClose call RT28xxPciAsicRadioOff fail !!
[ 1434.996000] tx_kickout_fail_count = 0
[ 1435.000000] tx_timeout_fail_count = 0
[ 1435.008000] rx_receive_fail_count = 0
[ 1435.016000] alloc_cmd_msg = 98
[ 1435.024000] free_cmd_msg = 98
[ 1435.032000] br-lan: port 2(ra0) entered disabled state
killall: ap_client: no process killed
[ 1435.120000] br-lan: port 1(eth0) entered disabled state
[ 1435.132000] device eth0 left promiscuous mode
[ 1435.144000] br-lan: port 1(eth0) entered disabled state
[ 1435.152000] ra2880stop()...Done
[ 1435.160000] eth1: ===> VirtualIF_close
[ 1435.168000] Free TX/RX Ring Memory!
[ 1435.176000] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 1435.188000] device ra0 left promiscuous mode
[ 1435.196000] br-lan: port 2(ra0) entered disabled state
[ 1435.260000] GDMA2_MAC_ADRH -- : 0x0000000c
[ 1435.268000] GDMA2_MAC_ADRL -- : 0x432880b0
killall: watchdog: no process killed
Sending TERM to remaining processes ... uhttpd ntpd dnsmasq quectel_cm ubusd logd netifd network
Sending KILL to remaining processes ...
Switching to ramdisk...
Performing system upgrade...
Unlocking firmware ...

Writing from <stdin> to firmware ...
Appending jffs2 data from /tmp/sysupgrade.tgz to firmware...
Writing from <stdin> to firmware[ 1446.164000] Stopped WatchDog Timer.
 ...    [ 1446.172000] Restarting system.

我們 proscend 的 image 被帶起來了

在我們的 image run 起來之後再試一次

root@MT7621:/tmp# sysupgrade sysupgrade.bin
Firmware upgrade is not implemented for this platform.

改用 tftp 下載 mitrastart 原本的 sysupgrade.bin 也是一樣的結果

1050

刻意用 proscend 的 image 而且跟 /www/cgi-bin/luci 並存

發現是可以用 web ui 做 upgrade 的

也就是 sysupgrade 是可以作動的

1310

sysupgrade 正常的動作需要 /lib/upgrade/

不過 ariel 在 remove useless files 這個 commit 把該 folder 幹掉了

1320

commit d050f52bdad6a1dbb203048002c0f2c4cf700cd4
Refs: [develop], {origin/develop}
Author: jeffrey <[email protected]>
Date:   Tue Jan 30 13:22:39 2018 +0800

    do not remove '/lib/upgrade/*' since openwrt '/sbin/sysupgrade' need them
    - 'sysupgrade' is the only way we can use to upgrade our firmware currently

 proscend/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

1530

web 的 https 不知為何起不來 砍掉先

commit 86f1e8aa8d0e61031b99c4dae1e51abfe1f1ef4a
Refs: [develop], {origin/develop}
Author: jeffrey <[email protected]>
Date:   Tue Jan 30 15:13:06 2018 +0800

    let the web module support the 'HTTPD' only currently

 proscend/prosrc/icos/icoslib/web/webcfg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

1610

commit 39670d3a4e979bd7e8ebaa406aa9785862793919
Refs: [develop], {origin/develop}
Author: jeffrey <[email protected]>
Date:   Tue Jan 30 16:09:11 2018 +0800

    use 'killall' instead of 'ICOS_process_killall'

 proscend/prosrc/icos/icoslib/vrrp/vrrp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

1620

做完 firmware upgrade 之後開機的第一次

jffs2 is not ready

...
jffs2 is not ready - marker found
[    9.216000] ra2880stop()...Done
[    9.224000] eth1: ===> VirtualIF_close
[    9.232000] Free TX/RX Ring Memory!
procd: - early -
procd: - ubus -
procd: - init -
Please press Enter to activate this console.
[   10.948000] Initializing XFRM netlink socket
[   10.960000] NET: Registered protocol family 15
[   10.972000] tun: Universal TUN/TAP device driver, 1.6
[   10.980000] tun: (C) 1999-2004 Max Krasnyansky <[email protected]>
[   11.012000] l2tp_core: L2TP core driver, V2.0
[   11.020000] l2tp_netlink: L2TP netlink interface
[   11.036000] gre: GRE over IPv4 demultiplexor driver
[   11.048000] ip_gre: GRE over IPv4 tunneling driver
[   11.068000] ip_tables: (C) 2000-2006 Netfilter Core Team
[   11.076000] Type=Restricted Cone
[   11.088000] nf_conntrack version 0.5.0 (1954 buckets, 7816 max)
[   11.108000] ip6_tables: (C) 2000-2006 Netfilter Core Team
[   11.124000] softdog: Software Watchdog Timer: 0.08 initialized. soft_noboot=0 soft_margin=60 sec soft_panic=0 (nowayout=0)
[   11.160000] hidraw: raw HID events driver (C) Jiri Kosina
[   11.176000] u32 classifier
[   11.180000]     input device check on
[   11.188000]     Actions configured
[   11.196000] Mirror/redirect action on
[   11.212000] GobiNet: Quectel_WCDMA&LTE_Linux&Android_GobiNet_Driver_V1.3.0
[   11.228000] add_ep parameters, dev_speed 3, is_in 1, isTT 0, ep_type 3, maxp 8, interval 256, burst 0, mult 0, ep 0x87425d80, ep_ctx 0xaf42d280, sch_ep 0x87694480
[   11.256000] add_ep parameters, dev_speed 3, is_in 1, isTT 0, ep_type 2, maxp 512, interval 1, burst 0, mult 0, ep 0x87425dac, ep_ctx 0xaf42d240, sch_ep 0x87694280
[   11.284000] add_ep parameters, dev_speed 3, is_in 0, isTT 0, ep_type 2, maxp 512, interval 1, burst 0, mult 0, ep 0x87425dd8, ep_ctx 0xaf42d160, sch_ep 0x8774af00
[   11.316000] GobiNet 1-2:1.4 eth2: register 'GobiNet' at usb-xhci-hcd-2, GobiNet Ethernet Device, 56:2e:c3:ba:ee:31
[   11.340000] creating qcqmi2
[   11.344000] usbcore: registered new interface driver GobiNet
[   11.360000] usbcore: registered new interface driver cdc_wdm
[   11.372000] crc_ccitt: exports duplicate symbol crc_ccitt (owned by kernel)
[   11.424000] l2tp_ppp: PPPoL2TP kernel driver, V2.0
[   11.484000] Netfilter messages via NETLINK v0.30.
[   11.496000] cannot register miscdev on minor=130 (err=-16)
[   11.528000] slhc: exports duplicate symbol slhc_compress (owned by kernel)
[   11.568000] usbcore: registered new interface driver usbhid
[   11.580000] usbhid: USB HID core driver
[   11.588000] usbcore: registered new interface driver usbserial
[   11.600000] usbcore: registered new interface driver usbserial_generic
[   11.616000] usbserial: USB Serial support registered for generic
[   11.660000] xt_time: kernel timezone is -0000
[   11.668000] zlib_deflate: exports duplicate symbol zlib_deflate (owned by kernel)
[   11.716000] zlib_inflate: exports duplicate symbol zlib_inflate (owned by kernel)
[   11.752000] crc_ccitt: exports duplicate symbol crc_ccitt (owned by kernel)
[   11.780000] usbcore: registered new interface driver ftdi_sio
[   11.792000] usbserial: USB Serial support registered for FTDI USB Serial Device
[   11.816000] cannot register miscdev on minor=130 (err=-16)
[   11.848000] slhc: exports duplicate symbol slhc_compress (owned by kernel)
[   11.884000] zlib_deflate: exports duplicate symbol zlib_deflate (owned by kernel)
[   11.916000] zlib_inflate: exports duplicate symbol zlib_inflate (owned by kernel)
[   11.944000] crc_ccitt: exports duplicate symbol crc_ccitt (owned by kernel)
[   11.976000] usbcore: registered new interface driver option
[   11.988000] usbserial: USB Serial support registered for GSM modem (1-port)
[   12.000000] option 1-2:1.0: GSM modem (1-port) converter detected
[   12.012000] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB0
[   12.028000] option 1-2:1.1: GSM modem (1-port) converter detected
[   12.040000] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB1
[   12.056000] option 1-2:1.2: GSM modem (1-port) converter detected
[   12.068000] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB2
[   12.080000] option 1-2:1.3: GSM modem (1-port) converter detected
[   12.096000] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB3
[   12.108000] cannot register miscdev on minor=130 (err=-16)
[   12.148000] slhc: exports duplicate symbol slhc_compress (owned by kernel)
[   12.184000] zlib_deflate: exports duplicate symbol zlib_deflate (owned by kernel)
[   12.224000] zlib_inflate: exports duplicate symbol zlib_inflate (owned by kernel)
[   12.252000] crc_ccitt: exports duplicate symbol crc_ccitt (owned by kernel)
[   12.280000] cannot register miscdev on minor=130 (err=-16)
[   12.316000] slhc: exports duplicate symbol slhc_compress (owned by kernel)
[   12.352000] zlib_deflate: exports duplicate symbol zlib_deflate (owned by kernel)
[   12.388000] zlib_inflate: exports duplicate symbol zlib_inflate (owned by kernel)
[   15.144000] jffs2_scan_eraseblock(): End of filesystem marker found at 0x0
[   15.156000] jffs2_build_filesystem(): unlocking the mtd device... done.
[   15.172000] jffs2_build_filesystem(): erasing all blocks after the end marker... done.
[   86.820000] jffs2: notice: (1100) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
### module <system> init
### module <syslog> init
### module <switch> init
### module <vlan> init
### module <lan> init
### module <firewall> init
### module <firewall6> init
### module <urlfilter> init
### module <macfilter> init
### module <ipFilter> init
### module <cwmp> init
### module <web> init
### module <virtual-server> init
### module <nat> init
### module <sntp> init
### module <snmp> init
### module <ssh> init
### module <ipsec> init
### module <ipv6lan> init
### module <dhcp6c> init
### module <alarm> init
### module <lte> init
### module <lte> init
### module <openvpn> init
### module <connmgr> init
### module <dmz> init
### module <cli> init
### module <vrrp> init
### module <route> init
### module <zebra> init
### module <smtp> init
### module <bgp> init
### module <ip_alias> init
### module <gre> init
### module <pptpd> init
### module <l2tp> init
procd: - init complete -

jffs2_build_filesystem() 耗時 86.820 - 15.156 = 71.664 秒

第二次開機之後就快了 - jffs2 is ready

...
jffs2 is ready
jffs2 is ready
[   12.736000] jffs2: notice: (317) 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 overlay
[   12.784000] ra2880stop()...Done
[   12.788000] eth1: ===> VirtualIF_close
[   12.800000] Free TX/RX Ring Memory!
procd: - early -
procd: - ubus -
procd: - init -
Please press Enter to activate this console.
[   14.544000] Initializing XFRM netlink socket
[   14.556000] NET: Registered protocol family 15
[   14.564000] tun: Universal TUN/TAP device driver, 1.6
[   14.576000] tun: (C) 1999-2004 Max Krasnyansky <[email protected]>
[   14.604000] l2tp_core: L2TP core driver, V2.0
[   14.616000] l2tp_netlink: L2TP netlink interface
[   14.632000] gre: GRE over IPv4 demultiplexor driver
[   14.644000] ip_gre: GRE over IPv4 tunneling driver
[   14.664000] ip_tables: (C) 2000-2006 Netfilter Core Team
[   14.672000] Type=Restricted Cone
[   14.684000] nf_conntrack version 0.5.0 (1954 buckets, 7816 max)
[   14.700000] ip6_tables: (C) 2000-2006 Netfilter Core Team
[   14.720000] softdog: Software Watchdog Timer: 0.08 initialized. soft_noboot=0 soft_margin=60 sec soft_panic=0 (nowayout=0)
[   14.752000] hidraw: raw HID events driver (C) Jiri Kosina
[   14.772000] u32 classifier
[   14.776000]     input device check on
[   14.784000]     Actions configured
[   14.792000] Mirror/redirect action on
[   14.808000] GobiNet: Quectel_WCDMA&LTE_Linux&Android_GobiNet_Driver_V1.3.0
[   14.824000] add_ep parameters, dev_speed 3, is_in 1, isTT 0, ep_type 3, maxp 8, interval 256, burst 0, mult 0, ep 0x87438a80, ep_ctx 0xaf421280, sch_ep 0x87555b80
[   14.852000] add_ep parameters, dev_speed 3, is_in 1, isTT 0, ep_type 2, maxp 512, interval 1, burst 0, mult 0, ep 0x87438aac, ep_ctx 0xaf421240, sch_ep 0x87555980
[   14.880000] add_ep parameters, dev_speed 3, is_in 0, isTT 0, ep_type 2, maxp 512, interval 1, burst 0, mult 0, ep 0x87438ad8, ep_ctx 0xaf421160, sch_ep 0x87555700
[   14.912000] GobiNet 1-2:1.4 eth2: register 'GobiNet' at usb-xhci-hcd-2, GobiNet Ethernet Device, ce:ec:9b:9f:31:ba
[   14.936000] creating qcqmi2
[   14.940000] usbcore: registered new interface driver GobiNet
[   14.956000] usbcore: registered new interface driver cdc_wdm
[   14.968000] crc_ccitt: exports duplicate symbol crc_ccitt (owned by kernel)
[   15.012000] l2tp_ppp: PPPoL2TP kernel driver, V2.0
[   15.088000] Netfilter messages via NETLINK v0.30.
[   15.100000] cannot register miscdev on minor=130 (err=-16)
[   15.140000] slhc: exports duplicate symbol slhc_compress (owned by kernel)
[   15.180000] usbcore: registered new interface driver usbhid
[   15.192000] usbhid: USB HID core driver
[   15.200000] usbcore: registered new interface driver usbserial
[   15.212000] usbcore: registered new interface driver usbserial_generic
[   15.228000] usbserial: USB Serial support registered for generic
[   15.268000] xt_time: kernel timezone is -0000
[   15.280000] zlib_deflate: exports duplicate symbol zlib_deflate (owned by kernel)
[   15.312000] zlib_inflate: exports duplicate symbol zlib_inflate (owned by kernel)
[   15.340000] crc_ccitt: exports duplicate symbol crc_ccitt (owned by kernel)
[   15.368000] usbcore: registered new interface driver ftdi_sio
[   15.380000] usbserial: USB Serial support registered for FTDI USB Serial Device
[   15.404000] cannot register miscdev on minor=130 (err=-16)
[   15.436000] slhc: exports duplicate symbol slhc_compress (owned by kernel)
[   15.464000] zlib_deflate: exports duplicate symbol zlib_deflate (owned by kernel)
[   15.496000] zlib_inflate: exports duplicate symbol zlib_inflate (owned by kernel)
[   15.524000] crc_ccitt: exports duplicate symbol crc_ccitt (owned by kernel)
[   15.556000] usbcore: registered new interface driver option
[   15.568000] usbserial: USB Serial support registered for GSM modem (1-port)
[   15.580000] option 1-2:1.0: GSM modem (1-port) converter detected
[   15.592000] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB0
[   15.608000] option 1-2:1.1: GSM modem (1-port) converter detected
[   15.620000] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB1
[   15.636000] option 1-2:1.2: GSM modem (1-port) converter detected
[   15.648000] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB2
[   15.664000] option 1-2:1.3: GSM modem (1-port) converter detected
[   15.676000] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB3
[   15.692000] cannot register miscdev on minor=130 (err=-16)
[   15.740000] slhc: exports duplicate symbol slhc_compress (owned by kernel)
[   15.776000] zlib_deflate: exports duplicate symbol zlib_deflate (owned by kernel)
[   15.804000] zlib_inflate: exports duplicate symbol zlib_inflate (owned by kernel)
[   15.836000] crc_ccitt: exports duplicate symbol crc_ccitt (owned by kernel)
[   15.868000] cannot register miscdev on minor=130 (err=-16)
[   15.908000] slhc: exports duplicate symbol slhc_compress (owned by kernel)
[   15.936000] zlib_deflate: exports duplicate symbol zlib_deflate (owned by kernel)
[   15.964000] zlib_inflate: exports duplicate symbol zlib_inflate (owned by kernel)
### module <system> init
### module <syslog> init
### module <switch> init
### module <vlan> init
### module <lan> init
### module <firewall> init
### module <firewall6> init
### module <urlfilter> init
### module <macfilter> init
### module <ipFilter> init
### module <cwmp> init
### module <web> init
### module <virtual-server> init
### module <nat> init
### module <sntp> init
### module <snmp> init
### module <ssh> init
### module <ipsec> init
### module <ipv6lan> init
### module <dhcp6c> init
### module <alarm> init
### module <lte> init
### module <lte> init
### module <openvpn> init
### module <connmgr> init
### module <dmz> init
### module <cli> init
### module <vrrp> init
### module <route> init
### module <zebra> init
### module <smtp> init
### module <bgp> init
### module <ip_alias> init
### module <gre> init
### module <pptpd> init
### module <l2tp> init
procd: - init complete -

待空閒時候再 survey

1715

commit 52b723976dce2dec3e7fa1398b6fbd21a6b82532
Refs: [develop], {origin/develop}
Author: jeffrey <[email protected]>
Date:   Tue Jan 30 17:14:56 2018 +0800

    now we can generate the firmware image for proscend web ui upgrade
    - web ui firmware upgrade not implement yet
    - please use 'image/sysupgrade.bin' via uboot currently
      - 'image/M360-P-<date code>.img' is combined from sysupgrade.bin and our mcsv

 proscend/Makefile | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

1535

commit 351c9f66a7819d94f262cd702c06ef7cc6cec020
Refs: [develop], {origin/develop}
Author: jeffrey <[email protected]>
Date:   Tue Jan 30 17:35:31 2018 +0800

    arrange the firmware generation makefile targets
    - every time you type 'make' the related images will generate again

 proscend/Makefile | 35 ++++++++++-------------------------
 1 file changed, 10 insertions(+), 25 deletions(-)
⚠️ **GitHub.com Fallback** ⚠️