RPi-Distro / pi-bluetooth

Loads BCM43430A1 firmware on boot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hciuart service fails to start occasionally

roni-kreinin opened this issue · comments

  • Raspberry Pi 4B 4GB
  • Ubuntu 20.04 Server

I am occasionally finding that on boot the hciuart service does not start. I get these errors:

Initialization timed out.
bcm43xx_init

Seems to be the same issue as #25

Is there a fix for this?

Adding to this, I install bluez, bluez-tools, and pi-bluetooth through apt to get bluetooth working.

I want to chip in that I am also experiencing this issue.

To provide more context, we are building our flagship ROS 2 educational robot, the TurtleBot4, on top of the RaspberryPi 4B. The Bluetooth controller we use to drive the robot consistently fails to connect to the RaspberryPi, and often makes the robot nearly unusable in certain situations. We're fairly confident that this is an issue on the Pi and not our controller (we've tried multiple brands of controller). We would really like to get this bug fixed before we ship out our first robots in a few months. If there is anything we can do to help expedite building a patch, please let us know. We're more than happy to review pull requests, run test code, provide more documentation of the error, or otherwise help in the debugging process. Feel free to reach out to me directly to discuss if that would help.

We really appreciate your help in fixing this issue.

IIRC, the pi-bluetooth package in Ubuntu is different from ours.

However, I've happened to stumble upon an issue that might be relevant. You can test the fix by editing /lib/systemd/system/hciuart.service

@@ -8,4 +8,4 @@ Type=forking
 ExecStart=/usr/bin/btuart
 
 [Install]
-WantedBy=multi-user.target
+WantedBy=dev-serial1.device

You'll then need to run sudo systemctl reenable hciuart. If you reboot and that solves the issue, that would be a great sign.

These instructions are for Raspberry Pi OS only. I can't comment on Ubuntu.

I've found that I am able to consistently recreate this issue by simply calling sudo systemctl restart hciuart. See logs:

Apr 22 20:16:17 ubuntu systemd[1]: Failed to start Configure Bluetooth Modems connected by UART.
Apr 22 20:16:17 ubuntu systemd[1]: hciuart.service: Failed with result 'exit-code'.
Apr 22 20:16:17 ubuntu systemd[1]: hciuart.service: Control process exited, code=exited, status=1/FAILURE
Apr 22 20:16:17 ubuntu btuart[1352]: bcm43xx_init
Apr 22 20:16:17 ubuntu btuart[1352]: Initialization timed out.
Apr 22 20:16:07 ubuntu systemd[1]: Starting Configure Bluetooth Modems connected by UART...
Apr 22 20:16:07 ubuntu systemd[1]: Stopped Configure Bluetooth Modems connected by UART.
Apr 22 20:16:07 ubuntu systemd[1]: hciuart.service: Succeeded.
Apr 22 20:16:05 ubuntu systemd[1]: Stopping Configure Bluetooth Modems connected by UART...
Apr 22 20:12:33 ubuntu systemd[1]: Started Configure Bluetooth Modems connected by UART.
Apr 22 20:12:33 ubuntu btuart[711]: Device setup complete
Apr 22 20:12:33 ubuntu btuart[711]: Set Controller UART speed to 3000000 bit/s
Apr 22 20:12:33 ubuntu btuart[711]: Flash firmware /lib/firmware/brcm/BCM4345C0.hcd
Apr 22 20:12:33 ubuntu btuart[711]: bcm43xx_init
Apr 22 20:12:25 ubuntu systemd[1]: Starting Configure Bluetooth Modems connected by UART...

I cannot get bluetooth to start working again unless I do a full reboot. Tested that fix too and did not see any change.

I am not too familiar with how the bluetooth services work, is there something else I need to do to properly restart it?

Seeing that message at boot and seeing it when restarting the service wouldn't be the same issue.

See raspberrypi/linux#2251

But since the package you've got is not from Raspberry Pi OS, this is the wrong place for it.