Configure BLE Module on STEVAL-MKSBOX1V1


Daniele Bortoluzzi <danieleb88@...>
 

Hi,
I'm Bortoluzzi Daniele, and I'm developing, for my master's thesis with University of Turin, a project using platformio and zephyr.

I would like to use the Ble Module (SPBTLE-1S) of the STEVAL-MKSBOX1V1 (SensorTile.box) in a zephyr project. This mcu is supported by zephyr, but the .dts file doesn't configure the spi2 interface used by bluetooth.

According with the hardware specs [1], I tried to start from ST BLE sensor project example [2] and configure:

prj.conf:

CONFIG_BT_SPI=y
CONFIG_BT_HCI=y
CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="SPBTLE-1S"
CONFIG_BT_GATT_CLIENT=y

app.overlay:

/ {
    chosen {
           zephyr,bt-hci-spi = &zephyr_bt_hci_spi;
           zephyr,bt-hci-spi-slave = &zephyr_bt_hci_spi_slave;
    };
};

&spi2 {
    pinctrl-0 = <&spi2_nss_pd0 &spi2_sck_pd1 &spi2_miso_pd3 &spi2_mosi_pc3>;
    pinctrl-names = "default";
    status = "okay";

    cs-gpios = <&gpiod 0 GPIO_ACTIVE_LOW>;

    zephyr_bt_hci_spi: zephyr_bt_hci_spi@0 {
        compatible = "zephyr,bt-hci-spi";
        reg = <0>;
        irq-gpios = <&gpiod 4 GPIO_ACTIVE_LOW>;
        reset-gpios = <&gpioa 8 GPIO_ACTIVE_LOW>;
        spi-max-frequency = <1000000>;
        label = "SPBTLE-1S";
    };

    zephyr_bt_hci_spi_slave: zephyr_bt_hci_spi_slave@1 {
        compatible = "zephyr,bt-hci-spi-slave";
        reg = <1>;
        irq-gpios = <&gpiod 4 GPIO_ACTIVE_LOW>;
    };
};

Unfortunately, bluetooth isn't enabled correctly and the system hangs up:
in the main.c, the bt_enable waits endlessly, because the function bt_spi_rx_thread of the file https://github.com/zephyrproject-rtos/zephyr/blob/v2.7-branch/drivers/bluetooth/hci/spi.c (line 343) doesn't return, looping in the do-while.

Thank you very much for your support.


Erwan Gouriou
 

Hello Daniele,

You're globally in the right direction, but please note that stm32l562_dk actually uses a SPBTLE-RFTR module, based on BlueNRG-MS (BLE v4.1).
SensorTile board use, depending on version:
- SPBTLE-1S Bluetooth Smart connectivity (BLE v4.2)
- BlueNRG-M2 (BLE v5.2)

These modules might differ from BlueNRG-MS on SPI API, likely not needing BT_SPI_BLUENRG,
or requiring an adaptation. Please refer to their respective manuals to see how to integrate them.

BR
Erwan

On Mon, 28 Feb 2022 at 13:23, Daniele Bortoluzzi <danieleb88@...> wrote:
Hi,
I'm Bortoluzzi Daniele, and I'm developing, for my master's thesis with University of Turin, a project using platformio and zephyr.

I would like to use the Ble Module (SPBTLE-1S) of the STEVAL-MKSBOX1V1 (SensorTile.box) in a zephyr project. This mcu is supported by zephyr, but the .dts file doesn't configure the spi2 interface used by bluetooth.

According with the hardware specs [1], I tried to start from ST BLE sensor project example [2] and configure:

prj.conf:

CONFIG_BT_SPI=y
CONFIG_BT_HCI=y
CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="SPBTLE-1S"
CONFIG_BT_GATT_CLIENT=y

app.overlay:

/ {
    chosen {
           zephyr,bt-hci-spi = &zephyr_bt_hci_spi;
           zephyr,bt-hci-spi-slave = &zephyr_bt_hci_spi_slave;
    };
};

