Skip to content

Commit

Permalink
ramips: add support for Creality WB-01
Browse files Browse the repository at this point in the history
The Creality WB-01 (unhelpfully referred to interchangably as the
"Creality Wifi Box" or simply the "Creality Box") is a device intended
to interface Creality brand 3D printers to a cloud service.

Specifications:

- SoC: MediaTek MT7688AN @ 580 MHz
- Flash: BoyaMicro BY25Q128AS (16 MiB, SPI NOR)
  This flash is not supported currently so I wrote a patch for it,
  see "kernel: add support for Boya BY25Q128AS SPI flash"
- RAM: 128 MiB DDR2 (Winbond W971GG6SB-25)
- Peripheral: Genesys Logic GL850G 2 port USB 2.0 hub
- I/O: 1x 10/100 Ethernet port, microSD SD-XC Class 10 slot, 4x LEDs,
  2x USB 2.0 ports, micro USB input (for power only), reset button
- FCC ID: 2AXH6CREALITY-BOX
- UART: test pads: (square on silkscreen) 3V3, TX, RX, GND

LEDs:
40 red    - microSD presence (OpenWrt has no function for this I think)
42 green  - "Cloud service or network configuration indicator"
43 blue   - Ethernet
44 yellow - Wi-Fi

Reset button = 38
SD presence switch = 23

MAC addresses:
factory+0x04 wlan and label MAC
factory+0x28 eth0
factory+0x2e has fc:ee:e6:xx:xx:xx here, but it appears to be unused

Stock firmware /proc/mtd
dev:    size   erasesize  name
mtd0: 01000000 00010000 "ALL"
mtd1: 00030000 00010000 "Bootloader"
mtd2: 00010000 00010000 "Config"
mtd3: 00010000 00010000 "Factory"
mtd4: 000d0000 00010000 "Kernel"
mtd5: 00ee0000 00010000 "RootFS"

Flashing:
1) Rename factory.bin to cxsw_update.tar.bz2
2) Copy it to the root of a FAT32 formatted microSD card.
3) Turn on the device, wait for it to start, then insert the card.
The stock firmware reads the install.sh script from this archive, the
build script I added creates one that works in a similar way.
Web firmware update didn't work in my testing.

You can use telnet on stock to flash without SD among other things
root@10.10.10.254, the default password is cxswprin
There is also a U-Boot accessible via the UART if you wish to use TFTP
through that, though the configuration doesn't seem usable and testing
seems like it doesn't work properly.

Stock firmware files can be downloaded from links in this JSON file:
https://file2-cdn.creality.com/model/cfg/android_setting.cg

Signed-off-by: George Brooke <figgyc@figgyc.uk>
  • Loading branch information
figgyc committed Mar 5, 2021
1 parent cd0e833 commit 19e0a05
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 4 deletions.
114 changes: 114 additions & 0 deletions target/linux/ramips/dts/mt7628an_creality_wb-01.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

#include "mt7628an.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/ {
compatible = "creality,wb-01", "mediatek,mt7628an-soc";
model = "Creality WB-01";

aliases {
led-boot = &led_status;
led-failsafe = &led_status;
led-upgrade = &led_status;
led-running = &led_status;
};

keys {
compatible = "gpio-keys";

reset {
label = "reset";
gpios = <&gpio 38 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
};

};

leds {
compatible = "gpio-leds";

lan {
label = "blue:lan";
gpios = <&gpio 43 GPIO_ACTIVE_LOW>;
};

wlan2g {
label = "yellow:wlan2g";
gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
linux,default-trigger = "phy0tpt";
};

led_status: status {
label = "green:status";
gpios = <&gpio 42 GPIO_ACTIVE_LOW>;
};

sd {
label = "red:sd";
gpios = <&gpio 40 GPIO_ACTIVE_LOW>;
};
};
};

&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;
};

factory: partition@40000 {
label = "factory";
reg = <0x40000 0x10000>;
read-only;
};

partition@50000 {
compatible = "denx,uimage";
label = "firmware";
reg = <0x50000 0xfb0000>;
};
};
};
};

&state_default {
gpio {
groups = "wdt", "p3led_an", "p1led_an", "p0led_an", "wled_an";
function = "gpio";
};
};

