Skip to content

Commit

Permalink
ath79: add support for NEC Aterm WR8750N
Browse files Browse the repository at this point in the history
NEC Aterm WR8750N is a 2.4/5 GHz band 11n (Wi-Fi 4) router, based on
AR9344.

Specification:

- SoC             : Atheros AR9344
- RAM             : DDR2 128 MiB (2x Hynix H5PS5162GFR-S6C)
- Flash           : SPI-NOR 8 MiB (Macronix MX25L6406EMI-12G)
- WLAN            : 2.4/5 GHz 2T2R
  - 2.4 GHz       : Atheros AR9344 (SoC)
  - 5 GHz         : Atheros AR9382
- Ethernet        : 5x 10/100/1000 Mbps
  - switch        : Atheros AR8327
- LEDs/Keys (GPIO): 10x/4x
  - note          : all LEDs are controlled by ath9k chip (AR9382)
- UART            : through-hole on PCB
  - assignment    : 3.3V, GND, NC, TX, RX from tri-angle marking
  - settings      : 9600n8
- USB             : 1x USB 2.0 Type-A
  - hub (internal): NEC uPD720114
- Power           : 12 VDC, 1.5 A (Max. 16 W)
- Stock OS        : NetBSD based

Flash instruction using initramfs-factory.bin image:

1. Boot WR8750N with router mode normally
2. Access to the WebUI ("http://aterm.me/" or "http://192.168.0.1/") on
   the device and open firmware update page ("ファームウェア更新")
3. Select the OpenWrt initramfs-factory.bin image and click update
   ("更新") button
4. After updating, the device will be rebooted and booted with OpenWrt
   initramfs image
5. On the initramfs image, upload (or download) uboot.bin and
   sysupgrade.bin image to the device
6. Replace the bootloader with a uboot.bin image

   mtd write <uboot.bin image> bootloader

7. Perform sysupgrade with a sysupgrade.bin image

   sysupgrade <sysupgrade image>

8. Wait ~120 seconds to complete flashing

Flash instruction using initramfs-necboot.bin image:

 1. Connect and open serial console
 2. Power on WR8750N and interrupt bootloader by ESC key
 3. Login to the bootloader CLI with a password "chiron"
 4. Start TFTP server by "tftpd" command
 5. Upload initramfs-necboot.bin via tftp from your computer

   example (Windows): tftp -i 192.168.0.1 PUT initramfs-necboot.bin

 6. Boot initramfs image by "boot" command
 7. On the initramfs image, back up the stock bootloader and firmware if
   needed
 8. Upload (or download) uboot.bin and sysupgrade.bin image to the device
 9. Replace the bootloader with a uboot.bin image
10. Perform sysupgrade with a sysupgrade.bin image
11. Wait ~120 seconds to complete flashing

Notes:

- All LEDs are connected to the GPIO controller on the ath9k chip
  (AR9382) and controlled by it. Those LEDs are probed after probing of
  ath9k chip, so they cannot be handled as status LEDs of OpenWrt while
  booting.

- A reset pin of the internal USB hub is connected to the GPIO
  controller of the ath9k chip, like LEDs above. That hub will be
  detected after probing of the ath9k chip.

- The stock bootloader requires an unknown filesystem on firmware area
  in the flash. Booting of OpenWrt from that filesystem cannot be
  handled, so the bootloader needs to be replaced to mainline U-Boot
  before OpenWrt installation.

MAC Addresses:

LAN    : 1C:B1:7F:xx:xx:00 (config,  0x6 (hex))
WAN    : 1C:B1:7F:xx:xx:01 (config,  0xc (hex))
2.4 GHz: 1C:B1:7F:xx:xx:02 (config,  0x0 (hex) / art, 0x1002 (hex))
5 GHz  : 1C:B1:7F:xx:xx:03 (config, 0x12 (hex) / art, 0x5002 (hex))

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
  • Loading branch information
musashino205 committed May 14, 2024
1 parent 6fdb536 commit 9e20d3d
Show file tree
Hide file tree
Showing 7 changed files with 491 additions and 5 deletions.
300 changes: 300 additions & 0 deletions target/linux/ath79/dts/ar9344_nec_aterm.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,300 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

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

#include "ar9344.dtsi"

/ {
aliases {
led-running = &led_power_green;
led-upgrade = &led_power_green;
};

chosen {
/*
* don't specify bootargs property in DeviceTree to
* enable a console with a default baudrate (9600)
* or passed console= parameter from the bootloader
*/
/delete-property/ bootargs;
stdout-path = &uart;
};

keys: keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&jtag_disable_pins>;

button-eco {
label = "eco";
gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
linux,code = <BTN_0>;
debounce-interval = <60>;
};

switch-ap {
label = "ap";
gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
linux,code = <BTN_1>;
debounce-interval = <60>;
};

button-reset {
label = "reset";
gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
debounce-interval = <60>;
};

button-wps {
label = "wps";
gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WPS_BUTTON>;
debounce-interval = <60>;
};
};

