【Tutorial】Use the WiFi module

It is translate from https://www.kancloud.cn/lichee/lpi0/327885

Install TF WiFi

TF WiFi can be installed to TF slot or stack on Zero.

###install to slot
install to slot, will occupy SDC0, and you can only boot from SPI Flash.
And only WiFi is enabled, BT is not connected.
https://box.kancloud.cn/7fbc4fa97325397229005658b7ff5822_1116x854.png

###stack on zero
for space restricted usage case, you can stack wifi module on zero, and there are several methods to stack on.

prepare step:
The First batch Zero have an error resistance, and you should remove the resistance to enable the wifi.
https://box.kancloud.cn/337af04ad7b806e06cf6aaf906d1af41_654x427.png

  1. stack on top side
    solder 8 pins for SDIO WiFi & 4 Pins for BT.
    https://box.kancloud.cn/12bd3ae7fa89edd264ff5e19109076ee_1024x768.jpg

https://box.kancloud.cn/b75f78d370c6938e3923442b267407c1_1024x768.jpg

This method have some disadvantage: CPU & WiFi stack together, and temperature will higher than 60℃

  1. stack on bottom side
    This method have better heat dissipation, but you should note:
    the red part need cut off, or you can’t insert LCD. and antenna should bend to bottom side.
    https://box.kancloud.cn/7eac090889135ebbfd7c749252f57e86_584x968.png

  2. stack with 2.54 slot

https://box.kancloud.cn/2930b42d1bb14685b34e7aab276e0629_1163x757.png

##WiFi usage
download the new wifi ko: http://pan.baidu.com/s/1bpB04XL
excute next cmd to open wlan0:

insmod r8723bs.ko
ifconfig wlan0 up

after edit /etc/wpa_supplicant.conf,excute connect_wx.sh to connect to network.

##BT usage
download or clone the code and make:
https://github.com/NextThingCo/rtl8723bs_bt

excute sudo ./start_bt.sh ttyS1 to create BT device.
Then use hcitools or bluez to use BT peripheral.

common WiFi error check

###wifi ko insert ok,but ifconfig -a have no wlan0
root@LicheePi:~# insmod r8723bs.ko
[ 37.054004] r8723bs: loading out-of-tree module taints kernel.
[ 37.090084] RTL8723BS: module init start
[ 37.094173] RTL8723BS: rtl8723bs v4.3.5.5_12290.20140916_BTCOEX20140507-4E40
[ 37.101496] RTL8723BS: rtl8723bs BT-Coex version = BTCOEX20140507-4E40
[ 37.108377] RTL8723BS: module init ret =0
root@LicheePi:~# ifconfig -a
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING 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)

usb0      Link encap:Ethernet  HWaddr 96:c0:f5:f1:ab:22  
          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)

check the first partition’s boot.scr is right?

root@LicheePi:~# mount /dev/mmcblk0p1 /mnt/
root@LicheePi:~# ls /mnt/
boot.scr			 sun8i-v3s-licheepi-zero-dock.dtb  zImage
sun8i-v3s-licheepi-zero-ctc.dtb  sun8i-v3s-licheepi-zero.dtb
root@LicheePi:~# cat /mnt/boot.scr 
'V·z?Xցܣ]Mڳetenv bootargs console=ttyS0,115200 panic=5 console=tty0 rootwait root=/dev/mmcblk0p2 earlyprintk rw
load mmc 0:1 0x41000000 zImage
load mmc 0:1 0x41800000 sun8i-v3s-licheepi-zero-ctc.dtb   <--wrong dtb
bootz 0x41000000 - 0x41800000

The right dtb that open the wifi function is sun8i-v3s-licheepi-zero-dock.dtb, you can find it in zero_imager or github.

###wifi ko insert failed
root@LicheePi:~# insmod r8723bs.ko
insmod: ERROR: could not insert module r8723bs.ko: Invalid module format
the ko version is wrong, download the right ko. http://pan.baidu.com/s/1bpB04XL

###always print something like SDIO RTO 0x52
WiFi module is poor welding, or you didn’t remove the resistance.

Hello,

Can you please tell us which images you provided the sun8i-v3s-licheepi-zero-dock.dtb file in, I am using minidb image and this does not exist on the boot partition like you are showing. Can you please post the .dtb files separately here or let us know where they can be downloaded from?

Thanks for all your help!

Cheers!

Okay, so after searching forever around in Chinese I found that there is another Baidu link which hasn’t been disclosed here:

https://pan.baidu.com/s/1nv7Fq2X
Password: 5gec

I am currently mirroring this to http://licheepizero.us and will also seperate out the DTS so those who wish to not have to dig through things can get it and I will come back here and update once posted.

Cheers!

I have added the following to https://licheepizero.us:

  • boot.scr - recompiled boot.scr showing the sun8i-v3s-licheepi-zero-dock.dtb as chosen.
  • sun8i-v3s-licheepi-zero-dock.dtb - DTB that activates WiFi
  • zero_imager.zip - contains the DTB and boot.cmd and other things needed to make changes your self

