Skip to content

Conversation

@erwango
Copy link
Member

@erwango erwango commented Mar 8, 2019

This series enable BLE on STM32WB.

It includes flash driver for persistent storage.

This is based on #16373

@erwango erwango added this to the v1.15.0 milestone Mar 8, 2019
@jfischer-no
Copy link
Contributor

@erwango Have you tried it with samples/bluetooth/peripheral* ? I noticed that RF Performance is not that good , 30dBm ... 40dBm worse than nRF52 DK boards or FRDM-KW41Z.

@erwango
Copy link
Member Author

erwango commented Mar 8, 2019

@erwango Have you tried it with samples/bluetooth/peripheral* ? I noticed that RF Performance is not that good , 30dBm ... 40dBm worse than nRF52 DK boards or FRDM-KW41Z.

Yes I have tried it but didn't pay attention, I can see now that RF performance is not quite good indeed. Though, with other fw this is working correctly, so I may have messed up with SET_TX_POWER command. Let me have a check.

@erwango
Copy link
Member Author

erwango commented Mar 8, 2019

@jfischer-phytec-iot, it should be fixed now.

@jfischer-no
Copy link
Contributor

jfischer-no commented Mar 12, 2019

@erwango I tested few peripheral samples (e.g. peripheral and peripheral_sc_only). The connection was not successful, log part from peripheral sample:

[00:00:28.727,176] <dbg> bt_hci_core.hci_rx_thread: calling fifo_get_wait
[00:00:29.042,027] <dbg> hci_ipm.TM_EvtReceivedCb: EVT: hcievt->evtserial.evt.evtcode: 0x01
[00:00:29.042,061] <dbg> bt_hci_core.bt_recv: buf 0x20002234 len 42
[00:00:29.042,114] <dbg> bt_hci_core.hci_rx_thread: buf 0x20002234 type 1 len 42
[00:00:29.042,122] <dbg> bt_hci_core.hci_event: event 0x01
[00:00:29.042,171] <wrn> bt_hci_core: Unhandled event 0x01 len 40: 0b0007000400100100ffff002800000~
[00:00:29.042,200] <dbg> bt_hci_core.hci_rx_thread: calling fifo_get_wait
[00:00:29.222,009] <dbg> hci_ipm.TM_EvtReceivedCb: EVT: hcievt->evtserial.evt.evtcode: 0x3e
[00:00:29.222,041] <dbg> bt_hci_core.bt_recv: buf 0x20002234 len 12
[00:00:29.222,093] <dbg> bt_hci_core.hci_rx_thread: buf 0x20002234 type 1 len 12
[00:00:29.222,102] <dbg> bt_hci_core.hci_event: event 0x3e
[00:00:29.222,125] <dbg> bt_hci_core.hci_le_meta_event: subevent 0x03
[00:00:29.222,135] <dbg> bt_hci_core.le_conn_update_complete: status 0, handle 2049
[00:00:29.222,145] <dbg> bt_conn.bt_conn_ref: handle 2049 ref 2
[00:00:29.222,156] <dbg> bt_conn.bt_conn_unref: handle 2049 ref 1
[00:00:29.222,185] <dbg> bt_hci_core.hci_rx_thread: calling fifo_get_wait
[00:00:33.961,587] <dbg> hci_ipm.TM_EvtReceivedCb: EVT: hcievt->evtserial.evt.evtcode: 0x01
[00:00:33.961,622] <dbg> bt_hci_core.bt_recv: buf 0x20002234 len 42
[00:00:33.961,675] <dbg> bt_hci_core.hci_rx_thread: buf 0x20002234 type 1 len 42
[00:00:33.961,683] <dbg> bt_hci_core.hci_event: event 0x01
[00:00:33.961,732] <wrn> bt_hci_core: Unhandled event 0x01 len 40: 0b0007000400100100ffff002800000~
[00:00:33.961,761] <dbg> bt_hci_core.hci_rx_thread: calling fifo_get_wait
[00:00:38.956,506] <dbg> hci_ipm.TM_EvtReceivedCb: EVT: hcievt->evtserial.evt.evtcode: 0x01
[00:00:38.956,540] <dbg> bt_hci_core.bt_recv: buf 0x20002234 len 42
[00:00:38.956,593] <dbg> bt_hci_core.hci_rx_thread: buf 0x20002234 type 1 len 42
[00:00:38.956,602] <dbg> bt_hci_core.hci_event: event 0x01
[00:00:38.956,651] <wrn> bt_hci_core: Unhandled event 0x01 len 40: 0b0007000400100100ffff002800000~
[00:00:38.956,680] <dbg> bt_hci_core.hci_rx_thread: calling fifo_get_wait
[00:00:42.526,520] <dbg> hci_ipm.TM_EvtReceivedCb: EVT: hcievt->evtserial.evt.evtcode: 0x3e
[00:00:42.526,553] <dbg> bt_hci_core.bt_recv: buf 0x20002234 len 12
[00:00:42.526,605] <dbg> bt_hci_core.hci_rx_thread: buf 0x20002234 type 1 len 12
[00:00:42.526,613] <dbg> bt_hci_core.hci_event: event 0x3e
[00:00:42.526,623] <dbg> bt_hci_core.hci_le_meta_event: subevent 0x03
[00:00:42.526,634] <dbg> bt_hci_core.le_conn_update_complete: status 0, handle 2049
[00:00:42.526,643] <dbg> bt_conn.bt_conn_ref: hDisconnected (reason 19)

