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 Beeline SmartBox TURBO+ #8161

Merged
merged 4 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
ramips: Add support for Beeline SmartBox TURBO+
This PR adds support for router Beeline Smart Box TURBO+.
OEM/ODM Serсomm. Almost identical to Serсomm S3.

Specification
-------------
SoC Type: MediaTek MT7621AT (880 MHz, 2 cores)
RAM (Nanya NT5CC64M16GP): 128 MiB
Flash (Macronix MX30LF1G18AC): 128 MiB
Wireless 2.4 GHz (MT7603EN): b/g/n, 2x2
Wireless 5 GHz (MT7615N): a/n/ac, 4x4
Ethernet: 5 ports - 5×GbE (WAN, LAN1-4)
USB ports: 1xUSB3.0
Buttons: 2 button (reset, wps)
LEDs: Red, Green, Blue
Zigbee (EFR32MG1B232GG): 3.0
Stock bootloader: U-Boot 1.1.3
Power: 12 VDC, 1.5 A

Installation
------------
Attach serial console, then boot the initramfs image via TFTP.
Once inside OpenWrt, run sysupgrade -n with the sysupgrade file.

Signed-off-by: Maximilian Weinmann <x1@disroot.org>
(cherry picked from commit d1f294521bd8bc462c76e09c57a5c8b0600170cd)
(factory recipe from a2cfe339995467308c9126c3d0f70d2a28aeb073)
(big NAND from e6e5837a625ba09e286a5bde05f2ce581cfbeab7)
(removed nvmem cells, fixed conflicts)
Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com>
  • Loading branch information
MaxS0niX authored and csharper2005 committed Oct 30, 2021
commit 5662f9c832dda17c7d63e6303611b731c9645e93
4 changes: 4 additions & 0 deletions package/boot/uboot-envtools/files/ramips
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ ampedwireless,ally-00x19k|\
ampedwireless,ally-r1900k)
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x20000" "4"
;;
beeline,smartbox-giga|\
beeline,smartbox-turbo-plus)
ubootenv_add_uci_config "/dev/mtd0" "0x80000" "0x1000" "0x20000"
;;
buffalo,wsr-1166dhp|\
buffalo,wsr-600dhp|\
mediatek,linkit-smart-7688|\
Expand Down
218 changes: 218 additions & 0 deletions target/linux/ramips/dts/mt7621_beeline_smartbox-turbo-plus.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

#include "mt7621.dtsi"

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

/ {
compatible = "beeline,smartbox-turbo-plus", "mediatek,mt7621-soc";
model = "Beeline SmartBox TURBO+";

aliases {
led-boot = &led_status_blue;
led-failsafe = &led_status_red;
led-running = &led_status_green;
led-upgrade = &led_status_red;
label-mac-device = &gmac0;
};

leds {
compatible = "gpio-leds";

led_status_blue: status_blue {
label = "blue:status";
gpios = <&gpio 13 GPIO_ACTIVE_HIGH>;
};

led_status_green: status_green {
label = "green:status";
gpios = <&gpio 15 GPIO_ACTIVE_HIGH>;
};

led_status_red: status_red {
label = "red:status";
gpios = <&gpio 16 GPIO_ACTIVE_HIGH>;
};
};

keys {
compatible = "gpio-keys";

wps {
label = "wps";
gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WPS_BUTTON>;
};

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

ubi-concat {
compatible = "mtd-concat";
devices = <&ubiconcat0 &ubiconcat1 &ubiconcat2>;

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

partition@0 {
label = "ubi";
reg = <0x0 0x4f80000>;
};
};
};
};

