Native LEDE firmware, make your Xperia Z1 Compact as a true wifi router

munjeni

Senior Member
Jun 2, 2011
9,019
21,774
263
Hi, just to share something I done for fun, Lede router firmware built for xperia z1c :) This is for experienced users, hope somebody continue on this!

Curent status, its booting and working but not a very, some more work is need! Got wifi by hack (see /etc/init.d/network for idea).

How to install:
- modify by hex editor boot.img cmdline, change myipaddr, myroute, ssid, enctype, passw... to be able to connect to your wifi network
- flash boot.img
- reboot
- watch your router to see if device is connected
- in case connected, open configuration interface from your pc web browser e.g. http://10.0.0.8 user: root , password no need, you can also connect with putty ssh

Some screenshoots -> https://forum.xda-developers.com/showpost.php?p=74826557&postcount=1038

Have fun! :D
 

Attachments

Last edited:

munjeni

Senior Member
Jun 2, 2011
9,019
21,774
263
As I understand it, in the above case, your router will act only as a repeater?
Yes. Thing which I can't understand is why I can't get wifi in managed mode, only getting client but can't swith to managed mode to create station, mean can't get server, only client. Probably because wpa_supplicant I started manualy trought /etc/init.d/network script? Or probably z1c don't support booth clent/server in the same time? Hope somebody continue on this and play with it. Good thing is lede is native now, ram is almost free, 1600mb free. Thing which need to be ported is overlayfs kernel module in order to use e.g. cache parrition as a overlayfs. I ported to jerpelea kernel 3.10 (current kernel in lede) but that overlayfs module have only upper and lower, workdir implementarion is missing :( I'm tried some more overlayfs source but booth have missing workdir. Newer kernels have that overlayfs ok, but a lot of work is need porting it to the jerpelea kernel. Also I'm tried to get wifi on latest mainline kernel, curently got only wnc remoteproc implemented, and got half working wcn36xx, and I'm stuck on it since getting some smem isues. If somebody interesting for mainline mernel I can publish patchset I done! Also if somebody interesting for lede on jerpelea kernel I can publish patchset too! Curently I have something more in my head, to start working on my old project (native ubuntu) to get freedreno working on it...
 
Last edited:

mirhl

Senior Member
Oct 15, 2012
3,064
1,146
253
If somebody interesting for mainline mernel I can publish patchset I done! Also if somebody interesting for lede on jerpelea kernel I can publish patchset too! Curently I have something more in my head, to start working on my old project (native ubuntu) to get freedreno working on it...
Not sure how many people would be interested to LEDE specifically, though MSM8974 on mainline is certainly very interesting.

Said this, are you really clear about freedreno?
I mean, 3xx series is certainly out of the maddening status of 2xx (for which, only halium seems will ever be an option) - but is it working well, or at least satisfactorily enough?
 
  • Like
Reactions: DcR-Nl

munjeni

Senior Member
Jun 2, 2011
9,019
21,774
263
I'm unsure right now about freedreno about how it stable and enought is but believing it can be done on z1c. See my ubuntu touch port thread, was soo close to get it, problem was kernel 3.4 whixh I was lazy to imement things from freedreno kernel 3.10, but believing jerpelea kernel can be good for that thing.
 
  • Like
Reactions: DcR-Nl

munjeni

Senior Member
Jun 2, 2011
9,019
21,774
263
Wifi on mainline kernel 4.15-r2:

