Skip to content

Instantly share code, notes, and snippets.

@nicholasaiello
Last active June 26, 2023 09:48
Show Gist options
  • Save nicholasaiello/c68b6e3458804e6545111333996286ba to your computer and use it in GitHub Desktop.
Save nicholasaiello/c68b6e3458804e6545111333996286ba to your computer and use it in GitHub Desktop.
Fix WiFI and BT in Venus OS

Enable WiFi and Bluetooth on Pi Zero 2 W

The following steps worked for me, but consider them untested. Use at your own risk!

That being said, the process should be fairly quick, as long as you use the custom image provided in this thread. Otherwise, the Pi02 won't even boot.

Setup

SD card

  • Download the image from the linked thread, and write it to your SD card
  • Create a directory in your SD card named, firmware/brcm
    • This is where you'll put the relevant files for the script
    • The name is arbitrary, so you can change it. Just make sure to update SRC_DIR, in the script

Firmware

  • Download BCM43430B0.hcd, from this repo, and move it to your SD card's firmware dir
  • From this other repo, download all files matching, brcmfmac43436-sdio.* (should be three), and move them to the SD card's firmware/

Scripts

  • Copy the patch script to your SD card, so that we can access it when the system boots (it doesn't need to go in firmware/)
  • Edit /u-boot/config.txt by adding ,krnbt=on to the miniuart-bt overlay. You only need to do this for [pi02]; it should look like the following This is now handled by the newer images

Install

  • Boot the device with your SD card
  • Run the resize script, which also makes the rootfs writable:
/opt/victronenergy/swupdate-scripts/resize2fs.sh
  • Set the datetime on the machine to the current UTC time using the following pattern, YYYY-MM-DD HH:MM:SS. Why? My instances were stuck at the time of epoch, and my bluetooth didn't work properly until I did this. Maybe others don't have this issue? Use the following command to set the datetime:
busybox date set YYYY-MM-DD HH:MM:SS

Bluetooth

  • Run the patch script added from the Install step:
. /u-boot/venus-os-pi02-patch.sh
  • Run dmesg | grep brcm to see if the patch was applied properly. If no errors, reboot your device

After reboot, WiFi and bluetooth should be working (maybe even before). Run hciconfig -a, to confirm hci0 is "UP" and running.

WiFi

  • Once BT is setup, you should be able to find the Pi02 in the Victron Connect app, and a lot of the setup will be just like any other Raspberry Pi
    • Connect and Pair with your device, and setup the WiFi connection, from the app
  • Or, you can setup WiFi from the CLI using connmanctl

More details can be found here:

connect-via-wifi

Configure

Setup Root User

Continue to setup your user:

set_access_level_to_superuser

#!/bin/sh
DEVICE_NAME="model-zero-2-w"
compat="$(cat /proc/device-tree/compatible | grep $DEVICE_NAME)"
if [ compat == "" ]; then
echo "Not running '$DEVICE_NAME'. Exiting early."
exit 0;
fi
# Add alias to /bin/ if missing
if ! [ -f "/bin/hciconfig" ]; then
if [ -f "/usr/bin/hciconfig" ]; then
echo "Add symlink for /bin/hciconfig"
ln -s /usr/bin/hciconfig /bin/hciconfig
fi
fi
BLUEZ_FIRMWARE="BCM43430B0"
BRCM_DIR="/lib/firmware/brcm"
DRIVER="brcmfmac43436"
SRC_DIR="/u-boot/firmware/brcm"
# Add bluez firmware file, create patch alias
if ! [ -f "$BRCM_DIR/$BLUEZ_FIRMWARE.hcd" ]; then
echo "Copy bluez file, $BRCM_DIR/$BLUEZ_FIRMWARE.hcd"
cp "$SRC_DIR/$BLUEZ_FIRMWARE.hcd" "$BRCM_DIR/"
ln -s "$BRCM_DIR/$BLUEZ_FIRMWARE.hcd" "$BRCM_DIR/BCM.hcd"
fi
# Add missing driver files, create device driver alias
if ! [ -f "$BRCM_DIR/$DRIVER-sdio.raspberrypi,$DEVICE_NAME.bin" ]; then
if ! [ -f "$BRCM_DIR/$DRIVER-sdio.bin" ]; then
echo "Copy wifi drivers, $BRCM_DIR/$DRIVER-sdio.bin"
cp -f "$SRC_DIR/$DRIVER-sdio.bin" "$BRCM_DIR/"
cp -f "$SRC_DIR/$DRIVER-sdio.clm_blob" "$BRCM_DIR/"
cp -f "$SRC_DIR/$DRIVER-sdio.txt" "$BRCM_DIR/"
fi
echo "Symlink device driver, $BRCM_DIR/$DRIVER-sdio.raspberrypi,$DEVICE_NAME.txt"
ln -s "$BRCM_DIR/$DRIVER-sdio.txt" "$BRCM_DIR/$DRIVER-sdio.raspberrypi,$DEVICE_NAME.txt"
fi
exit 0;
@nicholasaiello
Copy link
Author

i burned a new image, venus-image-large-raspberrypi2-20230529211714-v3.00.rootfs.wic.gz, to an sdcard for a new install using a pi02w. out of the box, both BT and WiFi did not work. i've made small updates to the patch script, so that it could resolve my issues w/ the newer images/builds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment