diff mbox series

[OpenWrt-Devel,RFC] ath79: support for MikroTik wAP AC: vmlinux.elf + DTB file

Message ID f71533ed-80c9-d17b-20de-57b4c1cb7e2a@guifi.net
State RFC
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel,RFC] ath79: support for MikroTik wAP AC: vmlinux.elf + DTB file | expand

Commit Message

Roger Pueyo Centelles | Guifi.net Oct. 17, 2019, 6:48 p.m. UTC
Hi,

I am trying to port the "MikroTik RouterBOARD wAP G-5HacT2HnD", also
known as "wAP AC" to ath79 (it's already supported in ar71xx) and I got
stuck. I think I can't add the corresponding DTB to the kernel image,
which has to be in ELF format so that the bootloader accepts it.

So far, I get the device to boot the vmlinux.elf or the
vmlinux-initramfs.elf images and show some output on the console, but it
stops immediately. From what I have been able to find around, I suspect
that the line:

[    0.000000] OF: fdt: No valid device tree found, continuing without

suggests that the DTB was not appended to the kernel, so it can not be
parsed and the device ends up stopping at:

[    0.000000] Failed to get CPU node
[    0.000000] sched_clock: 32 bits at 100 Hz, resolution 10000000ns,
wraps every 21474836475000000ns


I would like to ask you for your advice on how to generate the ELF
images so that they include the dtb, since I am not able to make it and
I can't go beyond that on supporting the device.

Please find attached the complete boot log (28 lines) and the patch I
have been working on (also at
https://github.com/rogerpueyo/openwrt/tree/ath79-mikrotik-rb-wapg-5hact2hnd_wip).

Thank you very much,

Roger
[    0.000000] Linux version 4.19.79 (le@builder) (gcc version 8.3.0 (OpenWrt GCC 8.3.0 r11237-d1072096f4)) #0 Tue Oct 15 21:31:13 2019
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019750 (MIPS 74Kc)
[    0.000000] SoC: Qualcomm Atheros QCA9556 ver 1 rev 0
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 04000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] OF: fdt: No valid device tree found, continuing without
[    0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] random: get_random_bytes called from start_kernel+0x98/0x4a8 with crng_init=0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 16240
[    0.000000] Kernel command line:   rootfstype=squashfs,jffs2
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Writing ErrCtl register=00000000
[    0.000000] Readback ErrCtl register=00000000
[    0.000000] Memory: 50756K/65536K available (4273K kernel code, 178K rwdata, 1008K rodata, 8036K init, 206K bss, 14780K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 51
[    0.000000] Failed to get CPU node
[    0.000000] sched_clock: 32 bits at 100 Hz, resolution 10000000ns, wraps every 21474836475000000ns
diff mbox series

Patch

diff --git a/target/linux/ath79/dts/qca9556_mikrotik_rb-wapg-5hact2hnd.dts b/target/linux/ath79/dts/qca9556_mikrotik_rb-wapg-5hact2hnd.dts
new file mode 100644
index 0000000000..9c86bd33c6
--- /dev/null
+++ b/target/linux/ath79/dts/qca9556_mikrotik_rb-wapg-5hact2hnd.dts
@@ -0,0 +1,110 @@ 
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+#include "qca9557.dtsi"
+
+/ {
+	compatible = "mikrotik,rb-wapg-5hact2hnd", "qca,qca9556";
+	model = "MikroTik RouterBOARD wAP G-5HacT2HnD";
+
+	aliases {
+		serial0 = &uart;
+	};
+
+	chosen {
+		bootargs = "console=ttyS0,115200n8";
+	};
+
+	leds {
+		compatible = "gpio-leds";
+		pinctrl-names = "default";
+	};
+
+	keys {
+		compatible = "gpio-keys";
+
+		reset {
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
+			debounce-interval = <60>;
+		};
+	};
+};
+
+&spi {
+	status = "okay";
+	num-cs = <1>;
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <25000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition@0 {
+				label = "routerboot";
+				reg = <0x000000 0x00e000>;
+				read-only;
+			};
+
+			partition@e000 {
+				label = "hard_config";
+				reg = <0x000e000 0x00f000>;
+				read-only;
+			};
+
+			partition@f000 {
+				label = "bios";
+				reg = <0x000f000 0x010000>;
+				read-only;
+			};
+
+			partition@10000 {
+				label = "routerboot2";
+				reg = <0x010000 0x01f000>;
+				read-only;
+			};
+
+			partition@1f000 {
+				label = "soft_config";
+				reg = <0x001f000 0x020000>;
+				read-only;
+			};
+
+			partition@20000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				reg = <0x020000 0x1000000>;
+			};
+		};
+	};
+};
+
+&uart {
+	status = "okay";
+};
+
+&pcie0 {
+	status = "okay";
+
+	wifi@0,0 {
+		compatible = "qcom,ath10k";
+		reg = <0 0 0 0 0>;
+	};
+};
+
+&eth0 {
+	status = "okay";
+};
+
+&wmac {
+	status = "okay";
+};
diff --git a/target/linux/ath79/image/common-mikrotik.mk b/target/linux/ath79/image/common-mikrotik.mk
new file mode 100644
index 0000000000..24bc02a0f2
--- /dev/null
+++ b/target/linux/ath79/image/common-mikrotik.mk
@@ -0,0 +1,25 @@ 
+define Device/mikrotik
+	DEVICE_VENDOR := MikroTik
+	DEVICE_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-usb-ledtrig-usbport
+	BOARD_NAME := routerboard
+	LOADER_TYPE := elf
+	KERNEL_NAME := vmlinux.elf
+	KERNEL_INITRAMFS_NAME := vmlinux-initramfs.elf
+	MIKROTIK_CHUNKSIZE :=
+endef
+DEVICE_VARS += MIKROTIK_CHUNKSIZE
+
+define Device/rb-nor-flash-16M
+	$(Device/mikrotik)
+	DEVICE_PACKAGES := rbcfg rssileds -nand-utils kmod-ledtrig-gpio
+	IMAGE_SIZE := 16000k
+	KERNEL_INSTALL := 1
+	IMAGE/sysupgrade.bin := append-kernel | kernel2minor -s 1024 -e | pad-to $$$$(BLOCKSIZE) | \
+	append-rootfs | pad-rootfs | append-metadata | check-size $$$$(IMAGE_SIZE)
+endef
+
+define Device/rb-nor-flash-16M-ac
+	$(Device/rb-nor-flash-16M)
+	DEVICE_PACKAGES += kmod-ath10k-ct ath10k-firmware-qca988x-ct ath10k-firmware-qca9887-ct kmod-usb-ehci
+	SUPPORTED_DEVICES += rb-wapg-5hact2hnd mikrotik_rb-wapg-5hact2hnd
+endef
diff --git a/target/linux/ath79/image/generic.mk b/target/linux/ath79/image/generic.mk
index acb1ab4b0b..d88b8ed5a7 100644
--- a/target/linux/ath79/image/generic.mk
+++ b/target/linux/ath79/image/generic.mk
@@ -1,4 +1,5 @@ 
 include ./common-buffalo.mk
+include ./common-mikrotik.mk
 include ./common-netgear.mk
 include ./common-tp-link.mk
 
@@ -684,6 +685,17 @@  define Device/librerouter_librerouter-v1
 endef
 TARGET_DEVICES += librerouter_librerouter-v1
 
+define Device/mikrotik_rb-wapg-5hact2hnd
+  $(Device/rb-nor-flash-16M-ac)
+  ATH_SOC := qca9556
+  DEVICE_VENDOR := MikroTik
+  DEVICE_MODEL := MikroTik RouterBOARD wAP G-5HacT2HnD (wAP AC)
+	LOADER_TYPE := elf
+	KERNEL := kernel-bin | append-dtb
+	KERNEL_INITRAMFS := kernel-bin | append-dtb
+endef
+TARGET_DEVICES += mikrotik_rb-wapg-5hact2hnd
+
 define Device/nec_wg1200cr
   ATH_SOC := qca9563
   DEVICE_VENDOR := NEC