ACK/Cmnt: [SRU][M:meta-laptop][PATCH] UBUNTU: Fix bluetooth public address

Juerg Haefliger juerg.haefliger at canonical.com
Wed Nov 22 13:23:37 UTC 2023


On Wed, 22 Nov 2023 13:46:04 +0100
Manuel Diewald <manuel.diewald at canonical.com> wrote:

> On Fri, Oct 27, 2023 at 08:26:52PM +0200, Juerg Haefliger wrote:
> > BugLink: https://bugs.launchpad.net/2041000
> > BugLink: https://bugs.launchpad.net/2037534  
> 
> I cannot access the BugLinks ('Error: Page not found'). Should they be
> publicly available?

Yes, missing /bugs/ in URL. Will fix at commit-time.


> > 
> > 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"
> > +
> > +mac="${nic}:${oui}"
> > +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}"  
> 
> LP: #2041496 seems to be fixed now, so maybe we can change the script to
> use --index now?

It's fixed in noble-proposed but not releases yet and hasn't been backported
to mantic yet.

...Juerg


> > 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
> > -- 
> > 2.39.2
> > 
> > 
> > -- 
> > kernel-team mailing list
> > kernel-team at lists.ubuntu.com
> > https://lists.ubuntu.com/mailman/listinfo/kernel-team  
> 
> Acked-by: Manuel Diewald <manuel.diewald at canonical.com>
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20231122/bf0a94e8/attachment.sig>


More information about the kernel-team mailing list