&spi2 {
    pinctrl-0 = <&spi2_nss_pd0 &spi2_sck_pd1 &spi2_miso_pd3 &spi2_mosi_pc3>;
    pinctrl-names = "default";
    status = "okay";

    cs-gpios = <&gpiod 0 GPIO_ACTIVE_LOW>;

    zephyr_bt_hci_spi: zephyr_bt_hci_spi@0 {
        compatible = "zephyr,bt-hci-spi";
        reg = <0>;
        irq-gpios = <&gpiod 4 GPIO_ACTIVE_LOW>;
        reset-gpios = <&gpioa 8 GPIO_ACTIVE_LOW>;
        spi-max-frequency = <1000000>;
        label = "SPBTLE-1S";
    };

    zephyr_bt_hci_spi_slave: zephyr_bt_hci_spi_slave@1 {
        compatible = "zephyr,bt-hci-spi-slave";
        reg = <1>;
        irq-gpios = <&gpiod 4 GPIO_ACTIVE_LOW>;
    };
};

Unfortunately, bluetooth isn't enabled correctly and the system hangs up:
in the main.c, the bt_enable waits endlessly, because the function bt_spi_rx_thread of the file https://github.com/zephyrproject-rtos/zephyr/blob/v2.7-branch/drivers/bluetooth/hci/spi.c (line 343) doesn't return, looping in the do-while.

Thank you very much for your support.


Daniele Bortoluzzi <danieleb88@...>
 

Hi Erwan,
thank you for the response.

We are using sensortile.box with SPBTLE-1S BLE v4.2 connectivity. In fact we are currently don't use BT_SPI_BLUENRG config.

What do you suggest us to integrate SPBTLE-1S? Is our .dts correct? Are there in zephyr other mcus supported that are using same connectivity?

Thank you.

Best regards

Daniele


Il mar 1 mar 2022, 09:56 Erwan Gouriou <erwan.gouriou@...> ha scritto:
Hello Daniele,

You're globally in the right direction, but please note that stm32l562_dk actually uses a SPBTLE-RFTR module, based on BlueNRG-MS (BLE v4.1).
SensorTile board use, depending on version:
- SPBTLE-1S Bluetooth Smart connectivity (BLE v4.2)
- BlueNRG-M2 (BLE v5.2)

These modules might differ from BlueNRG-MS on SPI API, likely not needing BT_SPI_BLUENRG,
or requiring an adaptation. Please refer to their respective manuals to see how to integrate them.

BR
Erwan

On Mon, 28 Feb 2022 at 13:23, Daniele Bortoluzzi <danieleb88@...> wrote:
Hi,
I'm Bortoluzzi Daniele, and I'm developing, for my master's thesis with University of Turin, a project using platformio and zephyr.

I would like to use the Ble Module (SPBTLE-1S) of the STEVAL-MKSBOX1V1 (SensorTile.box) in a zephyr project. This mcu is supported by zephyr, but the .dts file doesn't configure the spi2 interface used by bluetooth.

According with the hardware specs [1], I tried to start from ST BLE sensor project example [2] and configure:

prj.conf:

CONFIG_BT_SPI=y
CONFIG_BT_HCI=y
CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="SPBTLE-1S"
CONFIG_BT_GATT_CLIENT=y

app.overlay:

/ {
    chosen {
           zephyr,bt-hci-spi = &zephyr_bt_hci_spi;
           zephyr,bt-hci-spi-slave = &zephyr_bt_hci_spi_slave;
    };
};

&spi2 {
    pinctrl-0 = <&spi2_nss_pd0 &spi2_sck_pd1 &spi2_miso_pd3 &spi2_mosi_pc3>;
    pinctrl-names = "default";
    status = "okay";

    cs-gpios = <&gpiod 0 GPIO_ACTIVE_LOW>;

    zephyr_bt_hci_spi: zephyr_bt_hci_spi@0 {
        compatible = "zephyr,bt-hci-spi";
        reg = <0>;
        irq-gpios = <&gpiod 4 GPIO_ACTIVE_LOW>;
        reset-gpios = <&gpioa 8 GPIO_ACTIVE_LOW>;
        spi-max-frequency = <1000000>;
        label = "SPBTLE-1S";
    };

    zephyr_bt_hci_spi_slave: zephyr_bt_hci_spi_slave@1 {
        compatible = "zephyr,bt-hci-spi-slave";
        reg = <1>;
        irq-gpios = <&gpiod 4 GPIO_ACTIVE_LOW>;
    };
};

