Jump to content

User:Ignapk

From postmarketOS Wiki
Revision as of 20:36, 31 January 2021 by Ignapk (talk | contribs) (add wip information about getting wifi to work in huawei p10 lite hisilicon hi1102 chip)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

How ignapk made wifi work

How ignapk made wifi work. Inspired by the very helpful How_drebrez_made_wifi_work and How bonsaiblue made wifi work.

  • Find information online about the wifi chip of the device: in my case it uses HiSilicon HI1102 for wifi 802.11 b/g/n/ac and Bluetooth v4.1. If you have trouble finding it online, you can search kernel config for wifi drivers too, in my case `grep -i wifi config-huawei-warsaw.aarch64` gave me among others `CONFIG_HI1102_WIFI=y`.
  • Reading the WiFi page, in particular the part about Mediatek WiFi, it mentions that the best way to get to know how to make your specific SoC work is to look at the init.rc scripts from an Android ROM available for your phone.
  • I had previously installed stock EMUI8 before postmarketOS, so I mounted all partitions that were mountable from the overall /dev/mmcblk0p{1..56} in respective /mnt/{1..56} folders, and grepped them for 'hisi' string:
   # for i in $(seq 1 56); do mkdir /mnt/$i; mount /dev/mmcblk0p$i /mnt/$i; done
   find /mnt/{1..56} -name "*.rc"
   ...
   /mnt/54/etc/init/connectivity/init.connectivity.hi1102.rc
   ...

https://github.com/testandroidtests/hi6250_hi6250_dump/blob/883fb2ca0c890d7b0caea7a622a05d2da1451e02/vendor/etc/init/connectivity/init.connectivity.hi1102.rc In this init script there's a mention of /vendor/bin/start_connectivity_hisi, which luckily turns out to be a text file (in our case vendor partition is mounted in /mnt/54 instead of /vendor like in android roms), which is located in /mnt/54/bin/start_connectivity_hisi https://github.com/testandroidtests/hi6250_hi6250_dump/blob/883fb2ca0c890d7b0caea7a622a05d2da1451e02/vendor/bin/start_connectivity_hisi

  • After reading it we learn that the wifi chip drivers can be either builtin or compiled as modules (plat.ko and wifi.ko), in my case they were modules as I specified that in kernel config, by setting CONFIG_HI1102_PLATFORM=m and CONFIG_HI1102_WIFI=m (and that I learned by comparing with the kernel config extracted from stock kernel by unpackbootimg and scripts/extract-ikconfig script).
  • So I copied freshly compiled plat.ko and wifi.ko from the build chroot out directory to the phone with scp and manually inserted them with insmod, which resulted in errors in dmesg about missing config files in /vendor directory. For now I simply copied the entire vendor partition to /vendor directory to resolve these issues, in a long run I'll try to find out exactly which files are needed, and a way to change the hardcoded path.
  • The last thing to do before inserting wifi.ko and enabling the wlan0 interface worked was copy/link some config files from the /vendor/firmware directory to the root directory, specifically wifi_cfg, ram_reg_test_cfg, bfgx_cfg, bfgx_and_wifi_cfg. Again, I learned this by reading the dmesg output after numerous tries of insmod wifi.ko and ip link set wlan0 up.
  • After this the lsmod shows plat and wifi modules loaded, and ip link shows a wlan0 interface that can be turned on with ip link set wlan0 up.