&nand {
status = "okay";

partitions {
compatible = "sercomm,sc-partitions", "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

partition@0 {
label = "bootloader";
reg = <0x0 0x100000>;
scpart-id = <0>;
read-only;
};

partition@100000 {
label = "part_map";
reg = <0x100000 0x100000>;
scpart-id = <1>;
read-only;
};

factory: partition@200000 {
label = "factory";
reg = <0x200000 0x100000>;
scpart-id = <2>;
read-only;
};

partition@300000 {
label = "dual-flag";
reg = <0x300000 0x100000>;
scpart-id = <3>;
};

partition@400000 {
label = "kernel";
reg = <0x400000 0x600000>;
scpart-id = <4>;
};

partition@a00000 {
label = "uImage2";
reg = <0xa00000 0x600000>;
scpart-id = <5>;
read-only;
};

ubiconcat0: partition@1000000 {
label = "ubiconcat0";
reg = <0x1000000 0x2000000>;
scpart-id = <6>;
};

partition@3000000 {
label = "rootfs2";
reg = <0x3000000 0x2000000>;
scpart-id = <7>;
read-only;
};

ubiconcat1: partition@5000000 {
label = "ubiconcat1";
reg = <0x5000000 0x1400000>;
scpart-id = <8>;
};

ubiconcat2: partition@6400000 {
label = "ubiconcat2";
reg = <0x6400000 0x1b80000>;
scpart-id = <9>;
};

/*
* 512 kB bad block reserved
*/
};
};

&pcie {
status = "okay";
};

&pcie0 {
wifi@0,0 {
compatible = "mediatek,mt76";
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&factory 0x8000>;
ieee80211-freq-limit = <5000000 6000000>;
};
};

&pcie1 {
wifi@0,0 {
compatible = "mediatek,mt76";
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&factory 0x0>;
ieee80211-freq-limit = <2400000 2500000>;
};
};

&gmac0 {
mtd-mac-address = <&factory 0x21000>;
};

&switch0 {
ports {
port@0 {
status = "okay";
label = "wan";

mtd-mac-address = <&factory 0x21000>;
mtd-mac-address-increment = <1>;
};

port@1 {
status = "okay";
label = "lan1";
};

port@2 {
status = "okay";
label = "lan2";
};

port@3 {
status = "okay";
label = "lan3";
};

port@4 {
status = "okay";
label = "lan4";
};
};
};

&uartlite3 {
status = "okay";
};

&state_default {
gpio {
groups = "jtag", "uart2";
function = "gpio";
};
};
87 changes: 87 additions & 0 deletions target/linux/ramips/image/mt7621.mk
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,31 @@ define Build/iodata-mstc-header
)
endef

define Build/sercomm-tag-factory
$(eval magic_const=$(word 1,$(1)))
dd if=/dev/zero count=$$((0x200)) bs=1 of=$@.head 2>/dev/null
dd if=/dev/zero count=$$((0x70)) bs=1 2>/dev/null | tr '\000' '0' | \
dd of=$@.head conv=notrunc 2>/dev/null
printf $(SERCOMM_HWVER) | dd of=$@.head bs=1 conv=notrunc 2>/dev/null
printf $(SERCOMM_HWID) | dd of=$@.head bs=1 seek=$$((0x8)) conv=notrunc 2>/dev/null
printf $(SERCOMM_SWVER) | dd of=$@.head bs=1 seek=$$((0x64)) conv=notrunc \
2>/dev/null
dd if=$(IMAGE_KERNEL) skip=$$((0x100)) iflag=skip_bytes 2>/dev/null of=$@.clrkrn
dd if=$(IMAGE_KERNEL) count=$$((0x100)) iflag=count_bytes 2>/dev/null of=$@.hdrkrn0
dd if=/dev/zero count=$$((0x100)) iflag=count_bytes 2>/dev/null of=$@.hdrkrn1
wc -c < $@.clrkrn | tr -d '\n' | dd of=$@.head bs=1 seek=$$((0x70)) \
conv=notrunc 2>/dev/null
stat -c%s $@ | tr -d '\n' | dd of=$@.head bs=1 seek=$$((0x80)) \
conv=notrunc 2>/dev/null
printf $(magic_const) | dd of=$@.head bs=1 seek=$$((0x90)) conv=notrunc 2>/dev/null
cat $@.clrkrn $@ | md5sum | awk '{print $$1;}' | tr -d '\n' | dd of=$@.head bs=1 \
seek=$$((0x1e0)) conv=notrunc 2>/dev/null
cat $@.head $@.hdrkrn0 $@.hdrkrn1 $@.clrkrn $@ > $@.new
mv $@.new $@
rm $@.head $@.clrkrn
endef


