Skip to content

Commit b2f814f

Browse files
rbqvqhauke
authored andcommitted
ramips: add support for Qding QC202
This is a smart door lock device equipped with OpenWrt 14.07 OEM modified version Qdwrt The OEM has closed down, This commit is intended to maximize the remaining value of these devices. It can flash OpenWrt to become an AP Specification: - SoC: MediaTek MT7628NN - Flash: 8 MB - RAM: 64 MB - Power: DC 5V - 25V - Ethernet: 1 x RJ45 (10/100 Mbps) - Wireless radio: 802.11n 2.4g-only - On-Board LED: Status 1: GPIO/43 active-low Status 2: GPIO/44 active-low Power: AlwaysOn - Button: WPS / RESET: GPIO/14 active-low - Bluetooth: CC2541 via UART1 (ttyS1) and GPIO/26-29 - RFID: MF RC522 on I2C@28 - RTC: DS1339 on I2C@68 - Shell (via CON1 cable) - LED (Swipe card area): - Green GPIO/3 active-high - Red GPIO/11 active-high - Matrix keypad: (active-low) GPIO/20 GPIO/21 GPIO/19 (Rows) GPIO/24 1 2 3 GPIO/25 4 5 6 GPIO/22 7 8 9 GPIO/23 BACK 0 ENTER (Cols) - UART: 1 x UART on PCB - 57600 8N1 - GPIO Relay: GPIO/42 active-high - GPIO Buzzer: GPIO/15 active-high Warning: The original firmware does not use the device tree. This device tree is written based on the content of /sys/devices/platform and has been tested Note: - On the device, matrix keypad rows actually are columns, and the columns actually are rows - The key code of the CLEAR key of the matrix keypad is BACK in the original firmware. Issue: - No drivers in mainline kernel for RFID and Bluetooth. Flash Instruction: Using SSH/Telnet: 1. Connect the board to the computer via RJ45 Ethernet 2. Login 10.10.10.1 with root password "szqdingnet123" (SSH Port 22, Telnet Port 9900) 3. Download openwrt firmware on the computer. 4. Setup a http server on computer. And use wget download openwrt firmware from computer 5. Use command "mtd -r write openwrt-ramips-mt76x8-qding_qc202-squashfs-sysupgrade.bin firmware" to flash Using U-Boot WebUI: 1. Configure PC with a static IP address 10.10.10.2/24. 2. Open http://10.10.10.1 3. Use "mkqdimg -B qc202 -f openwrt-ramips-mt76x8-qding_qc202-squashfs-sysupgrade.bin" to make image. 4. Upload factory.bin via U-Boot WebUI. Original Firmware Dump / More details: https://blog.gov.cooking/archives/research-qianding-smart-locker-and-flash.html Original U-Boot firmware image tools: https://gitlab.com/CoiaPrant/mkqdimg Signed-off-by: Coia Prant <coiaprant@gmail.com> Tested-by: Coia Prant <coiaprant@gmail.com> Link: openwrt/openwrt#17471 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
1 parent f38abc0 commit b2f814f

File tree

4 files changed

+252
-0
lines changed

4 files changed

+252
-0
lines changed