ath9k_leds: ath9k-leds {
/* all LEDs are connected to ath9k chip (AR938x) */
compatible = "gpio-leds";

led_power_green: led-0 {
gpios = <&ath9k 0 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_POWER;
default-state = "on";
};

led-1 {
gpios = <&ath9k 1 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_RED>;
function = LED_FUNCTION_POWER;
};

led-2 {
gpios = <&ath9k 2 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_WAN_ONLINE;
};

led-3 {
gpios = <&ath9k 3 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_RED>;
function = LED_FUNCTION_WAN_ONLINE;
};

led-4 {
gpios = <&ath9k 4 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_WLAN_2GHZ;
linux,default-trigger = "phy0tpt";
};

led-5 {
gpios = <&ath9k 5 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_RED>;
function = LED_FUNCTION_WLAN_2GHZ;
};

led-6 {
gpios = <&ath9k 6 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_WLAN_5GHZ;
linux,default-trigger = "phy1tpt";
};

led-7 {
gpios = <&ath9k 7 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_RED>;
function = LED_FUNCTION_WLAN_5GHZ;
};

led-8 {
gpios = <&ath9k 12 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_GREEN>;
function = "tv";
};

led-9 {
gpios = <&ath9k 13 GPIO_ACTIVE_LOW>;
color = <LED_COLOR_ID_RED>;
function = "tv";
};
};

reg_usb_vbus: regulator {
compatible = "regulator-fixed";
regulator-name = "usb-vbus";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
gpio = <&gpio 20 GPIO_ACTIVE_HIGH>;
enable-active-high;
regulator-always-on;
};
};

&ref {
clock-frequency = <40000000>;
};

&spi {
status = "okay";

flash@0 {
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <25000000>;

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

/*
* since the OEM bootloader requires unknown
* filesystem on firmware area, needs to be
* replaced to u-boot before OpenWrt installation
*/
partition@0 {
label = "bootloader";
reg = <0x000000 0x020000>;
};

/* not compatible with u-boot */
partition@20000 {
label = "config";
reg = <0x020000 0x010000>;
read-only;

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

macaddr_config_6: macaddr@6 {
reg = <0x6 0x6>;
};
};
};

partition@30000 {
label = "art";
reg = <0x030000 0x010000>;
read-only;

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

cal_art_1000: calibration@1000 {
reg = <0x1000 0x440>;
};

cal_art_5000: calibration@5000 {
reg = <0x5000 0x440>;
};
};
};
};
};
};

&mdio0 {
status = "okay";

phy0: ethernet-phy@0 {
reg = <0>;

qca,ar8327-initvals = <
0x04 0x07a00000 /* PORT0_PAD_MODE_CTRL */
0x08 0x00000000 /* PORT5_PAD_MODE_CTRL */
0x0c 0x00000000 /* PORT6_PAD_MODE_CTRL */
0x10 0x81000080 /* POWER_ON_STRAP */
0x50 0xcf37cf37 /* LED_CTRL0 */
0x54 0x00000000 /* LED_CTRL1 */
0x58 0x00000000 /* LED_CTRL2 */
0x5c 0x03ffff00 /* LED_CTRL3 */
0x7c 0x0000007e /* PORT0_STATUS */
>;
};
};

&eth0 {
status = "okay";

pll-data = <0x06000000 0x00000101 0x00001616>;

phy-mode = "rgmii";
phy-handle = <&phy0>;

nvmem-cells = <&macaddr_config_6>;
nvmem-cell-names = "mac-address";

gmac-config {
device = <&gmac>;

rgmii-gmac0 = <1>;
rxdv-delay = <0>;
rxd-delay = <0>;
txd-delay = <0>;
txen-delay = <0>;
};
};

&gpio {
switch-reset {
gpio-hog;
gpios = <13 GPIO_ACTIVE_HIGH>;
output-high;
};
};

&pcie {
status = "okay";

ath9k: wifi@0,0 {
compatible = "pci168c,0030";
reg = <0x0000 0 0 0 0>;
#gpio-cells = <2>;
gpio-controller;

nvmem-cells = <&cal_art_5000>;
nvmem-cell-names = "calibration";

usb-hub-reset {
gpio-hog;
gpios = <10 GPIO_ACTIVE_HIGH>;
output-high;
};
};
};

