Message ID | 20231027182652.52217-1-juerg.haefliger@canonical.com |
---|---|
State | New |
Headers | show |
Series | [SRU,M:meta-laptop] UBUNTU: Fix bluetooth public address | expand |
On Fri, 27 Oct 2023 at 19:28, Juerg Haefliger <juerg.haefliger@canonical.com> wrote: > > BugLink: https://bugs.launchpad.net/2041000 > BugLink: https://bugs.launchpad.net/2037534 > > 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@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}" > 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@lists.ubuntu.com > https://lists.ubuntu.com/mailman/listinfo/kernel-team Acked-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com> okurrr, Dimitri
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@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
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? > > 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@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? > 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@lists.ubuntu.com > https://lists.ubuntu.com/mailman/listinfo/kernel-team Acked-by: Manuel Diewald <manuel.diewald@canonical.com>
On Wed, 22 Nov 2023 13:46:04 +0100 Manuel Diewald <manuel.diewald@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@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@lists.ubuntu.com > > https://lists.ubuntu.com/mailman/listinfo/kernel-team > > Acked-by: Manuel Diewald <manuel.diewald@canonical.com> >
On Wed, 22 Nov 2023 13:45:02 +0100 Thibault Ferrante <thibault.ferrante@canonical.com> wrote: > 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/' Yes. 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@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 ? Because btmgmt wants the MAC in reverse order. Don't ask me why... ...Juerg > > +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 >
This does not feel it is in the right place. This would mean people who install just the kernel would not have this support. It would also preclude having an HWE version of such a kernel (not planned admittedly). For SGX we did this via a new linux-base-<foo> binary package containing them (from source linux-base) and then IIRC the linux-image-<abi> packages depend on that. -apw On Wed, Nov 22, 2023 at 1:26 PM Juerg Haefliger < juerg.haefliger@canonical.com> wrote: > On Wed, 22 Nov 2023 13:45:02 +0100 > Thibault Ferrante <thibault.ferrante@canonical.com> wrote: > > > 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/' > > Yes. 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@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 ? > > Because btmgmt wants the MAC in reverse order. Don't ask me why... > > ...Juerg > > > > > +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 > > > > -- > kernel-team mailing list > kernel-team@lists.ubuntu.com > https://lists.ubuntu.com/mailman/listinfo/kernel-team >
On Thu, 23 Nov 2023, 09:53 Andy Whitcroft, <apw@canonical.com> wrote: > This does not feel it is in the right place. This would mean people who > install just the kernel would not have this support. It would also preclude > having an HWE version of such a kernel (not planned admittedly). For SGX > we did this via a new linux-base-<foo> binary package containing them (from > source linux-base) and then IIRC the linux-image-<abi> packages depend on > that. > What do you mean by "just install the kernel"? As that is not a supported configuration. And today many of our kernels do not work without a meta installed, due to initramfs hooks, udev rules, blacklists, deps on cloud tools etc. (Looking at this kernel, some cloud kernels, and riscv kernels). And this is an SKU specific kernel, and SKU specific hack. Since both systemd & bluez refuse to self generate MAC for WiFi & Bluetooth, despite doing it happily for ethernet. And kernel doesn't, and we don't (yet or ever) have any other support to gather the real device MACs. These scripts must not be used with any other kernel. And there must be only the one copy of them at a time.... Hence shipping these in meta. > -apw > > On Wed, Nov 22, 2023 at 1:26 PM Juerg Haefliger < > juerg.haefliger@canonical.com> wrote: > >> On Wed, 22 Nov 2023 13:45:02 +0100 >> Thibault Ferrante <thibault.ferrante@canonical.com> wrote: >> >> > 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/' >> >> Yes. 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@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 ? >> >> Because btmgmt wants the MAC in reverse order. Don't ask me why... >> >> ...Juerg >> >> >> > > +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 >> > >> >> -- >> kernel-team mailing list >> kernel-team@lists.ubuntu.com >> https://lists.ubuntu.com/mailman/listinfo/kernel-team >> > -- > kernel-team mailing list > kernel-team@lists.ubuntu.com > https://lists.ubuntu.com/mailman/listinfo/kernel-team >
Longer term, for migrating this SKU to generic flavour foundations wants a "settings" package built by ubuntu-meta or ubuntu-settings or a new one that mimicks raspi-settings package. But we don't have that yet, nor is it seeded, nor there is any infra to detect when to install or use it. So it is very fuzzy right now. On Thu, 23 Nov 2023, 11:09 Dimitri John Ledkov, < dimitri.ledkov@canonical.com> wrote: > > > On Thu, 23 Nov 2023, 09:53 Andy Whitcroft, <apw@canonical.com> wrote: > >> This does not feel it is in the right place. This would mean people who >> install just the kernel would not have this support. It would also preclude >> having an HWE version of such a kernel (not planned admittedly). For SGX >> we did this via a new linux-base-<foo> binary package containing them (from >> source linux-base) and then IIRC the linux-image-<abi> packages depend on >> that. >> > > What do you mean by "just install the kernel"? As that is not a supported > configuration. And today many of our kernels do not work without a meta > installed, due to initramfs hooks, udev rules, blacklists, deps on cloud > tools etc. > > (Looking at this kernel, some cloud kernels, and riscv kernels). > > And this is an SKU specific kernel, and SKU specific hack. Since both > systemd & bluez refuse to self generate MAC for WiFi & Bluetooth, despite > doing it happily for ethernet. And kernel doesn't, and we don't (yet or > ever) have any other support to gather the real device MACs. > > These scripts must not be used with any other kernel. And there must be > only the one copy of them at a time.... Hence shipping these in meta. > > > >> -apw >> >> On Wed, Nov 22, 2023 at 1:26 PM Juerg Haefliger < >> juerg.haefliger@canonical.com> wrote: >> >>> On Wed, 22 Nov 2023 13:45:02 +0100 >>> Thibault Ferrante <thibault.ferrante@canonical.com> wrote: >>> >>> > 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/' >>> >>> Yes. 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@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 ? >>> >>> Because btmgmt wants the MAC in reverse order. Don't ask me why... >>> >>> ...Juerg >>> >>> >>> > > +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 >>> > >>> >>> -- >>> kernel-team mailing list >>> kernel-team@lists.ubuntu.com >>> https://lists.ubuntu.com/mailman/listinfo/kernel-team >>> >> -- >> kernel-team mailing list >> kernel-team@lists.ubuntu.com >> https://lists.ubuntu.com/mailman/listinfo/kernel-team >> >
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}" 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
BugLink: https://bugs.launchpad.net/2041000 BugLink: https://bugs.launchpad.net/2037534 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@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