Bluetooth support under buildroot

  • Hello! I'd like to let you know that currently, some relevant dependencies of the Bluez tool in Buildroot only support glibc and not uclibc. So, unfortunately, you won't be able to use this tool. If you're using a uclibc system, you might want to consider switching to another Bluetooth protocol stack, such as btstack. Another option would be to change the compiler to build the rootfs. For now, when it comes to Bluetooth development, you can refer to this link: https://wiki.luckfox.com/zh/Luckfox-Pic ... tra-W-WIFI. I hope this helps!
  • Thanks for the reply.

    I tried to get btstack working using the posix-h4 port, even setting the device to /dev/ttyS1 and the baudrate to 1500000, but the device doesn't reply to the reset command sent by the examples. As far as I understand I shouldn't use hciconfig etc. when using btstack?
    Is there any more information on how I might get this to work?

    Regarding switching out the compiler for the rootfs, can you give me any hints on how I might do that?

    Thanks!
  • Quick update: After some more experimenting around, it seems like bluetoothd is actually running on the Luckfox Pico Pi W by default (/usr/libexec/bluetooth/bluetoothd) and there is even bluetoothctl, but none of the commands seem to work there. It seems to me like most of bluez is already there, so why does bluetooth not "just work"? Which part is actually missing?
  • Hello, bluetoothctl has dependencies on the glibc library. However, our system is built based on uclibc, and it lacks the necessary dependencies (such as the readline library), which prevents the interaction of bluetoothctl from being realized. Testing Bluetoothctl in the glibc and musl environments is normal.
  • Hello,

    thanks for the reply. With that, I finally got Bluetooth working under buildroot using btstack! It can take over the hci interface after it has been created by the hciattach:

    Code: Select all

    hciattach -s 1500000 /dev/ttyS1 any 1500000 flow
    For future reference, this is how I got it to work. First, create a folder under this path from the sdk: sysdrv/source/buildroot/buildroot-2023.02.6/package/btstack

    Then create a file Config.in within the btstack folder:

    Code: Select all

    config BR2_PACKAGE_BTSTACK
        bool "btstack"
        help
          BTSTACK
    
    Then create a file btstack.mk:

    Code: Select all

    BTSTACK_VERSION = 4d6a6c4c6e958cbf0104067baa6fb35e80e886a2   # (latest release, adjust if needed)
    BTSTACK_SITE = $(call github,bluekitchen,btstack,$(BTSTACK_VERSION))
    BTSTACK_LICENSE = BluekitchenLicense
    BTSTACK_LICENSE_FILES = LICENSE
    
    BTSTACK_CONF_OPTS =  -DCMAKE_CXX_FLAGS=-I$(STAGING_DIR)/usr/include -DCMAKE_C_FLAGS=-I$(STAGING_DIR)/usr/include
    BTSTACK_INSTALL_TARGET = YES
    BTSTACK_SUBDIR = port/linux
    
    define BTSTACK_INSTALL_TARGET_CMDS
        rm -rf $(TARGET_DIR)/btstack
        mkdir -p $(TARGET_DIR)/btstack
        cp -a $(@D)/port/linux/. $(TARGET_DIR)/btstack/
    endef
    
    $(eval $(cmake-package))
    
    Edit sysdrv/source/buildroot/buildroot-2023.02.6/package/Config.in to include your btstack/Config.in somewhere. Then enable btstack in the buildrootconfig. Funnily enough, btstack does have a dependency on bluez (libbluetooth) in this mode, but it doesn't seem to care that bluez doesn't fully work, only needs it headers I think. That's why the includes are so funky up above.

    After building, flash the image using rkflash.sh. Then you need to bring hci0 down:

    Code: Select all

    hciconfig hci0 down
    Or remove the line to bring hci0 up from /etc/init.d/S99hciinit (but keep the hciattach I mentioned above in).

    Afterwards, just run any example from /btstack, e.g. /btstack/le_counter.

    @Luckfox Maybe this information can be added to the wiki?
  • VayuDev wrote: 2025-09-06 17:41 Hello,

    thanks for the reply. With that, I finally got Bluetooth working under buildroot using btstack! It can take over the hci interface after it has been created by the hciattach:

    Code: Select all

    hciattach -s 1500000 /dev/ttyS1 any 1500000 flow
    For future reference, this is how I got it to work. First, create a folder under this path from the sdk: sysdrv/source/buildroot/buildroot-2023.02.6/package/btstack

    Then create a file Config.in within the btstack folder:

    Code: Select all

    config BR2_PACKAGE_BTSTACK
        bool "btstack"
        help
          BTSTACK
    
    Then create a file btstack.mk:

    Code: Select all

    BTSTACK_VERSION = 4d6a6c4c6e958cbf0104067baa6fb35e80e886a2   # (latest release, adjust if needed)
    BTSTACK_SITE = $(call github,bluekitchen,btstack,$(BTSTACK_VERSION))
    BTSTACK_LICENSE = BluekitchenLicense
    BTSTACK_LICENSE_FILES = LICENSE
    
    BTSTACK_CONF_OPTS =  -DCMAKE_CXX_FLAGS=-I$(STAGING_DIR)/usr/include -DCMAKE_C_FLAGS=-I$(STAGING_DIR)/usr/include
    BTSTACK_INSTALL_TARGET = YES
    BTSTACK_SUBDIR = port/linux
    
    define BTSTACK_INSTALL_TARGET_CMDS
        rm -rf $(TARGET_DIR)/btstack
        mkdir -p $(TARGET_DIR)/btstack
        cp -a $(@D)/port/linux/. $(TARGET_DIR)/btstack/
    endef
    
    $(eval $(cmake-package))
    
    Edit sysdrv/source/buildroot/buildroot-2023.02.6/package/Config.in to include your btstack/Config.in somewhere. Then enable btstack in the buildrootconfig. Funnily enough, btstack does have a dependency on bluez (libbluetooth) in this mode, but it doesn't seem to care that bluez doesn't fully work, only needs it headers I think. That's why the includes are so funky up above.

    After building, flash the image using rkflash.sh. Then you need to bring hci0 down:

    Code: Select all

    hciconfig hci0 down
    Or remove the line to bring hci0 up from /etc/init.d/S99hciinit (but keep the hciattach I mentioned above in).

    Afterwards, just run any example from /btstack, e.g. /btstack/le_counter.

    @Luckfox Maybe this information can be added to the wiki?
    Thank you for your sharing. We will verify the feasibility and consider incorporating it into the SDK. However, there are commercial usage restrictions for btstack. We also need to determine whether adding support to the SDK would violate the license agreement.