Skip to content

Instantly share code, notes, and snippets.

@leogallego
Forked from rometsch/BH456A_linux_driver.md
Created February 6, 2021 18:22
Show Gist options
  • Save leogallego/f8496524ab09ee5db2dd5b0d1f08a2df to your computer and use it in GitHub Desktop.
Save leogallego/f8496524ab09ee5db2dd5b0d1f08a2df to your computer and use it in GitHub Desktop.

Revisions

  1. @rometsch rometsch revised this gist Sep 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -44,7 +44,7 @@ Change `master` for whatever version you are on if its different.

    Then apply the patch with
    ``` shell
    patch -p < 2-1-1-Bluetooth-btrtl-Add-support-for-RTL8761B.diff
    patch -p 1 < 2-1-1-Bluetooth-btrtl-Add-support-for-RTL8761B.diff
    ```
    and fix possible conflicts.

  2. @rometsch rometsch revised this gist Sep 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ The MPOW Bluetooth 5 dongle (Model: BH456A) does not work out of the box on Ubun

    ## Solution

    Patch the bluetooth kernel module and copy the firmware binaries to `/etc/firmware`.
    Patch the bluetooth kernel module and copy the firmware binaries to `/lib/firmware`.

    ## Copy the fimware

  3. @rometsch rometsch revised this gist Sep 23, 2020. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -24,8 +24,8 @@ and copy the firmware files to the appropriate system directory

    ``` shell
    SRCDIR="20200610_LINUX_BT_DRIVER/rtkbt-firmware/lib/firmware"
    sudo cp $SRCDIR/rtl8761bu_fw /etc/firmware/rtl_bt/rtl8761b_fw.bin
    sudo cp $SRCDIR/rtl8761bu_config /etc/firmware/rtl_bt/rtl8761b_config.bin
    sudo cp $SRCDIR/rtl8761bu_fw /lib/firmware/rtl_bt/rtl8761b_fw.bin
    sudo cp $SRCDIR/rtl8761bu_config /lib/firmware/rtl_bt/rtl8761b_config.bin
    ```

    ## Patch the bluetooth kernel module
    @@ -36,7 +36,7 @@ For reference, I added the patch to this gist.
    To fix this, get the kernel source

    ``` shell
    9865 git clone --depth 1 --single-branch --branch master git://kernel.ubuntu.com/ubuntu/ubuntu-focal.git
    git clone --depth 1 --single-branch --branch master git://kernel.ubuntu.com/ubuntu/ubuntu-focal.git
    ```

    for your ubuntu version.
  4. @rometsch rometsch revised this gist Aug 4, 2020. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,3 @@
    # Install dirver and firmware

    ## Problem

    The MPOW Bluetooth 5 dongle (Model: BH456A) does not work out of the box on Ubuntu 20.04 (kernel 5.4.0-42).
  5. @rometsch rometsch created this gist Aug 4, 2020.
    88 changes: 88 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,88 @@
    # Install dirver and firmware

    ## Problem

    The MPOW Bluetooth 5 dongle (Model: BH456A) does not work out of the box on Ubuntu 20.04 (kernel 5.4.0-42).

    ## Solution

    Patch the bluetooth kernel module and copy the firmware binaries to `/etc/firmware`.

    ## Copy the fimware

    MPOW hosts a linux driver on their homepage.
    Download it via:

    ``` shell
    wget https://mpow.s3-us-west-1.amazonaws.com/mpow_MPBH456AB_driver+for+Linux.tgz
    ```

    Extract the contents
    ``` shell
    tar xvf mpow_MPBH456AB_driver+for+Linux.tgz
    ```

    and copy the firmware files to the appropriate system directory

    ``` shell
    SRCDIR="20200610_LINUX_BT_DRIVER/rtkbt-firmware/lib/firmware"
    sudo cp $SRCDIR/rtl8761bu_fw /etc/firmware/rtl_bt/rtl8761b_fw.bin
    sudo cp $SRCDIR/rtl8761bu_config /etc/firmware/rtl_bt/rtl8761b_config.bin
    ```

    ## Patch the bluetooth kernel module

    [This patch](https://patchwork.kernel.org/patch/11483367/) fixed a bug in the bluetooth module wrongly identifying the bluetooth chip as another version.
    For reference, I added the patch to this gist.

    To fix this, get the kernel source

    ``` shell
    9865 git clone --depth 1 --single-branch --branch master git://kernel.ubuntu.com/ubuntu/ubuntu-focal.git
    ```

    for your ubuntu version.
    Change `master` for whatever version you are on if its different.

    Then apply the patch with
    ``` shell
    patch -p < 2-1-1-Bluetooth-btrtl-Add-support-for-RTL8761B.diff
    ```
    and fix possible conflicts.

    Then its time to [build the bluetooth module](https://www.cnx-software.com/2015/03/06/how-to-build-a-single-kernel-module-driver-in-ubuntu/).

    First copy the old driver
    ``` shell
    sudo cp -r /lib/modules/$(uname -r)/kernel/drivers/bluetooth
    /lib/modules/$(uname -r)/kernel/drivers/bluetooth_bak
    ```

    Inside the cloned repository first get the current kernels config

    ``` shell
    make oldconfig
    make prepare
    make scripts
    ```

    and build the bluetooth module

    ``` shell
    cd drivers/bluetooth
    make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
    ```

    and copy the `ko` module files to the systems module dir which we backed up before.

    ``` shell
    sudo cp *.ko /lib/modules/$(uname -r)/kernel/drivers/bluetooth
    ```

    This will overwrite the existing modules.
    Running `make install` didn't work for me because of a missing certification error.
    Probably the official Ubuntu kernel is signed.

    I don't have secure boot activated, so for we unsigned drivers work fine.

    Now reboot and everything should be fine.
    33 changes: 33 additions & 0 deletions v2-1-1-Bluetooth-btrtl-Add-support-for-RTL8761B.diff
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
    index 67f4bc21e7c5..3a9afc905f24 100644
    --- a/drivers/bluetooth/btrtl.c
    +++ b/drivers/bluetooth/btrtl.c
    @@ -130,12 +130,19 @@ static const struct id_table ic_id_table[] = {
    .cfg_name = "rtl_bt/rtl8821c_config" },

    /* 8761A */
    - { IC_MATCH_FL_LMPSUBV, RTL_ROM_LMP_8761A, 0x0,
    + { IC_INFO(RTL_ROM_LMP_8761A, 0xa),
    .config_needed = false,
    .has_rom_version = true,
    .fw_name = "rtl_bt/rtl8761a_fw.bin",
    .cfg_name = "rtl_bt/rtl8761a_config" },

    + /* 8761B */
    + { IC_INFO(RTL_ROM_LMP_8761A, 0xb),
    + .config_needed = false,
    + .has_rom_version = true,
    + .fw_name = "rtl_bt/rtl8761b_fw.bin",
    + .cfg_name = "rtl_bt/rtl8761b_config" },
    +
    /* 8822C with UART interface */
    { .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV |
    IC_MATCH_FL_HCIBUS,
    @@ -267,6 +274,7 @@ static int rtlbt_parse_firmware(struct hci_dev *hdev,
    { RTL_ROM_LMP_8723B, 9 }, /* 8723D */
    { RTL_ROM_LMP_8821A, 10 }, /* 8821C */
    { RTL_ROM_LMP_8822B, 13 }, /* 8822C */
    + { RTL_ROM_LMP_8761A, 14 }, /* 8761B */
    };

    min_size = sizeof(struct rtl_epatch_header) + sizeof(extension_sig) + 3;