WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How can I make bluetooth work in piCore64 v. 17.  (Read 95 times)

Offline meo

  • Hero Member
  • *****
  • Posts: 759
How can I make bluetooth work in piCore64 v. 17.
« on: Today at 05:50:25 AM »
Hi there!

Trying to set up bluetooth in piCore64 v. 17 but I can't seem to find any relevant information to help me so if anyone knows how to make bluetooth work in piCore64 v. 17 I would be very grateful for any information!

Kind Regards,
meo
"All that is very well," answered Candide, "but let us cultivate our garden." - Francois-Marie Arouet Voltaire

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 15747
Re: How can I make bluetooth work in piCore64 v. 17.
« Reply #1 on: Today at 06:34:42 AM »
This script works for me on an RPi5 - I suspect there must be something more recent @paul_123?

Code: [Select]
#!/bin/sh

sudo cp /mnt/mmcblk0p2/conf/99-com.rules /etc/udev/rules.d/
sudo udevadm control --reload-rules
sudo udevadm trigger

sudo /usr/local/etc/init.d/bluez start

sudo modprobe hci_uart

while [ ! -r /dev/serial1 ]; do
        sleep 0.5
done

HCIATTACH=/usr/local/bin/hciattach
if grep -q "Pi 4" /proc/device-tree/model; then
        BDADDR=
else
        SERIAL=`cat /proc/device-tree/serial-number | cut -c9-`
        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))`
fi
uart0="`cat /proc/device-tree/aliases/uart0`"
serial1="`cat /proc/device-tree/aliases/serial1`"
if [ "$uart0" = "$serial1" ] ; then
        uart0_pins="`wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' '`"
        if [ "$uart0_pins" = "16" ] ; then
                sudo $HCIATTACH /dev/serial1 bcm43xx 3000000 flow - $BDADDR
        else
                sudo $HCIATTACH /dev/serial1 bcm43xx 921600 noflow - $BDADDR
        fi
else
        sudo $HCIATTACH /dev/serial1 bcm43xx 460800 noflow - $BDADDR
fi

Where:
Code: [Select]
cat 99-com.rules
SUBSYSTEM=="input", GROUP="staff", MODE="0660"
SUBSYSTEM=="i2c-dev", GROUP="staff", MODE="0660"
SUBSYSTEM=="spidev", GROUP="staff", MODE="0660"
SUBSYSTEM=="bcm2835-gpiomem", GROUP="staff", MODE="0660"

SUBSYSTEM=="gpio", GROUP="staff", MODE="0660"
SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c '\
        chown -R root:staff /sys/class/gpio && chmod -R 770 /sys/class/gpio;\
        chown -R root:staff /sys/devices/virtual/gpio && chmod -R 770 /sys/devices/virtual/gpio;\
        chown -R root:staff /sys$devpath && chmod -R 770 /sys$devpath\
'"

KERNEL=="ttyAMA[01]", PROGRAM="/bin/sh -c '\
        ALIASES=/proc/device-tree/aliases; \
        if cmp -s $ALIASES/uart0 $ALIASES/serial0; then \
                echo 0;\
        elif cmp -s $ALIASES/uart0 $ALIASES/serial1; then \
                echo 1; \
        else \
                exit 1; \
        fi\
'", SYMLINK+="serial%c"

KERNEL=="ttyS0", PROGRAM="/bin/sh -c '\
        ALIASES=/proc/device-tree/aliases; \
        if cmp -s $ALIASES/uart1 $ALIASES/serial0; then \
                echo 0; \
        elif cmp -s $ALIASES/uart1 $ALIASES/serial1; then \
                echo 1; \
        else \
                exit 1; \
        fi \
'", SYMLINK+="serial%c"

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1605
Re: How can I make bluetooth work in piCore64 v. 17.
« Reply #2 on: Today at 06:48:05 AM »
There are a few updates to the script.  It comes from raspiOS.  I’ll have to look it up.  But what you posted should still work

Offline meo

  • Hero Member
  • *****
  • Posts: 759
Re: How can I make bluetooth work in piCore64 v. 17.
« Reply #3 on: Today at 07:39:48 AM »
Hi Juanito and Paul_123!

Thanks for your time trying to help me out. I put the booth scripts together (???) and ran it. It can't find 99-com.rules I think it was but does the script make the RPi scan for bluetooth equipment to pair with or is that done in an other way?

Kind Greetings,
meo

PS I have searched for the 99-com.rules but I can't find anything about that in the wiki. DS
"All that is very well," answered Candide, "but let us cultivate our garden." - Francois-Marie Arouet Voltaire

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 15747
Re: How can I make bluetooth work in piCore64 v. 17.
« Reply #4 on: Today at 07:54:12 AM »
The second code box contains 99-com.rules - you need to save this somewhere after deleting the first line (cat 99-com.rules)

The script does not scan for bluetooth devices to pair with - you will either need to do this manually or use blueman, which I used to test that things work.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1605
Re: How can I make bluetooth work in piCore64 v. 17.
« Reply #5 on: Today at 08:32:58 AM »
Isn’t 99- com.rules in. The default image?

I’m just not in a spot to validate

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 15747
Re: How can I make bluetooth work in piCore64 v. 17.
« Reply #6 on: Today at 09:42:13 AM »
Ah - yes it is.

I must have had the script for a while...

Offline meo

  • Hero Member
  • *****
  • Posts: 759
Re: How can I make bluetooth work in piCore64 v. 17.
« Reply #7 on: Today at 09:52:35 AM »
Hi again Juanito and Paul_123!

With your help I got bluetooth to work! There is a negative side though since it depends on alsa I don't get any sound. I have tried even with the .asoundrc file in my home directory with pertinent information but nothing. So bluetooth works that's the pro the con is that I haven't been able to get alsa to work yet. Thanks for your willingness to help. And by the way 99-com.conf is there not visible but when I tried to copy it there the terminal asked if I wanted to overwrite?

Kind regards,
meo

PS I got some AI help as well DS
"All that is very well," answered Candide, "but let us cultivate our garden." - Francois-Marie Arouet Voltaire

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 15747
Re: How can I make bluetooth work in piCore64 v. 17.
« Reply #8 on: Today at 10:13:35 AM »
There is a negative side though since it depends on alsa I don't get any sound. I have tried even with the .asoundrc file in my home directory with pertinent information but nothing.

With the alsa, alsa-untils and graphics-KERNEL extensions loaded and without an .asoundrc file, you should get something like this on an RPi5:
Code: [Select]
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

speaker-test -c2 -t wav -l1

speaker-test 1.2.12

Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 4 to 65536
Period size range from 2 to 32768
Periods = 4
was set period_size = 12000
was set buffer_size = 48000
 0 - Front Left
 1 - Front Right
Time per period = 2.457287

Offline meo

  • Hero Member
  • *****
  • Posts: 759
Re: How can I make bluetooth work in piCore64 v. 17.
« Reply #9 on: Today at 11:50:44 AM »
Hi guys!

Things are strange but suddenly I have sound!!!!!!  Do you what the last thing I did? I changed in .ashrc I removed vi which I don't like nor use and put emacs which I like and have used for some 25 years or so. Then I start Firefox to see a video about setting up alsa and what had happened, I had sound. I could hardly believe it but it's a fact. So then I try to get bluetooth to work so I can use in-ear sound things I have and I can't get it to work. I'll try more but isn¨t it funny what can happen?

Regards,
meo
"All that is very well," answered Candide, "but let us cultivate our garden." - Francois-Marie Arouet Voltaire