Unfortunately, bluetooth isn't enabled correctly and the system hangs up:
in the main.c, the bt_enable waits endlessly, because the function bt_spi_rx_thread of the file https://github.com/zephyrproject-rtos/zephyr/blob/v2.7-branch/drivers/bluetooth/hci/spi.c (line 343) doesn't return, looping in the do-while.

Thank you very much for your support.


Erwan Gouriou
 

If you look at code under BT_SPI_BLUENRG, you'll see that it proposes some specific code that 
was required to add on top of bare hci_spi driver to get the module working.

I haven't add a look to other BlueNRG modules, but it's possible they require similar adaptation,
for this I suggest to have a check on modules documentation and see what is required to integrate
them with a bluetooth host over a HCI link.

Cheers
Erwan

On Tue, 1 Mar 2022 at 21:54, Daniele Bortoluzzi <danieleb88@...> wrote:
Hi Erwan,
thank you for the response.

We are using sensortile.box with SPBTLE-1S BLE v4.2 connectivity. In fact we are currently don't use BT_SPI_BLUENRG config.

What do you suggest us to integrate SPBTLE-1S? Is our .dts correct? Are there in zephyr other mcus supported that are using same connectivity?

Thank you.

Best regards

Daniele

Il mar 1 mar 2022, 09:56 Erwan Gouriou <erwan.gouriou@...> ha scritto:
Hello Daniele,

You're globally in the right direction, but please note that stm32l562_dk actually uses a SPBTLE-RFTR module, based on BlueNRG-MS (BLE v4.1).
SensorTile board use, depending on version:
- SPBTLE-1S Bluetooth Smart connectivity (BLE v4.2)
- BlueNRG-M2 (BLE v5.2)

These modules might differ from BlueNRG-MS on SPI API, likely not needing BT_SPI_BLUENRG,
or requiring an adaptation. Please refer to their respective manuals to see how to integrate them.

BR
Erwan

On Mon, 28 Feb 2022 at 13:23, Daniele Bortoluzzi <danieleb88@...> wrote:
Hi,
I'm Bortoluzzi Daniele, and I'm developing, for my master's thesis with University of Turin, a project using platformio and zephyr.

I would like to use the Ble Module (SPBTLE-1S) of the STEVAL-MKSBOX1V1 (SensorTile.box) in a zephyr project. This mcu is supported by zephyr, but the .dts file doesn't configure the spi2 interface used by bluetooth.

According with the hardware specs [1], I tried to start from ST BLE sensor project example [2] and configure:

prj.conf:

CONFIG_BT_SPI=y
CONFIG_BT_HCI=y
CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="SPBTLE-1S"
CONFIG_BT_GATT_CLIENT=y

app.overlay:

/ {
    chosen {
           zephyr,bt-hci-spi = &zephyr_bt_hci_spi;
           zephyr,bt-hci-spi-slave = &zephyr_bt_hci_spi_slave;
    };
};

&spi2 {
    pinctrl-0 = <&spi2_nss_pd0 &spi2_sck_pd1 &spi2_miso_pd3 &spi2_mosi_pc3>;
    pinctrl-names = "default";
    status = "okay";

    cs-gpios = <&gpiod 0 GPIO_ACTIVE_LOW>;

    zephyr_bt_hci_spi: zephyr_bt_hci_spi@0 {
        compatible = "zephyr,bt-hci-spi";
        reg = <0>;
        irq-gpios = <&gpiod 4 GPIO_ACTIVE_LOW>;
        reset-gpios = <&gpioa 8 GPIO_ACTIVE_LOW>;
        spi-max-frequency = <1000000>;
        label = "SPBTLE-1S";
    };

    zephyr_bt_hci_spi_slave: zephyr_bt_hci_spi_slave@1 {
        compatible = "zephyr,bt-hci-spi-slave";
        reg = <1>;
        irq-gpios = <&gpiod 4 GPIO_ACTIVE_LOW>;
    };
};

Unfortunately, bluetooth isn't enabled correctly and the system hangs up:
in the main.c, the bt_enable waits endlessly, because the function bt_spi_rx_thread of the file https://github.com/zephyrproject-rtos/zephyr/blob/v2.7-branch/drivers/bluetooth/hci/spi.c (line 343) doesn't return, looping in the do-while.

Thank you very much for your support.


Daniele Bortoluzzi <danieleb88@...>
 