&wmac {
status = "okay";
};

&ethernet {
mtd-mac-address = <&factory 0x28>;
};

&sdhci {
status = "okay";
mediatek,cd-low;
};
30 changes: 30 additions & 0 deletions target/linux/ramips/image/mt76x8.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ include ./common-tp-link.mk

DEFAULT_SOC := mt7628an

define Build/creality_wb-01-factory
echo '#!/bin/sh' > $@.install.sh
echo 'kernel_size=851968' >> $@.install.sh
echo 'file=$$2/factory.bin' >> $@.install.sh
echo 'file_size=$$(wc -c < $$file)' >> $@.install.sh
echo 'fs_size=$$((file_size - kernel_size))' >> $@.install.sh
echo 'mtd_write -o 0 -l $$kernel_size write $$file Kernel' \
>> $@.install.sh
echo 'mtd_write -r -o $$kernel_size -l $$fs_size write $$file RootFS' \
>> $@.install.sh

tar cjf $@.tar.bz2 -C $(dir $@) \
--transform="flags=r;s|$(notdir $@.install.sh)|install.sh|" \
--transform="flags=r;s|$(notdir $@)|factory.bin|" \
$(notdir $@ $@.install.sh) \

mv $@.tar.bz2 $@
rm $@.install.sh
endef

define Build/elecom-header
$(eval model_id=$(1))
( \
Expand Down Expand Up @@ -78,6 +98,16 @@ define Device/buffalo_wcr-1166ds
endef
TARGET_DEVICES += buffalo_wcr-1166ds

define Device/creality_wb-01
IMAGE_SIZE := 16064k
IMAGES += factory.bin
IMAGE/factory.bin := $$(sysupgrade_bin) | creality_wb-01-factory
DEVICE_VENDOR := Creality
DEVICE_MODEL := WB-01
DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-sdhci-mt7620
endef
TARGET_DEVICES += creality_wb-01

define Device/cudy_wr1000
IMAGE_SIZE := 7872k
IMAGES += factory.bin
Expand Down
3 changes: 3 additions & 0 deletions target/linux/ramips/mt76x8/base-files/etc/board.d/01_leds
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ netgear,r6120)
ucidef_set_led_switch "lan" "lan" "green:lan" "switch0" "0xf"
ucidef_set_led_switch "wan" "wan" "green:wan" "switch0" "0x10"
;;
creality,wb-01)
ucidef_set_led_switch "lan" "lan" "blue:lan" "switch0" "0x04"
;;
cudy,wr1000)
ucidef_set_led_switch "wan" "wan" "blue:wan" "switch0" "0x10"
ucidef_set_led_switch "lan1" "lan1" "blue:lan1" "switch0" "0x08"
Expand Down
10 changes: 6 additions & 4 deletions target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ramips_setup_interfaces()

case $board in
alfa-network,awusfree1|\
creality,wb-01|\
d-team,pbr-d1|\
glinet,microuter-n300|\
glinet,vixmini|\
Expand Down Expand Up @@ -167,6 +168,11 @@ ramips_setup_macs()
wan_mac="$(grep -m1 mac= "/dev/mtd${index}" | cut -d= -f2)"
lan_mac=$wan_mac
;;
creality,wb-01|\
vocore,vocore2|\
vocore,vocore2-lite)
label_mac=$(mtd_get_mac_binary factory 0x4)
;;
cudy,wr1000|\
hilink,hlk-7688a|\
wavlink,wl-wn577a2)
Expand Down Expand Up @@ -233,10 +239,6 @@ ramips_setup_macs()
tplink,archer-c50-v4)
wan_mac=$(macaddr_add "$(mtd_get_mac_binary rom 0xf100)" 1)
;;
vocore,vocore2|\
vocore,vocore2-lite)
label_mac=$(mtd_get_mac_binary factory 0x4)
;;
wavlink,wl-wn570ha1|\
zbtlink,zbt-we1226)
wan_mac=$(macaddr_add "$(mtd_get_mac_binary factory 0x2e)" 1)
Expand Down

0 comments on commit 19e0a05

Please sign in to comment.