[ath79]: Support for D-Link DCH-G020 (Z-Wave Hub)

Hi @s_2,
Did you managed to solve the problem? Any chances to flash the hub with openwrt? I would love to add the hub into my Home Assistant and not to rely on Dlinks cloud app?
Thanks

Hi @ValiE,
welcome to the OpenWRT forums.

I had not really continued porting after I couldn't fit the Domoticz package and all its dependencies into the image so easily, and especially since the ar71xx target is kind of a dead end for adding new devices now...

Back then I had crafted my first factory image by adding the D-Link header and manually fixing the checksum, for the latest state of the repo I only have the sysupgrade (since I could do all further flashing of my hub from the previous OpenWRT).

I could build a factory image for you, but you'd have to enable usb pins on each boot (see above), and there is currently no stand-alone solution for doing anything related to z-wave with this hub.

How much experience do you have with OpenWRT? I think the next step would be to start over with adding support for this device in the ath79 target (which hopefully allows for the gpio settings to work automagically on boot, even with the i2c expander) and also automate the creation of factory images.

Which other z-wave devices do you own / what's the plan for integration so far?

Hi @s_2
Thanks a lot for your warm welcome and for such a quick reply,
To answer your questions:

  1. my only experience with OpenWRT is as an enduser, back on WRT54GL ages.
  2. currently I own the hub, 5 door/window sensors and a PIR motion detector.
    My idea is/was to integrate into Home Assistant also this Zwave system - I might try also to find a good zwave USB stick to plug into Raspberry PI where the HA is running - i know there is a good zwave stick (i can't remember its name), that works perfectly in HA but is design for US and i'm living in Europe where (correct me if i'm wrong) zwave freq. is different.

The DCH-G020 contains a Sigma Devices (now Silabs) SD3503A, which is basically the same hardware as the Z-Wave UZB Dongle, it is also attached to the QCA9531 via USB inside the hub.

I found that hub years ago when I was searching for z-wave devices on ebay, as the typical USB sticks were so expensive. My first idea was to just cut the traces on the board and solder wires to it, so you can have a usb stick and just discard the rest of the hub, since the hubs were cheaper to get on ebay than the individual usb sticks :sweat_smile: (because the D-Link software was so crappy that many people discarded them).

Hass.io looks interesting, haven't heard of it before. It should also support the USB controller built into the hub, but when I read the minimum requirements are 32 GB of disk space and 1 GB of RAM, I'm no longer sure whether this would be the software I wanted to be in control of all devices in my home :grin:

So it definitely wouldn't run on OpenWRT itself, maybe there could be some agent running on the hub to attach its z-wave functionality to hass.io (a serial port tunnel over tcp!? the controller actually enumerates as ttyACM0), but the easiest way would probably be to cut the traces and solder a usb cable, rather than having two devices running at the same time.

I think i'll look for a cheap Zwave stick that can be directly attached to the Raspberry Pi where the Hassio is running.
Yep, Hassio is a very nice piece of software that can run on all kind of platforms (even though Raspberry Pi is the king - cheap and very low power consumption). It's a bit tricky to add different sensors into the app but is getting better and better with every version they release. Now it also supports Node-red integration making automation way easier then before. If you are into home automation then Hassio can be a good way of centralizing different ecosystems / sensors / all kind of small ESP8266/ESP32 developer boards etc

Hello,

Right now I just want to use this device only as wifi extender and try to upload OpenWRT by your manual. But I have stucked on flashing via regual web gui, it's write me only: "checksum error" without correct CRC. And I also don't know how exactly correcting the size and crc (what are the correct hex numbers on that possition), so can you please help me? Thank you.

PS:

Hi,

sorry, I actually don't have a working factory image at the moment either, it's been a few years since I made one, and I can no longer find the one I had initially used back then. Currently, you would need access to the serial console, then just try to flash your image via the WebUI and have a look at the error message in the serial console, it will print both the expected and the actual value for the crc, so you can just replace the actual value with the expected one in the image using a hex editor and flash again :slight_smile:

I agree this should really be fixed as soon as possible (i.e. find out the algorithm and auto-generate a working factory image); a few months ago I even made some progress with porting this device to ath79 (USB GPIO finally working on boot, even via i2c io expander), but I still couldn't make it set the WMAC address correctly (which is in 17 bytes ascii format inside the MP partition; only got this working for the ethernet mac via uci-defaults).

Hi,

thank you for reply. I already have access to the serial console, but nothing prints me when I try to upgrade firmware via WebUI. And I also try to load firmware via Recovery Web UI, but it's also fail without any messege in console. I think I must first correct size of firmware and then it's prints me correct crc. Bellow this post you can find my console log output when I also try to load the firmware. Thanks for help.

U-Boot 1.1.4--LSDK-10.2-00082-4 (Sep  8 2015 - 23:32:58)

ap143 - Honey Bee 2.0

DRAM:  64 MB
Top of RAM usable for U-Boot at: 84000000
Reserving 160k for U-Boot at: 83fd4000
Reserving 192k for malloc() at: 83fa4000
Reserving 44 Bytes for Board Info at: 83fa3fd4
Reserving 36 Bytes for Global Data at: 83fa3fb0
Reserving 128k for boot params() at: 83f83fb0
Stack Pointer at: 83f83f98
Now running in RAM - U-Boot at: 83fd4000
============================================ 
Date:Sep  8 2015  Time:23:32:58
Loader Version: v1.03 Build:1
Module Name: DCH-G020
============================================ 
Flash Manuf Id 0xc2, DeviceId0 0x20, DeviceId1 0x18
flash size 16MB, sector count = 256
Flash: 16 MB
* Scan for Linux kernel images ...
* Linux kernel found at 9F050000
* Scan completed.
Only one Linux kernel image found.

Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   ath_gmac_enet_initialize...
ath_gmac_enet_initialize: reset mask:c02200 
Scorpion ---->S27 PHY*
S27 reg init
: cfg1 0x800c0000 cfg2 0x7114
eth0: 1c:5f:2b:aa:fc:da
athrs27_phy_setup ATHR_PHY_CONTROL 4 :1000
athrs27_phy_setup ATHR_PHY_SPEC_STAUS 4 :10
eth0 up
Honey Bee ---->  MAC 1 S27 PHY *
S27 reg init
ATHRS27: resetting s27
ATHRS27: s27 reset done
: cfg1 0x800c0000 cfg2 0x7214
eth1: 1c:5f:2b:aa:fc:da
athrs27_phy_setup ATHR_PHY_CONTROL 0 :1000
athrs27_phy_setup ATHR_PHY_SPEC_STAUS 0 :10
athrs27_phy_setup ATHR_PHY_CONTROL 1 :1000
athrs27_phy_setup ATHR_PHY_SPEC_STAUS 1 :10
athrs27_phy_setup ATHR_PHY_CONTROL 2 :1000
athrs27_phy_setup ATHR_PHY_SPEC_STAUS 2 :10
athrs27_phy_setup ATHR_PHY_CONTROL 3 :1000
athrs27_phy_setup ATHR_PHY_SPEC_STAUS 3 :10
eth1 up
eth0, eth1
Setting 0x181162c0 to 0x2041a100
Hit any key to stop autoboot:  2  1  0 
## Booting image at 9f050000 ...
   Image Name:   Linux Kernel Image
   Created:      2016-06-29   9:47:18 UTC
   Image Type:   MIPS Linux Kernel Image (lzma compressed)
   Data Size:    989864 Bytes = 966.7 kB
   Load Address: 80002000
   Entry Point:  8023dd00
   Verifying Checksum at 0x9f050040 ...OK
   Uncompressing Kernel Image ... OK
No initrd
## Transferring control to Linux (at address 8023dd00) ...
## Giving linux memsize in bytes, 67108864

Starting kernel ...

Booting QCA953x
 
Linux version 2.6.31 (adminuser@adminuser-VirtualBox) (gcc version 4.3.3 (GCC) ) #1 Wed Jun 29 05:43:21 EDT 2016
flash_size passed from bootloader = 16
arg 1: console=ttyS0,115200
arg 2: root=31:6
arg 3: rootfstype=squashfs
arg 4: init=/sbin/init
arg 5: mtdparts=ath-nor0:64k(u-boot),64k(ART),64k(MP),128k(config),64k@0x40000(bootarg),2048k(uImage),12736k(rootfs1),64k(log),512k(mydlink),512k(data1),128k(data2),64k(data3)
arg 6: mem=64M
CPU revision is: 00019374 (MIPS 24Kc)
ath_sys_frequency: cpu apb ddr apb cpu 650 ddr 391 ahb 216
Determined physical RAM map:
 memory: 02000000 @ 00000000 (usable)
User-defined physical RAM map:
 memory: 04000000 @ 00000000 (usable)
Zone PFN ranges:
  Normal   0x00000000 -> 0x00004000
Movable zone start PFN for each node
early_node_map[1] active PFN ranges
    0: 0x00000000 -> 0x00004000
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: console=ttyS0,115200 root=31:6 rootfstype=squashfs init=/sbin/init mtdparts=ath-nor0:64k(u-boot),64k(ART),64k(MP),128k(config),64k@0x40000(bootarg),2048k(uImage),12736k(rootfs1),64k(log),512k(mydlink),512k(data1),128k(data2),64k(data3) mem=64M 
PID hash table entries: 256 (order: 8, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
Writing ErrCtl register=00000000
Readback ErrCtl register=00000000
Memory: 55732k/65536k available (2303k kernel code, 9728k reserved, 478k data, 120k init, 0k highmem)
NR_IRQS:128
plat_time_init: plat time init done
Calibrating delay loop... 433.15 BogoMIPS (lpj=866304)
Mount-cache hash table entries: 512

****************ALLOC***********************
 Packet mem: 802e84a0 (0x600000 bytes)
********************************************

NET: Registered protocol family 16
bio: create slab <bio-0> at 0
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
ATH GPIOC major 0
squashfs: version 4.0 (2009/01/31) Phillip Lougher
JFFS2 version 2.2 (NAND) (ZLIB) (RTIME) (c) 2001-2006 Red Hat, Inc.
msgmni has been set to 109
alg: No test for stdrng (krng)
io scheduler noop registered (default)
Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
serial8250.0: ttyS0 at MMIO 0xb8020000 (irq = 19) is a 16550A
console [ttyS0] enabled
loop: module loaded
12 cmdlinepart partitions found on MTD device ath-nor0
Creating 12 MTD partitions on "ath-nor0":
0x000000000000-0x000000010000 : "u-boot"
0x000000010000-0x000000020000 : "ART"
0x000000020000-0x000000030000 : "MP"
0x000000030000-0x000000050000 : "config"
0x000000040000-0x000000050000 : "bootarg"
0x000000050000-0x000000250000 : "uImage"
0x000000250000-0x000000ec0000 : "rootfs1"
0x000000ec0000-0x000000ed0000 : "log"
0x000000ed0000-0x000000f50000 : "mydlink"
0x000000f50000-0x000000fd0000 : "data1"
0x000000fd0000-0x000000ff0000 : "data2"
0x000000ff0000-0x000001000000 : "data3"
usbmon: debugfs is not available
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
Port Status 1c000004 
ath-ehci ath-ehci.0: ATH EHCI
ath-ehci ath-ehci.0: new USB bus registered, assigned bus number 1
ehci_reset Intialize USB CONTROLLER in host mode: 13
ehci_reset Port Status 1c000000 
ath-ehci ath-ehci.0: irq 3, io mem 0x1b000000
ehci_reset Intialize USB CONTROLLER in host mode: 13
ehci_reset Port Status 1c000000 
ath-ehci ath-ehci.0: USB 2.0 started, EHCI 1.00
usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: ATH EHCI
usb usb1: Manufacturer: Linux 2.6.31 ehci_hcd
usb usb1: SerialNumber: platform
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
usbcore: registered new interface driver cdc_acm
cdc_acm: v0.26:USB Abstract Control Model driver for USB modems and ISDN adapters
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for cp210x
usbcore: registered new interface driver cp210x
cp210x: v0.09:Silicon Labs CP210x RS232 serial adaptor driver
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
nf_conntrack version 0.5.0 (1024 buckets, 4096 max)
TCP cubic registered
NET: Registered protocol family 10
IPv6 over IPv4 tunneling driver
NET: Registered protocol family 17
Bridge firewalling registered
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
arch/mips/atheros/gpio.c (ath_simple_config_init) MP_GPIO: 15
arch/mips/atheros/gpio.c (ath_simple_config_init) RESET_BTN_GPIO: 17, RESET_BTN_TRIGGER_LEVEL: 0
arch/mips/atheros/gpio.c (ath_simple_config_init) WPS_BTN_GPIO: 3, WPS_BTN_TRIGGER_LEVEL: 0
arch/mips/atheros/gpio.c (ath_simple_config_init) WPS_LED_GPIO: 11, LED_ACTIVE_LEVEL: 0
arch/mips/atheros/gpio.c (ath_simple_config_init) I2C_SDA_GPIO: 0, INT_I2C_LOW: 0
arch/mips/atheros/gpio.c (ath_simple_config_init) I2C_SCL_GPIO: 1, INT_I2C_LOW: 0
arch/mips/atheros/gpio.c (ath_simple_config_init) POWER_LED_GPIO1: 13, LED_ACTIVE_LEVEL: 0
arch/mips/atheros/gpio.c (ath_simple_config_init) POWER_LED_GPIO2: 14
VFS: Mounted root (squashfs filesystem) readonly on device 31:6.
Freeing unused kernel memory: 120k freed

init started: BusyBox v1.21.1--LSDK-10.2-00082-4 (2016-06-29 05:45:06 EDT)

starting pid 177, tty '': '/etc/rc.d/rcS'
QCA953x Watchdog Timer enabled (30 seconds, nowayout)
<pca9554_config_set|42> i2c_value = 70


<pca9554_config_set|47> i2c_value = 03


<pca9554_config_set|52> i2c_value = 00


<pca9554_output_set|100> i2c_value = 70


<pca9554_output_set|105> i2c_value = 01


<pca9554_output_set|110> i2c_value = ff


vm.panic_on_oom = 1
kernel.panic = 2

Please press Enter to activate this console. Wed Jun 29 00:00:00 UTC 2016
256+0 records in
256+0 records out
tar: removing leading '/' from member names
11+1 records in
11+1 records out
/dev/watchdog device found. Try to launch watchdog daemon.
[control_center.c] dch mtd found: mtd8
[control_center.c] kernel jffs2 support detected.
[control_center.c] mount /dev/mtdblock8 to /dch.
killall: zw_meter_check: no process killed
killall: zw_center: no process killed
<pca9554_output_set|100> i2c_value = 70


<pca9554_output_set|105> i2c_value = 01


<pca9554_output_set|110> i2c_value = 02


<pca9554_output_set|100> i2c_value = 70


128+0 records in
128+0 records out
<pca9554_output_set|105> i2c_value = 01


qca955x_GMAC: Length per segment 1536
953x_GMAC: qca953x_gmac_attach
Link Int Enabled 
qca953x_set_gmac_caps  CHECK DMA STATUS 
mac:0 Registering S27....
qca955x_GMAC: RX TASKLET - Pkts per Intr:18
qca955x_GMAC: unit 0 --> 1c:5f:2b:aa:fc:da 
qca955x_GMAC: Max segments per packet :   1
qca955x_GMAC: Max tx descriptor count :   512
qca955x_GMAC: Max rx descriptor count :   128
qca955x_GMAC: Mac capability flags    :   2581
953x_GMAC: qca953x_gmac_attach
Link Int Enabled 
qca953x_set_gmac_caps  CHECK DMA STATUS 
mac:1 Registering S27....
qca955x_GMAC: RX TASKLET - Pkts per Intr:18
qca955x_GMAC: unit 1 --> 1c:5f:2b:aa:fc:da 
usb 1-1: new high speed USB device using ath-ehci and address 2
qca955x_GMAC: Max segments per packet :   1
qca955x_GMAC: Max tx descriptor count :   512
qca955x_GMAC: Max rx descriptor count :   128
qca955x_GMAC: Mac capability flags    :   2D81
<pca9554_output_set|110> i2c_value = 00


usb 1-1: New USB device found, idVendor=05e3, idProduct=0608
usb 1-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
usb 1-1: Product: USB2.0 Hub
usb 1-1: configuration #1 chosen from 1 choice
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
asf: module license 'Proprietary' taints kernel.
Disabling lock debugging due to kernel taint
usb 1-1.1: new full speed USB device using ath-ehci and address 3
usb 1-1.1: New USB device found, idVendor=0658, idProduct=0200
usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 1-1.1: configuration #1 chosen from 1 choice
cdc_acm 1-1.1:1.0: This device cannot do calls on its own. It is not a modem.
cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device
ath_hal: 0.9.17.1 (AR5416, AR9380, REGOPS_FUNC, WRITE_EEPROM, TX_DATA_SWAP, RX_DATA_SWAP, 11D)
ath_rate_atheros: Copyright (c) 2001-2005 Atheros Communications, Inc, All Rights Reserved
athr_gmac_ring_alloc Allocated 8192 at 0x8384e000
athr_gmac_ring_alloc Allocated 2048 at 0x83fdd800
HONEYBEE ----> S27 PHY MDIO
ATHRS27: resetting s27
ATHRS27: s27 reset done
Setting Drop CRC Errors, Pause Frames and Length Error frames 
Setting PHY...
ath_dev: Copyright (c) 2001-2007 Atheros Communications, Inc, All Rights Reserved
ath_ahb: 10.2-00082-4 (Atheros/multi-bss)
__ath_attach: Set global_scn[0]
Enterprise mode: 0x03fc0000
Restoring Cal data from Flash
Green-AP : Green-AP : Attached

ath_get_caps[6148] rx chainmask mismatch actual 3 sc_chainmak 0
ath_get_caps[6123] tx chainmask mismatch actual 3 sc_chainmak 0
ADDRCONF(NETDEV_UP): eth1: link is not ready
SC Callback Registration for wifi0
wifi0: Atheros ???: mem=0xb8100000, irq=2
ath_pci: 10.2-00082-4 (Atheros/multi-bss)
device eth1 entered promiscuous mode
route: resolving dev
Control Center(219) : Recive a request(410) from 303
Application Center(262) : Recive a request(410) from 219
Control Center(219) : Recive a response(410) from 262
Control Center(219) : Recive a request(414) from 303
Application Center(262) : Recive a request(414) from 219
Failed to kill daemon: No such file or directory
Control Center(219) : Recive a response(414) from 262
VAP device ath0 created 
ath0
 
 DES SSID SET=DCH-G020-FCDA 
 ieee80211_ioctl_siwmode: imr.ifm_active=131712, new mode=3, valid=1 
Interface doesn't accept private ioctl...
ForBiasAuto (8BE0): Operation not permitted
Set freq vap stop send + 82ef8000
Set freq vap stop send -82ef8000
Set wait done --82ef8000
device ath0 entered promiscuous mode
br0: port 2(ath0) entering learning state
Configuration fi ieee80211_ioctl_siwmode: imr.ifm_active=393856, new mode=3, valid=1 
le: /var/etc/oob_ieee80211_scan_unregister_event_handler: Failed to unregister evhandler=82e4bfc4 arg=82de0000
.ap_bss
 Scan in progress.. Cancelling it 
br0: port 2(ath0) entering disabled state
 DEVICE IS DOWN ifname=ath0
ath0: Could not  DEVICE IS DOWN ifname=ath0
connect to kernel driver
Using interface ath0 with hwaddr 1c:5f:2b:aa:fc:da and ssid 'DCH-G020-FCDA'
br0: port 2(ath0) entering learning state
[zw_center]:ZWave inital success!
Control Center(219) : Recive a request(513) from 364
<led_center:977>: CMD MATCHED cmd = 513
service_event : forward a zwave event to the zwave center(364)!
br0: port 2(ath0) entering forwarding state
mlme_create_infra_bss : Overriding HT40 channel with HT20 channel
enet1 port1 up 100Mbps Full duplex
953x_GMAC: Enet Unit:1 PHY:1 is UP eth1  RGMII  1000Mbps  full duplex
953x_GMAC: done cfg2 0x7215 ifctl 0x0 miictrl  
Setting Drop CRC Errors, Pause Frames and Length Error frames 
ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
br0: port 1(eth1) entering learning state
Control Center(219) : Recive a request(6) from 0
receive LAN_CABLE_UP_EVENT
Lan Center(303) : Recive a request(6) from 219
<ethernet_connStatusChange|460> Cable UP
Control Center(219) : Recive a request(411) from 303
Application Center(262) : Recive a request(411) from 219
Control Center(219) : Recive a request(408) from 303
Control Center(219) : Recive a request(414) from 303
Control Center(219) : Recive a response(6) from 303
Lan Center(303) : Recive a response(411) from 219
Lan Center(303) : Recive a response(408) from 219
Lan Center(303) : Recive a response(414) from 219
Control Center(219) : Recive a response(411) from 262
Application Center(262) : Recive a request(408) from 219
br0: port 1(eth1) entering forwarding state
udhcpc (v1.21.1--LSDK-10.2-00082-4) started
Control Center(219) : Recive a response(408) from 262
Application Center(262) : Recive a request(414) from 219
br0       Link encap:Ethernet  HWaddr 1C:5F:2B:AA:FC:DA  
          inet addr:192.168.0.60  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::1f:31ff:fea3:44c2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:49 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:13305 (12.9 KiB)

Sending discover...
Sending select for 192.168.2.86...
Lease of 192.168.2.86 obtained, lease time 86400
deleting routers
route: ioctl 0x890c failed: No such process
adding dns 192.168.2.250
Control Center(219) : Recive a request(9) from 580
<led_center:977>: CMD MATCHED cmd = 9
killall: dlink_time_sync: no process killed
42548 01245.507  118023.0    333.8  118668326968769.9  20004.3         0
killall: send_device_info: no process killed
Control Center(219) : Recive a request(427) from 616
killall: crond: no process killed
Apr  2 11:46:12 crond[636]: crond: crond (busybox 1.21.1--LSDK-10.2-00082-4) started, log level 8

Control Center(219) : Recive a response(414) from 262
Application Center(262) : Recive a request(418) from 219
killall: llmnr: no process killed
Control Center(219) : Recive a request(8) from 580
<led_center:977>: CMD MATCHED cmd = 8
DCHC Center(307) : Recive a request(3021) from 219
Control Center(219) : Recive a response(3021) from 307
Control Center(219) : Recive a response(418) from 262
Application Center(262) : Recive a request(416) from 219
killall: mdns-scan: no process killed
Control Center(219) : Recive a response(416) from 262
Application Center(262) : Recive a request(422) from 219
killall: chkfwd: no process killed
Control Center(219) : Recive a response(422) from 262
Application Center(262) : Recive a request(427) from 219
Control Center(219) : Recive a response(427) from 262
Application Center(262) : Recive a request(426) from 219
e[31;40m[  System Message  ]:Load AesEncrypt By Payload e[0m
killall: dch_scheduler: no process killed
Control Center(219) : Recive a response(426) from 262
Apr  2 11:46:14 crond[677]: crond: crond (busybox 1.21.1--LSDK-10.2-00082-4) started, log level 8

e[31;40m[  System Message  ]:Check duplicate launcher = [  ]e[0m
e[31;40m[  System Message  ]:Linkd is unbinding,skip version checke[0m
e[31;40m[  System Message  ]:Check duplicate launcher = [  ]e[0m
e[31;40m[  System Message  ]:Check duplicate agent = [  ]e[0m
e[31;40m[  System Message  ]:Linkd Run Path= [ /dch/linkd.out ]e[0m
-rwxrwxrwx    1 root     root        253512 Mar 30 15:38 /dch/linkd.out
e[31;40m[  System Message  ]:Linkd NOW STARTING.............e[0m
e[31;40m[  System Message  ]:LAUNCHER PID = 659 .............e[0m
e[31;40m[  System Message  ]:START LINKD WATCHDOG.............e[0m
e[31;40m[  System Message  ]:LINKD &bindStr.............e[0m
--2020-04-02 11:46:14--  http://127.0.0.1:5459/ws/api/getVersion
Connecting to 127.0.0.1:5459... failed: Connection refused.
--2020-04-02 11:46:16--  http://127.0.0.1:5459/ws/api/getVersion
Connecting to 127.0.0.1:5459... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/javascript]
Saving to: `/tmp/getVersion'


    [<=>                                    ] 0           --.-K/s              
    [ <=>                                   ] 102         --.-K/s   in 0.001s  

2020-04-02 11:46:16 (164 KB/s) - `/tmp/getVersion' saved [102]

Apr  2 11:47:01 crond[677]: crond: USER root pid 2465 cmd dch_scheduler mdns_watchdog

Apr  2 11:47:01 crond[677]: crond: USER root pid 2471 cmd dch_scheduler webserver_watchdog

Apr  2 11:47:01 crond[677]: crond: USER root pid 2474 cmd dch_scheduler zw_center_watchdog

Apr  2 11:47:01 crond[677]: crond: USER root pid 2477 cmd dch_scheduler ntp_watchdog

Control Center(219) : Recive a request(420) from 2479
Application Center(262) : Recive a request(420) from 219
killall: you need to specify whom to kill
43921 42422.808  119090.0    208.5   59047.9  20752.0         0
time_str: 20040204114702
Apr  2 11:47:03 crond[2647]: crond: crond (busybox 1.21.1--LSDK-10.2-00082-4) started, log level 8

Control Center(219) : Recive a request(545) from 262
service_event : forward a zwave event to the zwave center(364)!
Control Center(219) : Recive a response(420) from 262
Application Center(262) : Recive a response(545) from 219
Control Center(219) : Recive a response(545) from 364
Apr  2 11:47:03 crond[2724]: crond: crond (busybox 1.21.1--LSDK-10.2-00082-4) started, log level 8

Apr  2 11:48:01 crond[2724]: crond: USER root pid 2401 cmd dch_scheduler mdns_watchdog

Apr  2 11:48:01 crond[2724]: crond: USER root pid 2405 cmd dch_scheduler webserver_watchdog

Apr  2 11:48:01 crond[2724]: crond: USER root pid 2408 cmd dch_scheduler zw_center_watchdog

Apr  2 11:49:01 crond[2724]: crond: USER root pid 2329 cmd dch_scheduler mdns_watchdog

Apr  2 11:49:01 crond[2724]: crond: USER root pid 2334 cmd dch_scheduler webserver_watchdog

Apr  2 11:49:01 crond[2724]: crond: USER root pid 2336 cmd dch_scheduler zw_center_watchdog

Apr  2 11:50:01 crond[2724]: crond: USER root pid 2201 cmd dch_scheduler mdns_watchdog

Apr  2 11:50:01 crond[2724]: crond: USER root pid 2205 cmd dch_scheduler webserver_watchdog

Apr  2 11:50:02 crond[2724]: crond: USER root pid 2208 cmd dch_scheduler zw_center_watchdog

 

starting pid 220, tty '/dev/ttyS0': '/bin/login'
DCH-G020 login: Apr  2 11:51:01 crond[2724]: crond: USER root pid 1856 cmd dch_scheduler mdns_watchdog

Apr  2 11:51:01 crond[2724]: crond: USER root pid 1861 cmd dch_scheduler webserver_watchdog

Apr  2 11:51:01 crond[2724]: crond: USER root pid 1863 cmd dch_scheduler zw_center_watchdog


DCH-G020 login: root
Password: 
Apr  2 11:51:40 login[220]: root login on 'ttyS0'



BusyBox v1.21.1--LSDK-10.2-00082-4 (2016-06-29 05:45:06 EDT) built-in shell (ash)
Enter 'help' for a list of built-in commands.

~ # Apr  2 11:52:01 crond[2724]: crond: USER root pid 1651 cmd dch_scheduler mdns_watchdog

Apr  2 11:52:01 crond[2724]: crond: USER root pid 1655 cmd dch_scheduler webserver_watchdog

Apr  2 11:52:01 crond[2724]: crond: USER root pid 1658 cmd dch_scheduler zw_center_watchdog


~ # exit

process '/bin/login' (pid 220) exited. Scheduling for restart.

Please press Enter to activate this console. 

Okay this is weird, I just checked the OEM image from the dlink ftp, and it seems that 0x22E38A3F (5701695) is actually the file size - 9 bytes. I'm sorry for not better documenting the process of making the factory image, this is really embarrassing...

The machine I used to build the image is located in another apartment, which I will not be visiting within the next couple weeks during the pandemic.

Maybe you could also try uploading an initramfs-image via tftp from uboot.

Which part of the serial console log is when you tried to update? I think I did not actually login to the console when attempting the update, just watched the log, maybe there is some output then, but you have probably tried already.

Sorry I couldn't help :pensive:

Hello,

Finnaly I have successfully uploaded openwrt firmware yesterday. To get correct CRC and upload openwrt firmware you must all do it in recovery mode (via Recovery Web UI). In first time you try to upload an image, then expected crc will be printed in serial console, but it`s also continue printing some same errors, so you must stop it and read it from the first lines (in my case some error text with 1d7e42e7=0!). Then this CRC (1d7e42e7) you need to update values in hex editor in this firmware from address 0x00000004 to 0x00000007. Restart again to recovery and again upload the image via Web UI. After few second in console and in web UI it must show some uploading counter, if not, it's better to wait e.g. 10 minutes and then restart to recovery and try again (second time is my successfull). After successful update, it's auto loaded into openwrt. Upper connector is set as WAN and bottom is LAN, so if you connect cable to LAN, you can now disconnect serial and connect to router by ssh (ssh root@192.168.1.1). And now you can for example install Luci web UI:

  • set correct IP, gateway, dns to get internet and set WAN port to LAN in /etc/config/network. My file is:
config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config interface 'lan'        
        option type 'bridge'
        option proto 'static'             
        option ifname 'eth0 eth1'      
        option ipaddr '192.168.2.150'
        option netmask '255.255.255.0'  
        option gateway '192.168.2.250'
        list dns '8.8.8.8'     
  • restart service by: service network reload
  • update opkg and install Luci: opkg update && opkg install luci
  • enter luci web UI at 192.168.2.150
1 Like

Thanks for your work! :slight_smile: I will try to share my efforts on ath79 as soon as I'm back home (probably within the next couple weeks).
Aside from WMAC address, factory image generation would be the only thing that's not yet solved.

Have you tried to figure out which type of crc (or something else) is used, and would you mind sharing your factory image for the purpose of testing?

// Edit: I've checked out the GPL release by D-Link for this gateway, and it turns out the checksum is actually nothing but the sum over all bytes after the 72 bytes header :slight_smile:
i.e. python -c 'print(hex(sum(bytearray(open("sysupgrade.bin", "r").read()))))' should match the checksum at 0x0004 in the header, now I just wonder whether someone could turn this into bash / sed / awk / ... without having to call python :innocent:

Also the kernel image size should probably be corrected according to /tool/image_header/image_header.c, though it seemed to work without doing that!?

// we must make sure the size of struct image_hdr is as same as the struct image_hdr in public_util.h
#define MAX_HEADER_LEN        	31
#define MAX_FW_LEN		15
#define MAX_REG_LEN		7

typedef struct{		
	unsigned long hdr_len;
	unsigned long check_sum;
	unsigned long total_size;
	unsigned long kernel_size;
	unsigned char header[MAX_HEADER_LEN + 1];
	unsigned char fw_ver[MAX_FW_LEN + 1];
	unsigned char fw_reg[MAX_REG_LEN + 1];	
}image_hdr;

Thank you too for the really great work on this and I am very happy about your progress. I would not mind sharing my image, here is it: download link on uloz.to. By your investigation on CRC generating, so the CRC can be generated only once by firmware image? Also I can try to find bash/sed/awk alternative, but right know, I don't have much time, because of my newbord boy, we will see :). So I wish you good luck and have fun to your efforts on this.

Meanwhile, I have found that the factory image format is actually consistent with DAP-1330 from the ar71xx target, building the images works automatically now.

@Seirix Feel free to test this before I rebase to master and consider making a PR :grinning:

http://sebastianschaper.net/openwrt/openwrt-ath79-generic-dlink_dch-g020-a1-squashfs-factory.bin
http://sebastianschaper.net/openwrt/openwrt-ath79-generic-dlink_dch-g020-a1-squashfs-sysupgrade.bin

Known issues:

  • This is still based on 19.07.2, a few things might (hopefully?) become easier upon rebasing to master

  • MAC addresses are in 17 bytes ASCII format, there is currently no dts binding for this. The current workaround is to use ifconfig in /board.d/02_network (I thought the wifi stuff should belong in /hotplug.d/10-ath9k-eeprom, but that script is not even called)

  • real-time clock: currently no driver available
    can we just keep it in the dts anyways, e.g. compatible = "pericom,pt7c43390"; just in case a driver will someday be available?

  • z-wave is working (run MinOZW as proof-of-concept), though I haven't figured out how feasible it would be to use extroot for having enough free space to install domoticz

  • I wonder if we can safely overwrite mydlink and data partitions for a little more free space?
    Maybe we could check which OEM partitions the emergency bootloader actually overwrites

  • is there / will there be a dts binding for the switch ports?
    So we can leave that out of board.d/02_network

1 Like

Awesome work! Would it be possible to install it on A2 version of this unit? I've tried the firmware provided and I get a "header" error.

Hi, I just checked the file again, and indeed it seemed to be an old version that I uploaded long before opening the pull request... The header generation was not yet working correctly at that time, I just built new images based on current master and updated the download files. Sorry, should have checked that earlier, thanks for letting me know :slightly_smiling_face:

The image should work for all A revisions of the device now. LuCI is included.

For using Z-Wave you'd have to set up extroot with a USB drive, as the Domoticz and openzwave packages are too big for the 16M flash of this device.

Are these the updates files? Tried to flash them now and no luck, still a header error.

That is very interesting, I have just flashed the factory.img again to Rev. A1 from the stock firmware (after login in with the 6-digit Pin Code from the label) and it worked.
In case you flashed using the bootloader recovery, it does not work with modern browsers, only IE etc., but then it shouldn't give a header error.

I have only seen the A1 revision in germany, and on the German D-Link FTP there is only "reva" firmware, which should usually work for all A revisions. Do you have any link to an official D-Link Firmware for A2, that you could successfully flash to your device? So I might have a look at the image format, and see if they changed anything :slightly_smiling_face:

// Edit: Checked on the D-Link EU ftp, there are versions A and A2 available, but the file in the reva archive is actually the same as on the German ftp, which is named "DCHG020A2..." so they are only offering A2 for all A revisions.

Could you check again that the file you downloaded contains the string HONEYBEE-FIRMWARE at the very beginning of the file? (not WZR-HP-G450H), just to make sure the download was not cached etc.

// Edit2: just realized my device booted into recovery instead of OpenWRT after flashing, will check that again.

Thanks for the swift reply! I've downloaded the file again and it looks like it's cached, this is what I see with my hex viewer:


Also I can't really set it in the recovery mode (hold RESET button while inserting the power jack). It seems it gets stuck with just the red led on, I can't ping it via the network cable. Any ideas? Also I've flashed this firmware
ftp://ftp.dlink.de/dch/dch-g020/driver_software/DCH-G020_fw_reva_125b10_ALL_en_20160805.zip
It seems to be working (I get a countdown page with a reboot of this unit)

This is indeed the old version, I checked the file on the server again, it is definitely updated, please donwload again, maybe using a different browser etc.

However I just wondered why my first attempt of flashing through the regular Web UI resulted in the device booting to recovery, but flashing to OpenWRT from recovery the second time worked flawlessly (with IE11, since new browsers don't support the recovery file upload correctly anymore). I guess I'll also check with my device initially used for development again.

Success! I'll try adding my door sensor and alarm and see if it works :slight_smile: