{"id":119,"date":"2019-01-22T17:39:31","date_gmt":"2019-01-23T01:39:31","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=119"},"modified":"2019-01-24T10:35:24","modified_gmt":"2019-01-24T18:35:24","slug":"arm-stm32","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/stm32\/","title":{"rendered":"Developing STM32 projects with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to create a simple &#8216;Blinking LED&#8217; project for the STM32100B-EVAL board using Visual Studio.<\/p>\n<p>Before we begin, ensure that <a href=\"\/download\">VisualGDB<\/a>\u00a0is installed.<\/p>\n<ol>\n<li>Start Visual Studio. Go to File-&gt;New-&gt;Project:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/01-newprj-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4540\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/01-newprj-1.png\" alt=\"\" width=\"1069\" height=\"713\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/01-newprj-1.png 1069w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/01-newprj-1-300x200.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/01-newprj-1-768x512.png 768w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/01-newprj-1-1024x683.png 1024w\" sizes=\"(max-width: 1069px) 100vw, 1069px\" \/><\/a><\/li>\n<li>\u00a0Select VisualGDB -&gt; Embedded Project Wizard. Specify project directory and enter project name:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/02-prjname.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4541\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/02-prjname.png\" alt=\"\" width=\"841\" height=\"563\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/02-prjname.png 841w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/02-prjname-300x201.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/02-prjname-768x514.png 768w\" sizes=\"(max-width: 841px) 100vw, 841px\" \/><\/a><\/li>\n<li>Select &#8220;Embedded binary&#8221;. If you want VisualGDB to generate a .bin file additionally to an .elf file, ensure that the corresponding checkbox is checked.<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/03-newbin.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4542\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/03-newbin.png\" alt=\"\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/03-newbin.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/03-newbin-300x235.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/03-newbin-768x601.png 768w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>On the next page select the arm-eabi toolchain. If it is not installed, VisualGDB will install it automatically:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/04-getarm-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4545\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/04-getarm-1.png\" alt=\"\" width=\"885\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/04-getarm-1.png 885w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/04-getarm-1-300x235.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/04-getarm-1-768x601.png 768w\" sizes=\"(max-width: 885px) 100vw, 885px\" \/><\/a><\/li>\n<li>Once the ARM toolchain is selected, VisualGDB will show a list of the compatible targets. If you have not created STM32-based projects with VisualGDB before, click &#8220;Install&#8221; to automatically download and install the necessary files:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/05-getstm32.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4546\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/05-getstm32.png\" alt=\"\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/05-getstm32.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/05-getstm32-300x235.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/05-getstm32-768x601.png 768w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>Once the STM32 package is installed, you will be able to configure various device-specific properties (e.g. whether to run from FLASH or SRAM):<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/06-device.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4547\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/06-device.png\" alt=\"\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/06-device.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/06-device-300x235.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/06-device-768x601.png 768w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>VisualGDB will generate the default &#8216;Blinking LED&#8217; sample project. You can select the port number and the blinking delay on the next page:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/07-blink.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4548\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/07-blink.png\" alt=\"\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/07-blink.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/07-blink-300x235.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/07-blink-768x601.png 768w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>On the last wizard page you can select a debug method. VisualGDB will automatically detect and configure most of the JTAG\/SWD adapters. Simply plug it into the USB port and select it in the list:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/08-jlink.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4549\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/08-jlink.png\" alt=\"\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/08-jlink.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/08-jlink-300x235.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/08-jlink-768x601.png 768w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>In this tutorial we will show how to use VisualGDB with Segger J-Link using the Segger Software package. If you want to use ST-Link or another JTAG\/SWD debugger, simply select it from the list instead. VisualGDB will let you automatically download the debug method package if it is missing:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/09-get-jlink.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4550\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/09-get-jlink.png\" alt=\"\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/09-get-jlink.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/09-get-jlink-300x235.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/09-get-jlink-768x601.png 768w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>If you have not installed the Segger software package yet, follow the link in VisualGDB wizard to install it. Once installed, specify its location in the &#8220;Segger J-Link directory&#8221; field:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/10-config.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4551\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/10-config.png\" alt=\"\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/10-config.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/10-config-300x235.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/10-config-768x601.png 768w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>Use the &#8220;Test&#8221; button to automatically test the connection to the device:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/11-test-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4555\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/11-test-1.png\" alt=\"\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/11-test-1.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/11-test-1-300x235.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/11-test-1-768x601.png 768w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>Press Finish to complete the wizard. VisualGDB will generate a Visual Studio project for your STM32 device. Press Ctrl-Shift-B to build it:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4552\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/build.png\" alt=\"\" width=\"1069\" height=\"713\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/build.png 1069w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/build-300x200.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/build-768x512.png 768w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/build-1024x683.png 1024w\" sizes=\"(max-width: 1069px) 100vw, 1069px\" \/><\/a><\/li>\n<li>To start debugging it simply power on your board and connect the JTAG debugger to it. Ensure that Windows recognizes the device and loads the appropriate drivers. Set a breakpoint inside the loop and press F5 to start debugging. You can debug your firmware just like an ordinary Windows program:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/12-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4553\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/12-debug.png\" alt=\"\" width=\"1069\" height=\"713\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/12-debug.png 1069w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/12-debug-300x200.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/12-debug-768x512.png 768w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/12-debug-1024x683.png 1024w\" sizes=\"(max-width: 1069px) 100vw, 1069px\" \/><\/a><\/li>\n<li>Press F10 to step over the line that turns on the LED. You will see the LED turning on:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/stm32\/14-stm32board.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-13\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/stm32\/14-stm32board.png\" alt=\"14-stm32board\" width=\"700\" height=\"364\" \/><\/a><\/li>\n<li>You can customize various project settings by right-clicking on the project node in Solution Explorer and selecting &#8220;VisualGDB Project Properties&#8221;. E.g. you can reference various frameworks included in the STM32 package via the Embedded Frameworks page. VisualGDB will automatically update your makefile and synchronize IntelliSense settings:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/13-settings.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4556\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/13-settings.png\" alt=\"\" width=\"992\" height=\"660\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/13-settings.png 992w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/13-settings-300x200.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/13-settings-768x511.png 768w\" sizes=\"(max-width: 992px) 100vw, 992px\" \/><\/a><\/li>\n<li>VisualGDB will automatically index your sources (and the STM32 package sources) and will let you navigate through them using CodeJumps. Simply click the CodeJumps labels near the function declarations to view references, call trees, functions &#8220;implementing&#8221; specific function pointers and so on:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/14-calls.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4557\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/14-calls.png\" alt=\"\" width=\"1069\" height=\"713\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/14-calls.png 1069w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/14-calls-300x200.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/14-calls-768x512.png 768w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/14-calls-1024x683.png 1024w\" sizes=\"(max-width: 1069px) 100vw, 1069px\" \/><\/a><\/li>\n<li>Use the View-&gt;Embedded Memory Explorer to get a detailed report about the structure of your embedded binary, including the locations of sections in memory, sizes of individual functions, their disassembly view and worst-case stack analysis:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/eme.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4558\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/eme.png\" alt=\"\" width=\"1069\" height=\"713\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/eme.png 1069w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/eme-300x200.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/eme-768x512.png 768w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/02\/eme-1024x683.png 1024w\" sizes=\"(max-width: 1069px) 100vw, 1069px\" \/><\/a><\/li>\n<\/ol>\n<p>You can also use <a href=\"http:\/\/visualgdb.com\/tutorials\/arm\/stm32\/..\/st-link\">OpenOCD<\/a> to debug your STM32 projects. Follow the corresponding tutorials for more details.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to create a simple &#8216;Blinking LED&#8217; project for the STM32100B-EVAL board using Visual Studio. Before we<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[90],"tags":[53,61],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/119"}],"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=119"}],"version-history":[{"count":3,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/119\/revisions"}],"predecessor-version":[{"id":4559,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/119\/revisions\/4559"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}