From patchwork Fri Oct 27 18:26:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juerg Haefliger X-Patchwork-Id: 1856383 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SHB3F15HNz23jP for ; Sat, 28 Oct 2023 05:27:21 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1qwRY8-0001hX-67; Fri, 27 Oct 2023 18:27:12 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1qwRXr-0001dn-G6 for kernel-team@lists.ubuntu.com; Fri, 27 Oct 2023 18:26:59 +0000 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 2A24F3FD43 for ; Fri, 27 Oct 2023 18:26:55 +0000 (UTC) Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4083a670d25so18539115e9.0 for ; Fri, 27 Oct 2023 11:26:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698431214; x=1699036014; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mMw2pniXhpxgmh9gqjlomMe/2m/9lOVJvmL26qIG9kE=; b=AbIP1YqsvX9aOCcJgakSEN7gO13ULZzhcjDBFf+8jzkwbq/TQll40Iao6i0pa2sMYc zhdKrq8cxYZ0FqxV1do9fCIDstHvrZGwCgzsM7u1n+RSV06fNEJBF1H2LDeGfNsM6PVx Y56UyPack5NWVhvJZcYL1X6dOuQpVzB5+zbXC9ZIdPgYTVgVaja5H12O7uWa7spzwsos Ly0GKYEG4dpwf/fMOD4O4y38ma0L4ZwOFOKTAjq8xJhefLoMK7lhiryhm2YN2wmomx1r xLPuhJ/NqqvKSjV/4jIj7//FXbIXlmsjZSfkRgxar/RoEaHE3sCJIGuFbzRFY7wTB8nl IcOQ== X-Gm-Message-State: AOJu0YzHTyVqYLEwkK8ZJnVG0lXCwEiX3SrHphE30lNtMepABVUSSY1n L5boExNM1EccMJpc/GTky7Wi2CJ5SKTaaIMGgEF5cAMK/ND9OZCP1u0xXDjBK4dT9b0KZ8mIajl H8MIWxfDhmT5BlxEJO4jrFbyhnGICCSH95YDmMXkcUMWX1zWbHg== X-Received: by 2002:a05:600c:a04:b0:408:5a65:c9b2 with SMTP id z4-20020a05600c0a0400b004085a65c9b2mr2947323wmp.15.1698431214594; Fri, 27 Oct 2023 11:26:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHnXmsg0fdMhA1tBlssRD+LxNfH45ElkEySW0leUuckGP580v5DpAe1nbD+bZCVp2QnrfVLkw== X-Received: by 2002:a05:600c:a04:b0:408:5a65:c9b2 with SMTP id z4-20020a05600c0a0400b004085a65c9b2mr2947314wmp.15.1698431214289; Fri, 27 Oct 2023 11:26:54 -0700 (PDT) Received: from localhost ([194.191.244.86]) by smtp.gmail.com with ESMTPSA id o14-20020a05600c4fce00b0040775501256sm2202310wmq.16.2023.10.27.11.26.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 11:26:53 -0700 (PDT) From: Juerg Haefliger To: kernel-team@lists.ubuntu.com Subject: [SRU][M:meta-laptop][PATCH] UBUNTU: Fix bluetooth public address Date: Fri, 27 Oct 2023 20:26:52 +0200 Message-Id: <20231027182652.52217-1-juerg.haefliger@canonical.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" 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 Acked-by: Dimitri John Ledkov Acked-by: Manuel Diewald --- 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