define Build/ubnt-erx-factory-image
if [ -e $(KDIR)/tmp/$(KERNEL_INITRAMFS_IMAGE) -a "$$(stat -c%s $@)" -lt "$(KERNEL_SIZE)" ]; then \
echo '21001:7' > $(1).compat; \
Expand Down Expand Up @@ -226,6 +251,68 @@ define Device/asus_rt-n56u-b1
endef
TARGET_DEVICES += asus_rt-n56u-b1

define Device/beeline_smartbox-giga
$(Device/dsa-migration)
BLOCKSIZE := 128k
PAGESIZE := 2048
IMAGE_SIZE := 24576k
KERNEL_SIZE := 6144k
UBINIZE_OPTS := -E 5
LOADER_TYPE := bin
KERNEL_LOADADDR := 0x81001000
LZMA_TEXT_START := 0x82800000
KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | lzma | \
uImage lzma | sercomm-kernel
KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | \
lzma | uImage lzma
IMAGES += kernel0.bin rootfs0.bin factory.img
IMAGE/kernel0.bin := append-kernel
IMAGE/rootfs0.bin := append-ubi | check-size
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
IMAGE/factory.img := append-ubi | beeline-sbgiga-factory kernel rootfs
SERCOMM_KERNEL_OFFSET := 0x400100
SERCOMM_ROOTFS_OFFSET := 0x1000000
SERCOMM_HWID=444245
SERCOMM_HWVER=00010100
SERCOMM_SWVER=1001
DEVICE_VENDOR := Beeline
DEVICE_MODEL := SmartBox GIGA
DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7663-firmware-ap \
kmod-usb3 uboot-envtools
endef
TARGET_DEVICES += beeline_smartbox-giga

define Device/beeline_smartbox-turbo-plus
$(Device/dsa-migration)
BLOCKSIZE := 128k
PAGESIZE := 2048
UBINIZE_OPTS := -E 5
KERNEL_SIZE := 6144k
IMAGE_SIZE := 32768k
KERNEL_LOADADDR := 0x81001000
LZMA_TEXT_START := 0x82800000
SERCOMM_KERNEL_OFFSET := 0x400100
SERCOMM_ROOTFS_OFFSET := 0x1000000
KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | \
lzma | uImage lzma | sercomm-kernel
KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | \
lzma | uImage lzma
LOADER_TYPE := bin
IMAGES += kernel.bin rootfs.bin factory.img
IMAGE/kernel.bin := append-kernel
IMAGE/rootfs.bin := append-ubi | check-size
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
SERCOMM_HWID := 435152
SERCOMM_HWVER := 0001
SERCOMM_SWVER := 9999
IMAGE/factory.img := append-ubi | sercomm-tag-factory
DEVICE_VENDOR := Beeline
DEVICE_MODEL := SmartBox TURBO+
DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7615-firmware kmod-usb3 \
uboot-envtools
endef
TARGET_DEVICES += beeline_smartbox-turbo-plus

define Device/buffalo_wsr-1166dhp
$(Device/dsa-migration)
$(Device/uimage-lzma-loader)
Expand Down
5 changes: 5 additions & 0 deletions target/linux/ramips/mt7621/base-files/etc/init.d/bootcount
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ boot() {
[ -n "$(fw_printenv bootcount bootchanged 2>/dev/null)" ] &&\
echo -e "bootcount\nbootchanged\n" | /usr/sbin/fw_setenv -s -
;;
beeline,smartbox-turbo-plus)
[[ $(hexdump -n 1 -e '/1 "%1d"' -s $((0x20001)) /dev/mtd3) == \
$((0xFF)) ]] || printf '\xff' | dd of=/dev/mtdblock3 count=1 \
bs=1 seek=$((0x20001))
;;
linksys,e5600|\
linksys,ea7300-v1|\
linksys,ea7300-v2|\
Expand Down
2 changes: 2 additions & 0 deletions target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ platform_do_upgrade() {
ampedwireless,ally-r1900k|\
asus,rt-ac65p|\
asus,rt-ac85p|\
beeline,smartbox-giga|\
beeline,smartbox-turbo-plus|\
dlink,dir-1960-a1|\
dlink,dir-2640-a1|\
dlink,dir-2660-a1|\
Expand Down