Debian Stretch release – wifi woes with NetworkManager – quick fix

Goal;
Get all four USB Wifi Dongles working. Most importantly I want the AC one to work. I read lots of articles that it didn’t work. Well I got it working in Debian Stretch with Network Manager (nmcli).

Some of the story;
I was remembering that Debian Jessie was fantastic with Wifi. So it had to be something with stretch.

A little over a month and half later, I’m trying the four wifi dongles I have, to see which one actually works.

Tonight, guess what? None of the four USB wifi adapters I have are working. (They will, just continue reading.)
All the tools I’m familiar with are not installed either. Just NetworkManager (the GUI tool) and “iw” on the command line, and ifconfig.

Four USB Wifi Dongles;
Edimax EW-7811Un – Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]

ASUS USB N13 – iface wlx20cf30a29c9a

Netgear A6210 AC – just ID’s as Netgear Inc.
https://github.com/jurobystricky/Netgear-A6210 << using this driver
modprobe mt7662u_sta

Netgear High Speed Wifi USB adapter – NetGear, Inc. WNDA4100 802.11abgn 3×3:3 [Ralink RT3573]

This post assisted me;
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=839605

And the only change I needed from it was as follows;
sudo vi /etc/NetworkManager/NetworkManager.conf #add these two lines
[device-mac-randomization]
wifi.scan-rand-mac-address=no

sudo service network-manager restart

Four Network Devices;
Netgear, Inc. WNDA4100 802.11abgn 3×3:3 [Ralink RT3573] = Confirmed Working.
wlx6cb0ceefa32d: connected to faith-5G
“NETGEAR WNDA4100″
wifi (rt2800usb), 6C:B0:CE:EF:A3:2D, hw
ip4 default
inet4 192.168.1.235/24
inet6 fe80::b0a6:c0c0:dbc7:f2c4/64

iwconfig
wlx6cb0ceefa32d IEEE 802.11 ESSID:”faith-5G”
Mode:Managed Frequency:5.745 GHz Access Point: …………
Bit Rate=300 Mb/s Tx-Power=20 dBm
Retry short limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality=70/70 Signal level=-29 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:54 Missed beacon:0

Netgear A6210 AC = Confirmed working
nmcli shows;
wlan0: unmanaged
“NETGEAR A6210”
wifi (RALINK WLAN), 00:00:00:00:00:00, hw, mtu 1500

Confirmed working; (I had to reboot to get it online)
wlan0: connected to Wi-Fi connection 1
“NETGEAR A6210”
wifi (usb), 6C:B0:CE:E8:DD:11, hw, mtu 1500
inet4 192.168.1.34/24
inet6 fe80::7936:ee8f:711b:9356/64

ASUS USB N13 = Confirmed Working.
A reboot brought it back online. I can scan access points with iwlist wlx20cf30a29c9a scanning
dhcp discover fails.
‘device not managed’ by NetworkManager
Ok I looked that up; https://wiki.debian.org/NetworkManager
then removed wlan0 and wlx20cf30a29c9a from /etc/network/interfaces and now wifi works on the ASUS USB N13!

Edimax = Confirmed Working.

root@BillsStretch:~# nmcli
enp4s0: connected to Wired connection 1
“Qualcomm Atheros Killer E220x Gigabit Ethernet Controller”
ethernet (alx), D4:3D:7E:EB:49:06, hw, mtu 1500
ip4 default
inet4 192.168.1.231/24
inet6 fe80::d63d:7eff:feeb:4906/64

wlx20cf30a29c9a: connected to faith 2
“Ralink 802.11 n WLAN”
wifi (rt2800usb), 20:CF:30:A2:9C:9A, hw, mtu 1500
inet4 192.168.1.97/24
inet6 fe80::26de:bce2:c87:e589/64

lo: unmanaged
loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536

DNS configuration:
servers: 192.168.1.1
interface: enp4s0

servers: 192.168.1.1
interface: wlx20cf30a29c9a

Conclusion;

Don’t install any extra tools.  Stick with nmcli nmtui and NetworkManager. Dig deeper if the setting I list doesn’t work.

Rest assured, if your wifi worked before, you can probably get it to work again in Linux. See the solution I used to get NetworkManager to working on stretch.

Quick Notes;
A. Do not add any interfaces to /etc/network/interfaces if you plan to use the tools nmcli and network manager in Debian stretch.

B. The change listed above about the mac address in NetworkManager.conf got all my wifi usb dongles to work.

C. Hot Swapping some of the dongles resulted in the wifi usb dongle not working. restarting the network-manager after hotswap didn’t always work. A full reboot got it working each time however.

D. Notice any Strange MAC address’s as all Zero’s? 00:00:00:00:00  time to do a full reboot (well you could probably rmmod and modprobe/insmod it again, anything to prod it to reload the firmware.)  Frankly the reboot is the easiest in my mind.

E. Check your dmesg.  Some dmesg stuff can be misleading.  The AC6210 kept spitting out illegal channel information and wouldn’t work with the WPA Supplicant commands.  It will however work with nmcli/NetworkManager.

PocketCHIP Bluez 5.23 A2DP to headset for audio

