openwrt/target/linux/apm821xx/dts/netgear-wndr4700.dts
Christian Lamparter 82c8c38a5c apm821xx: prepare WNDR4700 for 6.6 - add preliminary u-boot-env access
With the default BUILD_BOT configuration on a linux 6.6 kernel,
the WNDR4700's kernel no longer fits into the alloted ~3.5MiB,
even with LZMA compression.

Bigger kernels are possible, but there's a problem with Netgear's
"bootcmd":

> if loadn_dniimg 0 0x180000 0x4e0000 && chk_dniimg 0x4e0000; then nand read 0x800000 0x180000 0x20000;bootm 0x500000 - 0x800040;else fw_recovery; fi"

This loads the dni-image starting offset 0x180000 from the NAND
flash (which is the DTB partition) to 0x4e0000 in the RAM. It then
checks whenever the provided image is "valid". If it is then it
reads the DTB again to 0x800000 in the RAM and starts the extraction
and boot process. (If the image wasn't valid then it starts the
automated firmware recovery).

The issues here are that first: the kernel image gets "squeezed"
between 0x500040 and 0x7fffff... And second, the decompressor
only has area 0x0 - 0x500000 for decompression.

Hence the image now requires to update the bootcmd by providing
new values (which have been successfully tested with the original
Netgear WNDR4700 v1.0.0.56 firmware) for the RAM locations and
make full use of the fact that loadn_dniimg loads the DTB as well.

This needs to be done only once. Just connect a serial adapter to
interface with uboot and overwrite (and save) the new bootcmd.

WARNING: The serial port needs a TTL/RS-232 3.3v level converter!

Steps:
 0. Power-off the WNDR4700
 1. Connect the serial interface (you need to open the WNDR4700)
 2. Power-up the WNDR4700
 3. Monitor the boot-sequence and hit "Enter"-key when it says:

  "Hit any key to stop autoboot" (Be quick, you have a ~2 second window)

 4. in the Prompt enter the following commands (copy & paste)

 setenv bootcmd "if loadn_dniimg 0 0x180000 0xce0000 && chk_dniimg 0xce0000; then bootm 0xd00000 - 0xce0040;else fw_recovery; fi"
 saveenv
 run bootcmd

Note: This new bootcmd will also unbrick devices that were bricked
by the bigger 4.19-6.1 kernels.

Note2: This method was tested with a WNDR4700. A big kernel with most
debug features enabled on v6.6.22 measured 4.30 MiB when compressed
with lzma. The uncompressed kernel is 12.34 MiB. This is over the 3 MiB,
the device reserves for the kernel... But it booted! For bigger kernels,
the device needs repartitioning of the the ubi partition due to the
kernel+dtb not fitting into the partition.

Note3: For initramfs development. I would advice to load the initramfs
images to 0x800000 (or higher). i.e.: tftp 800000 wndr4700.bin

Note4: the fw_recovery uboot command to transfer the factory image to
the flash still works.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
2024-04-05 09:26:26 +02:00

578 lines
12 KiB
Plaintext