I noticed that specific code too, and I agreed with you that probably we should adapt hci_spi driver.
Unfortunately, at the moment, it's out of scope for my thesis, because I don't have too much time to spend on it.

Thank you very much for your support.

Best regards,
Daniele

Il giorno lun 7 mar 2022 alle ore 16:45 Erwan Gouriou <erwan.gouriou@...> ha scritto:
If you look at code under BT_SPI_BLUENRG, you'll see that it proposes some specific code that 
was required to add on top of bare hci_spi driver to get the module working.

I haven't add a look to other BlueNRG modules, but it's possible they require similar adaptation,
for this I suggest to have a check on modules documentation and see what is required to integrate
them with a bluetooth host over a HCI link.

Cheers
Erwan

On Tue, 1 Mar 2022 at 21:54, Daniele Bortoluzzi <danieleb88@...> wrote:
Hi Erwan,
thank you for the response.

We are using sensortile.box with SPBTLE-1S BLE v4.2 connectivity. In fact we are currently don't use BT_SPI_BLUENRG config.

What do you suggest us to integrate SPBTLE-1S? Is our .dts correct? Are there in zephyr other mcus supported that are using same connectivity?

Thank you.

Best regards

Daniele

Il mar 1 mar 2022, 09:56 Erwan Gouriou <erwan.gouriou@...> ha scritto:
Hello Daniele,

You're globally in the right direction, but please note that stm32l562_dk actually uses a SPBTLE-RFTR module, based on BlueNRG-MS (BLE v4.1).
SensorTile board use, depending on version:
- SPBTLE-1S Bluetooth Smart connectivity (BLE v4.2)
- BlueNRG-M2 (BLE v5.2)

These modules might differ from BlueNRG-MS on SPI API, likely not needing BT_SPI_BLUENRG,
or requiring an adaptation. Please refer to their respective manuals to see how to integrate them.

BR
Erwan

On Mon, 28 Feb 2022 at 13:23, Daniele Bortoluzzi <danieleb88@...> wrote:
Hi,
I'm Bortoluzzi Daniele, and I'm developing, for my master's thesis with University of Turin, a project using platformio and zephyr.

I would like to use the Ble Module (SPBTLE-1S) of the STEVAL-MKSBOX1V1 (SensorTile.box) in a zephyr project. This mcu is supported by zephyr, but the .dts file doesn't configure the spi2 interface used by bluetooth.

According with the hardware specs [1], I tried to start from ST BLE sensor project example [2] and configure:

prj.conf:

CONFIG_BT_SPI=y
CONFIG_BT_HCI=y
CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="SPBTLE-1S"
CONFIG_BT_GATT_CLIENT=y

app.overlay:

/ {
    chosen {
           zephyr,bt-hci-spi = &zephyr_bt_hci_spi;
           zephyr,bt-hci-spi-slave = &zephyr_bt_hci_spi_slave;
    };
};

&spi2 {
    pinctrl-0 = <&spi2_nss_pd0 &spi2_sck_pd1 &spi2_miso_pd3 &spi2_mosi_pc3>;
    pinctrl-names = "default";
    status = "okay";

    cs-gpios = <&gpiod 0 GPIO_ACTIVE_LOW>;

    zephyr_bt_hci_spi: zephyr_bt_hci_spi@0 {
        compatible = "zephyr,bt-hci-spi";
        reg = <0>;
        irq-gpios = <&gpiod 4 GPIO_ACTIVE_LOW>;
        reset-gpios = <&gpioa 8 GPIO_ACTIVE_LOW>;
        spi-max-frequency = <1000000>;
        label = "SPBTLE-1S";
    };

    zephyr_bt_hci_spi_slave: zephyr_bt_hci_spi_slave@1 {
        compatible = "zephyr,bt-hci-spi-slave";
        reg = <1>;
        irq-gpios = <&gpiod 4 GPIO_ACTIVE_LOW>;
    };
};

Unfortunately, bluetooth isn't enabled correctly and the system hangs up:
in the main.c, the bt_enable waits endlessly, because the function bt_spi_rx_thread of the file https://github.com/zephyrproject-rtos/zephyr/blob/v2.7-branch/drivers/bluetooth/hci/spi.c (line 343) doesn't return, looping in the do-while.

Thank you very much for your support.