The reason for this post is to find a baseline for the actual bluetooth hardware on the PocketCHIP and see if bluez works properly on the device at all.

PocketCHIP is Jessie Debian based, I needed this information here, which I will build upon;
https://wiki.debian.org/BluetoothUser/a2dp

sudo apt-get install pulseaudio pulseaudio-module-bluetooth pavucontrol bluez-firmware
sudo service bluetooth restart
killall pulseaudio
sudo vi /etc/bluetooth/main.conf
Added “Enabled=Source,Sink” in [General] Section

reboot

sudo vi /etc/pulse/default.pa
load-module module-switch-on-connect

I needed a music player, this seemed great for this platform;
sudo apt-get install moc

mocp is command line to start it.

The sequence goes like this;

bluetoothctl to scan/trust/pair the a2dp headset

pacmd list sinks (sinks are outputs)
and
pactl set-default-sink bluez-device

pacmd list sinks | grep blue
Default sink name: bluez_sink.30_21_0A_30_06_CC
name: <module-bluetooth-policy>
module.description = “When a bluetooth sink or source is added, load module-loopback”
name: <module-bluetooth-discover>
name: <module-bluez5-discover>
name: <module-bluez4-discover>
name: <module-bluez5-device>
argument: <path=/org/bluez/hci0/dev_30_21_0A_30_06_CC>
name: <bluez_sink.30_21_0A_30_06_CC>
driver: <module-bluez5-device.c>
card: 1 <bluez_card.30_21_0A_30_06_CC>
bluetooth.protocol = “a2dp_sink”
device.api = “bluez”
device.bus = “bluetooth”
bluez.path = “/org/bluez/hci0/dev_30_21_0A_30_06_CC”
bluez.class = “0x240408”
bluez.alias = “BTH175”
device.icon_name = “audio-handsfree-bluetooth”
name: <bluez_sink.30_21_0A_30_06_CC.monitor>
driver: <module-bluez5-device.c>
card: 1 <bluez_card.30_21_0A_30_06_CC>
device.api = “bluez”
device.bus = “bluetooth”
bluez.path = “/org/bluez/hci0/dev_30_21_0A_30_06_CC”
bluez.class = “0x240408”
bluez.alias = “BTH175”
device.icon_name = “audio-handsfree-bluetooth”
name: <bluez_card.30_21_0A_30_06_CC>
driver: <module-bluez5-device.c>
device.api = “bluez”
device.bus = “bluetooth”
bluez.path = “/org/bluez/hci0/dev_30_21_0A_30_06_CC”
bluez.class = “0x240408”
bluez.alias = “BTH175”
device.icon_name = “audio-handsfree-bluetooth”
bluez_sink.30_21_0A_30_06_CC/#1: BTH175
bluez_sink.30_21_0A_30_06_CC.monitor/#2: Monitor of BTH175
chip@chip:~$ pactl set-default-sink bluez_sink.30_21_0A_30_06_CC

mocp

Notes on quality, pops in sound etc;
Worked great.
Sounded great.
It continually streamed properly like you would expect for a commercial device. 20+ minutes no issues.
PocketCHIP turned its display off and the audio kept playing.

Conclusions for this single test: A2DP wireless headsets can be used for PocketCHIP reliably.  The games will also use the pulseaudio default sink thru A2DP/Bluetooth which is great (no wires needed). With the Jessie provided Bluez 5.23 to boot.

Cross building bluez-5.46-1 for ARMHF

bluez is an interesting beast, requiring about 10 additional libraries to build if your building without a build system like dpkg-buildpackage.

Back Story: Last week I gave up cable TV (save yourself $100!!) to pursue more Linux projects to come up to speed with the community.  I love PocketCHIP and RaspberryPi 3 this year.  I want so many other linux gadgets (Voder, ReSpeaker V2 to name a few) I think I need to master  a few before looking much further.    The one constant with these small platforms is hindered by the ability to debug easily and effectively.  I’ve been actually working on a MIPSEL platform for 4 months and gdbserver interferes to much with our app, its slow. But to install GDB would require to many dependencies and we only have 95MB of free space.  Ideally a statically linked GDB would possibly work.  For now we (our team) will rely on static code checking, gdbserver, and gdb-multiarch.

Truly the Debian community have engineered wonderful solutions to the problems of multi-platform building.

I still need pbuilder to work on stretch, I will work that out today.  Once I do, I will then be able to provide ‘backport’ bluez packages to the debian community in the backports repository.

I need a Debian package sponsor!

How do I compile so fast?
quad core, but notice I’m not using -j4 to indicate four jobs.
look up and configure ccache for yourself.

A) First I check that the source and build system can build the package for the native architecture;

What surprised me here is that last week, I did a ‘sudo dpkg –add-architecture armhf’ and its still active.  At least I will be ready to cross build bluez.

