This might get tricky...
It's a start, basically you need to get to the point where btuart can run, that means the rpi firmware can be loaded and hciconfig and other tools can be run
add the following bluez patches to Nerves system, reachable through raspberrypi/linux#1314 (available at https://gist.github.com/nyaray/5d76432af70025b77f1d17ff8c781470)
first, mkdir -p patches/bluez5_utils
in your system repo root directory.
- patches/bluez5_utils/0001-bcm43xx-Add-bcm43xx-3wire-variant.patch
- patches/bluez5_utils/0002-bcm43xx-The-UART-speed-must-be-reset-after-the-firmw.patch
- patches/bluez5_utils/0003-Increase-firmware-load-timeout-to-30s.patch
- patches/bluez5_utils/0004-Move-the-43xx-firmware-into-lib-firmware.patch
-BR2_GLOBAL_PATCH_DIR="${BR2_EXTERNAL_NERVES_PATH}/patches"
+BR2_GLOBAL_PATCH_DIR="${BR2_EXTERNAL_NERVES_PATH}/patches ${NERVES_DEFCONFIG_DIR}/patches"
+BR2_PACKAGE_BLUEZ5_UTILS=y
+BR2_PACKAGE_BLUEZ5_UTILS_CLIENT=y
+BR2_PACKAGE_BLUEZ5_UTILS_DEPRECATED=y
+CONFIG_BT=y
+CONFIG_BT_HCIBTUSB=y
+CONFIG_BT_HCIUART=y
+CONFIG_BT_HCIUART_H4=y
+CONFIG_BT_HCIUART_BCSP=y
+CONFIG_BT_HCIBCM203X=m
btuart is a script normally on the rpi, looks like I didn't include a version in the patches, you'll want to check out the one on the pi for the logic. Bluez runs hciattach initially but determining the correct parameters depends a lot on the system
more context: raspberrypi/firmware#860
the script should be at /usr/bin/btuart
#!/bin/bash
HCIATTACH=/usr/bin/hciattach
SERIAL=`grep Serial /proc/cpuinfo | cut -c19-`
B1=`echo $SERIAL | cut -c3-4`
B2=`echo $SERIAL | cut -c5-6`
B3=`echo $SERIAL | cut -c7-8`
BDADDR=`printf b8:27:eb:%02x:%02x:%02x $((0x$B1 ^ 0xaa)) $((0x$B2 ^ 0xaa)) $((0x$B3 ^ 0xaa))`
if [ "$(cat /proc/device-tree/aliases/uart0)" = "$(cat /proc/device-tree/aliases/serial1)" ] ; then
if [ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = "16" ] ; then
$HCIATTACH /dev/serial1 bcm43xx 3000000 flow - $BDADDR
else
$HCIATTACH /dev/serial1 bcm43xx 921600 noflow - $BDADDR
fi
else
$HCIATTACH /dev/serial1 bcm43xx 460800 noflow - $BDADDR
fi