Code:
[    3.103967] mmc1: SDHCI controller on f98a4900.sdhci [f98a4900.sdhci] using ADMA
[    3.106009] qcom_adsp_pil adsp-pil: adsp-pil supply px not found, using dummy regulator
[    3.113660] remoteproc remoteproc0: adsp-pil is available
[    3.125095] s1: unsupportable voltage range: 1287500-1050000uV
[    3.126230] remoteproc remoteproc0: powering up adsp-pil
[    3.131655] remoteproc remoteproc0: Booting fw image adsp.mdt, size 3632
[    3.137727] mmc0: new HS200 MMC card at address 0001
[    3.139174] mmcblk0: mmc0:0001 MAG2GC 14.6 GiB 
[    3.141416] mmcblk0boot0: mmc0:0001 MAG2GC partition 1 4.00 MiB
[    3.141650] mmcblk0boot1: mmc0:0001 MAG2GC partition 2 4.00 MiB
[    3.141868] mmcblk0rpmb: mmc0:0001 MAG2GC partition 3 4.00 MiB, chardev (247:0)
[    3.142744] remoteproc remoteproc1: fb204000.wcnss is available
[    3.143766]  mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20 p21 p22 p23 p24 p25
[    3.220518] remoteproc remoteproc1: powering up fb204000.wcnss
[COLOR="Red"][    3.220581] remoteproc remoteproc1: Booting fw image wcnss.mdt, size 3424[/COLOR]
[    3.376505] mmc1: new high speed SD card at address 1234
[    3.377048] mmcblk1: mmc1:1234 SA01G 942 MiB 
[    3.382779]  mmcblk1: p1
[    3.392746] remoteproc remoteproc0: remote processor adsp-pil is now up
[COLOR="Red"][    4.258471] remoteproc remoteproc1: remote processor fb204000.wcnss is now up[/COLOR]
[COLOR="Red"][    4.364516] qcom_wcnss_ctrl remoteproc1:smd-edge.WCNSS_CTRL.-1.-1: WCNSS Version 1.5 1.2
[    4.371606] wcn36xx: mac address: 66:44:33:22:11:10
[    4.371696] wcn36xx fb204000.wcnss:smd-edge:wcnss:wlan: failed to parse qcom,smem-states property
[    4.376327] wcn36xx: ERROR failed to get tx-enable state
[    4.385372] wcn36xx: probe of fb204000.wcnss:smd-edge:wcnss:wlan failed with error -2[/COLOR]
This is device tree I have implemented:
Code:
	pronto: [email protected] {
		compatible = "qcom,pronto-v2-pil";
		reg = <0xfb204000 0x2000>, <0xfb202000 0x1000>, <0xfb21b000 0x3000>;
		reg-names = "ccu", "dxe", "pmu";

		interrupts-extended = <&intc 0 149 IRQ_TYPE_EDGE_RISING>,
				      <&wcnss_smp2p_in 0 IRQ_TYPE_EDGE_RISING>,
				      <&wcnss_smp2p_in 1 IRQ_TYPE_EDGE_RISING>,
				      <&wcnss_smp2p_in 2 IRQ_TYPE_EDGE_RISING>,
				      <&wcnss_smp2p_in 3 IRQ_TYPE_EDGE_RISING>;
		interrupt-names = "wdog", "fatal", "ready", "handover", "stop-ack";

		vddmx-supply = <&pm8841_s1>;
		vddcx-supply = <&pm8841_s2>;
		vddpx-supply = <&pm8941_s3>;

		qcom,smem-states = <&wcnss_smp2p_out 0>;
		qcom,smem-state-names = "stop";

		memory-region = <&wcnss_region>;

		pinctrl-names = "default";
		pinctrl-0 = <&wcnss_pin_a>;

		iris {
			compatible = "qcom,wcn3680";

			clocks = <&rpmcc RPM_SMD_CXO_A2>;
			clock-names = "xo";

			vddxo-supply = <&pm8941_l6>;
			vddrfa-supply = <&pm8941_l11>;
			vddpa-supply = <&pm8941_l19>;
			vdddig-supply = <&pm8941_s3>;
		};

		smd-edge {
			interrupts = <0 142 1>;

			qcom,ipc = <&apcs 8 17>;
			qcom,smd-edge = <6>;
			qcom,remote-pid = <4>;

			label = "pronto";

			wcnss {
				compatible = "qcom,wcnss";
				qcom,smd-channels = "WCNSS_CTRL";

				#address-cells = <1>;
				#size-cells = <1>;

				qcom,mmio = <&pronto>;

				bt {
					compatible = "qcom,wcnss-bt";

					/* BD address 00:11:22:33:44:55 */
					local-bd-address = [ 55 44 33 22 11 00 ];
				};

				wlan {
					compatible = "qcom,wcnss-wlan";

					/* WIFI address 00:11:22:33:44:66 */
					local-mac-address = [ 66 44 33 22 11 10 ];

					interrupts = <0 145 IRQ_TYPE_LEVEL_HIGH>,
						     <0 146 IRQ_TYPE_LEVEL_HIGH>;
					interrupt-names = "tx", "rx";

					qcom,smem-state = <&apps_smsm 10>, <&apps_smsm 9>;
					qcom,smem-state-names = "tx-enable", "tx-rings-empty";
				};
			};
		};
	};