However, I must have something wrong with my soldering as I am getting the following error from mmc1:
error -110 whilst initialising SDIO card

Will have to clean things and re-solder to see if that error keeps coming up.

Will let you know if I get it figured out.

Cheers!

@Zepan on the URGENT boards is it still necessary to remove a resistor like mentioned above?

I am wondering if this is my issue right now, cause I can see that there looks to be a resistor there?

Please let me know.

Thanks!

I removed the resistor on my URGENT board and it works. Not sure about BT yet

Thanks for the update @grw, when I get new wick and flux next week I will remove the resistor and see how things go.

Cheers!

You can pull off the resistor easily with a pair of clippers or pliers. I first tried with a heat-gun but was scared of damaging the nearby LED.

Is there any reason why this site is down :wink:

I just want to point out that when I download the boot.scr [wifi] I found out that it was pointing to the wrong DTB file.

What do I missed there.

daniel@acer:~/lichee/wifi$ cat boot.scr
'V???GY
?H??*?setenv bootargs console=ttyS0,115200 panic=5 console=tty0 rootwait root=/dev/mmcblk0p2 earlyprintk rw
load mmc 0:1 0x41000000 zImage
load mmc 0:1 0x41800000 sun8i-v3s-licheepi-zero.dtb
bootz 0x41000000 - 0x41800000

I thought it was supposed to point to sun8i-v3s-licheepi-zero-dock.dtb.

So I did an “mkimage” to correct it .
Right now I still have problem with my wifi . I will need more investigation to figure it out,

Well, it shouldn’t be down, seems like someone decided to reboot the server without notifying me and didn’t bother to bring services back online. This has been fixed, sorry about that. I am gonna add some monitoring to it tonight to prevent further unknown outages.

ARG! It also looks like somehow I posted the wrong boot.scr, I swear I had made the correct one when I tested. Thanks for bringing this to my attention, I will fix it here momentarily @danjperron.

Cheers!

@danjperron

The boot.scr on the licheepizero.us website has now been corrected. I must have scp’d the wrong file when I was moving the files up to the web server, my apologies. Thanks for catching that and I am glad you were able to work around it and build your own.

It seems the provider I am using for the website decided they needed to do emergency maintenance last night and restart things and I didn’t have things setup to come up on boot yet. Going forward I am adding monitoring so there are not further outages like that.

Have a great day!

Cheers!

Hello All!

So I finally got a chance to re-solder as well as remove the resistor needed to get WiFi working. Once attached correctly and resistor removed the WiFi card came up as expected:

[ 29.830932] r8723bs: loading out-of-tree module taints kernel.
[ 29.858863] RTL8723BS: module init start
[ 29.866416] RTL8723BS: rtl8723bs v4.3.5.5_12290.20140916_BTCOEX20140507-4E40
[ 29.876991] RTL8723BS: rtl8723bs BT-Coex version = BTCOEX20140507-4E40
[ 29.891025] pnetdev = c3340000
[ 29.954663] RTL8723BS: rtw_ndev_init(wlan0)
[ 29.969462] RTL8723BS: module init ret =0
[ 35.073537] rtl8723bs: accquire FW from file:rtlwifi/rtl8723bs_nic.bin
[ 43.311743] RTL8723BS: rtw_set_802_11_connect(wlan0) fw_state = 0x00000008
[ 43.349856] RTL8723BS: start auth
[ 43.359258] RTL8723BS: auth success, start assoc
[ 43.372360] RTL8723BS: rtw_cfg80211_indicate_connect(wlan0) BSS not found !!
[ 43.383236] RTL8723BS: assoc success
[ 43.394554] RTL8723BS: send eapol packet
[ 43.412001] RTL8723BS: send eapol packet
[ 43.420272] RTL8723BS: set pairwise key camid:4, addr:80:2a:a8:97:d7:4e, kid:0, type:AES
[ 43.434779] RTL8723BS: set group key camid:5, addr:80:2a:a8:97:d7:4e, kid:1, type:AES

For those who are curious, here is a link to a paste of the output of ‘iw phy’: https://paste.ee/p/wUjJQ

To get things to come up on boot, here is what I did:

root@LicheePi:~# nano /etc/wpa_supplicant.conf

Changed to match my SSID’s settings
root@LicheePi:~# chmod +x /root/connect_wx.sh
root@LicheePi:~# nano /etc/rc.local
Add:
sudo -u root /root/wifi.sh

root@LicheePi:~# nano /root/wifi.sh
Added:
#!/bin/bash
sleep 5
echo “Inserting WiFi Module…”
/sbin/insmod /root/r8723bs.ko
echo “WiFi Module inserted!”
sleep 5
/sbin/ifconfig wlan0 up
echo “Brought up Wlan0!”
sleep 5
/root/connect_wx.sh
echo “WiFi Started!”

