Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ramips: add support for Creality WB-01 #3802

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 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,126 @@
// 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;
label-mac-device = &wmac;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works in combination with mtd-mac-address. You will need to set the label MAC address in the lower section of 02_network; the correct lines are already there for vocore,vocore2 ...

};

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";
mediatek,mtd-eeprom = <&factory 0x0>;
};

&ethernet {
nvmem-cells = <&macaddr_factory_28>;
nvmem-cell-names = "mac-address";
};

&factory {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;

macaddr_factory_28: macaddr@28 {
reg = <0x28 0x6>;
};
};

&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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this up so Build/* recipes are sorting alphabetically.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether this can be written at once with some <-EOF syntax ...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so? It seems as though you have to use .ONESHELL: to do heredoc syntax in make but that caused errors like /usr/bin/env bash: No such file or directory for me when I tried, and it might also cause problems somewhere else because of how that directive works. There might be a better way but I can't think of one.


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 @@ -133,6 +153,16 @@ define Device/comfast_cf-wr758ac-v2
endef
TARGET_DEVICES += comfast_cf-wr758ac-v2

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 @@ -19,6 +19,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_netdev "lan" "lan" "blue:lan" "eth0"
;;
cudy,wr1000)
ucidef_set_led_switch "wan" "wan" "blue:wan" "switch0" "0x10"
ucidef_set_led_switch "lan1" "lan1" "blue:lan1" "switch0" "0x08"
Expand Down
16 changes: 9 additions & 7 deletions target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ramips_setup_interfaces()

case $board in
alfa-network,awusfree1|\
creality,wb-01|\
d-team,pbr-d1|\
dlink,dap-1325-a1|\
glinet,microuter-n300|\
Expand Down Expand Up @@ -191,6 +192,14 @@ ramips_setup_macs()
lan_mac=$wan_mac
label_mac=$wan_mac
;;
creality,wb-01|\
onion,omega2|\
onion,omega2p|\
vocore,vocore2|\
vocore,vocore2-lite|\
wavlink,wl-wn576a2)
label_mac=$(mtd_get_mac_binary factory 0x4)
;;
cudy,wr1000|\
hilink,hlk-7628n|\
hilink,hlk-7688a|\
Expand Down Expand Up @@ -236,13 +245,6 @@ ramips_setup_macs()
label_mac=$(mtd_get_mac_binary factory 0x4)
wan_mac=$(macaddr_add "$label_mac" 2)
;;
onion,omega2|\
onion,omega2p|\
vocore,vocore2|\
vocore,vocore2-lite|\
wavlink,wl-wn576a2)
label_mac=$(mtd_get_mac_binary factory 0x4)
;;
rakwireless,rak633|\
unielec,u7628-01-16m|\
wavlink,wl-wn575a3)
Expand Down