sudo apt-get build-dep bluez
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libasan3:armhf libatomic1:armhf libc6-dev:armhf libcap-ng0:armhf
libdbus-1-3:armhf libdbus-1-dev:armhf libdbus-glib-1-2:armhf libexpat1:armhf
libffi6:armhf libgcc-6-dev:armhf libgcrypt20:armhf libglib2.0-0:armhf
libgomp1:armhf libgpg-error0:armhf libical2:armhf libicu57:armhf
liblz4-1:armhf libpcre16-3:armhf libpcre3-dev:armhf libpcre32-3:armhf
libpcrecpp0v5:armhf libstdc++-6-dev:armhf libstdc++6:armhf libsubunit0:armhf
libsystemd0:armhf libubsan0:armhf linux-libc-dev:armhf zlib1g-dev:armhf
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
check:armhf libcap-ng-dev:armhf libdbus-glib-1-dev:armhf
libglib2.0-dev:armhf libical-dev:armhf libicu-dev:armhf libsubunit-dev:armhf
The following NEW packages will be installed:
check libcap-ng-dev libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev
libical-dev libicu-dev libpcre3-dev libpcre32-3 libpcrecpp0v5 libsubunit-dev
libsubunit0 zlib1g-dev
0 upgraded, 13 newly installed, 7 to remove and 0 not upgraded.
Need to get 0 B/21.6 MB of archives.
After this operation, 30.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

B) Well at this point I just grab my source,  the source is multi-platform dpkg-buildpackage ready.
wget https://github.com/eSpecialized/bluez-5.46-rpi3/archive/5.46-1.tar.gz
tar xvf 5.46-1.tar.gz
mv bluez-5.46-rpi3-5.46-1/ bluez-5.46

C) Native architecture build time.
time dpkg-buildpackage -rfakeroot -uc -b
real 1m25.610s
user 1m13.108s
sys 0m3.988s

D) Moving on to build for arm!
https://wiki.debian.org/CrossCompiling << I use this a lot

sudo dpkg --add-architecture armhf
sudo apt-get update
sudo apt-get install build-essential crossbuild-essential-armhf
sudo apt-get build-dep -aarmhf bluez
dpkg-buildpackage -rfakeroot -Tclean -d
time CONFIG_SITE=/etc/dpkg-cross/cross-config.armhf DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -aarmhf -rfakeroot -uc -b
real 1m35.282s
user 1m21.416s
sys 0m4.432s

D) Moving on to build for mipsel!

sudo dpkg --add-architecture mipsel
sudo apt-get update
sudo apt-get install build-essential crossbuild-essential-mipsel
sudo apt-get build-dep -amipsel bluez

#you must use -d to skip deps checking for cleaning.
dpkg-buildpackage -rfakeroot -Tclean -d
time CONFIG_SITE=/etc/dpkg-cross/cross-config.mipsel DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -amipsel -rfakeroot -uc -b
real 1m47.038s
user 1m34.288s
sys 0m4.996s

Results are three platforms all ready to install

bill@BillsStretch:~/crossBuildArm/bluez-5.46$ ls ../*amd64.deb ; ls ../*armhf.deb ; ls ../*mipsel.deb

../bluez_5.46_amd64.deb ../bluez-hcidump_5.46_amd64.deb ../libbluetooth3 dbg_5.46_amd64.deb
../bluez-cups_5.46_amd64.deb ../bluez-obexd_5.46_amd64.deb ../libbluetooth-dev_5.46_amd64.deb
../bluez-dbg_5.46_amd64.deb ../libbluetooth3_5.46_amd64.deb

../bluez_5.46_armhf.deb ../bluez-hcidump_5.46_armhf.deb ../libbluetooth3-dbg_5.46_armhf.deb
../bluez-cups_5.46_armhf.deb ../bluez-obexd_5.46_armhf.deb ../libbluetooth-dev_5.46_armhf.deb
../bluez-dbg_5.46_armhf.deb ../libbluetooth3_5.46_armhf.deb

../bluez_5.46_mipsel.deb ../bluez-hcidump_5.46_mipsel.deb ../libbluetooth3-dbg_5.46_mipsel.deb
../bluez-cups_5.46_mipsel.deb ../bluez-obexd_5.46_mipsel.deb ../libbluetooth-dev_5.46_mipsel.deb
../bluez-dbg_5.46_mipsel.deb ../libbluetooth3_5.46_mipsel.deb

 

What comes after this?

I’ve documented cross building. Unfortunately this won’t work for your old Jessie Raspberry Pi Rasbian. If you have stretch then yes it will work.  I won’t release the packages I just built until I get pbuilder up and running.

Well I will need to setup pbuilder, and setting up a debian repo for testing with. Finally getting a sponsor to provide backports.

Test out bluez 5.46 for stability.   My PocketCHIP had a corrupt NAND cell (or 2). It has been re-flashed, so I will test out this build on the chip AFTER I test 5.23 with a2dp and BLE.

 

What is backports?
Debian backports allow you to use new software on older systems like Jessie.  That or you are left with just doing what I did here. Unfortunately bluez is not in that pool of packages.

https://backports.debian.org/

What is pbuilder?
it allows a clean room environment to build package, thus ensuring a minimal package dependency build on your target platform, and a properly built one at that.  Notice that I’m using a fakeroot, but that isn’t quite the same. You still get all the packages and dependencies on my system (and Debian Stretch) that were used to build the packages.

pbuilder lets me target OS’s like Jessie and further back.