Continuation of https://github.com/postmarketOS/pmbootstrap/issues/143 and https://github.com/postmarketOS/pmbootstrap/issues/358
@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.
This is how it works:
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.serialnoro.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:
/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
This is a draft TODO:
ro.serialno). Is this the MAC address?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 :)
Awesome progress o/
@ollieparanoid Your comment on special partitions makes sense to me, and I tend to agree with that proposal.
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.
These are the md5 hashes for the blobs:
0f3d4a65a08bf0eda8c3a23e48e438ad wcnss.b00
f08f46da25e790ce436f6b31e8dc348f wcnss.b01
bc5fc4f6405e9d3d9a4ff633e5cdfcd4 wcnss.b02
4355bc68a61c942125781266d7a89a9d wcnss.b04
60c898e99adc6cf9a5c1cb0f6c2c3a52 wcnss.b06
4ae71336e44bf9bf79d2752e234818a5 wcnss.b07
cb18a5d28e77522dfec6a6255bc3847e wcnss.b08
88049c23cdf003738bb0cefb4dc49dfb wcnss.b09
8bf067bc8a30b9277a9b228e8a2a2252 wcnss.mdt
53cd45cb0f4dd730119e066333895eb5 WCNSS_qcom_wlan_cal.bin
Some GitHub searches:
Questions for @yuvadm about mozilla-flame:
ro.serial argument passed as kernel cmdline? (check /proc/cmdline)First, make these changes:
ro.serial value to /sys/devices/virtual/android_usb/android0/iSerial (check yours, might be different) (example)sudo sudmesg -cwcnss_serviceCheck 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_service
Getting prop "ro.serialno" : "" ("")
value: ZX1D229ZG4
Serial Number is 1d22ee74
CAL 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 (!)
loading /lib/firmware/postmarketos/wcnss.mdt
loading /lib/firmware/postmarketos/wcnss.b02
loading /lib/firmware/postmarketos/wcnss.b04
loading /lib/firmware/postmarketos/wcnss.b06
loading /lib/firmware/postmarketos/wcnss.b07
loading /lib/firmware/postmarketos/wcnss.b08
loading /lib/firmware/postmarketos/wcnss.b09
loading /lib/firmware/postmarketos/wlan/prima/WCNSS_qcom_wlan_nv.bin
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.
Great work again o/
Somewhere in the wiki, the TheMuppets organisation is linked, which seems to have quite a collection of these files. I suggest, that we cherry-pick the files from there (with GitHub's raw links), as shown in here: https://github.com/postmarketOS/pmbootstrap/pull/393#discussion_r133513782
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).
For the record these are the md5sums I get for these files on the Flame:
7a673f600e60f57100a8647eb270ae1b /lib/firmware/modem/wcnss.b00
d559413b468ca58f2526028cde2d3d43 /lib/firmware/modem/wcnss.b01
37444e89d4868707077f8e3f7bf35535 /lib/firmware/modem/wcnss.b02
43cdfa7f36e9e97d59c56f7070101cdb /lib/firmware/modem/wcnss.b04
093a100f1c4b9ecd8af5531fdd9e3e4d /lib/firmware/modem/wcnss.b06
469aa816010c9c8639a9176f625189af /lib/firmware/modem/wcnss.b07
6843138f05e560f2a679c9dcc3e01d94 /lib/firmware/modem/wcnss.b08
2927bfec9a71fc435d7c1436a697a91a /lib/firmware/modem/wcnss.b09
6b1f1ec9e4f081ad0487b33340092e96 /lib/firmware/modem/wcnss.mdt
ae4f1518310d4f25d32ceff402a7ba84 /persist/WCNSS_qcom_wlan_nv.bin
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: f30ecc8f
Serial Number is f30ecc8f
CAL file not found
Settings 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!
(Tracking this separately in #410)
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.
I have the same problem with not working wifi in Nexus 7 2013 flo. I will test your suggestions. I found some links that deal with this problem. @PabloCastellano and others thank you for your help fixing it!
Upstream prima firmware:
https://source.codeaurora.org/external/wlan/prima/tree/
SystemD launcher you can hack? :) :
https://git.linaro.org/landing-teams/working/qualcomm/wcnss-config.git
Arch linux chroot with wifi howto:
https://github.com/crondog/arch-flo#getting-wi-fi-working
Discussion how to load the firmware:
https://discuss.96boards.org/t/unable-to-boot-dragonboard-410c/149/3
https://discuss.96boards.org/t/enabling-wifi-support-in-custom-linux-kernel-and-rootfs/1104
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:
simg2img system.img system.raw.img or sdat2img system.transfer.list system.new.dat system.imgdmesg 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.```
sha512sums="ec6f014d324047a040c75f1922673021108a40d1b8d5ca53658995c4bd28b07e6ad8dd96560fb9bc82b45dfed7d6db3234ef5d8ec2a5d7246608f2423d023609 wcnss.mdt
5f6b1eff9304980a16eccf77ac201d0920c8562a6996f19e4fe0b8386f8d0ce31aaa745e7bc15e2ffd2ce6104192cd0b891211db6d895d632ed924a797e7d48b wcnss.b00
a91fc0f8aad8bb4d1664c09ff2203ddccb7f2ed3b49fc0dde4e527d1e864b65f8550bf4fc17120c555482deb3be75a028012e38ec8fa7c75216a9143b9ad38ca wcnss.b01
b21248769ed69b1f5a6372abf034bf3e88899df23bc98fea1338f27666065402fcb6adb37f1c0557f465360fd69a3840ccdf082c152bcac2dc4b92e2f087504a wcnss.b02
7252245a66bae6cc9d9dce2fd87e84447fd37072c05894d3adf730ac12cb42fb3372bba3ee8ace37cab7cb63472791c574362308f187832d277deec1bfd3198b wcnss.b04
b008c92dbb527f98dc402f018d72a3c715aea9a990766268ea66496a9371cc9b34c09e6119fe28fdff27e4fe083ee56f91fbf52c0570b5b6156b17fe3ff1c86c wcnss.b05
d9ec98e8fa795383678dc8ffd388d8a5fe2a475559c5996f551f02766bc3397e74c100548dcb06e2a65515c76cf28eac6f156aa805cf81ea3c580c859f4bd0f1 WCNSS_cfg.dat
df8bbc08774c1d8b479955e11e88964a172638934b98aeff3a1a76eeb2a6981f4ab9ef1c5e8abb050812ca2e99f21f661485c0c052f2103c76eccc19857f3f47 WCNSS_qcom_cfg.ini
d734e76a83960e0d6fbc11816417459ec17a72196cde727f7aeba509601965637234101cb17fa168f1cb128f1b63499cb68fe7acdef280654f25d0847a59960a WCNSS_qcom_wlan_nv.bin"
@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)!
Yes I need help but now I am going to sleep.
this firmware asks you to agree to the license. I don't know how you automate that:
https://dl.google.com/dl/android/aosp/qcom-flo-mob30x-43963492.tgz
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
echo sta > /sys/module/wlan/parameters/fwpath
wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf
udhcpc -iwlan0
ANDROID_PARANOID_NETWORK enabled in the kernel, see #737)Awesome news! So... the wcnss service is not even required?
No idea what it should do, but no. I'm just trying to get a proper time on my device for SSL to work but the alpine package manager is not very user friendly for dependency resolution unfortunately...
You could install and enable chrony, see #674.
@z3ntu Great progress! Will test this on the Flame when I get some spare time in the weekend.
@ollieparanoid I started it using rc-service chronyd start but both chronyc activity and chronyc sources didn't show any "sources". I even tried adding one directly via an IP address but it just didn't work. Maybe because of the paranoid security stuff but these rc services should be run as root (and didn't see anything other in the init.d script)...
@z3ntu Awesome finding! I will try it in my titan device soon
Yes, chrony connections are fixed with #742 .
localhost:~# chronyc sources
210 Number of sources = 1
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^? manage.mediainvent.at 2 6 1 15 -17430d[-17430d] +/- 57ms
But I needed makestep 1 -1 in my /etc/chrony/chrony.conf otherwise chrony wouldn't synchronize the time (it thinks it's really 1970 and apparently only changes it back slowly)
@z3ntu nice job, I was also trying to run the wcnss_service on the huawei y530 without success. I will try your solution to see if it also work for my device 馃憤
I confirm that z3ntu's instructions work in Moto G titan :tada:
wcnss_service is not really needed
Most helpful comment
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.mdton the device (wcnss.*files into/lib/firmware/postmarketos/andWCNSS_*files into/lib/firmware/postmarketos/wlan/prima/)Activate the driver:
Follow this guide.
ANDROID_PARANOID_NETWORKenabled in the kernel, see #737)