@erwango
Copy link
Member Author

erwango commented Mar 12, 2019

@jfischer-phytec-iot, I have no issue on peripheral on my side. From what I understand, you've already managed to get it working once, is that a new status? Or is this in particular conditions?
Regarding peripheral_sc_only, I don't know if this requires specific support from controller stack, I'll check this and get back to you. Thanks for interest!

@jfischer-no
Copy link
Contributor

From what I understand, you've already managed to get it working once, is that a new status? Or is this in particular conditions?

@erwango No, none of the peripheral samples work for me. Tested with nRF Connect and bluetoothctl on linux.

@erwango
Copy link
Member Author

erwango commented Mar 14, 2019

@erwango No, none of the peripheral samples work for me. Tested with nRF Connect and bluetoothctl on linux.

@jfischer-phytec-iot , ok. Well this is a big concern. Difference might come from the fact I use a pre mass market version. I'll get a board similar to yours and have a check.

@erwango
Copy link
Member Author

erwango commented Mar 14, 2019

@jfischer-phytec-iot, I had a check and got things working on the nucleo version you should own (ES MB1355C-01). And peripheral is working on both ST BLE Profile and nRF Connect. I don't know what could be the issue here.
@jhedberg, I think you own a nucleo_wb55rg yourself. Would you have time to do a simple peripheral test to see ig you face same issue as Johann?

@erwango erwango removed this from the v1.15.0 milestone Mar 15, 2019
@jfischer-no
Copy link
Contributor

jfischer-no commented Mar 15, 2019

@erwango How do you flash your device? I tried it over MSD support only.

@erwango
Copy link
Member Author

erwango commented Mar 15, 2019

@jfischer-phytec-iot, yes I'm using mass storage as well. open-ocd support is upcoming but not yet available (AFAIK)

@erwango
Copy link
Member Author

erwango commented Mar 15, 2019

@jfischer-phytec-iot , I'm sorry to say that, but would you consider having a try with stm32cube package?

@jfischer-no
Copy link
Contributor

I'm sorry to say that, but would you consider having a try with stm32cube package?

@erwango I have the package, but there is no way to build from command line?

@erwango
Copy link
Member Author

erwango commented Mar 15, 2019

@erwango I have the package, but there is no way to build from command line?

Using CubeMX Tool, you can generate a makefile. Though, it might not be direct.
Another option is I can generate send you a bin next week.

@jfischer-no
Copy link
Contributor

jfischer-no commented Mar 15, 2019

Another option is I can generate send you a bin next week.

👍 Thanks

@aescolar aescolar requested a review from thoh-ot March 17, 2019 12:18
@erwango erwango force-pushed the dev_stm32wb_hci branch 2 times, most recently from 40d4476 to 28e3962 Compare March 21, 2019 16:28
@zephyrbot
Copy link

zephyrbot commented Mar 21, 2019