This is where it fail https://searchcode.com/file/115655670/drivers/soc/qcom/smem_state.c line 115 , anybody have idea?
 
Last edited:
  • Like
Reactions: dmgZero and DcR-Nl

munjeni

Senior Member
Jun 2, 2011
9,019
21,774
263
Wifi on mainline kernel done! \o/

Code:
[    3.406782] remoteproc remoteproc0: remote processor adsp-pil is now up
[    4.271787] remoteproc remoteproc1: remote processor fb204000.pronto is now up
[    4.377776] qcom_wcnss_ctrl remoteproc1:smd-edge.WCNSS_CTRL.-1.-1: WCNSS Version 1.5 1.2
[    4.384895] wcn36xx: mac address: 66:44:33:22:11:10
[    5.857165] procd: - early -
[    6.512541] procd: - ubus -
[    6.564447] procd: - init -
[   12.920618] wcn36xx: firmware WLAN version 'WCN v2.0 RadioPhy vIris_TSMC_3.0 with 48MHz XO' and CRM version '39164'
[   12.920674] wcn36xx: firmware API 1.5.1.2, 41 stations, 2 bssids
[   12.930808] wcn36xx: FW Cap MCC
[   12.936199] wcn36xx: FW Cap P2P
[   12.938970] wcn36xx: FW Cap DOT11AC
[   12.942093] wcn36xx: FW Cap SLM_SESSIONIZATION
[   12.945700] wcn36xx: FW Cap DOT11AC_OPMODE
[   12.950081] wcn36xx: FW Cap SAP32STA
[   12.954273] wcn36xx: FW Cap TDLS
[   12.957892] wcn36xx: FW Cap P2P_GO_NOA_DECOUPLE_INIT_SCAN
[   12.961107] wcn36xx: FW Cap WLANACTIVE_OFFLOAD
[   12.966537] wcn36xx: FW Cap BEACON_OFFLOAD
[   12.970741] wcn36xx: FW Cap SCAN_OFFLOAD
[   12.974934] wcn36xx: FW Cap BCN_MISS_OFFLOAD
[   12.978902] wcn36xx: FW Cap STA_POWERSAVE
[   12.983153] wcn36xx: FW Cap STA_ADVANCED_PWRSAVE
[   12.987195] wcn36xx: FW Cap BCN_FILTER
[   12.991745] wcn36xx: FW Cap RTT
[   12.995414] wcn36xx: FW Cap RATECTRL
[   12.998346] wcn36xx: FW Cap WOW
[   13.002161] wcn36xx: FW Cap WLAN_ROAM_SCAN_OFFLOAD
[   13.005162] wcn36xx: FW Cap SPECULATIVE_PS_POLL
[   14.105956] EXT4-fs (mmcblk0p25): warning: maximal mount count reached, running e2fsck is recommended
[   14.107319] EXT4-fs (mmcblk0p25): mounted filesystem with ordered data mode. Opts: (null)
dummy0    Link encap:Ethernet  HWaddr 76:11:79:03:1A:CC  
          BROADCAST NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:1043 (1.0 KiB)

lo        Link encap:Local Loopback  
          LOOPBACK  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 66:44:33:22:11:10  
          inet addr:10.0.0.8  Bcast:10.0.0.255  Mask:255.0.0.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

~ #
Time for porting platform related things like display and etc :)
 

munjeni

Senior Member
Jun 2, 2011
9,019
21,774
263
Omg this saves my time https://gist.githubusercontent.com/...6239cdc3279094e4/panel-auo-novatek-720p.patch :D

