[SRU][M:meta-laptop][PATCH] UBUNTU: Fix bluetooth public address
Thibault Ferrante
thibault.ferrante at canonical.com
Wed Nov 22 12:45:02 UTC 2023
On 27-10-2023 20:26, Juerg Haefliger wrote:
> BugLink: https://bugs.launchpad.net/2041000
> BugLink: https://bugs.launchpad.net/2037534
These URLs are missing 'bugs/'
>
> The X13s comes up with no BT public address, it's hidden probably in
> secret storage that the kernel can't get to (yet), so it needs to be
> set by userspace after bluez is up. For some reason, a delay is
> required, so do that and also calculate a unique MAC based on
> /etc/machine-id.
>
> Signed-off-by: Juerg Haefliger <juerg.haefliger at canonical.com>
> ---
> debian/install | 1 +
> share/set-bt-public-addr | 34 +++++++++++++++++++
> ...laptop-image-bluetooth-public-addr.service | 3 +-
> 3 files changed, 37 insertions(+), 1 deletion(-)
> create mode 100755 share/set-bt-public-addr
>
> diff --git a/debian/install b/debian/install
> index aeb5be43a521..b2825799c756 100644
> --- a/debian/install
> +++ b/debian/install
> @@ -3,3 +3,4 @@ hooks/* usr/share/initramfs-tools/hooks/
> grub.d/* etc/default/grub.d/
> rules.d/* lib/udev/rules.d/
> systemd-system/* lib/systemd/system/
> +share/* usr/share/linux-laptop/
> diff --git a/share/set-bt-public-addr b/share/set-bt-public-addr
> new file mode 100755
> index 000000000000..b6443d8bff3a
> --- /dev/null
> +++ b/share/set-bt-public-addr
> @@ -0,0 +1,34 @@
> +#!/bin/sh
> +#
> +# Set X13s bluetooth public address
> +#
> +
> +idx=
> +for hci in /sys/class/bluetooth/hci* ; do
> + rp=$(realpath "${hci}")
> + case "${rp}" in
> + */serial0/serial0-0/*)
> + idx=${rp##*/hci}
> + break
> + ;;
> + esac
> +done
> +
> +if [ -z "${idx}" ] ; then
> + echo "No serial BT adapter found"
> + exit 0
> +fi
> +
> +
> +# Bytes 1-3 from /etc/machine-id
> +nic=$(sed 's/\(..\)/\1:/g' /etc/machine-id | cut -c 1-8)
> +
> +# Qualcomm OUI
> +oui="f0:fd:8c"
One of the Qualcom OUI is '8c:fd:f0', why it isn't in the same order ?
> +
> +mac="${nic}:${oui}"
Same about ordering, why nic is first here ?
> +echo "Set public addr of hci${idx} to ${mac}"
> +
> +# Do not use '--index N' yet since bluez is currently broken (LP: #2041496)
> +#/usr/bin/yes 2>/dev/null | /usr/bin/btmgmt --index "${idx}" public-addr "${mac}"
> +/usr/bin/yes 2>/dev/null | /usr/bin/btmgmt public-addr "${mac}"
> diff --git a/systemd-system/linux-laptop-image-bluetooth-public-addr.service b/systemd-system/linux-laptop-image-bluetooth-public-addr.service
> index fbe57b41da07..dd13274aff1f 100644
> --- a/systemd-system/linux-laptop-image-bluetooth-public-addr.service
> +++ b/systemd-system/linux-laptop-image-bluetooth-public-addr.service
> @@ -3,7 +3,8 @@ Description=Set Bluetooth Address
> After=bluetooth.service
>
> [Service]
> -ExecStart=/bin/bash -c "/usr/bin/btmgmt --timeout 30 public-addr AD:5A:00:F0:FD:8C"
> +ExecStartPre=/usr/bin/sleep 5
> +ExecStart=/usr/share/linux-laptop/set-bt-public-addr
>
> [Install]
> WantedBy=bluetooth.service
--
Thibault
More information about the kernel-team
mailing list