&usb_phy {
status = "okay";
};

&usb {
status = "okay";
#address-cells = <1>;
#size-cells = <0>;

dr_mode = "host";

/delete-node/ port@1;

/* NEC uPD720114 */
hub@1 {
compatible = "usb0409,005a";
reg = <1>;
};
};

&wmac {
status = "okay";

nvmem-cells = <&cal_art_1000>;
nvmem-cell-names = "calibration";
};
16 changes: 16 additions & 0 deletions target/linux/ath79/dts/ar9344_nec_wr8750n.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

#include "ar9344_nec_aterm.dtsi"

/ {
compatible = "nec,wr8750n", "qca,ar9344";
model = "NEC Aterm WR8750N";
};

&partitions {
partition@40000 {
compatible = "denx,uimage";
label = "firmware";
reg = <0x040000 0x7c0000>;
};
};
75 changes: 75 additions & 0 deletions target/linux/ath79/image/common-nec.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
DEVICE_VARS += NEC_FW_TYPE

define Build/nec-append-uboot
cat $(STAGING_DIR_IMAGE)/$(SOC)_nec_aterm-u-boot.bin >> $@
endef

define Build/nec-boot-header
$(eval flags=$(if $(1),$(word 1,$(1)),0x0002))
$(eval addr=$(if $(word 2,$(1)),$(word 2,$(1)),80060000))
$(eval databin=$(if $(word 3,$(1)),$(word 3,$(1)),$@))
( \
flags=$$(printf "%04x%04x" $(flags) $$((~$(flags) & 0xffff))); \
nec_fw_size=$$(printf '%08x' "$$(($$(stat -c%s $(databin)) + 0x18))"); \
printf $$(echo "$${flags}$${nec_fw_size}0000001800000000$(addr)$(addr)" | \
sed 's/../\\x&/g'); \
cat $(databin); \
) > $(databin).new
mv $(databin).new $(databin)
( \
cksum=$$( \
dd if=$(databin) ibs=4 skip=1 | od -A n -t u2 --endian=little | \
tr -s ' ' '\n' | \
awk '{s+=$$0}END{printf "%04x", 0xffff-(s%0x100000000)%0xffff}'); \
printf "\x$${cksum:2:2}\x$${cksum:0:2}" | \
dd of=$(databin) conv=notrunc bs=2 seek=6 count=1; \
)
endef

define Build/nec-usbaterm-fw
( \
printf "VERSION: 9.99.99\nOEM1 VERSION: 9.9.99\n"; \
printf "$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION)\n"; \
) | dd of=$@.copyblk bs=4 conv=sync
touch $@.endblk
$(call Build/nec-boot-header,0x0000 00000000 $@.copyblk)
$(call Build/nec-boot-header,0x0001 00000000 $@.endblk)
( \
printf "USB ATERMWL3050\x00"; \
printf $$(echo "ffffffffffffffffffffffffffffffff" | sed 's/../\\x&/g'); \
cat $@.copyblk $@ "$(KDIR)/loader-$(DEVICE_NAME).bin" $@.endblk; \
) > $@.new
printf "Binary Type$(1) File END \r\n" > $@.footer
( \
pad=$$((0x20 - $$(stat -c%s $@.footer))); \
for i in $$(seq 1 $$pad); do printf "\xff"; done; \
cat $@.footer; \
) >> $@.new
mv $@.new $@
rm -f $@.copyblk $@.endblk $@.footer
endef

define Build/remove-uimage-header
dd if=$@ of=$@.new iflag=skip_bytes skip=64 2>/dev/null
mv $@.new $@
endef

define Device/nec-netbsd-aterm
DEVICE_VENDOR := NEC
LOADER_TYPE := bin
KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | uImage none
KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | uImage none
ARTIFACTS := uboot.bin
ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
COMPILE := loader-$(1).bin
COMPILE/loader-$(1).bin := loader-okli-compile | pad-to 4 | nec-boot-header
ARTIFACTS += initramfs-factory.bin initramfs-necboot.bin
ARTIFACT/initramfs-factory.bin := append-image-stage initramfs-kernel.bin | \
remove-uimage-header | pad-to 4 | nec-boot-header 0003 | \
nec-usbaterm-fw $$$$(NEC_FW_TYPE) | check-size
ARTIFACT/initramfs-necboot.bin := append-image-stage initramfs-kernel.bin | \
remove-uimage-header | pad-to 4 | nec-boot-header
endif
ARTIFACT/uboot.bin := nec-append-uboot | check-size 128k
DEVICE_PACKAGES := kmod-usb2 -uboot-envtools
endef
Loading

0 comments on commit 9e20d3d

Please sign in to comment.