Edit:
Got some progress :)
Code:
[    2.646820] msm fd900000.mdss: fd900000.mdss supply vdd not found, using dummy regulator
[    2.647184] msm_mdp fd900100.mdp: Using legacy clk name binding.  Use "lut" instead of "lut_clk"
[    2.647317] msm_mdp fd900100.mdp: MDP5 version v1.2
[    2.647346] msm fd900000.mdss: bound fd900100.mdp (ops mdp5_ops)
[    2.647494] msm_dsi fd922800.dsi: fd922800.dsi supply gdsc not found, using dummy regulator
[    2.647751] msm_dsi fd922800.dsi: fd922800.dsi supply gdsc not found, using dummy regulator
[    2.648252] msm_dsi fd922800.dsi: Using legacy clk name binding.  Use "mdp_core" instead of "mdp_core_clk"
[    2.648282] msm_dsi fd922800.dsi: Using legacy clk name binding.  Use "iface" instead of "iface_clk"
[    2.648316] msm_dsi fd922800.dsi: Using legacy clk name binding.  Use "bus" instead of "bus_clk"
[    2.648377] msm_dsi fd922800.dsi: Using legacy clk name binding.  Use "core_mmss" instead of "core_mmss_clk"
[    2.648416] msm_dsi fd922800.dsi: Using legacy clk name binding.  Use "byte" instead of "byte_clk"
[    2.648459] msm_dsi fd922800.dsi: Using legacy clk name binding.  Use "pixel" instead of "pixel_clk"
[    2.648507] msm_dsi fd922800.dsi: Using legacy clk name binding.  Use "core" instead of "core_clk"
[    2.649078] msm fd900000.mdss: bound fd922800.dsi (ops dsi_ops)
[    2.649085] [drm] using 16m VRAM carveout
[    2.649094] ------------[ cut here ]------------
[    2.649111] WARNING: CPU: 3 PID: 79 at mm/page_alloc.c:3915 __alloc_pages_nodemask+0x15c/0xffc
[    2.649115] Modules linked in:
[    2.649128] CPU: 3 PID: 79 Comm: kworker/3:2 Not tainted 4.15.0-rc2-00001-gb423273-dirty #36
[    2.649131] Hardware name: Generic DT based system
[    2.649148] Workqueue: events deferred_probe_work_func
[    2.649174] [<c03109ac>] (unwind_backtrace) from [<c030cc84>] (show_stack+0x10/0x14)
[    2.649193] [<c030cc84>] (show_stack) from [<c0ad29dc>] (dump_stack+0x88/0x9c)
[    2.649209] [<c0ad29dc>] (dump_stack) from [<c031ea30>] (__warn+0xf8/0x110)
[    2.649221] [<c031ea30>] (__warn) from [<c031eb18>] (warn_slowpath_null+0x40/0x48)
[    2.649234] [<c031eb18>] (warn_slowpath_null) from [<c03ebcdc>] (__alloc_pages_nodemask+0x15c/0xffc)
[    2.649248] [<c03ebcdc>] (__alloc_pages_nodemask) from [<c0315714>] (__dma_alloc_buffer+0x30/0x180)
[    2.649259] [<c0315714>] (__dma_alloc_buffer) from [<c0316094>] (remap_allocator_alloc+0x34/0x8c)
[    2.649268] [<c0316094>] (remap_allocator_alloc) from [<c0315a3c>] (__dma_alloc+0x1a8/0x2b4)
[    2.649278] [<c0315a3c>] (__dma_alloc) from [<c0315bc0>] (arm_dma_alloc+0x40/0x48)
[    2.649291] [<c0315bc0>] (arm_dma_alloc) from [<c074086c>] (msm_drm_bind+0x408/0x480)
[    2.649310] [<c074086c>] (msm_drm_bind) from [<c075b330>] (try_to_bring_up_master+0x1c8/0x298)
[    2.649325] [<c075b330>] (try_to_bring_up_master) from [<c075b4a8>] (component_add+0xa8/0x170)
[    2.649340] [<c075b4a8>] (component_add) from [<c0762cf8>] (platform_drv_probe+0x4c/0xb0)
[    2.649353] [<c0762cf8>] (platform_drv_probe) from [<c0760de0>] (driver_probe_device+0x2e0/0x4bc)
[    2.649364] [<c0760de0>] (driver_probe_device) from [<c075ee74>] (bus_for_each_drv+0x60/0x94)
[    2.649375] [<c075ee74>] (bus_for_each_drv) from [<c07609b8>] (__device_attach+0xb0/0x140)
[    2.649386] [<c07609b8>] (__device_attach) from [<c075fdc4>] (bus_probe_device+0x84/0x8c)
[    2.649398] [<c075fdc4>] (bus_probe_device) from [<c0760324>] (deferred_probe_work_func+0x4c/0x16c)
[    2.649412] [<c0760324>] (deferred_probe_work_func) from [<c033803c>] (process_one_work+0x138/0x4b8)
[    2.649424] [<c033803c>] (process_one_work) from [<c03383f0>] (worker_thread+0x34/0x4f4)
[    2.649439] [<c03383f0>] (worker_thread) from [<c033d57c>] (kthread+0x128/0x158)
[    2.649456] [<c033d57c>] (kthread) from [<c03087e8>] (ret_from_fork+0x14/0x2c)
[    2.649463] ---[ end trace 970617fbe8683b2e ]---
[    2.649472] msm fd900000.mdss: failed to allocate VRAM
[    2.650286] msm fd900000.mdss: master bind failed: -12
[    2.650309] msm_dsi: probe of fd922800.dsi failed with error -12
Guys did you saw this https://puri.sm/shop/librem-5/ ? I see that for the first time! Looks very promissing
 