Found the following issues, please fix and resubmit:

License issues

In most cases you do not need to do anything here, especially if the files
reported below are going into ext/ and if license was approved for inclusion
into ext/ already. Fix any missing license/copyright issues. The license
exception if a JFYI for the maintainers and can be overriden when merging the
pull request.

  • ext/hal/st/lib/stm32wb/hci/app_common.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/app_common.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/app_conf.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/app_conf.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/hci_tl.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/hci_tl.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/hw.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/hw.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/hw_conf.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/hw_conf.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/hw_ipcc.c is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/hw_ipcc.c is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/mbox_def.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/mbox_def.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/shci.c is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/shci.c is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/shci.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/shci.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/shci_tl.c is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/shci_tl.c is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/shci_tl.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/shci_tl.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/stm32_wpan_common.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/stm32_wpan_common.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/stm_list.c is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/stm_list.c is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/stm_list.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/stm_list.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/tl.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/tl.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/tl_conf.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/tl_conf.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/tl_if.c is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/tl_if.c is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/tl_mbox.c is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/tl_mbox.c is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/utilities_common.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/utilities_common.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/utilities_conf.h is not apache-2.0 licensed: bsd-new
  • ext/hal/st/lib/stm32wb/hci/utilities_conf.h is not apache-2.0 licensed: bsd-new

@erwango erwango force-pushed the dev_stm32wb_hci branch from e443124 to 0b5983f Compare May 24, 2019 12:45
@yhvh
Copy link

yhvh commented May 24, 2019

bluetoothctl and nrf app on android, both fail to connect

@erwango
Copy link
Member Author

erwango commented May 24, 2019

bluetoothctl and nrf app on android, both fail to connect

Ok, I just tested it 2 hours back and was working. Also has been tested by others successfully.
Might come from your M0 f/w version that require an upgrade.
We know there are nucleo_wb samples in the wild that hold a M0 f/w not compatible with use on Zephyr. Can I ask you to create a dedicated issue for this and I'll try to support you on that track?

@nashif
Copy link
Member

nashif commented May 29, 2019

tested with samples/bluetooth/peripheral_hr, works for me.

Needs rebase.

erwango added 10 commits June 3, 2019 09:37
Library providing hci driver for host/controller communication
over shared RAM

Origin: ST Microelectronics
License: BSD-3-Clause
URL: http://www.st.com/en/embedded-software/stm32cubewb.html
Commit: 1.0.0
Purpose: Shared RAM driver for STM32WB
Maintained-by: External

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Implement HCI driver for STM32WB. It allows host to controller.
It is based on ST library allowing communication over RAM shared
bewteen chip's C-M4 and C-M0 cores.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
In order to enable HCI mode in M0 firmware,
enable CFG_BLE_LL_ONLY in hci lib.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
STM32WB HCI driver requires definition of 2 RAM regions to support
use of 3 shared memory sections: MAPPING_TABLE, MB_MEM1 and MB_MEM2.
In linker.ld, under conditions of HCI driver to be enabled,
define SRAM1 and SRAM2 based on input defined in stm32wb linker.
Then define the 3 sections MAPPING_TABLE, MB_MEM1 and MB_MEM

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
sram2a and sram2b where defined in the prospect of defining
HCI shared memory sections from device tree.
Remove them, since this is not the case anymore.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Add requested configuration to enable HCI driver

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Add flash driver for stm32wb

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
stm32wb55rg is a dual core SoC (M4/M0) with a radio/protocol stack
running on M0 core. M0 FW starts at flash address 0x80CB000.
So flash size available to zephyr is 812K instead of 1M.
Configure package size to reflect this (flash size is now 812K)
and update MPU setting to exclude M0 FW. From MPU point of view,
we set flash size to 512K since we should chose a size being a power
of 2.
If we consider there will be 2 images partitions in a FOTA scheme,
512 K is beyond image-0 and hence is sufficient to cover application
image.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Configure flash partitions on nucleo_wb55rg

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Add HSEM for Flash access since shared between 2 cores.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
@erwango erwango force-pushed the dev_stm32wb_hci branch from 0b5983f to 376c857 Compare June 3, 2019 07:37
@erwango
Copy link
Member Author

