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

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

WARNING: If flash device with breed-mt7688-reset38.bin, please reflash
original bootloader after flash ROM. Breed will cause RTC 2082-year
problem, and wrong GPIOs.

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:
  Ethernet: GPIO 43/555 active-low
  Wifi: GPIO 44/556 active-low
  Power: AlwaysOn
- Button:
  WPS / RESET: GPIO 14/526  active-low
- Bluetooth: CC2541
- RFID: MF RC522 on I2C@28
- RTC: DS1339 on I2C@68
- Matrix keypad
  LED: Green GPIO 3/515 active-high, Red GPIO 11/523 active-high, Yellow = Green + Red
- UART: 1 x UART on PCB - 57600 8N1
- GPIO Relay: GPIO 42/554 active-high
- GPIO Buzzer: GPIO 15/527 active-high

Issue:
- No drivers in mainline kernel for RFID.
- Bluetooth not working. The bus is not known yet,
 and no driver in mainline kernel.
- Matrix keypad not working.

Flash with Breed (Verified):
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)
   Backup bootloader (mtdblock1) and download to computer.
   It is best to backup the full original firmware.
3. Download breed-mt7688-reset38.bin and BreedEnter.zip from https://breed.hackpascal.net/
4. Setup a http server on computer. And use wget download breed from computer
5. Use command "mtd write breed-mt7688-reset38.bin Bootloader" to flash breed
6. Open the Breed Enter and restart board.
7. Flash ROM and original uboot via Breed Web UI.
   It is best to backup the full flash and eeprom in Breed Web UI.

Original Firmware Dump / More details:
https://blog.gov.cooking/archives/research-qianding-smart-locker-and-flash.html

Signed-off-by: Coia Prant <coiaprant@gmail.com>
Tested-by: Coia Prant <coiaprant@gmail.com>
This commit is contained in:
Coia Prant 2024-12-10 23:18:13 +08:00
parent 1b6f7ec679
commit da04b2b261
4 changed files with 175 additions and 1 deletions

View File

@ -0,0 +1,165 @@
#include "mt7628an.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>
/ {
compatible = "qding,qc202", "mediatek,mt7628an-soc";
model = "Qding QC202";
leds {
compatible = "gpio-leds";
status_1 {
label = "status_1";
gpios = <&gpio 43 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_WHITE>;
function-enumerator = <1>;
function = LED_FUNCTION_STATUS;
};
status_2 {
label = "status_2";
gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_WHITE>;
function-enumerator = <2>;
function = LED_FUNCTION_STATUS;
};
red_matrix_keypad {
label = "red:matrix_keypad";
gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
color = <LED_COLOR_ID_RED>;
function = LED_FUNCTION_STATUS;
};
green_matrix_keypad {
label = "green:matrix_keypad";
gpios = <&gpio 3 GPIO_ACTIVE_HIGH>;
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_STATUS;
};
};
keys {
compatible = "gpio-keys";
reset {
label = "reset";
gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};
};
gpio_export {
compatible = "gpio-export";
buzzer {
gpio-export,name = "buzzer";
gpio-export,output = <0>;
gpios = <&gpio 15 GPIO_ACTIVE_HIGH>;
};
relay {
gpio-export,name = "relay";
gpio-export,output = <0>;
gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
};
};
};
&state_default {
gpio {
groups = "gpio";
function = "gpio";
};
};
&spi0 {
status = "okay";
flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <40000000>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "u-boot";
reg = <0x0 0x30000>;
read-only;
};
partition@30000 {
label = "u-boot-env";
reg = <0x30000 0x10000>;
read-only;
};
partition@40000 {
label = "factory";
reg = <0x40000 0x10000>;
read-only;
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
eeprom_factory_0: eeprom@0 {
reg = <0x0 0x400>;
};
macaddr_factory_4: macaddr@4 {
reg = <0x4 0x6>;
};
};
};
partition@50000 {
compatible = "denx,uimage";
label = "firmware";
reg = <0x50000 0x7b0000>;
};
};
};
spidev@1{
#address-cells = <1>;
#size-cells = <1>;
compatible = "linux,spidev";
reg = <1>;
spi-max-frequency = <40000000>;
};
};
&ethernet {
nvmem-cells = <&macaddr_factory_4>;
nvmem-cell-names = "mac-address";
};
&wmac {
status = "okay";
nvmem-cells = <&eeprom_factory_0>;
nvmem-cell-names = "eeprom";
};
&i2c {
status = "okay";
rfid@28 {
compatible = "mfrc522";
reg = <0x28>;
};
rtc@68 {
compatible = "dallas,ds1339";
reg = <0x68>;
};
};

View File

@ -522,6 +522,14 @@ define Device/oraybox_x1
endef
TARGET_DEVICES += oraybox_x1
define Device/qding_qc202
IMAGE_SIZE := 7872k
DEVICE_VENDOR := Qding
DEVICE_MODEL := QC202
DEVICE_PACKAGES := kmod-rtc-ds1307 kmod-i2c-mt7628 kmod-spi-dev
endef
TARGET_DEVICES += qding_qc202
define Device/rakwireless_rak633
IMAGE_SIZE := 7872k
DEVICE_VENDOR := Rakwireless

View File

@ -21,6 +21,7 @@ ramips_setup_interfaces()
minew,g1-c|\
onion,omega2p|\
onion,omega2|\
qding,qc202|\
ravpower,rp-wd009|\
tama,w06|\
tplink,re200-v2|\

View File

@ -4,7 +4,7 @@
SUBTARGET:=mt76x8
BOARDNAME:=MT76x8 based boards
FEATURES+=usb ramdisk small_flash
FEATURES+=usb ramdisk rtc small_flash
CPU_TYPE:=24kc
DEFAULT_PACKAGES += kmod-mt7603 wpad-basic-mbedtls swconfig