package/boot/uboot-tools/uboot-envtools/files/ramips

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ engenius,esr600h|\
2222
hongdian,h8922-v30|\
2323
linksys,re7000|\
2424
meig,slt866|\
25+
qding,qc202|\
2526
sitecom,wlr-4100-v1-002|\
2627
zyxel,keenetic-lite-iii-a)
2728
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x1000"
Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
2+
3+
#include "mt7628an.dtsi"
4+
5+
#include <dt-bindings/gpio/gpio.h>
6+
#include <dt-bindings/input/input.h>
7+
#include <dt-bindings/leds/common.h>
8+
9+
/ {
10+
compatible = "qding,qc202", "mediatek,mt7628an-soc";
11+
model = "Qding QC202";
12+
13+
aliases {
14+
led-boot = &led_status_1;
15+
led-failsafe = &led_status_1;
16+
led-running = &led_status_1;
17+
led-upgrade = &led_status_1;
18+
label-mac-device = &wmac;
19+
};
20+
21+
leds {
22+
compatible = "gpio-leds";
23+
24+
led-indicator-green {
25+
gpios = <&gpio 3 GPIO_ACTIVE_HIGH>;
26+
color = <LED_COLOR_ID_GREEN>;
27+
function = LED_FUNCTION_INDICATOR;
28+
};
29+
30+
led-indicator-red {
31+
gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
32+
color = <LED_COLOR_ID_RED>;
33+
function = LED_FUNCTION_INDICATOR;
34+
};
35+
36+
led_status_1: led-status-1 {
37+
gpios = <&gpio 43 GPIO_ACTIVE_LOW>;
38+
color = <LED_COLOR_ID_WHITE>;
39+
function-enumerator = <1>;
40+
function = LED_FUNCTION_STATUS;
41+
};
42+
43+
led-status-2 {
44+
gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
45+
color = <LED_COLOR_ID_WHITE>;
46+
function-enumerator = <2>;
47+
function = LED_FUNCTION_STATUS;
48+
};
49+
};
50+
51+
keys {
52+
compatible = "gpio-keys";
53+
54+
reset {
55+
label = "reset";
56+
gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
57+
linux,code = <KEY_RESTART>;
58+
};
59+
};
60+
61+
beeper {
62+
compatible = "gpio-beeper";
63+
gpios = <&gpio 15 GPIO_ACTIVE_HIGH>;
64+
};
65+
66+
gpio-export {
67+
compatible = "gpio-export";
68+
69+
// When device is disassembled, GPIO will be activated
70+
disassemble {
71+
gpio-export,name = "disassemble";
72+
gpios = <&gpio 2 GPIO_ACTIVE_HIGH>;
73+
};
74+
75+
cc2541-boot {
76+
gpio-export,name = "cc2541-boot";
77+
gpio-export,output = <0>;
78+
gpios = <&gpio 26 GPIO_ACTIVE_LOW>;
79+
};
80+
81+
cc2541-reset {
82+
gpio-export,name = "cc2541-reset";
83+
gpio-export,output = <0>;
84+
gpios = <&gpio 27 GPIO_ACTIVE_HIGH>;
85+
};
86+
87+
cc2541-clk {
88+
gpio-export,name = "cc2541-clk";
89+
gpio-export,output = <0>;
90+
gpios = <&gpio 28 GPIO_ACTIVE_HIGH>;
91+
};
92+
93+
cc2541-data {
94+
gpio-export,name = "cc2541-data";
95+
gpio-export,direction_may_change;
96+
gpios = <&gpio 29 GPIO_ACTIVE_HIGH>;
97+
};
98+
99+
/*
100+
When "OPEN THE DOOR" button is pressed
101+
GPIO will be activated via the KEY signal cable
102+
*/
103+
key {
104+
gpio-export,name = "key";
105+
gpios = <&gpio 37 GPIO_ACTIVE_HIGH>;
106+
};
107+
108+
// Activate GPIO to control the relay to open the door
109+
relay {
110+
gpio-export,name = "relay";
111+
gpio-export,output = <0>;
112+
gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
113+
};
114+
};
115+
116+
matrix-keypad {
117+
compatible = "gpio-matrix-keypad";
118+
debounce-delay-ms = <10>;
119+
col-scan-delay-us = <10>;
120+
gpio-activelow;
121+
wakeup-source;
122+
123+
row-gpios = <&gpio 20 GPIO_ACTIVE_LOW
124+
&gpio 21 GPIO_ACTIVE_LOW
125+
&gpio 19 GPIO_ACTIVE_LOW>;
126+
127+
col-gpios = <&gpio 24 GPIO_ACTIVE_LOW
128+
&gpio 25 GPIO_ACTIVE_LOW
129+
&gpio 22 GPIO_ACTIVE_LOW
130+
&gpio 23 GPIO_ACTIVE_LOW>;
131+
132+
linux,keymap = <MATRIX_KEY(0, 0, KEY_1)
133+
MATRIX_KEY(1, 0, KEY_2)
134+
MATRIX_KEY(2, 0, KEY_3)
135+
MATRIX_KEY(0, 1, KEY_4)
136+
MATRIX_KEY(1, 1, KEY_5)
137+
MATRIX_KEY(2, 1, KEY_6)
138+
MATRIX_KEY(0, 2, KEY_7)
139+
MATRIX_KEY(1, 2, KEY_8)
140+
MATRIX_KEY(2, 2, KEY_9)
141+
MATRIX_KEY(0, 3, KEY_BACK)
142+
MATRIX_KEY(1, 3, KEY_0)
143+
MATRIX_KEY(2, 3, KEY_ENTER)>;
144+
};
145+
};
146+
147+
&state_default {
148+
gpio {
149+
groups = "i2s", "gpio", "spis", "pwm1", "uart2", "sdmode", "refclk", "p1led_an", "p0led_an", "wled_an";
150+
function = "gpio";
151+
};
152+
};
153+
154+
&spi0 {
155+
status = "okay";
156+
157+
flash@0 {
158+
compatible = "jedec,spi-nor";
159+
reg = <0>;
160+
spi-max-frequency = <40000000>;
161+
162+
partitions {
163+
compatible = "fixed-partitions";
164+
#address-cells = <1>;
165+
#size-cells = <1>;
166+
167+
partition@0 {
168+
label = "u-boot";
169+
reg = <0x0 0x30000>;
170+
read-only;
171+
};
172+
173+
partition@30000 {
174+
label = "u-boot-env";
175+
reg = <0x30000 0x10000>;
176+
read-only;
177+
};
178+
179+
partition@40000 {
180+
label = "factory";
181+
reg = <0x40000 0x10000>;
182+
read-only;
183+
184+
nvmem-layout {
185+
compatible = "fixed-layout";
186+
#address-cells = <1>;
187+
#size-cells = <1>;
188+
189+
eeprom_factory_0: eeprom@0 {
190+
reg = <0x0 0x400>;
191+
};
192+
193+
macaddr_factory_4: macaddr@4 {
194+
compatible = "mac-base";
195+
reg = <0x4 0x6>;
196+
};
197+
};
198+
};
199+
200+
partition@50000 {
201+
compatible = "denx,uimage";
202+
label = "firmware";
203+
reg = <0x50000 0x7b0000>;
204+
};
205+
};
206+
};
207+
};
208+
209+
&ethernet {
210+
nvmem-cells = <&macaddr_factory_4 (-1)>;
211+
nvmem-cell-names = "mac-address";
212+
};
213+
214+
&esw {
215+
mediatek,portmap = <0x3f>;
216+
mediatek,portdisable = <0x3e>;
217+
};
218+
219+
&wmac {
220+
status = "okay";
221+
222+
nvmem-cells = <&eeprom_factory_0>;
223+
nvmem-cell-names = "eeprom";
224+
};
225+
226+
&i2c {
227+
status = "okay";
228+
229+
rfid@28 {
230+
compatible = "mfrc522";
231+
reg = <0x28>;
232+
};
233+
234+
rtc@68 {
235+
compatible = "dallas,ds1339";
236+
reg = <0x68>;
237+
};
238+
};
239+
240+
&uart1 {
241+
status = "okay";
242+
};

target/linux/ramips/image/mt76x8.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,14 @@ define Device/oraybox_x1
642642
endef
643643
TARGET_DEVICES += oraybox_x1
644644

645+
define Device/qding_qc202
646+
IMAGE_SIZE := 7872k
647+
DEVICE_VENDOR := Qding
648+
DEVICE_MODEL := QC202
649+
DEVICE_PACKAGES := kmod-i2c-mt7628 kmod-gpio-beeper kmod-input-matrix-keypad kmod-input-evdev uboot-envtools
650+
endef
651+
TARGET_DEVICES += qding_qc202
652+
645653
define Device/rakwireless_rak633
646654
IMAGE_SIZE := 7872k
647655
DEVICE_VENDOR := Rakwireless

target/linux/ramips/mt76x8/base-files/etc/board.d/02_network

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ramips_setup_interfaces()
2222
minew,g1-c|\
2323
onion,omega2p|\
2424
onion,omega2|\
25+
qding,qc202|\
2526
ravpower,rp-wd009|\
2627
tama,w06|\
2728
tplink,re200-v2|\

0 commit comments

Comments
 (0)