// SPDX-License-Identifier: GPL-2.0-only
/*
* Device Tree Source for Netgear WNDR4700/WNDR4720 Series
*
* Copyright 2008 DENX Software Engineering, Stefan Roese <sr@denx.de>
*/
/dts-v1/;
#include <dt-bindings/thermal/thermal.h>
#include <dt-bindings/leds/common.h>
#include "apm82181.dtsi"
/ {
model = "Netgear WNDR4700/WNDR4720 Series";
compatible = "netgear,wndr4700", "apm,bluestone";
aliases {
serial0 = &UART0;
};
chosen {
stdout-path = "/plb/opb/serial@ef600300:115200n8";
};
thermal-zones {
cpu_thermal: cpu-thermal {
polling-delay-passive = <10000>; /* milliseconds */
polling-delay = <20000>; /* milliseconds */
thermal-sensors = <&temp0 1>;
/*
* REVISIT:
*
* Add the <&drive_temp>; sensor there and wire up
* the coefficients = <1 1>; property.
*
* Note: The kernel does not yet support more than
* one sensor (see of_thermal.c's function:
* thermal_of_build_thermal_zon()). Once this is
* implemented.
*/
trips {
/*
* Once the thermal governers are a bit smarter
* and do hysteresis properly, we can disable
* the fan when the HDD and CPU has < 39 C.
*/
cpu_alert0: board-alert0 {
temperature = <25000>;
hysteresis = <2000>;
type = "active";
};
cpu_alert1: cpu-alert1 {
temperature = <27000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "active";
};
cpu_alert2: cpu-alert2 {
temperature = <65000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "active";
};
cpu_alert3: cpu-alert3 {
temperature = <70000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "active";
};
cpu_alert4: cpu-alert4 {
temperature = <75000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "active";
};
cpu_alert5: cpu-alert5 {
temperature = <80000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "active";
};
cpu_alert6: cpu-alert6 {
temperature = <85000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "active";
};
cpu_crit: cpu-crit {
temperature = <90000>; /* millicelsius */
hysteresis = <2000>; /* millicelsius */
type = "critical";
};
};
cooling-maps {
map0 {
trip = <&cpu_alert0>;
cooling-device = <&fan0 THERMAL_NO_LIMIT 0>;
};
map1 {
trip = <&cpu_alert1>;
cooling-device = <&fan0 1 1>;
};
map2 {
trip = <&cpu_alert2>;
cooling-device = <&fan0 2 4>;
};
map3 {
trip = <&cpu_alert3>;
cooling-device = <&fan0 4 8>;
};
map4 {
trip = <&cpu_alert4>;
cooling-device = <&fan0 9 12>;
};
map5 {
trip = <&cpu_alert5>;
cooling-device = <&fan0 13 15>;
};
map6 {
trip = <&cpu_alert6>;
cooling-device =<&fan0 16 THERMAL_NO_LIMIT>;
};
};
};
};
};
&CRYPTO {
status = "okay";
};
&PKA {
status = "okay";
};
&TRNG {
status = "okay";
};
&SATA1 {
status = "okay";
/*
* This drive may have a temperature sensor with a
* thermal zone we can use for thermal control of the
* chassis temperature using the fan.
*/
drive_temp: sata-port@0 {
reg = <0>;
#thermal-sensor-cells = <0>;
};
};
&USBOTG0 {
status = "okay";
dr_mode = "host";
};
&ndfc {
status = "okay";
/* 128 MiB Nand Flash */
nand {
nand-is-boot-medium;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "uboot";
reg = <0x00000000 0x00180000>;
compatible = "fixed-partitions";
read-only;
partition@40000 {
label = "u-boot-env-main";
compatible = "u-boot,env-redundant-count";
reg = <0x00040000 0x20000>; /* one block is 128k */
read-only;
};
/*
* Causes u_boot_env: probe of 4e4000000.ndfc:nand:partitions:partition@0:partition@60000
* failed with error -17
*
* partition@60000 {
* label = "u-boot-env-redundant";
* compatible = "u-boot,env-redundant-count";
* reg = <0x00060000 0x20000>;
* read-only;
* };
*/
};
partition@180000 {
label = "firmware";
reg = <0x00180000 0x01860000>;
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
partition@0 {
label = "kernel";
reg = <0x00000000 0x00480000>;
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
/*
* device-tree is @ 0x00180000 - 0x0019ffff
* kernel starts from 0x20000.
* this is coded into netgear's u-boot.
*/
partition@0 {
label = "dtb";
reg = <0x00000000 0x20000>;
};
/*
* this partition will also contain a
* fake/empty rootfs at the end to fool
* Netgear's uboot rootfs integrety checks.
*/
};
partition@480000 {
label = "ubi";
reg = <0x00480000 0x013e0000>;
};
};
/*
* Netgear's u-boot in the fw_recovery mode (can be
* triggered by holding the reset button, or if
* "bootm" fails) will not flash past this point
* (= 0x19E0000).
*/
partition@19e0000 {
label = "config";
reg = <0x019e0000 0x00080000>;
read-only;
};
partition@1a60000 {
label = "pot";
reg = <0x01a60000 0x00080000>;
read-only;
};
partition@1ae0000 {
label = "traffic_meter";
reg = <0x01ae0000 0x00300000>;
read-only;
};
partition@1de0000 {
label = "language";
reg = <0x01de0000 0x001c0000>;
read-only;
};
partition@1fa0000 {
label = "ecos";
reg = <0x01fa0000 0x06020000>;
read-only;
};
partition@7fc0000 {
label = "wifi_data";
reg = <0x07fc0000 0x00040000>;
read-only;
nvmem-layout {
compatible = "fixed-layout";
#address-cells = <1>;
#size-cells = <1>;
macaddr_wifi_0: macaddr@0 {
reg = <0x0 0x6>;
};
macaddr_wifi_c: macaddr@c {
reg = <0xc 0x6>;
};
calibration_wifi_1000: calibration@1000 {
reg = <0x1000 0x440>;
};
calibration_wifi_5000: calibration@5000 {
reg = <0x5000 0x440>;
};
};
};
};
};
};
&UART0 {
status = "okay";
};
&GPIO0 {
status = "okay";
};
&IIC0 {
status = "okay";
fan0: fan@1b {
compatible = "microchip,tc654";
reg = <0x1b>;
#cooling-cells = <2>; /* min followed by max */
gpios = <&GPIO0 16 GPIO_ACTIVE_LOW>; /* fan status */
alarm-gpios = <&GPIO0 5 GPIO_ACTIVE_LOW>; /* fault */
interrupt-parent = <&UIC3>;
interrupts = <0x16 IRQ_TYPE_EDGE_FALLING>; /* fault */
};
temp0: temp@4d {
compatible = "gmt,g781";
reg = <0x4d>;
#thermal-sensor-cells = <1>;
/*
* The LM90 has two sensors:
* temp0 -> internal to LM90
* temp1 -> external NTC near CPU
*/
};
};
&EMAC0 {
status = "okay";
phy-handle = <&phy0>;
fifo-entry-size = <10>;
mdio {
#address-cells = <1>;
#size-cells = <0>;
phy0: ethernet-phy@0 {
device_type = "ethernet-phy";
reg = <0>;
qca,mib-poll-interval = <500>;
qca,ar8327-initvals = <
0x0010 0x40000000
0x0624 0x007f7f7f
0x0004 0x07a00000 /* PAD0_MODE */
0x000c 0x01000000 /* PAD6_MODE */
0x007c 0x0000007e /* PORT0_STATUS */
>;
};
};
};
&POB0 {
keys {
compatible = "gpio-keys";
button-restart {
label = "Reset button";
gpios = <&GPIO0 15 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RESTART>;
interrupt-parent = <&UIC1>;
interrupts = <0x14 IRQ_TYPE_EDGE_FALLING>;
debounce-interval = <60>;
};
button-backup_hd {
label = "Backup HD button";
gpios = <&GPIO0 19 GPIO_ACTIVE_LOW>;
linux,code = <BTN_0>;
interrupt-parent = <&UIC1>;
interrupts = <0x1e IRQ_TYPE_EDGE_FALLING>;
debounce-interval = <60>;
};
button-rfkill {
label = "RFKILL button";
gpios = <&GPIO0 20 GPIO_ACTIVE_LOW>;
linux,code = <KEY_RFKILL>;
interrupt-parent = <&UIC1>;
interrupts = <0x1f IRQ_TYPE_EDGE_FALLING>;
debounce-interval = <60>;
};
button-wps {
label = "WPS button";
gpios = <&GPIO0 23 GPIO_ACTIVE_LOW>;
linux,code = <KEY_WPS_BUTTON>;
interrupt-parent = <&UIC2>;
interrupts = <0x19 IRQ_TYPE_EDGE_FALLING>;
debounce-interval = <60>;
};
};
leds {
compatible = "gpio-leds";
led-0 {
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_POWER;
gpios = <&GPIO0 8 GPIO_ACTIVE_HIGH>;
};
led-1 {
color = <LED_COLOR_ID_AMBER>;
function = LED_FUNCTION_FAULT;
gpios = <&GPIO0 9 GPIO_ACTIVE_LOW>;
panic-indicator;
};
led-2 {
color = <LED_COLOR_ID_BLUE>;
function = LED_FUNCTION_USB;
gpios = <&GPIO0 10 GPIO_ACTIVE_HIGH>;
trigger-sources = <&usb2_port 1>, <&usb2_port 2>,
<&usb3_port 1>, <&usb3_port 2>;
linux,default-trigger = "usbport";
};
led-3 {
color = <LED_COLOR_ID_WHITE>;
function = LED_FUNCTION_INDICATOR;
gpios = <&GPIO0 11 GPIO_ACTIVE_HIGH>;
};
led-4 {
color = <LED_COLOR_ID_YELLOW>;
function = LED_FUNCTION_WAN;
gpios = <&GPIO0 3 GPIO_ACTIVE_HIGH>;
};
led-5 {
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_WAN;
gpios = <&GPIO0 12 GPIO_ACTIVE_HIGH>;
};
led-6 {
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_DISK;
gpios = <&GPIO0 14 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "disk-activity";
};
led-7 {
color = <LED_COLOR_ID_RED>;
function = LED_FUNCTION_DISK_ERR;
gpios = <&GPIO0 17 GPIO_ACTIVE_HIGH>;
};
led-8 {
color = <LED_COLOR_ID_BLUE>;
function = LED_FUNCTION_WLAN;
gpios = <&GPIO0 18 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "phy0tpt";
};
};
};
&PCIE0 {
status = "okay";
/*
* relevant lspci topology:
*
* -+-[0000:40]---00.0-[41-7f]----00.0-[42-45]--+-02.0-[43]----00.0
* +-03.0-[44]----00.0
* \-04.0-[45]----00.0
*
*/
bridge@64,0 {
reg = <0x00400000 0 0 0 0>;
#address-cells = <3>;
#size-cells = <2>;
ranges;
bridge@65,0 {
/* IDT PES4T4 PCI Express Switch */
compatible = "pci111d,803a";
reg = <0x00410000 0 0 0 0>;
#address-cells = <3>;
#size-cells = <2>;
ranges;
bridge@66,2 {
compatible = "pci111d,803a";
reg = <0x00421000 0 0 0 0>;
#address-cells = <3>;
#size-cells = <2>;
ranges;
wifi0: wifi@67,0 {
/* Atheros AR9380 5GHz */
compatible = "pci168c,0030";
reg = <0x00430000 0 0 0 0>;
interrupts = <3>; /* INTC */
nvmem-cell-names = "mac-address", "calibration";
nvmem-cells = <&macaddr_wifi_0>, <&calibration_wifi_1000>;
/*
* Because this was such a pain.
* Here's the full device path:
* pci0000:40/0000:40:00.0/0000:41:00.0/0000:42:02.0/0000:43:00.0
*/
};
};
bridge@66,3 {
compatible = "pci111d,803a";
reg = <0x00421800 0 0 0 0>;
#address-cells = <3>;
#size-cells = <2>;
ranges;
wifi1: wifi@68,0 {
/* Atheros AR9381 2.4GHz */
compatible = "pci168c,0033";
reg = <0x00440000 0 0 0 0>;
interrupts = <4>; /* INTD */
nvmem-cell-names = "mac-address", "calibration";
nvmem-cells = <&macaddr_wifi_c>, <&calibration_wifi_5000>;
};
};
bridge@66,4 {
compatible = "pci111d,803a";
reg = <0x00422000 0 0 0 0>;
#address-cells = <3>;
#size-cells = <2>;
ranges;
usb1: usb@69,0 {
/* Renesas uPD720202 */
compatible = "pci1912,0015";
reg = <0x00450000 0 0 0 0>;
interrupts = <1>; /* INTA */
#address-cells = <1>;
#size-cells = <0>;
usb2_port: port@1 {
reg = <1>;
#trigger-source-cells = <1>;
};
usb3_port: port@2 {
reg = <2>;
#trigger-source-cells = <1>;
};
};
};
};
};
};