Note: you must have the ‘sudo’ app installed for this to work (apt-get install sudo). The driver doesn’t seem to want to insert correctly if run directly from /etc/rc.local, this is why I am calling an external script specifically as the ‘root’ uid:gid by using sudo -u root.

root@LicheePi:~# iwconfig
wlan0 IEEE 802.11bgn ESSID:“SSIDSSID” Nickname:“WIFI@REALTEK
Mode:Managed Frequency:2.412 GHz Access Point: 80:2A:A8:97:E7:4E
Bit Rate:72.2 Mb/s Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Encryption key:------- Security mode:open
Power Management:off
Link Quality=97/100 Signal level=95/100 Noise level=0/100
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

I have noticed an issue with the driver however in my testing:

[19107.836967] RTL8723BS: ERROR sd_recv_rxfifo: alloc recvbuf FAIL!
[19107.843612] RTL8723BS: ERROR sd_recv_rxfifo: alloc recvbuf FAIL!
[19107.850274] RTL8723BS: ERROR sd_recv_rxfifo: alloc recvbuf FAIL!
[19107.856933] RTL8723BS: ERROR sd_recv_rxfifo: alloc recvbuf FAIL!
[19107.863568] RTL8723BS: ERROR sd_recv_rxfifo: alloc recvbuf FAIL!
[19107.870224] RTL8723BS: ERROR sd_recv_rxfifo: alloc recvbuf FAIL!
[19107.878647] RTL8723BS: ERROR sd_recv_rxfifo: alloc recvbuf FAIL!
[19107.885432] RTL8723BS: ERROR sd_recv_rxfifo: alloc recvbuf FAIL!
[19107.892167] RTL8723BS: ERROR sd_recv_rxfifo: alloc recvbuf FAIL!

Upon hitting about 3.5M/sec download speed of a test file of 100-500MB in size being written to /dev/null you start to see the above on/in uart/dmesg.

This may potentially relate to this reported memory leak in the driver. So maybe after patching and recompile of module this would go away?

Hope this helps some people out!

Cheers!

Hi all, I got my Lichee Pi Zero (x2) on Friday, and spent the day today fiddling with one. I’ve been making great progress however I have not been able to get the wifi module working as of yet. Here’s what I’ve done so far:

Downloaded the module, dtb, and boot.scr from the page at licheepizero.us (thanks TheLinuxBug), edited /etc/wpa_supplicant.conf and then inserted the module with insmod:

[ 66.608220] r8723bs: loading out-of-tree module taints kernel.
[ 66.618867] RTL8723BS: module init start
[ 66.618885] RTL8723BS: rtl8723bs v4.3.5.5_12290.20140916_BTCOEX20140507-4E40
[ 66.618889] RTL8723BS: rtl8723bs BT-Coex version = BTCOEX20140507-4E40
[ 66.619055] RTL8723BS: module init ret =0

then tried ‘ifconfig wlan0 up’

wlan0: ERROR while getting interface flags: No such device

So I checked the boot.scr, just to be sure:

'V�$YA����gCH3droid u-boot script�setenv bootargs console=ttyS0,115200 panic=5 console=tty0 rootwait root=/dev/mmcblk0p2 earlyprintk rw
load mmc 0:1 0x41000000 zImage
load mmc 0:1 0x41800000 sun8i-v3s-licheepi-zero-dock.dtb
bootz 0x41000000 - 0x41800000

Yep, right .dtb. So I checked and the resistors matched the image in the original post, so I removed the marked one and repeated all the steps with identical results.

Hopefully I’m just missing something simple - any ideas?

Hi, you can check follow those instructions:

  1. check the wifi soldering, maybe some cold solder joint? (insmod without wifi module will get your messge too)
  2. you have 2 ZeroW, and you can replace the wifi module to see if it is something wrong with the first wifi module.

Ok, I will check both of these tomorrow!

After testing the 2nd wifi module I got the same results, so I carefully touched up the soldering on the Lichee Pi Zero board itself, and now everything works great!

Cheers! WiFi solder is a little hard for somebody, I will consider an onboard wifi version

Question, I do not see a wpa_supplicant.conf file in my /etc directory… I’m using the Debian_ LXDE image. I can manually create one if someone would share the format they have… I also do not see the connect_wx.sh file…

Just an FYI. Perhaps I am missing something?

Jeremy

First make sure you’ve installed the new wifi module, .dtb, and boot.scr files to enable the wifi module (all 3 can be found at https://licheepizero.us/ under 8. Downloads at the bottom.) the wpa_supplicant.conf file may be under /etc/wap_supplicant/wpa_supplicant.conf. You can get all the info you need to create one from the manpage on the debian website: https://manpages.debian.org/jessie/wpasupplicant/wpa_supplicant.conf.5.en.html

all the connect_wx.sh contains is:

#!/bin/sh
wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf &
udhcpc -i wlan0

However I don’t use it, instead I just have a call to ifup wlan0 in my rc.local.

澳洲幸运10 The code here is very good, but where is the use?