Developing ST BlueNRG-LP Projects with Visual Studio

This tutorial shows how to use Visual Studio with VisualGDB to target the STEVAL-IDB011V1 board featuring the BlueNRG-LP device. We will show how to quickly clone the examples from the BlueNRG SDK, edit them and debug them in Visual Studio.

  1. Start Visual Studio and open the VisualGDB Embedded Project Wizard:
  2. Enter the name and location for your project, then press “Create”:
  3. On the first page of the VisualGDB-specific part of the wizard, select “Create a new project -> Application -> Advanced CMake“:
  4. On the next page select the ARM toolchain and pick the BlueNRG-LP device. If you have not installed the BlueNRG-LP BSP, click “Install” to automatically download and install it:
  5. Once the BSP is installed, VisualGDB will allow selecting the BlueNRG-LP device and will show various configuration options for it:
  6. The next page allows selecting a project sample to clone. Both basic samples and BlueNRG SDK samples are using the embedded framework system and can be easily reconfigured later. Hence, you can select either of them:
  7. In this tutorial we will select the BLE_Beacon sample from BlueNRG SDK Samples:
  8. The last page of the wizard allows configuring debug settings. Unlike most development boards from ST, the BlueNRG-LP board has an on-board CMSIS-DAP instead of an ST-Link. Connect it to the USB port an make sure VisualGDB recognizes it: WARNING! Many BlueNRG-LP examples put the device into the low power mode where it is not debuggable. If this happens, you would not be able to connect toe the device unless you enable the “Connect under reset”  checkbox in Debug Settings.
  9. Press “Finish” to generate the project. Once it is generated, build it by pressing “Ctrl-Shift-B”:
  10. Right-click on the project in Solution Explorer and go to the Embedded Frameworks page. VisualGDB will display various frameworks from the SDK, allowing you to reference them or change their configuration. The frameworks used by the sample will be already selected:
  11. Set a breakpoint in main() and press F5 to start debugging. The breakpoint will hit:
  12. Note that if you continue the execution now, OpenOCD will display the “Error connecting DP: cannot read IDR” error:
  13. This happens because the device has entered the low-power mode. You can comment out the call to HAL_PWR_MNGR_Request() to prevent this from happening. Now you will be able to debug the program without interruptions:
  14. As of June 2021, the on-board CMSIS-DAP probe sometimes fails to connect to the target right after it has been started. VisualGDB would then display a message that OpenOCD has exited. Simply starting the debug session again solves the problem in most cases.