Netgear R7800 exploration (IPQ8065, QCA9984)

Pci driver seem to be missing, it's patch 110 from patches-4.4
Edit: patch 111. 110 is documentation.

yep, i'll merge/test it in a sec, almost done with porting ipq4019 support

It's DTS issue, pcie patch is in kernel now and it has different compatibility string
'qcom,pcie-ipq8064'

indeed i was just going to post that same finding. will push a fix in a sec

[quote="dissent1, post:223, topic:285, full:true"]
It's DTS issue, pcie patch is in kernel now and it has different compatibility string'qcom,pcie-ipq8064'
[/quote]Hopefully I got it right:
I changed the three occurences of
'qcom,pcie-v0' to 'qcom,pcie-ipq8064' in the pcie definitions' compatible lines in qcom-ipq8064.dtsi
Recompiling...

Looks like I got it wrong.
I flashed the image and the router did not boot. Froze just at "starting kernel" in uboot.

Here are fixes for upstream driver
https://source.codeaurora.org/quic/qsdk/oss/kernel/linux-msm/log/drivers/pci/host/pcie-qcom.c?h=release/dandelion_preview

@hnyman you've got it right, but it seem to fail, there are some fixes should be applied in order to get it working it seems (link above)

I've ported those fixes and since I'm away I can't test it
https://github.com/dissent1/r7800/tree/k49-1

@dissent1 @blogic

Thanks.
After those changes from dissent1's k49-1 branch I have again a working wifi :wink:
Kernel bootlog: https://gist.github.com/hnyman/038e9393de6b2ae8a3c76c08d40bdc7a

I downloaded the six new patch files 0071-0076
https://github.com/dissent1/r7800/tree/k49-1/target/linux/ipq806x/patches-4.9
And in addition I edited manually the two separate changes to dts files:
https://github.com/dissent1/r7800/commit/f83b202bda756740de82701b74adb4df45052613
https://github.com/dissent1/r7800/commit/8350b99b726f630106c0bc4945a47bc43b8088af

I have not tested the router extensively but so far it looks good. (

I noticed that @nbd had pushed a ipq806x pcie patch to LEDE main sources. So I replaced the patches from @dissent1 with the official version as of r3742, but that did not work for me. The R7800 router got again into a bootloop, but with different errors than earlier. Bootlog
https://gist.github.com/hnyman/5f4c9b1d325c1296b68f1a632b8db643

The combined patch from nbd is a bit different than dissent's separate patches, (I think that the contents of dissent's patch 0076 are no present), and additionally the related DTS change to force "generation 1" pcie to be used for 8065-r7800 is missing. Could that be the reason?

(or could it just have been a bad flash?)

According to bootlog it's ubi has failed, have you tried reflashing?

I reflashed this morning the firmware with nbd's changes (r3742-894ee9510b) and now it worked. So, funny coincidence that a ubi flash failure while testing this 4.9 bump.

But in any case, so far everything seems to work ok with the firmware built from r3742-894ee9510b.

EDIT:
I compared the bootlog from yesterday and the bootlog from the same firmware after a reflash and I notice a difference right in the beginning of the boot process. The failed firmware's bootlog is missing few lines regarding memory mapping??? Looks strange as I think that the very early part should be identical.

These lines are missing from the bootlog when router failed (at ubi):

[    0.000000] On node 0 totalpages: 122880
[    0.000000] free_area_init_node: node 0, pgdat c076b500, node_mem_map dda39000
[    0.000000]   Normal zone: 960 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 122880 pages, LIFO batch:31
...
[    0.000000] pcpu-alloc: s20940 r8192 d24116 u53248 alloc=13*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1 

Failure:

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.9.14 (perus@ub1610) (gcc version 5.4.0 (LEDE GCC 5.4.0 r3598-eb09d79c16) ) #0 SMP Mon Mar 13 20:49:39 2017
[    0.000000] CPU: ARMv7 Processor [512f04d0] revision 0 (ARMv7), cr=10c5787d
[    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: Netgear Nighthawk X4S R7800
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] percpu: Embedded 13 pages/cpu @dda09000 s20940 r8192 d24116 u53248
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 121920
[    0.000000] Kernel command line:
[    0.000000] Bootloader command line (ignored): console=ttyHSL1,115200n8
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 479224K/491520K available (3728K kernel code, 239K rwdata, 1184K rodata, 236K init, 232K bss, 12296K reserved, 0K cma-reserved, 0K highmem)

OK boot:

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.9.14 (perus@ub1610) (gcc version 5.4.0 (LEDE GCC 5.4.0 r3598-eb09d79c16) ) #0 SMP Mon Mar 13 20:49:39 2017
[    0.000000] CPU: ARMv7 Processor [512f04d0] revision 0 (ARMv7), cr=10c5787d
[    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: Netgear Nighthawk X4S R7800
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] On node 0 totalpages: 122880
[    0.000000] free_area_init_node: node 0, pgdat c076b500, node_mem_map dda39000
[    0.000000]   Normal zone: 960 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 122880 pages, LIFO batch:31
[    0.000000] percpu: Embedded 13 pages/cpu @dda09000 s20940 r8192 d24116 u53248
[    0.000000] pcpu-alloc: s20940 r8192 d24116 u53248 alloc=13*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1 
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 121920
[    0.000000] Kernel command line: 
[    0.000000] Bootloader command line (ignored): console=ttyHSL1,115200n8
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 479224K/491520K available (3728K kernel code, 239K rwdata, 1184K rodata, 236K init, 232K bss, 12296K reserved, 0K cma-reserved, 0K highmem)

Yeah, frustrating :slight_smile:

Glad that k4.9 is fixed at last, so i can test it when I'm at it.

@blogic That ubi failure is worrying. It may repeat I suppose, wonder if it's that dma workaround causing corruption during nand writes?

Edit: posted before @hnyman findings, so it may be not related to nand changes

Advice for those wanting to access the serial connector in R7800:

It is pretty easy to lead serial cable through the side grill to get access to the serial header even when the router has been reassembled and cover is closed. You need to open the case once and attach the jumper cables, but the cover can be closed after that:

I think that I found one regression in kernel 4.9:
the CPU frequency scaling ramps both CPU cores up/down simultaneously, while with kernel 4.4 the cores reacted independently. Might be just a config change, a DTS change, or alternatively the driver has changed somewhat...

What if you remove patch 0046?

Edit: aha, you can't..

I noticed the same. Apparently removing that patch requires more work.

@blogic
Any idea why the "independent-clocks" definition is removed? cpufreq-dt is not implemented here? It worked in 4.4.

Well, looks like the include file linux/cpufreq-dt.h has been removed between 4.4 and 4.9, but that should not be a big hurdle as the file has been really really simple. The only definition in that file has actually been the independent clocks thing...
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/tree/include/linux/cpufreq-dt.h?h=linux-4.4.y

I will try to investigate where it has gone and when.

Try this https://github.com/dissent1/r7800/blob/sta27/target/linux/ipq806x/patches-4.9/0047.patch

I will try that.

And I found the Linux commit where the include file has been removed:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/diff/?h=linux-4.7.y&id=eb96924acddc709db58221c210ca05cd9effb1df

Apparently there has been no users for that in the main Linux, so the devs have just removed that structure and include file.

So, the other approach would be to just re-define that structure in 0046 instead of removing the usage of it.