Sunday, August 14, 2016

Converting Serial-WiFi Routers to OpenWRT

While experimenting with connecting control system's serial interfaces to wireless routers, I came across KEYNICE HLK-WR02 Wireless Serial-Interface Router. The interface/coding was atrocious, unsupported, and in Mandarin. It's documentation was also outdated as it pointed to the original manufacturer (Fulling Way Technologies); however, software and firmware links ceased to be available. In effort to retain some functionality, I decided to open the device in hopes of finding standardized hardware. Fortunately, I found a Hi-Link UART WiFi module sitting on top of a $4 HLK-RM04 test board (kit-V2.2). The latter having an available and somewhat, recent OpenWRT image.

Although flashing OpenWRT on a device is fairly trivial, I did see some inconsistencies with the site's instructions. As a result, the below steps will walk you through the process I followed for flashing the HLK-RM04 test board (kit-V2.2) with a minimal OpenWRT image.

1. Download the OpenWRT's RT305X-HLK-RM04 Generic Factory image: https://github.com/bogdanr/HLK-RM04/raw/master/images/rt305x-hlk-rm04-generic-factory.bin

2. Navigate to the HLK-RM04's Administration > Upload Firmware tab and 'Browse' to the above image. Press 'Upload'.

3. The file will upload and the device will reboot. Set a continuous ping to its default IPv4 address (192.168.16.254).

4. Once the above IP address is no longer reachable, set a continuous ping to OpenWRT's default IPv4 address (192.168.1.1). Note that this will require a reconfiguration of the workstation's IP address and default gateway.

5. Connect your workstation to the HLK-RM04 device using a RS-232 cable and a USB-to-Serial adapter (e.g., Keyspan Tripp-Lite). Unlike connecting to a Cisco networking device, you will need to change your serial settings to reflect the below:
  - Speed (baud): 57600
  - Data bits: 8
  - Stop bits: 1
  - Parity: None
  - Flow Control: XON/XOFF

6. At the root prompt, change your default password: root@OpenWrt:/# passwd

7. Now you are able to SSH into the device over Ethernet using PuTTY. SSH to 192.168.1.1 and authenticate as the 'root' using the newly created password.

I will update this post after I have had sufficient time with testing this OpenWRT image in hopes of addressing resource limitations and package functionality on this platform. Note: The above test board's Hi-Link WiFi module also compatible with Arduino, so more fun can be had by all!

References
https://github.com/JiapengLi/OpenWrt-HiLink-HLK-RM04
https://wiki.openwrt.org/toh/hilink/hlk-rm04
http://www.hlktech.net/product_detail.php?ProId=39
http://www.hlktech.com/Article/Read/135.aspx
http://www.hlktech.com/upfile/2016/07/10/20160710161758_575.pdf
http://www.instructables.com/id/Arduino-WiFi-Temperature-Meter-with-web-page/?ALLSTEPS