{"id":5011,"date":"2019-07-08T17:16:20","date_gmt":"2019-07-09T00:16:20","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=5011"},"modified":"2019-07-08T17:16:20","modified_gmt":"2019-07-09T00:16:20","slug":"developing-stm32wb-projects-with-visual-studio","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/stm32\/stm32wb\/","title":{"rendered":"Developing STM32WB Projects with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to create, build and debug a basic Bluetooth LE project for the STM32WB Nucleo board using Visual Studio and VisualGDB.<\/p>\n<p>Before you begin, install VisualGDB 5.4R10 or later.<\/p>\n<ol>\n<li>Open Visual Studio, select File-&gt;New-&gt;Project and locate the VisualGDB Embedded Project Wizard:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/01-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5012\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/01-newprj.png\" alt=\"\" width=\"1024\" height=\"710\" \/><\/a><\/li>\n<li>Specify the name and location for your project and press &#8220;Create&#8221; to launch the VisualGDB&#8217;s wizard:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/02-emb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5013\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/02-emb.png\" alt=\"\" width=\"1024\" height=\"710\" \/><\/a><\/li>\n<li>On the first page of the wizard select <strong>Create a new project -&gt; Embedded Binary -&gt; MSBuild<\/strong> and press &#8220;Next&#8221;: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/03-binary.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5014\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/03-binary.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a>Note that due to the excessive amounts of the include directories used by the STM32WB SDK, the GNU Make will not be able to build most STM32WB projects correctly. Hence, please ensure you use the MSBuild subsystem instead.<\/li>\n<li>On the next page select an ARM toolchain and pick your STM32WB device from the list. The STM32WB-Nucleo board features the STm32WB55RGV6 device, so we select it from the list:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/04-device.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5015\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/04-device.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>The next page of the wizard allows selecting a project sample that will be cloned into the newly created project. ST provides numerous samples demonstrating various functionality of the STM32WB devices, so select &#8220;<strong>STM32CubeMX Samples<\/strong>&#8221; and pick a sample to clone. In this tutorial we will clone the <strong>BLE_Beacon<\/strong> sample:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/05-beacon.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5016\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/05-beacon.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>On the next page select the debugging settings for your device. If you are using the STM32WB-Nucleo board, simply plug it into the USB port (ensure you use the ST-Link&#8217;s USB port) and let VisualGDB detect the settings automatically. As many STM32WB examples use the sleep mode to reduce power usage that disables SWD functionality, enable the &#8220;Connect under reset&#8221; checkbox:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/06-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5017\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/06-debug.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>Press &#8220;Finish&#8221; to generate the project. Once it is generated, build it by pressing Ctrl-Shift-B. Then locate and open the <strong>readme.txt<\/strong> file showing the instructions for trying out this specific sample:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/07-readme.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5018\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/07-readme.png\" alt=\"\" width=\"1184\" height=\"763\" \/><\/a><\/li>\n<li>In order to use the wireless functionality of the STM32WB devices, you will need to program a wireless co-processor stack into the FLASH memory. As of July 2019, this cannot be done via ST-Link and requires connecting the device in the bootloader mode. Use our <a href=\"https:\/\/visualgdb.com\/tools\/STM32WBUpdater\/\">Wireless Stack Updater tool<\/a> to program the correct wireless stack binary into your device (including the FUS binary update):\u00a0 <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/08-update.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5019\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/08-update.png\" alt=\"\" width=\"586\" height=\"606\" \/><\/a>You can find instructions on connecting your STM32WB Nucleo board in bootloader mode on <a href=\"https:\/\/visualgdb.com\/tools\/STM32WBUpdater\/connecting\/\">this page<\/a>.<\/li>\n<li>Once the wireless stack has been programmed, connect the board in ST-Link mode and press F5 to start debugging. The board will begin advertising itself as an iBeacon-compatible Bluetooth LE beacon. You can use the Beacon Scanner app on your Android device to verify that the board is working as intended:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/09-screen.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5020\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/09-screen.png\" alt=\"\" width=\"820\" height=\"1686\" \/><\/a><\/li>\n<li>Now we will change the ID transmitted by the beacon example. Open the <strong>ibeacon_service.c<\/strong> file, locate the <strong>UuID<\/strong> field on top of the file and use CodeJumps to display functions using that field: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/10-refs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5021\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/10-refs.png\" alt=\"\" width=\"1184\" height=\"763\" \/><\/a><\/li>\n<li>Click on the <strong>IBeacon_Process()<\/strong> function to go to its definition. Note how the ID is assigned from the UUID macro. Click on the macro and press F12 to locate the macro definition:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/11-uuid.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5022\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/11-uuid.png\" alt=\"\" width=\"1184\" height=\"763\" \/><\/a><\/li>\n<li>VisualGDB will open the <strong>ibeacon.h<\/strong> file that contains definitions for various beacon configuration parameters. Replace the <strong>MINOR_ID<\/strong> with &#8220;0, 2&#8221;, stop the debug session and press F5 again to begin debugging the updated code: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/12-id.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5023\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/12-id.png\" alt=\"\" width=\"1184\" height=\"763\" \/><\/a><\/li>\n<li>The Beacon Scanner app will now show another beacon with the minor ID of 2: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/13-newid.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5024\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/13-newid.png\" alt=\"\" width=\"720\" height=\"1480\" \/><\/a><\/li>\n<li>If you clone a different sample project, you may encounter a &#8220;<strong>Received a 0: Signal 0<\/strong>&#8221; error accompanied by the &#8220;<strong>jtag status contains invalid mode value<\/strong>&#8221; message in the OpenOCD window:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/14-sig0.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5025\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/14-sig0.png\" alt=\"\" width=\"1184\" height=\"763\" \/><\/a><\/li>\n<li>This happens because some samples put the CPU to sleep (disabling JTAG\/SWD functionality) in order to reduce the power usage. You can disable this by locating the <strong>CFG_DEBUGGER_SUPPORTED<\/strong> macro in the <strong>app_conf.h<\/strong> file and changing it to 1:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/15-debugenable.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5026\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2019\/07\/15-debugenable.png\" alt=\"\" width=\"1184\" height=\"763\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to create, build and debug a basic Bluetooth LE project for the STM32WB Nucleo board using<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89],"tags":[96,56,61,184],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/5011"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=5011"}],"version-history":[{"count":2,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/5011\/revisions"}],"predecessor-version":[{"id":5052,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/5011\/revisions\/5052"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=5011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=5011"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=5011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}