Help! I'm looking for code for ST BLUENRG-M2SP on a F401RE

I bought this Bluetooth 5.0 module and noticed there is no code to drive it from mbed despite it being mbed 6.0 compatible (according to the mbed website) I can’t find anything about it. The Bluetooth examples I have tried appear to be for earlier versions, including a deprecated message.

A PR is waiting for review on mbed-os that will add the necessary HCI drivers for this BLE module.

You can pull the changes and try them on your local mbed-os clone.

Or you can use the BlueNRG-MS that already works with mbed (we use this one for our product).

Thanks Ladislas for the info.

I pulled the repo, but I could not perform the first operation in the readme, where the ARM Cordio stack is required to be programmed onto the X-NUCLEO-BNRG2A1 board using a firmware image for a different board than the one I am currently using (STMF401RE vs STM32L476RG)

I set the wire from J12 to CN9 I drop the firmware BIN file onto the STMF401RE board and nothing happens.

I guess I will have to use ST’s CubeMX software to try and get this board to work at all. I wanted so much to learn about BT5 with mbed but there’s just nothing from ST for mbed despite their advertising.


EDIT: I loaded the entire STCubeMX onto my Mac and spent hours trying to get the BLE Beacon example to work, nothing. I guess it’s time to dump the old faithful 401 and cave into ST and buy the 476 (even though I am in no need of it whatsoever) the Cube thing is so complicated and buggy and it needs Java to work. I’m sorely tempted to find another vendor’s implementation and toss this X-NUCLEO-BNRG2A1 in the trash - but - no, just relax and fingers crossed, someone will have a solution to make this board work. It is “new” so I’m in the twilight zone of being too new and there’s no decent support and other stuff is too old and only supported in mbed2. The time-of-flight module also doesn’t work on the F401 - it keeps losing connection to the terrible Windows software - so I am RMAing that board (X-NUCLEO-53L0A1) - not having much luck/fun with ST stuff at the moment :unamused:

Would the STM32WB55 be a good fit for you? It works great out of the box!

Dear user,

The PR has been just updated including the binary to update the BlueNRG-2 FW with a Nucleo-F401RE.

Hope this can help.
Apologize for the inconvenience.

Thanks, I have bought that kit and it is sitting on my bench the USB key style of device is definitely interesting!

Thanks for the PR, I’ve tried to put the FW onto the 401 and I get an error in the serial console;

BlueNRG-2 IFR/Stack Updater.
Start Stack updater…
… error.

I have also put the required reset jumper wire from J12 to PA_8/RESET on CN9 this doesn’t have an effect on the message though.

An alternative could be to update the FW following the procedure described in the documentation attached hereafter

Let us know if it is suitable and works for you.

Thanks for the information. My board is marked 2022, I will buy an ST Link programmer and see if that will fix the problem.

I bought an ST Link v2 programmer and programmed the X-NUCLEO-BNRG2A1 with new firmware and still, it refuses to work.


  1. Flashed ST Link V2 to latest FW
  2. Connected ST Link V2 to the pins on the X-NUCLEO-BNRG2A1
  3. Run STSW-BNRGFLASHER select the ST Link V2 in the SWD list
  4. Mass Erase and was successful
  5. Load firmware from BlueNRG GUI 4.0.0\Firmware\BlueNRG2\DTM\DTM_SPI.hex
  6. Flash board and was successful
  7. Disconnect ST Link V2
  8. Put X-NUCLEO-BNRG2A1 onto NUCLEO-F401RE (the supported combination)
  9. Compiled BLE_GattServer example against the NUCLEO-F401RE
  10. In the Output Window I get;
    Ble process started.
    …and that’s it.

The same code, this time targetting the P-NUCLEO-WB55 results in;
Ble process started.
Ble instance initialized
Adding demo service
clock service registered
service handle: 11
hour characteristic value handle 13
minute characteristic value handle 16
second characteristic value handle 19
Advertising started.

P.S. the recommended ST BLE Profile App v 2.0.2 is useless, avoid it, download the Nordic Semiconductor nRF Connect - it actually works!

in step 5 try the DTM_SPI.bin referenced by the updated PR

Thanks for sharing your consideration about the ST BLE Profile App. You can find the list of the supported profiles on the Play Store page:

Thanks for the help, unfortunately, it is still dead and does not respond. I tried the PR firmware, an older v3 firmware, it programs and verifies without any problem, it just doesn’t go anything more than output “Ble process started.” :anguished:

I have the schematic open on the desktop and noticed the pin mappings don’t look right. I’m not 100% sure but it seems that the pins mapped should be;

SPI_CS -> PA_4
PWM_OUT -> PA_10

rather than

SPI_CS -> PB_6

The schematic for the board doesn’t make any sense, there are resistors that don’t exist, i.e. there is no screen printing for them.

How does the STM board communicate with the BNRG2A1? Is it SPI or serial?

I’ll return the board and in the meantime continue on with the WB-55.

regarding your pin mapping could you check the README of the PR on github

and the pinout reported on this page?

Communication is done via SPI bus.

so your board gets stuck after that? if you have another thread blinking a led, does it still work?

We had an issue that looked like this. I don 't remember exactly how we fixed it but I think it was by adding a new ble dedicated thread and have the ble event queue run with it.

I’ve put together a working example we have, if it can be helpful.

Thanks for the example code, I put it into an empty mbed 6 project and added the F401RE (with the X-NUCLEO-BNRG2A1 daughterboard on the Ardiuno sockets) to the mbed_app.json. I added some extra lines to print to the serial console so I could see what the program is doing. It gets through to the sleep loop and there isn’t any new BLE service being provided. My guess is the board is dead, I set up an RMA and was given a refund and told to “responsibly dispose” of the board.

Again, thanks for your help. I’ll continue on with the WB55, it is a fascinating device!