Netgear X10 (R9000)

Opened my router today, now waiting for my serial cable to arrive and then i can finally boot an OpenWrt image. Was pretty easy to open.

Built Alpine OpenWRT image today, used DTS from DDWRT. Let see whether i can boot into OpenWRT.

Took a few stabs at that approach. Enabling basic Alpine support and using the alpine-r9000.dts did not yield positive results on my end but this could simply be an issue with my image attempt.

DDWRT contains the following drivers however all supporting code is blended in with their customized kernel build.

/arch/arm/mach-alpine/*
/drivers/cpuidel/cpuidle-alpine.c
/drivers/crypto/al/*
/drivers/dma/al/*
/drivers/edac/al_mc_edac.c
/drivers/mtd/nand/al/*
/drivers/net/ethernet/al/*
/drivers/thermal/al/*

I was able to merge all Kconfigs under the master OpenWRT branch however it fails to compile without patches for supporting code. I have no idea how to identify everything required..

We also need to fix the factory image generation. I used the R7800 as a template and made the following as a test but the device complains about a wrong magic number on tftp recovery.

(Test) R9000 Image MakeFile
# Copyright (c) 2014 The Linux Foundation. All rights reserved.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk

DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_HW_ID

define Device/Default
	PROFILES := Default
	KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
	KERNEL_INITRAMFS_PREFIX := $$(IMG_PREFIX)-$(1)-initramfs
	KERNEL_PREFIX := $$(IMAGE_PREFIX)
	KERNEL_LOADADDR = 0x42208000
	DEVICE_DTS = $$(SOC)-$(lastword $(subst _, ,$(1)))
	IMAGES := sysupgrade.bin
	IMAGE/sysupgrade.bin = sysupgrade-tar | append-metadata
	IMAGE/sysupgrade.bin/squashfs :=
endef

define Device/DniImage
	KERNEL_SUFFIX := -uImage
	KERNEL = kernel-bin | append-dtb | uImage none
	KERNEL_NAME := zImage
	NETGEAR_BOARD_ID :=
	NETGEAR_HW_ID :=
	UBINIZE_OPTS := -E 5
	IMAGES += factory.img
	IMAGE/factory.img := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-uImage-fakehdr filesystem | pad-to $$$$(KERNEL_SIZE) | append-ubi | netgear-dni
	IMAGE/sysupgrade.bin := append-kernel | pad-offset $$$$(BLOCKSIZE) 64 | append-uImage-fakehdr filesystem | sysupgrade-tar kernel=$$$$@ | append-metadata
endef


define Device/netgear_r9000
	$(call Device/DniImage)
	DEVICE_VENDOR := NETGEAR
	DEVICE_MODEL := Nighthawk X10 R9000
	SOC := alpine
	KERNEL_SIZE := 4096k
	NETGEAR_BOARD_ID := R9000
	NETGEAR_HW_ID := 29765235+0+512+1024+4x4+4x4
	BLOCKSIZE := 128k
	PAGESIZE := 2048
	BOARD_NAME := r9000
	SUPPORTED_DEVICES += r9000	
endef
TARGET_DEVICES += netgear_r9000


$(eval $(call BuildImage))
(GPL) R9000 Image MakeFile
# Copyright (c) 2013 The Linux Foundation. All rights reserved.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk

ifneq "x$(CONFIG_TARGET_MODELNAME_LIST)" "x"
	MODULE_LIST ?= $(call qstrip,$(CONFIG_TARGET_MODELNAME_LIST))
endif

MODULE_NAME=R9000
HW_VERSION=R9000
FW_VERSION=V1.0.5.18
LG_VERSION=V1.0.0.385
CLOUD_VERSION=20161111
HW_ID="29765235+0+512+1024+4x4+4x4"
ifndef FW_REGION
	FW_REGION=""
endif

# 2015/03/19
# Torby and Tony confirmed that Netgear have sent new requirement out to resize
# whole kernel and rootfs to 32MB.
# Leave 4MB to kernel and others will be reserved to rootfs and bad block.
#
# * page size = 2KB, block size = 128KB.
# * kernel + rootfs = 32MB = 256 blocks
# * bad blocks = 2MB = 16 blocks
# Partitions have to align to block size.
#MAX_KERNEL_SIZE=$(shell echo $$((17 * 128 * 1024))) # kernel blocks * 128 * 1024
#MAX_IMAGE_SIZE=$(shell echo $$(((256 - 16) * 128 * 1024))) # (kernel blocks + rootfs blocks - reserved block for bad block) * 128 * 1024

# KERNEL_SIZE align to block size and must be precise block of true kerne size. when change kernel size, please also modify the kernel partition size patch.
MAX_KERNEL_SIZE=$(shell echo $$((36 * 128 * 1024)))
MAX_IMAGE_SIZE=$(shell echo $$(((34 + 319) * 128 * 1024)))

UBIFS_OPTS = -m 2048 -e 124KiB -c 4096 -U -F
UBINIZE_OPTS = -m 2048 -p 128KiB

E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_PARTSIZE)*1024)))

define Image/Prepare
	echo "$(MODULE_NAME)" > $(TARGET_DIR)/module_name
	echo "$(HW_VERSION)" > $(TARGET_DIR)/hardware_version
	echo "$(FW_VERSION)" > $(TARGET_DIR)/firmware_version
	echo "$(CLOUD_VERSION)" > $(TARGET_DIR)/cloud_version
	echo "$(FW_REGION)" > $(TARGET_DIR)/firmware_region
	echo "$(LG_VERSION)" > $(TARGET_DIR)/default_language_version
	echo $(HW_ID) > $(TARGET_DIR)/hw_id
	date > $(TARGET_DIR)/firmware_time
	echo "1" > $(TARGET_DIR)/etc/init.d/.hidden_new_features
	$(BUILD_DIR_BASE)/Host-encrypt-files.sh "$(BUILD_DIR_BASE)/deif_original.key" "$(TARGET_DIR)"
endef

define MkImageLzma
	mkimage -A arm -O linux -C lzma -T kernel -a 0x40908000 \
		-e 0x40908000 -n 'Linux-$(LINUX_VERSION)' \
		-d $(1) $(2)
endef

define Image/Build/Firmware
	# FIXME: removing this line will cause strange behaviour in the foreach loop below
	$(STAGING_DIR_HOST)/bin/mkdniimg \
		-B $(3) -v $(FW_VERSION) -r $(FW_REGION) -H $(HW_ID) \
		-i $(BIN_DIR)/$(IMG_PREFIX)$(2)-sysupgrade.bin \
		-o $(BIN_DIR)/$(4)-$(FW_VERSION)$(FW_REGION).img
endef

define Image/Build/r9000
	echo "Image/Build/r9000"
	dd if=$(LINUX_DIR)/arch/arm/boot/uImage of=$(KDIR)/vmlinux-$(2).uImage
	$(STAGING_DIR_HOST)/bin/r9000 \
		$(KDIR)/vmlinux-$(2).uImage \
		$(KDIR)/vmlinux-$(2).uImage.normal add_image_size
	dd if=$(KDIR)/root.$(2).$(1) of=$(KDIR)/root.$(2).$(1).final bs=2k conv=sync
	$(call MkImageLzma,$(KDIR)/root.$(2).$(1).final,$(KDIR)/squashfs-$(2).uImage)
	$(STAGING_DIR_HOST)/bin/r9000 \
		$(KDIR)/squashfs-$(2).uImage \
		$(KDIR)/squashfs-$(2).uImage.tmp
	cat $(KDIR)/vmlinux-$(2).uImage.normal > $(KDIR)/vmlinux-$(2).uImage.tmp
	$(STAGING_DIR_HOST)/../../tools/checksize $(KDIR)/vmlinux-$(2).uImage.tmp $(shell expr $(MAX_KERNEL_SIZE) - 64) $(shell expr $(MAX_KERNEL_SIZE) - 64 - 131072)
	dd if=$(KDIR)/vmlinux-$(2).uImage.tmp bs=$(shell expr $(MAX_KERNEL_SIZE) - 64) conv=sync of=$(KDIR)/vmlinux-$(2).uImage.final
	dd if=$(KDIR)/squashfs-$(2).uImage.tmp bs=64 count=1 >> $(KDIR)/vmlinux-$(2).uImage.final
	( \
		dd if=$(KDIR)/vmlinux-$(2).uImage.final bs=$(MAX_KERNEL_SIZE) conv=sync; \
		dd if=$(KDIR)/root.$(2).$(1).final bs=64k; \
	) > $(BIN_DIR)/$(IMG_PREFIX)$(2)-sysupgrade.bin
	$(STAGING_DIR_HOST)/../../tools/checksize $(BIN_DIR)/$(IMG_PREFIX)$(2)-sysupgrade.bin $(MAX_IMAGE_SIZE)
	$(call Image/Build/Firmware,$(1),$(2),$(2),$(2))
endef

define Image/BuildKernel
	$(CP) $(LINUX_DIR)/vmlinux $(BIN_DIR)/$(IMG_PREFIX)vmlinux.elf
	$(CP) $(LINUX_DIR)/arch/arm/boot/Image $(BIN_DIR)/$(IMG_PREFIX)vmlinux.bin
	dd if=$(LINUX_DIR)/arch/arm/boot/uImage of=$(BIN_DIR)/$(IMG_PREFIX)$(KERNEL)-uImage bs=2k conv=sync
endef

define Image/Build
	$(call Image/Build/$(1),$(1))
	mkdir -p $(BIN_DIR)
	dd if=$(KDIR)/root.$(2).$(1) of=$(BIN_DIR)/$(IMG_PREFIX)$(2)-$(1)-root.img bs=2k conv=sync
	$(call Image/Build/r9000,$(1),$(2))
endef

define Sysupgrade
	cat $(BIN_DIR)/$(IMG_PREFIX)$(KERNEL)-uImage \
	    $(BIN_DIR)/$(IMG_PREFIX)$(2)-$(1)-root.img > \
		$(BIN_DIR)/$(IMG_PREFIX)sysupgrade.bin
endef

$(eval $(call BuildImage))

My serial cable arrived today and i was able to make some progress.

I managed to boot the linux 5.4 kernel built with OpenWrt but it hanged in https://elixir.bootlin.com/linux/v5.4.99/source/arch/arm/mm/mmu.c#L1336. Good news is that the kernel early console works (early_printk) that‘s how i was able to find out where it stopped. I haven‘t patched anything in the kernel yet.

I created an OpenWrt branch for r9000 here https://github.com/egorenar/openwrt/tree/netgear-r9000.

How to open serial console:
sudo picocom -b115200 /dev/ttyUSB0

How to run TFTP server:

sudo ip addr add 192.168.1.10/24 dev enp4s0f0
sudo ip route add 0.0.0.0/0 via 192.168.1.1 dev enp4s0f0

sudo dnsmasq -d --port=0 --enable-tftp --tftp-no-blocksize --user=root --group=root \
             --tftp-root ~/Repositories/openwrt/bin/targets/alpine/generic/

How i boot OpenWrt uImage:

tftpboot $loadaddr_dt image-alpine-r9000.dtb
tftpboot $loadaddr openwrt-alpine-generic-netgear_r9000-initramfs-uImage
fdt addr $loadaddr_dt
setenv bootargs pci=pcie_bus_perf console=ttyS0,115200
bootm $loadaddr - $fdtaddr

I also tested uImage built with DDWRT and it boots fine with the DTB produced by OpenWRT.

I think we need to diff the DDWRT‘s kernel sources against vanilla ones 4.9. And check what was changed.

And i think first is important to boot with initramfs (no flash), and then add support for peripherals, step after step.

It is great that i‘m not the only one investigating this and to share information.

Regards

u-boot serial output
Annapurna Labs stage 2: stage2_eth3_ram_loader v1.65.1
Executing next!
Annapurna Labs stage 2: stage2.5_loader v1.65.1
SPD I2C Address:00000057
Executing next!

-----------------------------------------------------
Stage 3 version: 1.65.1
Commit ID: e88c9c4
CVOS commit ID: d32367c
HAL commit ID: 8b8f7b5
Build date: May 20 2015 19:57:35
-----------------------------------------------------

EEPROM Revision ID = 38
Device ID = a314
Device Info: AL31400-1700
Loading DT to 00100000 (17996 bytes)...
Board config ID: alpine_db (hw29765235p0p512p1024p4x4p4x4)
Loading application to 00100000 (450240 bytes)...
Executing application...


U-Boot 2015.01-gd836bbb (Jul 22 2016 - 13:32:00)

U-boot dni1 V1.8 for DNI HW ID: 29765235 NOR flash 0MB; NAND flash 512MB; RAM 1024MB; 1st Radio 4x4; 2nd Radio 4x4
I2C:   ready
DRAM:  1 GiB
WARNING: Caches not enabled

   _
  /_\  _ __  _ __   __ _ _ __  _   _ _ __ _ __   __ _
 //_\\| '_ \| '_ \ / _` | '_ \| | | | '__| '_ \ / _` |
/  _  \ | | | | | | (_| | |_) | |_| | |  | | | | (_| |
\_/ \_/_| |_|_| |_|\__,_| .__/ \__,_|_|  |_| |_|\__,_|
   __       _           |_|
  / /  __ _| |__  ___
 / /  / _` | '_ \/ __|
/ /__| (_| | |_) \__ \
\____/\__,_|_.__/|___/
               ___             _
 /\ /\        / __\ ___   ___ | |_
/ / \ \_____ /__\/// _ \ / _ \| __|
\ \_/ /_____/ \/  \ (_) | (_) | |_
 \___/      \_____/\___/ \___/ \__|

Board config ID: alpine_db (hw29765235p0p512p1024p4x4p4x4)
NAND:  512 MiB
*** Warning - bad CRC, using default environment

  00:00.0     - 1c36:0002 - Network controller
  00:01.0     - 1c36:0001 - Network controller
  00:03.0     - 1c36:0001 - Network controller
  00:04.0     - 1c36:0011 - Cryptographic device
  00:05.0     - 1c36:0021 - Base system peripheral
PCIE_0: Link up. Speed 5GT/s Width x1
  01:00.0     - 1b21:1182 - Bridge device
PCIE_1: Link up. Speed 5GT/s Width x1
  02:00.0     - 1b21:1142 - Serial bus controller
PCIE_2: Link up. Speed 5GT/s Width x1
  03:00.0     - 1ae9:0310 - Network controller
In:    serial
Out:   serial
Err:   serial
eeprom_per_device_init: no valid information found!
eeprom_per_device_init#104: Try reading from NAND flash
eeprom_per_device_init#116: Reading from NAND flash OK
Net:   (QCA8337) Check Status Port 3 status is 0x0
al_eth0, al_eth1 [PRIME], al_eth3
Warning: al_eth3 using MAC address from net device

Hit any key to stop autoboot:  0
u-boot env
ALPINE_DB> env print
arch=arm
autoload=n
baudrate=115200
board=alpine_hw29765235p0p512p1024p4x4p4x4_32_db
board_name=alpine_hw29765235p0p512p1024p4x4p4x4_32_db
boot_instance_active=0
boot_instance_non_active=1
bootargshd=run rootargshd; setenv bootargs $rootargs pci=pcie_bus_perf console=ttyS0,115200 $bootargsextra; printenv bootargs
bootargsnand=run rootargsnand; setenv bootargs $rootargs pci=pcie_bus_perf console=ttyS0,115200 $bootargsextra; printenv bootargs
bootargsnfs=run rootargsnfs; setenv bootargs $rootargs pci=pcie_bus_perf console=ttyS0,115200 $bootargsextra; printenv bootargs
bootcmd=nmrp;run check_dni_image;run bootargsnand;qca8337_init_one; ledtoggle;sleep 1;run bootnand
bootdelay=2
bootext4=lcd_print "Loading OS...";scsi init; ext4load scsi ${ext4dev}:${ext4part} $loadaddr ${ext4dir}${dt_filename};if test $? -ne 0; then run fail; exit; fi;if test ${dt_is_from_toc} != 1; then; else flash_contents_obj_read_mem $loadaddr_dt $loadaddr;if test $? -ne 0; then run fail; exit; fi;fi;ext4load scsi ${ext4dev}:${ext4part} $loadaddr ${ext4dir}uImage;if test $? -ne 0; then run fail; exit; fi;fdt addr $loadaddr_dt;bootm $loadaddr - $fdtaddr;run fail; exit
bootnand=lcd_print "Loading OS...";nand set_partition_offset $nand_pt_addr_kernel;nand read $loadaddr $nand_pt_addr_kernel 4;setenvmem filesize $loadaddr;incenv filesize 4;nand read $loadaddr $nand_pt_addr_kernel $filesize;ledtoggle;nand set_partition_offset $nand_pt_addr_al_boot;bootm $loadaddr_payload - $fdtaddr;lcd_print Failed!
bootnandmulti=run kernel_select;if test $kernel_selected -ne 0; then run bootnand; fi
boottftp=lcd_print "Loading OS...";tftpboot $loadaddr ${tftpdir}${dt_filename};if test $? -ne 0; then run fail; exit; fi;if test ${dt_is_from_toc} != 1; then; else flash_contents_obj_read_mem $loadaddr_dt $loadaddr;if test $? -ne 0; then run fail; exit; fi;fi;tftpboot $loadaddr ${tftpdir}uImage;if test $? -ne 0; then run fail; exit; fi;fdt addr $loadaddr_dt;bootm $loadaddr - $fdtaddr;run fail; exit
bootupd=is_nand_boot; if test $? -eq 0; then run bootupdspi; else; run bootupdnand; fi
bootupdnand=lcd_print "Updating al-boot" "to NAND"; tftpboot $loadaddr ${tftpdir}boot.img; if test $? -ne 0; then run fail; exit; fi;nand set_partition_offset $nand_pt_addr_al_boot;nand erase.spread $nand_pt_addr_al_boot $filesize; nand write $loadaddr $nand_pt_addr_al_boot $filesize; lcd_print "Done"
bootupdnandy=lcd_print "Updating al-boot" "to NAND"; echo >> Use YModem to upload the boot image binary...;loady $loadaddr;if test $? -ne 0; then run fail; exit; fi;nand set_partition_offset $nand_pt_addr_al_boot;nand erase.spread $nand_pt_addr_al_boot $filesize; nand write $loadaddr $nand_pt_addr_al_boot $filesize; lcd_print "Done"
bootupdspi=lcd_print "Updating al-boot" "to SPI"; tftpboot ${loadaddr} ${tftpdir}boot.img; if test $? -ne 0; then run fail; exit; fi;sf probe; sf erase 0 +${filesize}; sf write ${loadaddr} 0 ${filesize}; echo bootupd done;echo Notice: Changes in default environment variables will only take effect once the;echo environment variables are deleted from flash using the 'delenv' script;lcd_print "Done"
bootupdspiy=lcd_print "Updating al-boot" "to SPI"; echo >> Use YModem to upload the boot image binary...;loady ${loadaddr};if test $? -ne 0; then run fail; exit; fi;sf probe; sf erase 0 +${filesize}; sf write ${loadaddr} 0 ${filesize}; echo bootupd done;echo Notice: Changes in default environment variables will only take effect once the;echo environment variables are deleted from flash using the 'delenv' script;lcd_print "Done"
bootupdy=is_nand_boot; if test $? -eq 0; then run bootupdspiy;else; run bootupdnandy; fi
check_dni_image=lcd_print "Loading DNI firmware for checking...";nand set_partition_offset $nand_pt_addr_kernel;ledtoggle;loadn_dniimg 0 $nand_pt_addr_kernel $loadaddr;ledtoggle;calc_rootaddr $nand_pt_addr_kernel $loadaddr;nand set_partition_offset $nand_pt_addr_al_boot;setenv kernel_addr_for_fw_checking $loadaddr;incenv kernel_addr_for_fw_checking 4;iminfo $kernel_addr_for_fw_checking;if test $? -ne 0; then echo "linux checksum error";fw_recovery; fi;ledtoggle;iminfo $rootfs_addr_for_fw_checking;if test $? -ne 0; then echo "rootfs checksum error";fw_recovery; fi;ledtoggle;lcd_print Failed!
cpu=armv7
cvos_tags=0x01000000
cvos_tags_seed_a=0x01000004
cvos_tags_seed_b=0x01000008
cvos_tags_validate=mw.l ${cvos_tags} 0xcf05cf05
delenv=is_nand_boot; if test $? -eq 0; then run delenvspi; else; run delenvnand; fi
delenvnand=lcd_print "Deleting env..."; nand erase ${env_offset} 2000; if test -n ${env_offset_redund}; then nand erase ${env_offset_redund} 2000; fi;lcd_print "Done"
delenvspi=lcd_print "Deleting env..."; sf probe; sf erase ${env_offset} +2000;if test -n ${env_offset_redund}; then sf erase ${env_offset_redund} +2000;fi;lcd_print "Done"
dt_filename=dt.img
dt_is_from_toc=1
dt_location=80000
dtupd=is_nand_boot; if test $? -eq 0; then run dtupdspi; else; run dtupdnand; fi
dtupdnand=lcd_print "Updating DT" "to NAND"; tftpboot $loadaddr_dt ${tftpdir}${dt_filename};if test $? -ne 0; then run fail; exit; fi;if test ${dt_is_from_toc} != 1; then; else flash_contents_obj_read_mem $loadaddr $loadaddr_dt;if test $? -ne 0; then run fail; exit; fi;fi;nand set_partition_offset $nand_pt_addr_al_boot;nand erase.spread ${dt_location} 10000; nand write ${loadaddr_dt} ${dt_location} 10000; lcd_print "Done"
dtupdnandy=lcd_print "Updating DT" "to NAND"; echo >> Use YModem to upload the device tree binary...;loady $loadaddr_dt;if test $? -ne 0; then run fail; exit; fi;if test ${dt_is_from_toc} != 1; then; else flash_contents_obj_read_mem $loadaddr $loadaddr_dt;if test $? -ne 0; then run fail; exit; fi;fi;nand set_partition_offset $nand_pt_addr_al_boot;nand erase.spread ${dt_location} 10000; nand write ${loadaddr_dt} ${dt_location} 10000; lcd_print "Done"
dtupdspi=lcd_print "Updating DT" "to SPI"; tftpboot $loadaddr_dt ${tftpdir}${dt_filename};if test $? -ne 0; then run fail; exit; fi;if test ${dt_is_from_toc} != 1; then; else flash_contents_obj_read_mem $loadaddr $loadaddr_dt;if test $? -ne 0; then run fail; exit; fi;fi;sf probe; sf erase ${dt_location} +${filesize}; sf write ${loadaddr_dt} ${dt_location} ${filesize};echo dtupd done;lcd_print "Done"
dtupdspiy=lcd_print "Updating DT" "to SPI"; echo >> Use YModem to upload the device tree binary...;loady $loadaddr_dt;if test $? -ne 0; then run fail; exit; fi;if test ${dt_is_from_toc} != 1; then; else flash_contents_obj_read_mem $loadaddr $loadaddr_dt;if test $? -ne 0; then run fail; exit; fi;fi;sf probe; sf erase ${dt_location} +${filesize}; sf write ${loadaddr_dt} ${dt_location} ${filesize}; echo dtupd done;lcd_print "Done"
dtupdy=is_nand_boot; if test $? -eq 0; then run dtupdspiy; else; run dtupdnandy; fi
eepromupd=confirm_msg "Perform EEPROM update? [y/n] ";if test $? -ne 0; then exit; fi;tftpboot ${tftpdir}eeprom.bin;if test $? -ne 0; then exit; fi;i2c probe ${pld_i2c_addr};if test $? -ne 0; then exit; fi;i2c write $fileaddr ${pld_i2c_addr} 0.2 $filesize;if test $? -ne 0; then exit;fi;echo eepromupd done
eepromupdy=confirm_msg "Perform EEPROM update? [y/n] ";if test $? -ne 0; then exit; fi;echo >> Use YModem to upload the EEPROM binary...;loady $loadaddr;if test $? -ne 0; then exit; fi;i2c probe ${pld_i2c_addr};if test $? -ne 0; then exit; fi;i2c write $loadaddr ${pld_i2c_addr} 0.2 $filesize;if test $? -ne 0; then exit;fi;echo eepromupdy done
env_offset=1e0000
env_offset_redund=200000
eth1addr=38:94:ed:2c:a4:ff
eth3addr=52:12:d3:7f:72:b1
ethact=al_eth1
ethaddr=38:94:ed:2c:a5:00
ethprime=al_eth1
ext4dev=0
ext4dir=boot/
ext4part=1
fail=echo Failed!; lcd_print "Failed!"
fdtaddr=3b73008
fwupd=tftpboot ${tftpdir}uboot_script_fw_update.bin;source ${loadaddr}
hdroot=/dev/sda1
iocc_force=1
iocc_force_val=1
ipaddr=192.168.1.1
kernel_rename_1=editenv nand_pt_desc_kernel_1;saveenv
kernel_rename_2=editenv nand_pt_desc_kernel_2;saveenv
kernel_select=setenv kernel_selected 0;setenv bootmenu_0 ${nand_pt_desc_kernel_1}=run kernel_select_1;setenv bootmenu_1 ${nand_pt_desc_kernel_2}=run kernel_select_2;bootmenu
kernel_select_1=setenv nand_pt_addr_kernel ${nand_pt_addr_kernel_1};setenv kernel_selected 1
kernel_select_2=setenv nand_pt_desc_kernel ${nand_pt_desc_kernel_2};setenv nand_pt_addr_kernel ${nand_pt_addr_kernel_2};setenv nand_pt_desc_kernel_2 ${nand_pt_desc_kernel_1};setenv nand_pt_addr_kernel_2 ${nand_pt_addr_kernel_1};setenv nand_pt_desc_kernel_1 ${nand_pt_desc_kernel};setenv nand_pt_addr_kernel_1 ${nand_pt_addr_kernel};saveenv;setenv kernel_selected 2
kernelupd=lcd_print "Updating kernel...";tftpboot $loadaddr_payload ${tftpdir}uImage;if test $? -ne 0; then run fail; exit; fi;nand set_partition_offset $nand_pt_addr_kernel;mw.l $loadaddr $filesize;incenv filesize 4;nand erase.spread $nand_pt_addr_kernel $filesize;nand write $loadaddr $nand_pt_addr_kernel $filesize;nand set_partition_offset $nand_pt_addr_al_boot;echo kernelupd done;lcd_print "Done"
loadaddr=0x08000000
loadaddr_dt=0x07000000
loadaddr_payload=0x08000004
loadaddr_rootfs_chk=0x07000000
nand_pt_addr_al_boot=0x0
nand_pt_addr_fs=0x01000000
nand_pt_addr_kernel=0x00580000
nand_pt_addr_kernel_1=0x00400000
nand_pt_addr_kernel_2=0x00a00000
nand_pt_desc_kernel_1=Test kernel A
nand_pt_desc_kernel_2=Test kernel B
nand_pt_size_fs=0x1f000000
nand_pt_size_kernel=0x00c00000
netmask=255.255.255.0
nfsrootdir=/srv/root/
pld_i2c_addr=57
rootargshd=setenv rootargs root=${hdroot} rw
rootargsnand=setenv rootargs root=ubi0:root rootfstype=ubifs ubi.mtd=3
rootargsnfs=setenv rootargs root=/dev/nfs rw nfsroot=${serverip}:${nfsrootdir},tcp,nolock rw ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${board_name}:eth1:none
rootfsupd=lcd_print "Updating rootfs...";tftpboot $loadaddr_rootfs_chk ${tftpdir}rootfs.ubi.md5;if test $? -ne 0; then run fail; exit; fi;tftpboot $loadaddr ${tftpdir}rootfs.ubi;if test $? -ne 0; then run fail; exit; fi;md5sum -v $loadaddr $filesize *$loadaddr_rootfs_chk;if test $? -ne 0; then run fail; exit; fi;nand set_partition_offset $nand_pt_addr_fs;nand erase.spread $nand_pt_addr_fs $nand_pt_size_fs;nand write $loadaddr $nand_pt_addr_fs $filesize;nand set_partition_offset $nand_pt_addr_al_boot;echo rootfsupd done;lcd_print "Done"
serverip=192.168.1.10
skip_eth_halt=0
soc=alpine_hw29765235p0p512p1024p4x4p4x4
test=echo this is a test!
vendor=annapurna-labs

Environment size: 10461/16379 bytes

My approach to tftp on the r9000 was wayyy off.. This helps!

To be able to see early debug messages displayed during kernel 5.4 boot, enable CONFIG_DEBUG_LL and choose CONFIG_DEBUG_ALPINE_UART0. Then you can use early_print to output extra messages or see already present ones.

Some more progress after enabling earlycon earlyprintk memblock=debug.

## Booting kernel from Legacy Image at 08000000 ...
   Image Name:   ARM OpenWrt Linux-5.4.99
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    7385564 Bytes = 7 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 07000000
   Booting using the fdt blob at 0x7000000
   Loading Kernel Image ... OK
   reserving fdt memory region: addr=0 size=100000
   Loading Device Tree to 03b58000, end 03b5f64b ... OK
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I/O CC forced to 1!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.4.99 (egorenar@voidlinux) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r15888+1-f79f496ed6)) #0 SMP Tue Feb 23 20:40:56 2021
[    0.000000] CPU: ARMv7 Processor [412fc0f4] revision 4 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
[    0.000000] OF: fdt: Machine model: Annapurna Labs Alpine Dev Board
[    0.000000] Malformed early option 'earlycon'
[    0.000000] printk: bootconsole [earlycon0] enabled
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] memblock_reserve: [0x00300000-0x0106f737] arm_memblock_init+0x30/0x158
[    0.000000] memblock_reserve: [0x00204000-0x00207fff] arm_memblock_init+0x108/0x158
[    0.000000] memblock_reserve: [0x0173d2d0-0x0174191b] arm_memblock_init+0x11c/0x158
[    0.000000] memblock_reserve: [0x00000000-0x000fffff] early_init_fdt_scan_reserved_mem+0x58/0x78
[    0.000000] MEMBLOCK configuration:
[    0.000000]  memory size = 0x00000000 reserved size = 0x00e77d84
[    0.000000]  memory.cnt  = 0x1
[    0.000000]  memory[0x0]     [0x00000000-0xffffffff], 0x00000000 bytes flags: 0x0
[    0.000000]  reserved.cnt  = 0x4
[    0.000000]  reserved[0x0]   [0x00000000-0x000fffff], 0x00100000 bytes flags: 0x0
[    0.000000]  reserved[0x1]   [0x00204000-0x00207fff], 0x00004000 bytes flags: 0x0
[    0.000000]  reserved[0x2]   [0x00300000-0x0106f737], 0x00d6f738 bytes flags: 0x0
[    0.000000]  reserved[0x3]   [0x0173d2d0-0x0174191b], 0x0000464c bytes flags: 0x0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 early_alloc+0x24/0x50
[    0.000000] Kernel panic - not syncing: early_alloc: Failed to allocate 8192 bytes align=0x2000
[    0.000000] Rebooting in 1 seconds..
[    0.000000] Reboot failed -- System halted

early_alloc() fails in https://elixir.bootlin.com/linux/v5.4.99/source/arch/arm/mm/mmu.c#L1345

Hmm, memblock says memory size = 0x00000000. That means we have no memory :slight_smile: That's why early_alloc fails. The problem is probably u-boot not passing the correct memory to the kernel.

If i add mem=1G to the kernel command-line then kernel is able to make more progress. So, we need to find out how the correct memory size is passed from u-boot to the kernel and fix it. Now i'm able to boot into initramfs :grin:

## Booting kernel from Legacy Image at 08000000 ...
   Image Name:   ARM OpenWrt Linux-5.4.99
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    7385708 Bytes = 7 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 07000000
   Booting using the fdt blob at 0x7000000
   Loading Kernel Image ... OK
   reserving fdt memory region: addr=0 size=100000
   Loading Device Tree to 03b58000, end 03b5f64b ... OK
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I/O CC forced to 1!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.4.99 (egorenar@imac5k-voidlinux) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r15888+1-f79f496ed6)) #0 SMP Tue Feb 23 20:40:56 2021
[    0.000000] CPU: ARMv7 Processor [412fc0f4] revision 4 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
[    0.000000] OF: fdt: Machine model: Annapurna Labs Alpine Dev Board
[    0.000000] Malformed early option 'earlycon'
[    0.000000] printk: bootconsole [earlycon0] enabled
[    0.000000] memblock_remove: [0x00000000-0xffffffff] early_mem+0x48/0xb4
[    0.000000] memblock_add: [0x00000000-0x3fffffff] arm_add_memory+0x154/0x17c
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] memblock_reserve: [0x00300000-0x0106f737] arm_memblock_init+0x30/0x158
[    0.000000] memblock_reserve: [0x00204000-0x00207fff] arm_memblock_init+0x108/0x158
[    0.000000] memblock_reserve: [0x0173d360-0x017419ab] arm_memblock_init+0x11c/0x158
[    0.000000] memblock_reserve: [0x00000000-0x000fffff] early_init_fdt_scan_reserved_mem+0x58/0x78
[    0.000000] MEMBLOCK configuration:
[    0.000000]  memory size = 0x40000000 reserved size = 0x00e77d84
[    0.000000]  memory.cnt  = 0x1
[    0.000000]  memory[0x0]     [0x00000000-0x3fffffff], 0x40000000 bytes flags: 0x0
[    0.000000]  reserved.cnt  = 0x4
[    0.000000]  reserved[0x0]   [0x00000000-0x000fffff], 0x00100000 bytes flags: 0x0
[    0.000000]  reserved[0x1]   [0x00204000-0x00207fff], 0x00004000 bytes flags: 0x0
[    0.000000]  reserved[0x2]   [0x00300000-0x0106f737], 0x00d6f738 bytes flags: 0x0
[    0.000000]  reserved[0x3]   [0x0173d360-0x017419ab], 0x0000464c bytes flags: 0x0
[    0.000000] memblock_alloc_try_nid: 8192 bytes align=0x2000 nid=-1 from=0x00000000 max_addr=0x00000000 early_alloc+0x24/0x50
[    0.000000] memblock_reserve: [0x2fffe000-0x2fffffff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 early_alloc+0x24/0x50
[    0.000000] memblock_reserve: [0x2fffd000-0x2fffdfff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 40 bytes align=0x4 nid=-1 from=0x00000000 max_addr=0x00000000 iotable_init+0x38/0xf0
[    0.000000] memblock_reserve: [0x2fffcfd8-0x2fffcfff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 early_alloc+0x24/0x50
[    0.000000] memblock_reserve: [0x2fffb000-0x2fffbfff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 40 bytes align=0x4 nid=-1 from=0x00000000 max_addr=0x00000000 vm_reserve_area_early+0x30/0x74
[    0.000000] memblock_reserve: [0x2fffcfb0-0x2fffcfd7] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 early_alloc+0x24/0x50
[    0.000000] memblock_reserve: [0x2fffa000-0x2fffafff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 early_alloc+0x24/0x50
[    0.000000] memblock_reserve: [0x2fff9000-0x2fff9fff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 early_alloc+0x24/0x50
[    0.000000] memblock_reserve: [0x2fff8000-0x2fff8fff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 9437184 bytes align=0x40 nid=0 from=0x00000000 max_addr=0x00000000 alloc_node_mem_map.constprop.17+0x74/0xd8
[    0.000000] memblock_reserve: [0x2f6f8000-0x2fff7fff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 96 bytes align=0x40 nid=0 from=0x00000000 max_addr=0x00000000 setup_usemap.constprop.21+0x60/0x8c
[    0.000000] memblock_reserve: [0x2fffcf40-0x2fffcf9f] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 32 bytes align=0x40 nid=0 from=0x00000000 max_addr=0x00000000 setup_usemap.constprop.21+0x60/0x8c
[    0.000000] memblock_reserve: [0x2fffcf00-0x2fffcf1f] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 32 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 setup_arch+0x7f4/0xae8
[    0.000000] memblock_reserve: [0x2fffcec0-0x2fffcedf] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 56944 bytes align=0x4 nid=-1 from=0x00000000 max_addr=0x00000000 early_init_dt_alloc_memory_arch+0x30/0x64
[    0.000000] memblock_reserve: [0x2f6ea190-0x2f6f7fff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] ------------[ cut here ]------------
[    0.000000] WARNING: CPU: 0 PID: 0 at arch/arm/kernel/devtree.c:150 arm_dt_init_cpu_maps+0x154/0x1fc
[    0.000000] DT /cpu 3 nodes greater than max cores 2, capping them
[    0.000000] Modules linked in:
[    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.4.99 #0
[    0.000000] Hardware name: Generic DT based system
[    0.000000] [<c030ec64>] (unwind_backtrace) from [<c030b068>] (show_stack+0x10/0x14)
[    0.000000] [<c030b068>] (show_stack) from [<c087f4d8>] (dump_stack+0x94/0xa8)
[    0.000000] [<c087f4d8>] (dump_stack) from [<c032a02c>] (__warn+0xbc/0xd8)
[    0.000000] [<c032a02c>] (__warn) from [<c032a0cc>] (warn_slowpath_fmt+0x84/0x94)
[    0.000000] [<c032a0cc>] (warn_slowpath_fmt) from [<c0b043dc>] (arm_dt_init_cpu_maps+0x154/0x1fc)
[    0.000000] [<c0b043dc>] (arm_dt_init_cpu_maps) from [<c0b0381c>] (setup_arch+0x934/0xae8)
[    0.000000] [<c0b0381c>] (setup_arch) from [<c0b009c0>] (start_kernel+0x54/0x49c)
[    0.000000] [<c0b009c0>] (start_kernel) from [<00000000>] (0x0)
[    0.000000] random: get_random_bytes called from print_oops_end_marker+0x24/0x4c with crng_init=0
[    0.000000] ---[ end trace 0000000000000000 ]---
[    0.000000] memblock_alloc_try_nid: 75 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc.constprop.2+0x20/0x28
[    0.000000] memblock_reserve: [0x2fffce40-0x2fffce8a] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 75 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc.constprop.2+0x20/0x28
[    0.000000] memblock_reserve: [0x2fffcdc0-0x2fffce0a] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 75 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc.constprop.2+0x20/0x28
[    0.000000] memblock_reserve: [0x2fffcd40-0x2fffcd8a] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2f6e9000-0x2f6e9fff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 4096 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2f6e8000-0x2f6e8fff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 122880 bytes align=0x1000 nid=-1 from=0x3fffffff max_addr=0x00000000 pcpu_dfl_fc_alloc+0x24/0x2c
[    0.000000] memblock_reserve: [0x2f6ca000-0x2f6e7fff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000]    memblock_free: [0x2f6d9000-0x2f6d8fff] pcpu_embed_first_chunk+0x5bc/0x6b0
[    0.000000]    memblock_free: [0x2f6e8000-0x2f6e7fff] pcpu_embed_first_chunk+0x5bc/0x6b0
[    0.000000] percpu: Embedded 15 pages/cpu s30156 r8192 d23092 u61440
[    0.000000] memblock_alloc_try_nid: 4 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2fffcd00-0x2fffcd03] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 4 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2fffccc0-0x2fffccc3] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 8 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2fffcc80-0x2fffcc87] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 8 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2fffcc40-0x2fffcc47] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 120 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2fffcbc0-0x2fffcc37] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 92 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2fffcb40-0x2fffcb9b] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 384 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2fffc9c0-0x2fffcb3f] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 388 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2fffc800-0x2fffc983] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 96 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2fffc780-0x2fffc7df] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 92 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2fffc700-0x2fffc75b] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 768 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2fffc400-0x2fffc6ff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 772 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2fffc0c0-0x2fffc3c3] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] memblock_alloc_try_nid: 192 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 memblock_alloc+0x1c/0x24
[    0.000000] memblock_reserve: [0x2fffc000-0x2fffc0bf] memblock_alloc_range_nid+0xd8/0x140
[    0.000000]    memblock_free: [0x2f6e9000-0x2f6e9fff] pcpu_embed_first_chunk+0x68c/0x6b0
[    0.000000]    memblock_free: [0x2f6e8000-0x2f6e8fff] pcpu_embed_first_chunk+0x6a0/0x6b0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 260416
[    0.000000] Kernel command line: console=ttyconsole=ttyS0,115200 earlycon earlyprintk memblock=debug mem=1G
[    0.000000] memblock_alloc_try_nid: 524288 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_large_system_hash+0x1a4/0x2cc
[    0.000000] memblock_reserve: [0x2f64a000-0x2f6c9fff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
[    0.000000] memblock_alloc_try_nid: 262144 bytes align=0x40 nid=-1 from=0x00000000 max_addr=0x00000000 alloc_large_system_hash+0x1a4/0x2cc
[    0.000000] memblock_reserve: [0x2f60a000-0x2f649fff] memblock_alloc_range_nid+0xd8/0x140
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 1023564K/1048576K available (5739K kernel code, 215K rwdata, 1572K rodata, 5120K init, 229K bss, 25012K reserved, 0K cma-reserved, 262144K highmem)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] GIC: Using split EOI/Deactivate mode
[    0.000000] arch_timer: cp15 timer(s) running at 50.00MHz (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0xb8812736b, max_idle_ns: 440795202655 ns
[    0.000003] sched_clock: 56 bits at 50MHz, resolution 20ns, wraps every 4398046511100ns
[    0.007986] Switching to timer-based delay loop, resolution 20ns
[    0.014081] Calibrating delay loop (skipped), value calculated using timer frequency.. 100.00 BogoMIPS (lpj=500000)
[    0.024497] pid_max: default: 32768 minimum: 301
[    0.029164] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.036463] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.044539] CPU: Testing write buffer coherency: ok
[    0.049426] CPU0: Spectre v2: firmware did not set auxiliary control register IBE bit, system vulnerable
[    0.059218] Setting up static identity map for 0x300000 - 0x300060
[    0.065440] rcu: Hierarchical SRCU implementation.
[    0.070364] smp: Bringing up secondary CPUs ...
[    0.075088] smp: Brought up 1 node, 1 CPU
[    0.079100] SMP: Total of 1 processors activated (100.00 BogoMIPS).
[    0.085349] CPU: All CPU(s) started in HYP mode.
[    0.089959] CPU: Virtualization extensions available.
[    0.097311] VFP support v0.3: implementor 41 architecture 4 part 30 variant f rev 0
[    0.105005] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.114810] futex hash table entries: 512 (order: 3, 32768 bytes, linear)
[    0.121634] pinctrl core: initialized pinctrl subsystem
[    0.127230] NET: Registered protocol family 16
[    0.131777] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.138995] cpuidle: using governor ladder
[    0.143088] cpuidle: using governor menu
[    0.147083] Serial: AMBA PL011 UART driver
[    0.152124] OF: amba_device_add() failed (-2) for /soc/timer1
[    0.162303] cryptd: max_cpu_qlen set to 1000
[    0.167986] usbcore: registered new interface driver usbfs
[    0.173477] usbcore: registered new interface driver hub
[    0.178799] usbcore: registered new device driver usb
[    0.184060] pca953x 0-0020: 0-0020 supply vcc not found, using dummy regulator
[    0.191307] pca953x 0-0020: using no AI
[    0.195530] pps_core: LinuxPPS API ver. 1 registered
[    0.200480] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.209607] PTP clock support registered
[    0.213659] workqueue: max_active 576 requested for napi_workq is out of range, clamping between 1 and 512
[    0.223645] clocksource: Switched to clocksource arch_sys_counter
[    0.229972] thermal_sys: Registered thermal governor 'step_wise'
[    0.230078] NET: Registered protocol family 2
[    0.240642] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
[    0.248990] TCP established hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    0.256750] TCP bind hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.263940] TCP: Hash tables configured (established 8192 bind 8192)
[    0.270314] UDP hash table entries: 512 (order: 2, 16384 bytes, linear)
[    0.276932] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)
[    0.284045] NET: Registered protocol family 1
[    0.288401] PCI: CLS 0 bytes, default 64
[    0.440163] workingset: timestamp_bits=14 max_order=18 bucket_order=4
[    0.448854] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.454681] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.478334] bounce: pool size: 64 pages
[    0.482529] pl061_gpio fd887000.gpio0: PL061 GPIO chip registered
[    0.488716] pl061_gpio fd888000.gpio1: PL061 GPIO chip registered
[    0.494891] pl061_gpio fd889000.gpio2: PL061 GPIO chip registered
[    0.501061] pl061_gpio fd88a000.gpio3: PL061 GPIO chip registered
[    0.507237] pl061_gpio fd88b000.gpio4: PL061 GPIO chip registered
[    0.513402] pl061_gpio fd897000.gpio5: PL061 GPIO chip registered
[    0.519914] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    0.526587] fd883000.uart0: ttyS0 at MMIO 0xfd883000 (irq = 40, base_baud = 23437500) is a 16550A
[    0.535595] fd884000.uart1: ttyS1 at MMIO 0xfd884000 (irq = 41, base_baud = 23437500) is a 16550A
[    0.546240] loop: module loaded
[    0.549731] libphy: Fixed MDIO Bus: probed
[    0.553930] i2c /dev entries driver
[    0.557625] sp805-wdt fd88c000.wdt0: registration successful
[    0.563458] sdhci: Secure Digital Host Controller Interface driver
[    0.569629] sdhci: Copyright(c) Pierre Ossman
[    0.573978] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.580021] NET: Registered protocol family 10
[    0.584850] Segment Routing with IPv6
[    0.588533] NET: Registered protocol family 17
[    0.593033] 8021q: 802.1Q VLAN Support v1.8
[    0.597253] Registering SWP/SWPB emulation handler
[    0.603860] hctosys: unable to open rtc device (rtc0)
[    0.608955] Warning: unable to open an initial console.
[    0.615825] Freeing unused kernel memory: 5120K
[    0.623761] Run /init as init process
[    0.744539] init: Console is alive
[    0.747995] init: - watchdog -
[    0.755270] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    0.765503] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.776319] SCSI subsystem initialized
[    0.785347] ehci-fsl: Freescale EHCI Host controller driver
[    0.793248] ehci-platform: EHCI generic platform driver
[    0.807277] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.815815] ohci-platform: OHCI generic platform driver
[    0.828071] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    0.853729] init: - preinit -
[    0.900624] random: jshn: uninitialized urandom read (4 bytes read)
[    0.910816] random: jshn: uninitialized urandom read (4 bytes read)
[    2.969104] procd: - early -
[    2.971998] procd: - watchdog -
[    3.493667] procd: - watchdog -
[    3.496848] procd: failed to set stdio: No such device
[    3.502016] procd: - ubus -
[    3.506621] random: ubusd: uninitialized urandom read (4 bytes read)
[    3.563775] random: ubusd: uninitialized urandom read (4 bytes read)
[    3.570217] random: ubusd: uninitialized urandom read (4 bytes read)
[    3.577464] procd: - init -
[    3.678563] urngd: v1.0.2 started.
[    3.717001] random: crng init done
[    3.720394] random: 5 urandom warning(s) missed due to ratelimiting
[    3.736409] kmodloader: loading kernel modules from /etc/modules.d/*
[    3.768341] Loading modules backported from Linux version v5.10.16-0-gde53befa79cf
[    3.775913] Backport generated by backports.git v5.10.16-1-0-g21d2a1d2
[    3.806611] xt_time: kernel timezone is -0000
[    3.869010] PPP generic driver version 2.4.2
[    3.883873] NET: Registered protocol family 24
[    3.940182] kmodloader: done loading kernel modules from /etc/modules.d/*

Next steps would be:

  • Fix passing of memory size from u-boot to kernel
  • Start porting device drivers (console first, then probably pci)
2 Likes

I think i know now why the kernel is not given the correct memory size by u-boot. It is because i append the DTB to zImage and the kernel ignores the DTB passed by u-boot. We have to disable CONFIG_ARM_APPENDED_DTB in the kernel config. See https://elixir.bootlin.com/linux/v5.4.99/source/arch/arm/boot/compressed/head.S#L305 and https://elixir.bootlin.com/linux/v5.4.99/source/arch/arm/boot/compressed/head.S#L389. If CONFIG_ARM_APPENDED_DTB is enabled then the decompressor will override the pointer to the DTB passed by u-boot in register r2 by the address to the DTB appended to the kernel image :wink: And the appended DTB of course contains all zeros in the memory node.

2 Likes

Nice one! Looks like you have smp and dma working without messing with the gpl driver stack?

Having some trouble reproducing results here though. Verified kernel configuration against the latest commit and it builds successfully but still stuck with no output.

ALPINE_DB> tftpboot $loadaddr
*** Warning: no boot file name; using 'C0A80101.img'
Using al_eth1 device
TFTP from server 192.168.1.10; our IP address is 192.168.1.1
Filename 'C0A80101.img'.
Load address: 0x8000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ##########################
         3.2 MiB/s
done
Bytes transferred = 5141820 (4e753c hex)
ALPINE_DB> tftpboot $loadaddr_dt alpine-r9000.dtb
Using al_eth1 device
TFTP from server 192.168.1.10; our IP address is 192.168.1.1
Filename 'alpine-r9000.dtb'.
Load address: 0x7000000
Loading: ##
         2.1 MiB/s
done
Bytes transferred = 17996 (464c hex)
ALPINE_DB> fdt addr $loadaddr_dt
ALPINE_DB> setenv bootargs earlycon earlyprintk memblock=debug pci=pcie_bus_perf console=ttyS0,115200 mem=1G
ALPINE_DB> bootm $loadaddr - $fdtaddr
## Booting kernel from Legacy Image at 08000000 ...
   Image Name:   ARM OpenWrt Linux-5.4.99
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    5141756 Bytes = 4.9 MiB
   Load Address: 42208000
   Entry Point:  42208000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 07000000
   Booting using the fdt blob at 0x7000000
   Loading Kernel Image ... OK
   reserving fdt memory region: addr=0 size=100000
   Loading Device Tree to 03b58000, end 03b5f64b ... OK
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I/O CC forced to 1!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Starting kernel ...

I see that you are using a different load address: 42208000. I'm using 8000. But i'm not sure this is the reason. Also set the kernel command-line in the kernel config and add all debug parameters to see early printk messages. See my GitHub branch.

I don't think it's working yet. I need to port al_hal first and smp stuff from DDWRT's kernel.

Regards

That did the trick!

Using your branch here.. Not sure how it hit 42208000. Just updated the image config from 0x8000 to 0x00008000.

Confirmed no smp or dma under default kernel support but that's only a minor set back at least.

1 Like

I agree. We can boot now into initramfs and testing will get much much easier now :slightly_smiling_face:

And i would like to move forwards stepwise, not trying to just copy everything from DDWRT to kernel 5.4 but one piece after another and do it in a clean way acceptable for upstreaming to OpenWRT. Meaning clean and small patch sets, not like DDWRT is doing, just throw everything into a heap :nauseated_face:

I'm with you.. OpenWRT uses a very clean patch system where DDWRT just tries to maintain a fully customized kernel source tree for some reason. I had a couple drivers compiling previously however the majority is a mess of backtracking and integrating relevant diff's.

Some work ahead but this is the best start we have seen so far!

Yeah, i spent yesterday hours analyzing the diff between DDWRT's 4.9 kernel and the vanilla 4.9.258.
That was horrible :sob: Check the commit history, most of the times the commit messages do not contain any useful information at all, frequently it is just something like update. Many commits contain changes of independent files and some Makefiles are even executable :rofl:

Yay, booted OpenWRT into shell with initramfs :stuck_out_tongue_closed_eyes:
I was right with regard to DTB appending. Now i don't need to pass mem=1G kernel parameter.

I updated my GitHub branch. Now the real porting work can start. No SMP yet.

Good news is that now not only memory passed by u-boot works, but also the kernel command-line. There is no need now to hard code it into kernel image. Use u-boot's setenv bootargs.

BusyBox v1.33.0 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r15888+1-f79f496ed6
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:/#
root@OpenWrt:/# uname -a
Linux OpenWrt 5.4.99 #0 SMP Tue Feb 23 20:40:56 2021 armv7l GNU/Linux
root@OpenWrt:/# cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 100.00
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x2
CPU part        : 0xc0f
CPU revision    : 4

Hardware        : Generic DT based system
Revision        : 0000
Serial          : 0000000000000000

root@OpenWrt:/# cat /proc/meminfo
MemTotal:        1028564 kB
MemFree:         1002096 kB
MemAvailable:     966736 kB

The memory node from DTB looks now sane. In total 1GB of memory.

root@OpenWrt:/# hexdump -C /proc/device-tree/memory/reg
00000000  00 00 00 00 00 00 00 00  00 00 00 00 10 00 00 00  |................|
00000010  00 00 00 00 10 00 00 00  00 00 00 00 10 00 00 00  |................|
00000020  00 00 00 00 20 00 00 00  00 00 00 00 10 00 00 00  |.... ...........|
00000030  00 00 00 00 30 00 00 00  00 00 00 00 10 00 00 00  |....0...........|
00000040

I think as next i will port SMP support but not just copy it, i want to try and untangle this mess named al_hal. This way it will be easier to debug and fix bugs in contrast to looking at a giant ball of spaghetti code.

1 Like

Initial SMP support is finished.

root@OpenWrt:/# dmesg
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.4.100 (egorenar@imac5k-voidlinux) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r15888+1-f79f496ed6)) #0 SMP Fri Feb 26 22:04:28 2021
[    0.000000] CPU: ARMv7 Processor [412fc0f4] revision 4 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
[    0.000000] OF: fdt: Machine model: Annapurna Labs Alpine Dev Board
[    0.000000] Malformed early option 'earlycon'
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] On node 0 totalpages: 262144
[    0.000000]   Normal zone: 1728 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 196608 pages, LIFO batch:63
[    0.000000]   HighMem zone: 65536 pages, LIFO batch:15
[    0.000000] percpu: Embedded 15 pages/cpu s30988 r8192 d22260 u61440
[    0.000000] pcpu-alloc: s30988 r8192 d22260 u61440 alloc=15*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 260416
[    0.000000] Kernel command line: console=ttyS0,115200 earlycon earlyprintk
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 1024460K/1048576K available (5817K kernel code, 220K rwdata, 1592K rodata, 4096K init, 233K bss, 24116K reserved, 0K cma-reserved, 262144K highmem)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] GIC: Using split EOI/Deactivate mode
[    0.000000] Registering 64 msixs, starting at 96
[    0.000000] random: get_random_bytes called from start_kernel+0x2f0/0x49c with crng_init=0
[    0.000000] arch_timer: cp15 timer(s) running at 50.00MHz (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0xb8812736b, max_idle_ns: 440795202655 ns
[    0.000002] sched_clock: 56 bits at 50MHz, resolution 20ns, wraps every 4398046511100ns
[    0.000008] Switching to timer-based delay loop, resolution 20ns
[    0.000067] clocksource: arm,sp804: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 5096694524 ns
[    0.000075] sched_clock: 32 bits at 375MHz, resolution 2ns, wraps every 5726622718ns
[    0.000190] Calibrating delay loop (skipped), value calculated using timer frequency.. 100.00 BogoMIPS (lpj=500000)
[    0.000198] pid_max: default: 32768 minimum: 301
[    0.000273] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.000281] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.000642] CPU: Testing write buffer coherency: ok
[    0.000661] CPU0: Spectre v2: firmware did not set auxiliary control register IBE bit, system vulnerable
[    0.000804] CPU0: update cpu_capacity 1024
[    0.000810] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.001094] Setting up static identity map for 0x300000 - 0x300060
[    0.001146] rcu: Hierarchical SRCU implementation.
[    0.001327] smp: Bringing up secondary CPUs ...
[    0.001598] CPU1: update cpu_capacity 1024
[    0.001602] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[    0.001605] CPU1: Spectre v2: firmware did not set auxiliary control register IBE bit, system vulnerable
[    0.001939] CPU2: update cpu_capacity 1024
[    0.001942] CPU2: thread -1, cpu 2, socket 0, mpidr 80000002
[    0.001946] CPU2: Spectre v2: firmware did not set auxiliary control register IBE bit, system vulnerable
[    0.002269] CPU3: update cpu_capacity 1024
[    0.002273] CPU3: thread -1, cpu 3, socket 0, mpidr 80000003
[    0.002276] CPU3: Spectre v2: firmware did not set auxiliary control register IBE bit, system vulnerable
[    0.002345] smp: Brought up 1 node, 4 CPUs
[    0.002351] SMP: Total of 4 processors activated (400.00 BogoMIPS).
[    0.002356] CPU: All CPU(s) started in HYP mode.
[    0.002361] CPU: Virtualization extensions available.
root@OpenWrt:/# cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 100.00
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x2
CPU part        : 0xc0f
CPU revision    : 4

processor       : 1
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 100.00
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x2
CPU part        : 0xc0f
CPU revision    : 4

processor       : 2
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 100.00
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x2
CPU part        : 0xc0f
CPU revision    : 4

processor       : 3
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 100.00
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x2
CPU part        : 0xc0f
CPU revision    : 4

Hardware        : AnnapurnaLabs Alpine (Device Tree)
Revision        : 0000
Serial          : 0000000000000000

SMP is still unstable, sometimes it hangs. Need to investigate it.
To disable SMP , add nosmp or maxcpus=1 to kernel command-line in u-boot.

But got GPIOs working now.
To control e.g. the WPS LED do this:

echo 39 > /sys/class/gpio/unexport
echo 39 > /sys/class/gpio/export
echo 0 > /sys/class/gpio/gpio39/value
echo 1 > /sys/class/gpio/gpio39/value

I found out that SMP hangs can be traced back to either cpuidle or cpufreq.
If i disable both with cpuidle.off=1 cpufreq.off=1 then SMP ist stable :wink:
At least i know now where to look for bugs.

Another tip from me, to avoid typing u-boot commands again and again, do the following.

This only once.

setenv bootowrt 'setenv bootargs console=ttyS0,115200 earlycon earlyprintk $bootargsextra; tftpboot $loadaddr_dt image-alpine-r9000.dtb; tftpboot $loadaddr openwrt-alpine-generic-netgear_r9000-initramfs-uImage; fdt addr $loadaddr_dt; bootm $loadaddr - $fdtaddr'
savenv

And this every to time to boot OpenWRT.

setenv bootargsextra 'cpuidle.off=1 cpufreq.off=1'
run bootowrt

Update: Fixed cpuidle. Hardware cache coherency in the fabric seems to be the reason.

I think it would make sense to port Ethernet next because that would enable me to do tests a lot faster due to kexec. I could send a new OpenWrt image via network to the router and kexec it from the old one. That way i wouldn't need to restart and use u-boot anymore.

Implemented initial PCI support. Still unstable.

root@OpenWrt:/# lspci -v
0000:00:00.0 Ethernet controller: Annapurna Labs Ltd. SFP+ 10G Ethernet Adapter (rev 01)
        Flags: bus master, fast devsel, latency 0, IRQ 255
        Memory at fe000000 (64-bit, non-prefetchable) [size=128K]
        Memory at fe150000 (64-bit, non-prefetchable) [size=4K]
        Memory at fe140000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [40] Express Root Complex Integrated Endpoint, MSI 00
        Capabilities: [80] Power Management version 3
        Capabilities: [90] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Vendor Specific Information: ID=1c36 Rev=0 Len=200 <?>
        Capabilities: [300] Single Root I/O Virtualization (SR-IOV)
lspci: Unable to load libkmod resources: error -12

0000:00:01.0 Ethernet controller: Annapurna Labs Ltd. Gigabit Ethernet Adapter (rev 01)
        Flags: bus master, fast devsel, latency 0
        Memory at fe080000 (64-bit, non-prefetchable) [size=128K]
        Memory at fe151000 (64-bit, non-prefetchable) [size=4K]
        Memory at fe144000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [40] Express Root Complex Integrated Endpoint, MSI 00
        Capabilities: [80] Power Management version 3
        Capabilities: [90] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Vendor Specific Information: ID=1c36 Rev=0 Len=200 <?>

0000:00:03.0 Ethernet controller: Annapurna Labs Ltd. Gigabit Ethernet Adapter (rev 01)
        Flags: bus master, fast devsel, latency 0, IRQ 255
        Memory at fe0a0000 (64-bit, non-prefetchable) [size=128K]
        Memory at fe152000 (64-bit, non-prefetchable) [size=4K]
        Memory at fe148000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [40] Express Root Complex Integrated Endpoint, MSI 00
        Capabilities: [80] Power Management version 3
        Capabilities: [90] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Vendor Specific Information: ID=1c36 Rev=0 Len=200 <?>

0000:00:04.0 Network and computing encryption device: Annapurna Labs Ltd. Device 0011 (rev 01)
        Flags: fast devsel, IRQ 255
        Memory at fe0c0000 (64-bit, non-prefetchable) [disabled] [size=128K]
        Memory at fe14c000 (64-bit, non-prefetchable) [disabled] [size=8K]
        Capabilities: [40] Express Root Complex Integrated Endpoint, MSI 00
        Capabilities: [80] Power Management version 3
        Capabilities: [90] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Vendor Specific Information: ID=1c36 Rev=0 Len=200 <?>
        Capabilities: [300] Single Root I/O Virtualization (SR-IOV)

0000:00:05.0 System peripheral: Annapurna Labs Ltd. Device 0021 (rev 01)
        Flags: fast devsel, IRQ 255
        Memory at fe100000 (64-bit, non-prefetchable) [disabled] [size=128K]
        Memory at fe14e000 (64-bit, non-prefetchable) [disabled] [size=8K]
        Capabilities: [40] Express Root Complex Integrated Endpoint, MSI 00
        Capabilities: [80] Power Management version 3
        Capabilities: [90] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Vendor Specific Information: ID=1c36 Rev=0 Len=200 <?>
        Capabilities: [300] Single Root I/O Virtualization (SR-IOV)

0001:00:00.0 PCI bridge: Annapurna Labs Ltd. Device 0031 (rev 01) (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0
        Memory at e0010000 (32-bit, non-prefetchable) [size=4K]
        Memory at e0011000 (32-bit, prefetchable) [size=4K]
        Bus: primary=00, secondary=01, subordinate=04, sec-latency=0
        I/O behind bridge: [disabled]
        Memory behind bridge: e0200000-e05fffff [size=4M]
        Prefetchable memory behind bridge: [disabled]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [70] Express Root Port (Slot-), MSI 00
        Capabilities: [b0] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [140] Device Serial Number 00-00-00-00-00-00-00-00
        Capabilities: [150] Secondary PCI Express

0001:01:00.0 PCI bridge: ASMedia Technology Inc. Device 1182 (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0
        Bus: primary=01, secondary=02, subordinate=04, sec-latency=0
        I/O behind bridge: [disabled]
        Memory behind bridge: e0200000-e05fffff [size=4M]
        Prefetchable memory behind bridge: [disabled]
        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [78] Power Management version 3
        Capabilities: [80] Express Upstream Port, MSI 00
        Capabilities: [c0] Subsystem: ASMedia Technology Inc. Device 118f
        Capabilities: [100] Virtual Channel
        Capabilities: [200] Advanced Error Reporting
        Capabilities: [300] Vendor Specific Information: ID=0000 Rev=0 Len=c00 <?>

0001:02:03.0 PCI bridge: ASMedia Technology Inc. Device 1182 (prog-if 00 [Normal decode])
        Flags: fast devsel
        Bus: primary=02, secondary=03, subordinate=03, sec-latency=0
        I/O behind bridge: [disabled]
        Memory behind bridge: e0200000-e03fffff [size=2M]
        Prefetchable memory behind bridge: [disabled]
        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [78] Power Management version 3
        Capabilities: [80] Express Downstream Port (Slot+), MSI 00
        Capabilities: [c0] Subsystem: ASMedia Technology Inc. Device 118f
        Capabilities: [100] Virtual Channel
        Capabilities: [200] Advanced Error Reporting

0001:02:07.0 PCI bridge: ASMedia Technology Inc. Device 1182 (prog-if 00 [Normal decode])
        Flags: fast devsel
        Bus: primary=02, secondary=04, subordinate=04, sec-latency=0
        I/O behind bridge: [disabled]
        Memory behind bridge: e0400000-e05fffff [size=2M]
        Prefetchable memory behind bridge: [disabled]
        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [78] Power Management version 3
        Capabilities: [80] Express Downstream Port (Slot+), MSI 00
        Capabilities: [c0] Subsystem: ASMedia Technology Inc. Device 118f
        Capabilities: [100] Virtual Channel
        Capabilities: [200] Advanced Error Reporting

0001:03:00.0 Network controller: Qualcomm Atheros QCA9984 802.11ac Wave 2 Wireless Network Adapter
        Subsystem: Qualcomm Atheros Device cafe
        Flags: fast devsel, IRQ 255
        Memory at e0200000 (64-bit, non-prefetchable) [disabled] [size=2M]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable- Count=1/32 Maskable+ 64bit+
        Capabilities: [70] Express Endpoint, MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [148] Device Serial Number 00-00-00-00-00-00-00-00
        Capabilities: [158] Latency Tolerance Reporting
        Capabilities: [160] L1 PM Substates

0001:04:00.0 Network controller: Qualcomm Atheros QCA9984 802.11ac Wave 2 Wireless Network Adapter
        Subsystem: Qualcomm Atheros Device cafe
        Flags: fast devsel, IRQ 255
        Memory at e0400000 (64-bit, non-prefetchable) [disabled] [size=2M]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable- Count=1/32 Maskable+ 64bit+
        Capabilities: [70] Express Endpoint, MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [148] Device Serial Number 00-00-00-00-00-00-00-00
        Capabilities: [158] Latency Tolerance Reporting
        Capabilities: [160] L1 PM Substates

0002:00:00.0 PCI bridge: Annapurna Labs Ltd. Device 0031 (rev 01) (prog-if 00 [Normal decode])
        Flags: fast devsel
        Memory at e8010000 (32-bit, non-prefetchable) [size=4K]
        Memory at e8011000 (32-bit, prefetchable) [size=4K]
        Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
        I/O behind bridge: [disabled]
        Memory behind bridge: e8100000-e81fffff [size=1M]
        Prefetchable memory behind bridge: [disabled]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [70] Express Root Port (Slot-), MSI 00
        Capabilities: [b0] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [140] Device Serial Number 00-00-00-00-00-00-00-00
        Capabilities: [150] Secondary PCI Express

0002:01:00.0 USB controller: ASMedia Technology Inc. ASM1042A USB 3.0 Host Controller (prog-if 30 [XHCI])
        Subsystem: ASMedia Technology Inc. ASM1042A USB 3.0 Host Controller
        Flags: fast devsel, IRQ 255
        Memory at e8100000 (64-bit, non-prefetchable) [disabled] [size=32K]
        Capabilities: [50] MSI: Enable- Count=1/8 Maskable- 64bit+
        Capabilities: [68] MSI-X: Enable- Count=8 Masked-
        Capabilities: [78] Power Management version 3
        Capabilities: [80] Express Legacy Endpoint, MSI 00
        Capabilities: [100] Virtual Channel

0003:00:00.0 PCI bridge: Annapurna Labs Ltd. Device 0031 (rev 01) (prog-if 00 [Normal decode])
        Flags: fast devsel
        Memory at f0010000 (32-bit, non-prefetchable) [size=4K]
        Memory at f0011000 (32-bit, prefetchable) [size=4K]
        Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
        I/O behind bridge: [disabled]
        Memory behind bridge: f0200000-f03fffff [size=2M]
        Prefetchable memory behind bridge: [disabled]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [70] Express Root Port (Slot-), MSI 00
        Capabilities: [b0] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [140] Device Serial Number 00-00-00-00-00-00-00-00
        Capabilities: [150] Secondary PCI Express

0003:01:00.0 Network controller: Wilocity Ltd. Wil6200 802.11ad Wireless Network Adapter (rev 02)
        Subsystem: Wilocity Ltd. Device 0000
        Flags: fast devsel, IRQ 255
        Memory at f0200000 (64-bit, non-prefetchable) [disabled] [size=2M]
        Capabilities: [40] Power Management version 3
        Capabilities: [b0] MSI: Enable- Count=1/4 Maskable- 64bit+
        Capabilities: [70] Express Endpoint, MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [148] Latency Tolerance Reporting
        Capabilities: [150] L1 PM Substates
3 Likes

I fixed PCI finally. Sometimes you just need to sleep over it and the solution just jumps at you.

The WLAN devices as well as USB host are working now :blush:
I'm able to mount my USB3 drive but ath10k can't load FW.

root@OpenWrt:/# ifconfig  -a
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:192 errors:0 dropped:0 overruns:0 frame:0
          TX packets:192 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:14976 (14.6 KiB)  TX bytes:14976 (14.6 KiB)

wlan0     Link encap:Ethernet  HWaddr CC:C0:79:FE:94:15
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:4000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
[    7.814117] wil6210 0003:01:00.0: wil6210 device found [1ae9:0310] (rev 2) bar size 0x200000
[    7.822825] wil6210 0003:01:00.0: enabling device (0140 -> 0142)
[    7.828857] wil6210 0003:01:00.0 (unnamed net_device) (uninitialized): wil_pcie_probe: CSR at [mem 0xf0200000-0xf03fffff 64bit] -> 0x4d4750eb
[    7.841533] wil6210 0003:01:00.0 (unnamed net_device) (uninitialized): wil_set_capabilities: Board hardware is Sparrow B0, flash exist
[    7.853597] wil6210 0003:01:00.0 (unnamed net_device) (uninitialized): wil_set_capabilities: platform_capa 0x0
[    7.864676] wil6210 0003:01:00.0 (unnamed net_device) (uninitialized): wil_refresh_fw_capabilities: keep_radio_on_during_sleep (0)
[    7.876397] wil6210 0003:01:00.0: using dma mask 48
[    7.881279] wil6210 0003:01:00.0 (unnamed net_device) (uninitialized): wil_if_pcie_enable: 3 MSI mode failed, try 1 MSI
[    7.946325] wil6210 0003:01:00.0 (unnamed net_device) (uninitialized): wil_get_bl_info: Boot Loader struct v2: MAC = cc:c0:79:fe:94:15 RF = 0x0000 (status 0x0000) bband = 0x00000000
[    7.962467] wil6210 0003:01:00.0 (unnamed net_device) (uninitialized): wil_get_bl_info: Boot Loader build 255.255.0.6836
[    7.973318] wil6210 0003:01:00.0 (unnamed net_device) (uninitialized): wil_set_oob_mode: oob_mode to 0
[    7.995167] irq: no irq domain found for pcie-legacy-intc !
[    8.000758] ath10k 5.10 driver, optimized for CT firmware, probing pci device: 0x46.
[    8.009205] ath10k_pci 0001:03:00.0: enabling device (0140 -> 0142)
[    8.015812] ath10k_pci 0001:03:00.0: pci irq msi oper_irq_mode 2 irq_mode 0 reset_mode 0
[    8.201446] ath10k_pci 0001:03:00.0: qca9984/qca9994 hw1.0 target 0x01000000 chip_id 0x00000000 sub 168c:cafe
[    8.211359] ath10k_pci 0001:03:00.0: kconfig debug 0 debugfs 1 tracing 0 dfs 1 testmode 0
[    8.220356] ath10k_pci 0001:03:00.0: firmware ver 10.4b-ct-9984-fW-13-5ae337bb1 api 5 features mfp,peer-flow-ctrl,txstatus-noack,wmi-10.x-CT,ratemask-CT,regdump-CT,txrate-CT,flush-all-CT,pingpong-CT,ch-regs-CT,nop-CT,set-special-CT,tx-rc-CT,cust-stats-CT,txrate2-CT,beacon-cb-CT,wmi-block-ack-CT,wmi-bcn-rc-CT crc32 7ea63dc5
[   10.535528] ath10k_pci 0001:03:00.0: failed to fetch board data for bus=pci,vendor=168c,device=0046,subsystem-vendor=168c,subsystem-device=cafe from ath10k/QCA9984/hw1.0/board-2.bin
[   10.555846] ath10k_pci 0001:03:00.0: failed to fetch board-2.bin or board.bin from ath10k/QCA9984/hw1.0
[   10.565234] ath10k_pci 0001:03:00.0: failed to fetch board file: -12
[   10.571668] ath10k_pci 0001:03:00.0: could not probe fw (-12)
[   10.577547] irq: no irq domain found for pcie-legacy-intc !
[   10.583109] ath10k 5.10 driver, optimized for CT firmware, probing pci device: 0x46.
[   10.591372] ath10k_pci 0001:04:00.0: enabling device (0140 -> 0142)
[   10.597965] ath10k_pci 0001:04:00.0: pci irq msi oper_irq_mode 2 irq_mode 0 reset_mode 0
[   10.781200] ath10k_pci 0001:04:00.0: qca9984/qca9994 hw1.0 target 0x01000000 chip_id 0x00000000 sub 168c:cafe
[   10.791110] ath10k_pci 0001:04:00.0: kconfig debug 0 debugfs 1 tracing 0 dfs 1 testmode 0
[   10.800118] ath10k_pci 0001:04:00.0: firmware ver 10.4b-ct-9984-fW-13-5ae337bb1 api 5 features mfp,peer-flow-ctrl,txstatus-noack,wmi-10.x-CT,ratemask-CT,regdump-CT,txrate-CT,flush-all-CT,pingpong-CT,ch-regs-CT,nop-CT,set-special-CT,tx-rc-CT,cust-stats-CT,txrate2-CT,beacon-cb-CT,wmi-block-ack-CT,wmi-bcn-rc-CT crc32 7ea63dc5
[   13.115445] ath10k_pci 0001:04:00.0: failed to fetch board data for bus=pci,vendor=168c,device=0046,subsystem-vendor=168c,subsystem-device=cafe from ath10k/QCA9984/hw1.0/board-2.bin
[   13.135771] ath10k_pci 0001:04:00.0: failed to fetch board-2.bin or board.bin from ath10k/QCA9984/hw1.0
[   13.145159] ath10k_pci 0001:04:00.0: failed to fetch board file: -12
[   13.151589] ath10k_pci 0001:04:00.0: could not probe fw (-12)
[    2.560602] ehci-pci: EHCI PCI platform driver
[    2.565630] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    2.572075] ohci-platform: OHCI generic platform driver
[    2.577592] ohci-pci: OHCI PCI platform driver
[    2.584534] irq: no irq domain found for pcie-legacy-intc !
[    2.590195] xhci_hcd 0002:01:00.0: xHCI Host Controller
[    2.595420] xhci_hcd 0002:01:00.0: new USB bus registered, assigned bus number 1
[    2.736855] xhci_hcd 0002:01:00.0: hcc params 0x0200e081 hci version 0x100 quirks 0x0000000010000410
[    2.747005] hub 1-0:1.0: USB hub found
[    2.750804] hub 1-0:1.0: 2 ports detected
[    2.755141] xhci_hcd 0002:01:00.0: xHCI Host Controller
[    2.760377] xhci_hcd 0002:01:00.0: new USB bus registered, assigned bus number 2
[    2.767845] xhci_hcd 0002:01:00.0: Host supports USB 3.0 SuperSpeed
[    2.774254] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[    2.782856] hub 2-0:1.0: USB hub found
[    2.786645] hub 2-0:1.0: 2 ports detected
root@OpenWrt:/# lspci -v
0000:00:00.0 Ethernet controller: Annapurna Labs Ltd. SFP+ 10G Ethernet Adapter (rev 01)
        Flags: bus master, fast devsel, latency 0, IRQ 255
        Memory at fe000000 (64-bit, non-prefetchable) [size=128K]
        Memory at fe150000 (64-bit, non-prefetchable) [size=4K]
        Memory at fe140000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [40] Express Root Complex Integrated Endpoint, MSI 00
        Capabilities: [80] Power Management version 3
        Capabilities: [90] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Vendor Specific Information: ID=1c36 Rev=0 Len=200 <?>
        Capabilities: [300] Single Root I/O Virtualization (SR-IOV)
lspci: Unable to load libkmod resources: error -12

0000:00:01.0 Ethernet controller: Annapurna Labs Ltd. Gigabit Ethernet Adapter (rev 01)
        Flags: bus master, fast devsel, latency 0
        Memory at fe080000 (64-bit, non-prefetchable) [size=128K]
        Memory at fe151000 (64-bit, non-prefetchable) [size=4K]
        Memory at fe144000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [40] Express Root Complex Integrated Endpoint, MSI 00
        Capabilities: [80] Power Management version 3
        Capabilities: [90] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Vendor Specific Information: ID=1c36 Rev=0 Len=200 <?>

0000:00:03.0 Ethernet controller: Annapurna Labs Ltd. Gigabit Ethernet Adapter (rev 01)
        Flags: bus master, fast devsel, latency 0, IRQ 255
        Memory at fe0a0000 (64-bit, non-prefetchable) [size=128K]
        Memory at fe152000 (64-bit, non-prefetchable) [size=4K]
        Memory at fe148000 (64-bit, non-prefetchable) [size=16K]
        Capabilities: [40] Express Root Complex Integrated Endpoint, MSI 00
        Capabilities: [80] Power Management version 3
        Capabilities: [90] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Vendor Specific Information: ID=1c36 Rev=0 Len=200 <?>

0000:00:04.0 Network and computing encryption device: Annapurna Labs Ltd. Device 0011 (rev 01)
        Flags: fast devsel, IRQ 255
        Memory at fe0c0000 (64-bit, non-prefetchable) [disabled] [size=128K]
        Memory at fe14c000 (64-bit, non-prefetchable) [disabled] [size=8K]
        Capabilities: [40] Express Root Complex Integrated Endpoint, MSI 00
        Capabilities: [80] Power Management version 3
        Capabilities: [90] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Vendor Specific Information: ID=1c36 Rev=0 Len=200 <?>
        Capabilities: [300] Single Root I/O Virtualization (SR-IOV)

0000:00:05.0 System peripheral: Annapurna Labs Ltd. Device 0021 (rev 01)
        Flags: fast devsel, IRQ 255
        Memory at fe100000 (64-bit, non-prefetchable) [disabled] [size=128K]
        Memory at fe14e000 (64-bit, non-prefetchable) [disabled] [size=8K]
        Capabilities: [40] Express Root Complex Integrated Endpoint, MSI 00
        Capabilities: [80] Power Management version 3
        Capabilities: [90] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Vendor Specific Information: ID=1c36 Rev=0 Len=200 <?>
        Capabilities: [300] Single Root I/O Virtualization (SR-IOV)

0001:00:00.0 PCI bridge: Annapurna Labs Ltd. Device 0031 (rev 01) (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 172
        Memory at e0010000 (32-bit, non-prefetchable) [size=4K]
        Memory at e0011000 (32-bit, prefetchable) [size=4K]
        Bus: primary=00, secondary=01, subordinate=04, sec-latency=0
        I/O behind bridge: [disabled]
        Memory behind bridge: e0200000-e05fffff [size=4M]
        Prefetchable memory behind bridge: [disabled]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [70] Express Root Port (Slot-), MSI 00
        Capabilities: [b0] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [140] Device Serial Number 00-00-00-00-00-00-00-00
        Capabilities: [150] Secondary PCI Express
        Kernel driver in use: pcieport

0001:01:00.0 PCI bridge: ASMedia Technology Inc. Device 1182 (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 173
        Bus: primary=01, secondary=02, subordinate=04, sec-latency=0
        I/O behind bridge: [disabled]
        Memory behind bridge: e0200000-e05fffff [size=4M]
        Prefetchable memory behind bridge: [disabled]
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [78] Power Management version 3
        Capabilities: [80] Express Upstream Port, MSI 00
        Capabilities: [c0] Subsystem: ASMedia Technology Inc. Device 118f
        Capabilities: [100] Virtual Channel
        Capabilities: [200] Advanced Error Reporting
        Capabilities: [300] Vendor Specific Information: ID=0000 Rev=0 Len=c00 <?>
        Kernel driver in use: pcieport

0001:02:03.0 PCI bridge: ASMedia Technology Inc. Device 1182 (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 174
        Bus: primary=02, secondary=03, subordinate=03, sec-latency=0
        I/O behind bridge: [disabled]
        Memory behind bridge: e0200000-e03fffff [size=2M]
        Prefetchable memory behind bridge: [disabled]
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [78] Power Management version 3
        Capabilities: [80] Express Downstream Port (Slot+), MSI 00
        Capabilities: [c0] Subsystem: ASMedia Technology Inc. Device 118f
        Capabilities: [100] Virtual Channel
        Capabilities: [200] Advanced Error Reporting
        Kernel driver in use: pcieport

0001:02:07.0 PCI bridge: ASMedia Technology Inc. Device 1182 (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 175
        Bus: primary=02, secondary=04, subordinate=04, sec-latency=0
        I/O behind bridge: [disabled]
        Memory behind bridge: e0400000-e05fffff [size=2M]
        Prefetchable memory behind bridge: [disabled]
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [78] Power Management version 3
        Capabilities: [80] Express Downstream Port (Slot+), MSI 00
        Capabilities: [c0] Subsystem: ASMedia Technology Inc. Device 118f
        Capabilities: [100] Virtual Channel
        Capabilities: [200] Advanced Error Reporting
        Kernel driver in use: pcieport

0001:03:00.0 Network controller: Qualcomm Atheros QCA9984 802.11ac Wave 2 Wireless Network Adapter
        Subsystem: Qualcomm Atheros Device cafe
        Flags: bus master, fast devsel, latency 0, IRQ 184
        Memory at e0200000 (64-bit, non-prefetchable) [size=2M]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable+ Count=1/32 Maskable+ 64bit+
        Capabilities: [70] Express Endpoint, MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [148] Device Serial Number 00-00-00-00-00-00-00-00
        Capabilities: [158] Latency Tolerance Reporting
        Capabilities: [160] L1 PM Substates
        Kernel driver in use: ath10k_pci

0001:04:00.0 Network controller: Qualcomm Atheros QCA9984 802.11ac Wave 2 Wireless Network Adapter
        Subsystem: Qualcomm Atheros Device cafe
        Flags: bus master, fast devsel, latency 0, IRQ 185
        Memory at e0400000 (64-bit, non-prefetchable) [size=2M]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable+ Count=1/32 Maskable+ 64bit+
        Capabilities: [70] Express Endpoint, MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [148] Device Serial Number 00-00-00-00-00-00-00-00
        Capabilities: [158] Latency Tolerance Reporting
        Capabilities: [160] L1 PM Substates
        Kernel driver in use: ath10k_pci

0002:00:00.0 PCI bridge: Annapurna Labs Ltd. Device 0031 (rev 01) (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 176
        Memory at e8010000 (32-bit, non-prefetchable) [size=4K]
        Memory at e8011000 (32-bit, prefetchable) [size=4K]
        Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
        I/O behind bridge: [disabled]
        Memory behind bridge: e8100000-e81fffff [size=1M]
        Prefetchable memory behind bridge: [disabled]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [70] Express Root Port (Slot-), MSI 00
        Capabilities: [b0] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [140] Device Serial Number 00-00-00-00-00-00-00-00
        Capabilities: [150] Secondary PCI Express
        Kernel driver in use: pcieport

0002:01:00.0 USB controller: ASMedia Technology Inc. ASM1042A USB 3.0 Host Controller (prog-if 30 [XHCI])
        Subsystem: ASMedia Technology Inc. ASM1042A USB 3.0 Host Controller
        Flags: bus master, fast devsel, latency 0
        Memory at e8100000 (64-bit, non-prefetchable) [size=32K]
        Capabilities: [50] MSI: Enable- Count=1/8 Maskable- 64bit+
        Capabilities: [68] MSI-X: Enable+ Count=8 Masked-
        Capabilities: [78] Power Management version 3
        Capabilities: [80] Express Legacy Endpoint, MSI 00
        Capabilities: [100] Virtual Channel
        Kernel driver in use: xhci_hcd

0003:00:00.0 PCI bridge: Annapurna Labs Ltd. Device 0031 (rev 01) (prog-if 00 [Normal decode])
        Flags: bus master, fast devsel, latency 0, IRQ 177
        Memory at f0010000 (32-bit, non-prefetchable) [size=4K]
        Memory at f0011000 (32-bit, prefetchable) [size=4K]
        Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
        I/O behind bridge: [disabled]
        Memory behind bridge: f0200000-f03fffff [size=2M]
        Prefetchable memory behind bridge: [disabled]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [70] Express Root Port (Slot-), MSI 00
        Capabilities: [b0] MSI-X: Enable- Count=64 Masked-
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [140] Device Serial Number 00-00-00-00-00-00-00-00
        Capabilities: [150] Secondary PCI Express
        Kernel driver in use: pcieport

0003:01:00.0 Network controller: Wilocity Ltd. Wil6200 802.11ad Wireless Network Adapter (rev 02)
        Subsystem: Wilocity Ltd. Device 0000
        Flags: bus master, fast devsel, latency 0, IRQ 183
        Memory at f0200000 (64-bit, non-prefetchable) [size=2M]
        Capabilities: [40] Power Management version 3
        Capabilities: [b0] MSI: Enable+ Count=1/4 Maskable- 64bit+
        Capabilities: [70] Express Endpoint, MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [148] Latency Tolerance Reporting
        Capabilities: [150] L1 PM Substates
        Kernel driver in use: wil6210

Update: I managed to get WLAN fully operational but only with DDWRT's firmware. Need to investigate it.

root@OpenWrt:/# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 4000
    link/ether cc:c0:79:fe:94:15 brd ff:ff:ff:ff:ff:ff
3: wlan1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether 00:34:56:78:7b:7b brd ff:ff:ff:ff:ff:ff
4: wlan2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether 00:34:56:78:8c:8c brd ff:ff:ff:ff:ff:ff

I think i know why ath10k is not able to load firmware:
[ 10.535528] ath10k_pci 0001:03:00.0: failed to fetch board data for bus=pci,vendor=168c,device=0046,subsystem-vendor=168c,subsystem-device=cafe from ath10k/QCA9984/hw1.0/board-2.bin

We need to create a board.bin file for this hardware.

2 Likes

board-2.bin needs to be extracted from the OEM firmware (its rootfs, you will probably need qca-swissarmyknife to convert it), furthermore you'll have to extract the pre-cal values from ART in firstboot conditions.

Thanks for the pointer.


binwalk -e R9000-V1.0.5.28.img

There are just too many :frowning:

 ls _R9000-V1.0.5.28.img.extracted/squashfs-root/lib/firmware/QCA9984/hw.1
athwlan.bin                                 boardData_QCA9984_CUS239_5G_v1_001.bin                      boardData_QCA9984_CUS240_2G_v1_004.bin                      FCC_CE   utf.codeswap.bin
athwlan.codeswap.bin                        boardData_QCA9984_CUS239_5G_v1_001_ctl.bin                  boardData_QCA9984_CUS240_2G_v1_004_CTL.bin                  HK       VN
AU                                          boardData_QCA9984_CUS239_5G_v1_MAX_001.bin                  boardData_QCA9984_CUS260_2G_v1_002.bin                      Japan    waltest.codeswap.bin
boarddata_0.bin                             boardData_QCA9984_CUS239_high_band_5G_v1_006.bin            boardData_QCA9984_CUS260_2G_v1_002_ctl.bin                  otp.bin
boarddata_1.bin                             boardData_QCA9984_CUS239_low_band_5G_v1_005.bin             boardData_QCA9984_CUS260_2G_v1_MAX_002.bin                  PR
boardData_QCA9984_CUS238_5G_v1_003.bin      boardData_QCA9984_CUS239_low_pwr_pa_5G_v1_007.bin           boardData_QCA9984_CUS260_negative_pwr_offset_2G_v1_009.bin  SG
boardData_QCA9984_CUS238_5G_v1_003_CTL.bin  boardData_QCA9984_CUS239_negative_pwr_offset_5G_v1_008.bin  Canada                                                      utf.bin

Maybe i should take a break from WLAN and start porting ETH which doesn't need any firmware.

Any pointers where to get that ? I see it on DDWRT's firmware:

root@dd-wrt:~# ls -l /lib/firmware/ath10k/
drwxr-xr-x    3 root     root            28 Dec 19 06:53 QCA988X
drwxr-xr-x    3 root     root            28 Dec 19 06:53 QCA9984
drwxr-xr-x    3 root     root            28 Dec 19 06:53 QCA99X0
lrwxrwxrwx    1 root     root            15 Feb 10 21:06 pre-cal-pci-0000:01:00.0.bin -> /tmp/board1.bin
lrwxrwxrwx    1 root     root            15 Feb 10 21:06 pre-cal-pci-0001:01:00.0.bin -> /tmp/board2.bin

Ah got it :slight_smile: It's extracted from MTD ART partition, just a piece of data from NAND. That would mean i need first to port the NAND driver to automate it at boot. I wonder whether OpenWRT does it in a similar way at boot.

https://svn.dd-wrt.com/browser/src/router/services/sysinit/sysinit-alpine.c

Hmm, but on the other hand, when i used DDWRT's board.bin, i did not have any cal files and the driver and card still worked. I could at least scan and see WLAN BSSs :confused:

Update

Ported drivers for EDAC and NAND controller.
OpenWRT images built with NAND commit don't boot for some reason but i don't think the reason is the driver because the kernel hangs during decompression. My guess is that kernel has gotten too big because the commit introducing NAND contains a considerable amount of new files. Need to understand and debug kernel decompression. When NAND finally works, we will be finally able to get the board.bin file from the ART NAND partition at boot and use ath10k.

1 Like