Last edited:
  • Like
Reactions: dmgZero

munjeni

Senior Member
Jun 2, 2011
9,019
21,774
263
Trivia: that's mostly based on this previous work by freedreno dev.
(speaking of which, after some pretty deep insight, I think should be totally promising for A3xx)
No, thats writen from the stratch folowing this guide https://github.com/freedreno/freedreno/wiki/DSI-Panel-Driver-Porting , at least I am believing that since panel device trees on z3 and z1c is much diferent, init routine and etc is diferent too. Msm gpu code in mainline kernel IS maintained, wcn36xx too, many more tbings too, thats realy amazing. We juzt need to investigate device trees for things. Until that waiting libra 5 as a next phone. Z1c is last half dev phone, will not be foled again by somebody fake marketing, will double check next time what I'm buying as I want to have MY PHONE :)
 
Last edited:

mirhl

Senior Member
Oct 15, 2012
3,064
1,146
253
Then it's really weird for Red Hat copyright notice to be also present in novatek 720p code, isn't it? ?? EDIT: pretty confirmed
Though, it's true this (I think) postmarketOS guy went much further - yes.

p.s. I don't doubt Purism will be able to deliver the final product, but putting aside the very important i.MX6/i.MX8 matter (and how, nonetheless, in 2019 something cool to have could be x86 emulation), I wouldn't really be that sure for vivante gpus to be in that much better shape *by then* than adreno is today.
p.p.s. I just now realize i.MX being manufactured by NXP.. That means oddly we are still in qualcomm's ballpark.
 
Last edited:

munjeni

Senior Member
Jun 2, 2011
9,019
21,774
263
I don't care, I just waiting/watching for bying something which will be fully mainline kernel supported and fully open sourced. In case it gets similar to our xperias I will not buy. In that case I will buy an old nokia with 2" display , I tasted everything and I do not want to buy anymore anything that are half open source or "not a mine", I boughting something and expecting it to be true mine. Fully agree with Theodotos Andreou on his site and his citate "this is my phone!", I dream it too.
 
Last edited:

mirhl

Senior Member
Oct 15, 2012
3,064
1,146
253
Yeah, I see.
Though I really don't see the reason for being that dark. Outlooks for 2019 are quite positive imo (between newest phones using 4.4, and treble)
Also TIL indeed both freedreno and etnaviv are already in good shapes.
 

munjeni

Senior Member
Jun 2, 2011
9,019
21,774
263
https://postmarketos.org/blog/2017/12/31/219-days-of-postmarketOS/

*Whistles very noisily*
Perhaps your purist dream is closer than you thought.
Wow! Thats a realy good news! :) I see guys got good progress on Z1, curently Z1C have panel not working :) It can be because Z1C have many diferent panels so booth must be ported to mainline kernel. I searched for download link for postmarketos for z1 or for z1c but didn't found it :( Contacted
ata2001 on his git https://gist.github.com/ata2001/4bfb6320aded76cdd21e9f798416b2f7#comments hope we get some progress with it :fingers-crossed:
 
Last edited:
  • Like
Reactions: dmgZero and mirhl

mirhl

Senior Member
Oct 15, 2012
3,064
1,146
253
I noticed.
You see? Outlook is really rosy for the future :victory:

I'd recommend you to follow the advice he gave to me, and join their irc or matrix channels (so no more daily "remembering to check the stupid page")
 
  • Like
Reactions: munjeni