This article is about:
- Problems with concurrent Bluetooth and WiFi on Raspberry Pi Zero 2 W
- Connecting USB-ethernet dongle and making the static MAC address
- Configuring NFS-boot
1. Concurrent Bluetooth and WiFi on a Pi Zero 2 W
As wrote in previous article I am trying to make use of Pi Zero and BT dongle at the same time. Generally it is working quite OK but in some corner cases the Bluetooth and WiFi communication is interfering and I have problems at that time.
I isolated the problem: the problem occurs only when I am trying to connect to a Bluetooth dongle which is not in range. It is reproducible. As you may know the dongle is in the car’s OBD port. When the car leaves the garage I am constantly trying to connect it in regular intervals and for some short period the WiFi communication (tested eg. on ping) is lost. It is about 1% of total time (BT dongle connection reattempts every 100s). I can see that about 2-3 pings are lost; it is looking exactly like this:
64 bytes from pizero (192.168.1.37): icmp_seq=583 ttl=64 time=1.31 ms
64 bytes from pizero (192.168.1.37): icmp_seq=584 ttl=64 time=1.07 ms
64 bytes from pizero (192.168.1.37): icmp_seq=585 ttl=64 time=1.11 ms
64 bytes from pizero (192.168.1.37): icmp_seq=586 ttl=64 time=1.08 ms
no answer yet for icmp_seq=587
64 bytes from pizero (192.168.1.37): icmp_seq=588 ttl=64 time=725 ms
no answer yet for icmp_seq=589
no answer yet for icmp_seq=590
64 bytes from pizero (192.168.1.37): icmp_seq=589 ttl=64 time=2085 ms
64 bytes from pizero (192.168.1.37): icmp_seq=590 ttl=64 time=1085 ms
64 bytes from pizero (192.168.1.37): icmp_seq=591 ttl=64 time=73.2 ms
64 bytes from pizero (192.168.1.37): icmp_seq=592 ttl=64 time=1.00 ms
I know this is not the end of the world, but I prefer to have a stable link, so I just took out from the shelf an old USB-ethernet dongle I had there:
It is visible in Linux in lsusb as:
Bus 001 Device 002: ID 0b95:772a ASIX Electronics Corp. AX88772A Fast Ethernet
2. Connecting the dongle
I’ve connected the dongle and here is the dmesg
for it:
[ 3.479462] usb 1-1: New USB device found, idVendor=0b95, idProduct=772a, bcdDevice= 0.01
[ 3.483454] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 3.485325] usb 1-1: Product: AX88772
[ 3.487181] usb 1-1: Manufacturer: ASIX Elec. Corp.
[ 3.488987] usb 1-1: SerialNumber: 000001
[ 4.147977] asix 1-1:1.0 (unnamed net_device) (uninitialized): PHY [usb-001:002:10] driver [Asix Electronics AX88772A] (irq=POLL)
[ 4.155176] Asix Electronics AX88772A usb-001:002:10: attached PHY driver (mii_bus:phy_addr=usb-001:002:10, irq=POLL)
[ 4.159839] asix 1-1:1.0 eth0: register 'asix' at usb-3f980000.usb-1, ASIX AX88772 USB 2.0 Ethernet, 72:a8:99:7d:61:27
[ 4.164147] usbcore: registered new interface driver asix
[ 4.905092] asix 1-1:1.0 eth0: configuring for phy/internal link mode
[ 7.045241] asix 1-1:1.0 eth0: Link is Up - 100Mbps/Full - flow control rx/tx
I tested it for a while and it seems that this connection seems to be perfect stable comparing to the WiFi of course. Here on this list:
https://elinux.org/RPi_USB_Ethernet_adapters
This chip is also listed in some other brand and marked as working stable.
I connected it directly to the Pi Zero’s USB-OTG port without any USB hub.
The main problem with simultaneous Bluetooth and WiFi is gone. No connectivity problems using a LAN cable at all 🙂
MAC address problem
The card has one problem though: it doesn’t have a valid MAC address in the EPROM/configuration.
In regular Linux there was no problem for this as I just put two files for systemd-networkd
:
/etc/systemd/network/50-usb.link:
[Match]
Driver=asix
[Link]
Name=ethusb0
MACAddress=XX:XX:XX:XX:XX:XX
/etc/systemd/network/60-usb.network:
[Match]
Name=ethusb0
[Network]
DHCP=ipv4
… but here in Raspberry Pi i wanted to boot via NFS and so the constant MAC address is a must.
Unfortunately a kernel patch for setting the MAC for NFS-boot was rejected (for the same reason as mine patch for setting MTU) telling us that “why you are not using initramfs”. Maybe because for some reason the NFS-boot is still there in linux and initramfs is just another layer which could be omitted in some scenarios?
OK, so the only solution for me was to create a proper initramfs image for the Pi.
Preparing initramfs with initramfs-tools
First I’ve added those two lines to /etc/initramfs-tools/modules
:
asix
ax88796b
So the ethernet modules get’s loaded during early boot.
Then I’ve created a file:/etc/initramfs-tools/scripts/init-premount/asix
With the contents:
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
. /scripts/functions
INTERFACE="eth0"
MAC="00:0e:c6:XX:XX:XX"
log_begin_msg "MAC address re-configuration..."
ip link set dev $INTERFACE address $MAC
configure_networking
Finally made it executable:chmod +x asix
In some tutorials (probably for older Raspberry Pi OS-es) I saw instructions, that you need to copy the resulting initrd image to the SD card’s boot partition and also make a change in boot/config.txt like this:
initramfs initrd.img followkernel
In my case however it seems it is done automatically. The image is copied, and the config.txt has this:
# Automatically load initramfs files, if found
auto_initramfs=1
To sum it up: fortunately it was as easy as:
# update-initramfs -u -k $(uname -r)
update-initramfs: Generating /boot/initrd.img-6.1.0-rpi7-rpi-v8
And this is sufficient to boot with this new initramfs image.
Related helpful articles/manuals:
- https://manpages.ubuntu.com/manpages/xenial/man8/initramfs-tools.8.html
- https://github.com/ralsina/zero-nfsroot
- https://dev.webonomic.nl/how-to-run-or-boot-raspbian-on-a-raspberry-pi-zero-without-an-sd-card
- http://retinal.dehy.de/docs/doku.php?id=technotes:raspberryrootnfs
3. NFS-root
I think it should work as in other methods (so passing an ip=...
to the kernel commandline, adjusting fstab
, etc). I didn’t do it yet, but I will write something here only if I encounter some problems.
How did you get the Mac address?
00:0e:c6 is the official prefix for Asix Elec. Corp., so I just used it at the beginning.
Generally you can set what you want.