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.

Some infos:
- Zephyr version: 2.7.0
- Sources:
[1] https://www.st.com/resource/en/schematic_pack/steval-mksbox1v1_schematic.pdf : electric schema of the sensortile.box
[2] https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/bluetooth/st_ble_sensor : st ble example project
[3] https://github.com/zephyrproject-rtos/zephyr/blob/main/boards/arm/stm32l562e_dk/stm32l562e_dk_common.dtsi : similar dtsi (SPBTLE-RF module)