I’m trying to set up a development environment to study how blue_heron works and maybe work on some open issues/features. Inspired by this gist from @fhunleth I figured that it should be possible to bridge the uart device from the rpi to my local development machine. This setup relies on a proper setup of usb-gadget mode and socat to create a bridge. It’s quite neat, and sounds like a good setup for fast feedback when developing.
Unfortunately I don’t own an rpi0, but instead have rpi0-2w. I thought it would be a good exercise to get comfortable with buildroot and embedded linux to create a similar setup but for the newer rpi0-2w. But after a few days of trying to figure out the correct buildroot options and kernel settings I must admit that I can’t find the magic combination. I know it must be possible, since the nerves-livebook images runs fine on my rpi0-2w, with the blue_heron examples.
My strategy was to start from the vanilla raspberrypizero2w defconfig in the buildroot sources. I managed to add usb-gadget support and connect through usb. But whatever I change in the rpi specific files (e.g. config.txt and cmdline.txt), I can’t make the bluetooth device appear. I’ve read up on the miniuart-bt overlay. Toggeling that overlay works as expected with regards to the serial device that’s mapped to the GPIO pins (so either /dev/ttyS0 or /dev/ttyAMA0 is available). But I never find both devices at the same time. The bluetooth one is always missing.
One dmesg message that appears consistently is:
[ 2.992154] 3f215040.serial: ttyS0 at MMIO 0x3f215040 (irq = 86, base_baud = 31250000) is a 16550
[ 2.996671] serial serial0: tty port ttyS0 registered
[ 2.999585] bcm2835-wdt bcm2835-wdt: Broadcom BCM2835 watchdog timer
[ 3.002049] bcm2835-power bcm2835-power: Broadcom BCM2835 power domains driver
[ 3.005552] mmc-bcm2835 3f300000.mmcnr: mmc_debug:0 mmc_debug2:0
[ 3.007846] mmc-bcm2835 3f300000.mmcnr: DMA channel allocated
[ 3.039163] sdhost: log_buf @ 03e6aa8d (d5911000)
[ 3.090196] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[ 3.093425] uart-pl011 3f201000.serial: there is not valid maps for state default
[ 3.096029] uart-pl011 3f201000.serial: cts_event_workaround enabled
In config.txt I have enable_uart=1
. I’ve futzed with dtoverlay=miniuart-bt
(I also have dtoverlay=dwc2
enabled for the usb-gadget mode). I also tried core_freq=250
because that seemed to have enabled bluetooth on the rpi3a nerves system before. But IMHO I think only enable_uart=1
is required to make the pi run on a fixed frequency to make miniuart usable (apparently miniuart is coupled to the GPU frequency).
Other buildroot options that I’ve tried are:
BR2_PACKAGE_BRCMFMAC_SDIO_FIRMWARE_RPI=y
BR2_PACKAGE_BRCMFMAC_SDIO_FIRMWARE_RPI_BT=y
Kernel options paired with that firmware:
CONFIG_SERIAL_8250_BCM2835AUX=y
CONFIG_BT_HCIUART=y
CONFIG_BT_HCIUART_BCM=y
The above two sets of options were just some guesses based on LLM suggestions (it’s not like I knew what I was doing
). But still no cigar.
There is a 32 bit and a 64 bit version of the raspberrypizero2w defconfig in the buildroot boards. But I only could get the 32 bit up and running with usb-gadget mode on. If the 64 bit one is key here, I’d love to know, because then I can try to get that running with a bit more effort.
My hypothesis is that I’m lacking the correct kernel options to enable the bluetooth uart device. Something chipset specific. But I’m surprised that bluetooth isn’t working on the vanilla defconfig shipped with buildroot. But that’s probably a wrong expectation from my part.
Anyway. A lot of linux kernel compiling last few days
. How do you develop for blue_heron? Am I right to pursue this setup? Or are there other ways to have a comfortable feedback loop for this?
Another strategy I can come up with is using the buildroot that’s underlying the official nerves systems (which one then, there seem to be two different ones suitable for rpi0-2w). But I haven’t figured yet out how that would work.
If I get it to work, I can submit a guide to save other developers having to figure this out in the future.