erwango commented Jun 3, 2019

@nashif , rebased

Copy link
Contributor

@jfischer-no jfischer-no left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested peripheral_sc_only and peripheral_hr

@nashif nashif merged commit 51033a5 into zephyrproject-rtos:master Jun 3, 2019
@mtuxpe
Copy link
Contributor

mtuxpe commented Aug 2, 2019

Hi there,
I am testing HCI driver using WB55Nucleo and also P-NUCLEO-WB55 USB dongle.
Sometimes BLE stack doesn't start on dngle but I don't know how to reproduce yet.
I am developing a custom peripheral application to connect with ST BLE Sensor mobile.
To flash dongle on linux you can use STM32Programmer:
https://community.st.com/s/question/0D50X00009q3X4jSAE/stm32cubeprogrammer-for-linux
Use the bash script described on stefan1.5521405057577783E12 post.
Anyway good job @erwango

@erwango erwango deleted the dev_stm32wb_hci branch September 3, 2019 12:05
@lst426
Copy link

lst426 commented Sep 9, 2019

Why can't I configure Bluetooth to find out who's going to direct it? Thank you, God. Have you ever met?

@mtuxpe
Copy link
Contributor

mtuxpe commented Sep 20, 2019

Hi all,
Sometimes I got "Unhandled event" message while trying to connect to ST BLE Sensor Android app
On Zephyr side I am running BLE peripheral.
How to get detailed log ?

[01:06:01.840,000] main: Connected
[01:06:02.287,000] bt_hci_core: Unhandled event 0x02 len 40: 0b0007000400100d00ffff002800000~

@erwango
Copy link
Member Author

erwango commented Sep 20, 2019

@mtuxpe, there's a dedicated application to trace HCI messages called monitor.
You can enable with CONFIG_BT_DEBUG_MONITOR=y, but this require to disable CONSOLE.
Then, you can get trace output over serial port with bluez btmon binary.

@joerchan
Copy link
Contributor

@mtuxpe It's possible that the HCI driver sent an event through bt_recv_prio, when it should have sent it through bt_recv.

@pavlohamov
Copy link
Contributor

@mtuxpe Hi. I've faces with the same issue. M0 firmware update - fixed the issue.

But now i'm seeing something strange with peripheral device. For all incoming connections the peer addresses are set to FF:FF:FF:FF:FF:FF, no matter how do i configure the BLE stack. for the Central role Addrs are ok. This issue block the secure connection.
@erwango Could you be so kid to point where to dig on this?

@erwango
Copy link
Member Author

erwango commented Oct 1, 2019

@pavlohamov @mtuxpe, if you're facing a particular issue, please raise a new issue and provide details on your set up so we can look at it in details. Current PR is merged, we won't do much here.

@PoojaKatariya
Copy link

Hello All,
I downloaded the BLE_TransparentMode.hex file on the Nucleo board using STM32CubeProgrammer. Once the board was loaded with that hex file I tried to connect it with STM32CubeMonitor-RF. But while I'm trying to connect the device I'm getting a prompt which says "Device under test not responding COM port closed".

Also, before having received your support I tried to run the default application which comes in built with the board along with ST BLE Sensor mobile application. Then I tried to write the code as per the You Tube tutorial on STM32WB55 OLT session by STMicroelectronics and after which I flashed
the board with stm32wb5x_BLE_Stack_fw.bin file as per one of the blogs on st.com. And now after having flashed the board; the blue tooth is not even getting detected on the sensor application.
Also, I am using STM32CubeIDE version 1.0.1 for all the development and not CubeMX platform.

Also I tried to boot up the Nucleo board right now as instructed in STM32WB package by:

a) Add a jumper between CN7.5 (VDD) and CN7.7 (BOOT0).
b) Power on the board via USB_USER and J2 jumper (USB_MCU)

Yet I am getting no results and facing the same issues as mentioned above.

@erwango
Copy link
Member Author

erwango commented Oct 5, 2019

@PoojaKatariya, this github project is dedicated to zephyr RTOS, which is not the default application delivered with the board or in Cube package.
You will get proper support for your issue on st.community.com.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.