Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hciattach times out sometimes on first boot for rpi0w #148

Closed
keeslinp opened this issue Nov 1, 2017 · 10 comments · Fixed by #183
Closed

hciattach times out sometimes on first boot for rpi0w #148

keeslinp opened this issue Nov 1, 2017 · 10 comments · Fixed by #183

Comments

@keeslinp
Copy link

keeslinp commented Nov 1, 2017

Description
I'm using this layer with yocto to build an image for the rpi0-w, and when I first boot the image on the device sometimes it works flawlessly but other times it doesn't set up the bluetooth properly. If it doesn't work on the first boot then rebooting will usually fix it eventually, sometimes running hciattach manually fixes the problem as well. When I dig through the logs I find that the hciattach has timed out during boot.

Steps to reproduce the issue:

  1. bitbake rpi-hwup-image
  2. dd image onto sd card
  3. boot

Describe the results you received:
Sometimes Bluetooth isn't working. There are no devices under hcitool dev or hciconfig. Also rfkill doesn't list the bluetooth device.

Describe the results you expected:
For bluetooth to setup the first time.

Additional information you deem important (e.g. issue happens only occasionally):
here is the output of systemctl status brcm43438:

Active: [[0;1;31mfailed[[0m (Result: exit-code) since Mon 2017-10-30 18:21:54 UTC; 28s ago
Process: 162 ExecStart=/usr/bin/hciattach -n /dev/ttyAMA0 bcm43xx 921600 noflow -[[0;1;31m(code=exited, status=1/FAILURE)[[0m
Main PID: 162 (code=exited, status=1/FAILURE)

systemd[1]: Started Broadcom BCM43438 bluetooth HCI.
hciattach[162]: Initialization timed out.
hciattach[162]: bcm43xx_init
systemd[1]: [[0;1;39mbrcm43438.service: Main process exited, code=exited, status=1/FAILURE[[0m
systemd[1]: [[0;1;39mbrcm43438.service: Unit entered failed state.[[0m
systemd[1]: [[0;1;39mbrcm43438.service: Failed with result `exit-code`.[[0m

Additional details (revisions used, host distro, etc.):
local.conf

BB_DISKMON_DIRS = "\
    STOPTASKS,${TMPDIR},1G,100K \
    STOPTASKS,${DL_DIR},1G,100K \
    STOPTASKS,${SSTATE_DIR},1G,100K \
    STOPTASKS,/tmp,100M,100K \
    ABORT,${TMPDIR},100M,1K \
    ABORT,${DL_DIR},100M,1K \
    ABORT,${SSTATE_DIR},100M,1K \
    ABORT,/tmp,10M,1K"
CONF_VERSION = "1"
CORE_IMAGE_EXTRA_INSTALL += "openssh rsync sensorhub"
IMAGE_INSTALL_append += "nodejs nodejs-npm bluez5 networkmanager linux-firmware-bcm43430 config systemd"
IMAGE_INSTALL_append += " crda i2c-tools hostapd linux-firmware-bcm43430 linux-firmware-ralink linux-firmware-rtl8192ce linux-firmware-rtl8192cu linux-firmware-rtl8192su wireless-tools dhcp-client iw wpa-supplicant"
DISTRO_FEATURES_append += " bluez5 bluetooth wifi systemd"```
@keeslinp
Copy link
Author

keeslinp commented Nov 1, 2017

I've done some more testing, it seems that systemctl restart brcm43438 fixes the problem consistently without a reboot. My band-aid solution is going to be adding a script on startup that checks if bluetooth is broken and if it is it will run that to fix it. Hopefully, that works until we can find a permanent solution :).

@agherzan
Copy link
Owner

That sounds like a hardware issue. Are you able to reproduce this on a raspbian?

@keeslinp
Copy link
Author

I never had this issue on raspbian. I also tested it on 5+ pi's. For what it's worth, once I got the reset script working I never had any more problems. The key is to make sure that nothing tries to use bluetooth before it has been set up properly, otherwise, you have to reboot before it'll work again.

@agherzan
Copy link
Owner

agherzan commented Dec 1, 2017

If you stop the service and run it manually after everything boots up, does it always work? I'm wondering if there is a dependency that we are not aware of.

@keeslinp
Copy link
Author

keeslinp commented Dec 1, 2017

Yeah, that fixes it fairly consistently. I'll do some tests to see if anything have changed over the last month, but here is the script that I've been using that has worked consistently:

if [ ! -d "/sys/class/bluetooth/hci0" ]; then
        sleep 20
        if [ ! -d "/sys/class/bluetooth/hci0" ]; then
                systemctl restart brcm43438
                sleep 20
                systemctl restart start-sensorhub
        fi
fi

@agherzan
Copy link
Owner

agherzan commented Dec 4, 2017

It's definitely something that we need to fix for stability.

@keeslinp
Copy link
Author

keeslinp commented Dec 4, 2017

Also, I tried removing my fix and the problem returned.

@sherifomran
Copy link

sherifomran commented Dec 15, 2017

i have the same issue, tested with systemv and systemd, i can not get the device to get initialized.
scan on > gives > no default controller available
do we need to flash the bluetooth chip ? I used daisy branch

@sherifomran
Copy link

sherifomran commented Dec 16, 2017

i tried to reproduce the colleagues error. First I am using rpi0w, in the image, there is no /etc/firmware folder, the files are installed in lib/firmware/ , second it does not have the bcm43430A1.hcd file. As far as i know, the file is needed to reflash the chip. When i created the folders manually in mkdir -p /etc/firmware/brcm/ and copied the files to these locations, i get intialization time out. I then copied the file LICENSE.broadcom_bcm43xx from /lib/firmware to /etc/firmware and i ran hciattach again, i get patch not found .. which patch does it mean? may be the firmware file BCM43430A1.hcd ? see blue5.bbappend, FILES_${PN}_append_raspberrypi0-wifi is missing. thank you

@agherzan
Copy link
Owner

Moving #174 discussion here. As per @sherifomran investigation this sounds like an outdated firmware. Is anybody able to provide a patch with an updated version of it to master? @keeslinp are you able to test this as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants