@yuvadm and I are working (see my titan-wifi branch and yuvadm's device-mozilla-flame) on the dynamic firmware loading feature (https://github.com/postmarketOS/pmbootstrap/issues/147) which is required by the wlan-prima module to load blobs (are these considered blobs?) in order to initialize the wireless interface later. This is the case for mozilla-flame and motorola-titan so far.
I made the wcnss-service (initially written for Android) some modifications (removed Android stuff, mocked Android functions) and added a Makefile and now it compiles and works in real linuxes.
This so-called service reads the following system variables:
ro.serialno
ro.baseband (the MODEM_BASEBAND_PROPERTY constant)
and writes wlan.driver.config and wlan.driver.ath.
Maybe writing the variables is not needed for postmarketOS. However ro.serialno is used to generate a serial number, used to initialize the interface. I have hardcoded this value for testing but it can be read from /proc/cmdline.
However my device gets frozen right after running wcnss-service. There must be something I've left back.
Things we should take the chance to discuss:
Firmware path(s). Is it /lib/firmware or /lib/firmware/postmarketos?
yuvadm commented on Matrix:
also keep in mind that at least for the flame I have firmware that is flashed on some special partitions and ideally i would want to mount them to /lib/firmware/$foo
Fix wcnss-service so that it doesn't hang the device :)
Investigate also other versions of wcnss-service (will paste the link later, I found some newer version, that might fix the hang) and compiling options (is -DWCNSS_QMI needed?)
Research what does the serial number (derived from ro.serialno). Is this the MAC address?
1 of 4 checklist items completed
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items 0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items 0
Link issues together to show that they're related.
Learn more.
We have discussed elsewhere, that it would make sense to put postmarketOS specific firmware files in /lib/firmware/postmarketos, so we don't have any clashes with the linux-firmware package.
In other words, I would put everything that is not in linux-firmware in /lib/firmware/postmarketos.
About special firmware partitions: I would rather have the files installed with packages in postmarketOS in the root partition, even if they were duplicated. That way we could make sure that we have a specific version installed, and even update them as necessary (for the devices, where the vendors still supply firmware updates, or maybe at some point in the future for open source firmware) and don't risk writing to that partition, which may break other (Android) operating systems. But as always, this is open for discussion - just my two cents on the topic :)
I have pushed the wlan-prima-wcnss branch with wcnss-service (aports/main/wcnss-service) packaged and some modifications to make the firmware load for titan devices.
The module requires the following blobs in my case: wcnss.b00, wcnss.b01, wcnss.b02, wcnss.b04, wcnss.b06, wcnss.b07, wcnss.b08, wcnss.b09, wcnss.mdt (note that some numbers are missing). I extracted them from a LineageOS rom and since I don't know where it is better to fetch these, I've put them in a tgz file in the branch.
I said in my case because in the process of finding a repo to fetch these, I've found that some repos have a wcnss.b05 but don't have wcnss.b08 nor wcnss.b09...
So it looks like depending on the device, you might need only some.
Another file needed is WCNSS_qcom_wlan_cal.bin which seems to be used for some kind of calibration.
linux-$flavor must depend on wcnss-service and install the firmware files (example)
In my case, I set the ro.serial value to /sys/devices/virtual/android_usb/android0/iSerial (check yours, might be different) (example)
pmbootstrap install
login through ssh and then
sudo su
dmesg -c
wcnss_service
Check dmesg again. In my case, this is what I get:
[ 81.709055,2] wcnss_wlan triggered by userspace[ 81.743479,2] pil_pronto fb21b000.qcom,pronto: wcnss: loading from 0x0d200000 to 0x0d7ae000[ 82.101310,0] pil_pronto fb21b000.qcom,pronto: wcnss: Brought out of reset[ 82.388533,1] pil_pronto fb21b000.qcom,pronto: wcnss: Power/Clock ready interrupt received[ 82.489502,0] pil_pronto fb21b000.qcom,pronto: Subsystem error monitoring/handling services are up[ 82.490933,0] platform sound.41: Driver msm8226-asoc-tapan requests probe deferral[ 82.491068,3] diag: In diag_send_msg_mask_update, invalid status 0[ 82.491081,3] diag: In diag_send_log_mask_update, invalid status 0[ 82.491646,0] platform sound-9302.42: Driver msm8226-asoc-tapan requests probe deferral[ 82.603095,0] wcnss_wlan_ctrl_probe: SMD ctrl channel up[ 82.603913,0] platform sound-9302.42: Driver msm8226-asoc-tapan requests probe deferral[ 82.604438,0] platform sound.41: Driver msm8226-asoc-tapan requests probe deferral[ 82.604491,0] wcnss: version 01050102[ 82.604518,0] wcnss: schedule dnld work for pronto[ 82.604690,0] wcnss: build version 12045421[ 85.118404,0] wcnss: NV download[ 85.118418,0] wcnss: NV file name = wlan/prima/WCNSS_qcom_wlan_nv.bin[ 85.131659,0] wcnss: NV bin size: 29812, total_fragments: 10[ 85.131763,0] wcnss: no space available for smd frame[ 85.155112,0] wcnss: no space available for smd frame[ 85.178447,0] wcnss: no space available for smd frame[ 85.201779,0] wcnss: no space available for smd frame[ 85.234793,0] platform sound.41: Driver msm8226-asoc-tapan requests probe deferral[ 85.235355,0] platform sound-9302.42: Driver msm8226-asoc-tapan requests probe deferral[ 85.236457,0] platform sound-9302.42: Driver msm8226-asoc-tapan requests probe deferral[ 85.237062,0] platform sound.41: Driver msm8226-asoc-tapan requests probe deferral[ 85.239887,0] platform sound.41: Driver msm8226-asoc-tapan requests probe deferral[ 85.240386,0] platform sound-9302.42: Driver msm8226-asoc-tapan requests probe deferral[ 92.628405,0] wcnss_post_bootup: Cancel APPS vote for Iris & WCNSS
This is the output from wcnss_service:
localhost:/home/user# wcnss_serviceGetting prop "ro.serialno" : "" ("")value: ZX1D229ZG4Serial Number is 1d22ee74CAL file not found
I'm not using the calibration file at the moment. I want to see if it is device-specific or what. It is still not working but good news is that the device doesn't hang up (maybe because of the calibration file?).
@PabloCastellano from an initial test I get totally different hashes on the blobs, but I don't have access to all of them right now. I'm going to try testing your PR on the flame and report back with more details.
Apparently these files are called Peripherial Image Loader (PIL). I have no idea about this stuff but some documentation is here: Documentation/arm/msm/pil.txt.
Also, as reported in /var/log/firmwareload.log, my device is not loading all the blobs (!)
The .mdt is the first one loaded (maybe some kind of table that says what to load then?). It seems that the loading happens here. Another references are in include/linux/qseecom.h and drivers/misc/qseecom.c.
Last thing, file sizes seem to be completely different too from other blobs with same names I've found:
-rw-r--r-- 1 pablo pablo 372 Feb 3 2015 wcnss.b00-rw-r--r-- 1 pablo pablo 6760 Feb 3 2015 wcnss.b01-rw-r--r-- 1 pablo pablo 10880 Feb 3 2015 wcnss.b02-rw-r--r-- 1 pablo pablo 45056 Aug 27 2014 wcnss.b04-rw-r--r-- 1 pablo pablo 2841224 Feb 3 2015 wcnss.b06-rw-r--r-- 1 pablo pablo 16 Aug 27 2014 wcnss.b07-rw-r--r-- 1 pablo pablo 786432 Aug 27 2014 wcnss.b08-rw-r--r-- 1 pablo pablo 36788 Feb 3 2015 wcnss.b09-rw-r--r-- 1 pablo pablo 7132 Feb 3 2015 wcnss.mdt
We definitely need someone who is familiar to this stuff.
This assumes, that it has the files with the right hashes somewhere of course. Otherwise we could dig through the LineageOS dependencies for your devices, and find out where it pulls the sources from (I can help with that, if it is unclear!).
If necessary, you could also cherry-pick files from multiple repositories - this is still better, than including them in our aports folder.
Regarding talking to someone who knows about PIL files. Maybe @McBitter does, otherwise you could ask in a kernel-development IRC channel or something (not saying that I know one).
Ok made some progress testing the branch on the flame, I cherry picked some of your commits and added some flame specific stuff just for testing (device-mozilla-flame-wifi).
When running:
$ wcnss_service Getting prop "ro.serialno" : "" ("")value: f30ecc8fSerial Number is f30ecc8fCAL file not foundSettings prop "wlan.driver.ath" = "0"wcnss_read_and_store_cal_data trying to read cal
And the process just hangs there. This is what I get on dmesg:
[ 307.153504] wcnss_wlan triggered by userspace[ 307.185667] wcnss_trigger_config: adc get failed[ 307.201502] pil_pronto fb21b000.qcom,pronto: wcnss: loading from 0x0d200000 to 0x0d7ae000[ 307.794145] pil_pronto fb21b000.qcom,pronto: wcnss: Brought out of reset[ 308.536404] pil_pronto fb21b000.qcom,pronto: wcnss: Power/Clock ready interrupt received[ 308.646108] pil_pronto fb21b000.qcom,pronto: Subsystem error monitoring/handling services are up[ 308.647876] diag: In diag_send_msg_mask_update, invalid status 0[ 308.647892] diag: In diag_send_log_mask_update, invalid status 0[ 308.891588] wcnss_wlan_ctrl_probe: SMD ctrl channel up[ 308.894578] wcnss: version 01050102[ 308.894609] wcnss: schedule dnld work for pronto[ 308.895557] wcnss: build version 12053614[ 311.435296] wcnss: NV download[ 311.448544] wcnss: NV bin size: 29812, total_fragments: 10[ 311.448637] wcnss: no space available for smd frame[ 311.475367] wcnss: no space available for smd frame[ 311.505342] wcnss: no space available for smd frame[ 311.535353] wcnss: no space available for smd frame[ 311.588453] wcnss: not setting up vbatt[ 318.905460] wcnss_post_bootup: Cancel APPS vote for Iris & WCNSS
Actually this might be proper behavior. If I keep the service open, I'm now able to get past this and actually attempt to start loading the wlan driver. I'm stuck on a few things there, but overall this looks good!
Regarding the -DWCNSS_QMI flag used to compile wcnss-service, I've started reading and collecting useful information about QMI (Qualcomm MSM Interface). However, I'm still not sure if the qmi_wwan driver and libqmi can totally replace the interface initialization done by wcnss-service.
Okay so I see that the prima driver is in here:
https://source.codeaurora.org/external/wlan/prima/tree/
But it is for the android kernel so uses wakelocks. The good news is that wakelocks are included in mainline kernel but under a different name.
How would one patch the drivers to include them in mainline kernel?
I see the lineage flo google kernel has the prima driver in /staging and the Qualcomm WCNSS CORE driver in wifi enabled.
@PabloCastellano maybe it would be better to use the lineage version as it uses the upstream WCNSS_qcom_wlan_nv.bin instead of your patch with WCNSS_qcom_wlan_cal.bin?
It seems Linaro guys are working on WCNSS support:
https://git.linaro.org/people/john.stultz/flo.git/
Okay, so finally after two days of work I found out how to load the wifi drivers for Nexus 7 2013 flo and want to share with you all so it may help with your devices:
See if your kernel has this /drivers/net/wireless/ath/wcn36xx as new kernels have this driver and select it in menuconfig if you are compiling the kernel.
Download the official or community ROM for your device or learn how to extract files from your phones Android system.
Find and convert system.img or system.new.dat file to a raw image so you can exctract firmware:
simg2img system.img system.raw.img or sdat2img system.transfer.list system.new.dat system.img
The files you need are in /vendor/firmware/ and /etc/wifi/. For Linux support overwrite /vendor/firmware/wlan/prima/ with /etc/wifi/ files. If you have a WCNSS_qcom_wlan_nv*.bin file - rename it to WCNSS_qcom_wlan_nv.bin and overwrite the old WCNSS_qcom_wlan_nv.bin as it is only a symlink.
Put the created /firmware/ folder to your system /lib/firmware/ folder. Alternatively for wifi you only need WCNSS_cfg.dat, WCNSS_qcom_cfg.ini, WCNSS_qcom_wlan_nv.bin and all the wcnss* files.
IMPORTANT! Check if the checksums of the files on your pc and device are the same with sha512sum *
Reboot and after startup write dmesg and see if the wifi driver has loaded and ip link to see if you have a wlan0 device if not try to run wcnss-start manualy or reboot again. Try to build the kernel wifi driver as a module.
Try to run wpa suplicant and dhcp to see if you can connect to the Internet.
@montvid, awesome work! Let us know if you need any help with packaging that for postmarketOS (so it can be installed automatically when selecting the asus-flo device)!
It seems the upstream codeaurora https://source.codeaurora.org/external/wlan/prima/tree/ firmware(the WCNSS_qcom_wlan_nv.bin) does not work with my Nexus 7 2013/flo wifi so I had to extract the files from the rom or download from lineageos flo device repo. I updated the instructions and the SHA512.
I tried the wcnss_service on the huawei y530, I had to change the source url because it wasn't working anymore. @PabloCastellano If you want I can push my changes directly on the branch, but I tried to rebase the branch on master and there were conflicts on other files that are not related to the wcnss_service.
Is it ok for you if I create a new branch with the new APKBUILD I created (it's a cleaned up version of your with a github repository as source and with your patches)?
Got WiFi to work on the FP2 with the Prima/Pronto driver (run all commands as root!):
Get the files:
WCNSS_qcom_cfg.ini, WCNSS_cfg.dat, WCNSS_qcom_wlan_nv.bin, wcnss.b0{0,1,2,3,4,5,6,7,8,9}, wcnss.mdt on the device (wcnss.* files into /lib/firmware/postmarketos/ and WCNSS_* files into /lib/firmware/postmarketos/wlan/prima/)
Activate the driver:
echo 1 > /dev/wcnss_wlan
Run some other command (I don't know yet what it does exactly, but it seems to be required):