[Android Software/Hacking General [Developers Only]] Mr.Tom_Tom:
The intention behind this thread is to share some experience of a little project where I try to migrate the Sony Xperia Shinano devices (based on Qualcomm MSM8974 chipset with a Broadcom BCM4339 wifi/bluetooth chip) from the old bcmdhd wifi driver to a close-to-mainline brcmfmac driver. I want to share the progress and status here, and maybe get some hints. It is work in progress, and for sure it still contains some mistakes - I haven't done something like this before and am still learning.

Why?

The Shinano devices are still maintained by the LineageOS, and some devices are currently on the official LineageOS 17.1 stream.

The kernel however is terribly outdated, based on msm-3.4

There are some wifi issues with all LineageOS-based ROMs since years, like weak 5GHz connections and non-working wifi in some countries. There are some hacks around that, but they work (afaik) by practically disabling the kernel-level regulatory system by e.g. setting a static country code like "DE".

I am curious if we can improve that by updating the kernel drivers and network/wifi components, and maybe also the firmware (to the latest release available from Broadcom, 6.37.34.43 ?) . I got the ideas from Sonyxperiadev/Loire (+ related platform config), the Linux Backport Project and other MSM8974 based devices.

Working so far:

Did a few tests only so far, STA with WPA2 and p2p (hotspot) seem to work

Wifi connection is stable on 2,4GHz on 00 world regulatory domain (tested on a Z3 and a Z3c)

5GHz manually setting a country code (could only test DE)

Switching countries / setting new regulatory domains is now working, too

Download speed looks OK to me, in my case at least better than before Download >60MBit, Upload >30 Mbit on some initial tests.

Not working yet:

WifiHAL (qcom-caf) does not work correctly. This may create multiple issues, tbd.

Connection bandwidth seems to be not reported correctly

I don't know if wowlan works (interrupts working?)

Stability: After 1-2 days without reboot wifi sometimes crashes but immediately reconnects. Reason not yet understood.

Patches & Picks

Kernel:

backported and configured brcmfmac, cfg800211 wireless configuration API and wireless network stack from linux-stable v5.8 by adopting the compatibility patches from the linux backporting project.

updated Shinano device tree, updated Z3, Z3c and Z2 (Z2 test needed!) defconfigs (unset bcmdhd and enabled brcmfmac) and removed board-sony_shinano-wifi.o in the arch-msm makefile

Note: the backported drivers and compatibility-patches are located in a separate backports/ subdirectory

Sorry, this is work in progress and contains some hacks, to be cleaned up later

--> https://github.com/LineageOS/androi...1...Tom1000:lineage-17.1-driver-backport-v5.8

Vendor blobs / device z3(c): removed proprietary firmware and replaced that by publicly available firmware for bcm4339 on linux-firmware.git

z3c --> https://github.com/LineageOS/androi.../lineage-17.1...Tom1000:lineage-17.1-brcmfmac

z3 --> https://github.com/LineageOS/androi.../lineage-17.1...Tom1000:lineage-17.1-brcmfmac

Shinano-common: Use qcwcn instead of bcmdhd WLAN device, serve wpa_supplicant_overlay.conf

--> https://github.com/LineageOS/androi.../lineage-17.1...Tom1000:lineage-17.1-brcmfmac

msm8974-common: raise wpa_supplicant version (unknown if we need that) and update sysfs node for MAC address

--> https://github.com/LineageOS/androi.../lineage-17.1...Tom1000:lineage-17.1-brcmfmac