{"id":503,"date":"2015-08-16T21:18:00","date_gmt":"2015-08-17T04:18:00","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=503"},"modified":"2015-08-16T21:24:51","modified_gmt":"2015-08-17T04:24:51","slug":"developing-stm32f7-firmware-with-visual-studio-and-openocd","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/stm32\/stm32f7\/","title":{"rendered":"Developing STM32F7 firmware with Visual Studio and OpenOCD"},"content":{"rendered":"<p>This tutorial shows how to develop a simple program for the STM32F7 devices using Visual Studio and VisualGDB. Before you begin, install VisualGDB 5.0 or later and ensure that you are using the latest versions of the toolchains and packages:<\/p>\n<ul>\n<li>ARM GCC 5.2.0 or later<\/li>\n<li>STM32 package 3.3 or later<\/li>\n<li>OpenOCD package 0.9.0r2 or later<\/li>\n<\/ul>\n<p>If you were using VisualGDB before, open Tools-&gt;Embedded Tool Manager and update the packages there. Otherwise, you can install the new versions of the packages from the VisualGDB project wizard.<\/p>\n<ol>\n<li>Start Visual Studio and select the VisualGDB Embedded Project Wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/01-start.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-504\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/01-start.png\" alt=\"01-start\" width=\"800\" height=\"512\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/01-start.png 800w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/01-start-300x192.png 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/li>\n<li>Proceed with the default &#8220;Create a new project&#8221; choice:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/02-new.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-505\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/02-new.png\" alt=\"02-new\" width=\"702\" height=\"571\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/02-new.png 702w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/02-new-300x244.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a><\/li>\n<li>Select the ARM toolchain. If you don&#8217;t have it installed, VisualGDB will automatically download and install it once you select it from the list:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/03-toolchain.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-506\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/03-toolchain.png\" alt=\"03-toolchain\" width=\"702\" height=\"571\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/03-toolchain.png 702w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/03-toolchain-300x244.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a><\/li>\n<li>Locate your device in the device list. We will use the STM32F746NG device on the STM32F7-Discovery board:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/04-device.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-507\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/04-device.png\" alt=\"04-device\" width=\"702\" height=\"571\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/04-device.png 702w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/04-device-300x244.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a><\/li>\n<li>On the next page select a sample. We will use the most basic &#8220;Blinking LED&#8221; sample. According to the <a href=\"http:\/\/www.st.com\/st-web-ui\/static\/active\/en\/resource\/technical\/layouts_and_diagrams\/schematic_pack\/stm32f746g-disco_sch.zip\">STM32F7-Discovery schematics<\/a>, an LED is connected to GPIOI1. Specify this on the Sample Selection page:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/06-openocd.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-508\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/05-sample.png\" alt=\"05-sample\" width=\"702\" height=\"571\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/05-sample.png 702w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/05-sample-300x244.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a><\/li>\n<li>Select OpenOCD as the debugging method. If you have already connected the STM32F7-Discovery board, VisualGDB will recognize it and select the ST-Link interface automatically. Otherwise you can select it manually or click &#8220;Detect&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/06-openocd.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-509\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/06-openocd.png\" alt=\"06-openocd\" width=\"702\" height=\"571\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/06-openocd.png 702w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/06-openocd-300x244.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a><\/li>\n<li>Click &#8220;Test OpenOCD Settings&#8221; to ensure that OpenOCD can connect to ST-Link and all necessary drivers are installed:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/07-test.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-510\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/07-test.png\" alt=\"07-test\" width=\"663\" height=\"542\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/07-test.png 663w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/07-test-300x245.png 300w\" sizes=\"(max-width: 663px) 100vw, 663px\" \/><\/a><\/li>\n<li>Press Finish in the wizard to complete the creation of the project. Build it with Ctrl-Shift-B:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/08-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-511\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/08-build.png\" alt=\"08-build\" width=\"695\" height=\"605\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/08-build.png 695w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/08-build-300x261.png 300w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/a><\/li>\n<li>Set a breakpoint on the call to HAL_GPIO_WritePin() and press F5 to start debugging:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/09-bkpt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-512\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/09-bkpt.png\" alt=\"09-bkpt\" width=\"695\" height=\"607\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/09-bkpt.png 695w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/09-bkpt-300x262.png 300w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/a><\/li>\n<li>When the breakpoint is hit, look at the board and note that no LEDs except the power indicator are on:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10a-noled.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-513\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10a-noled.jpg\" alt=\"10a-noled\" width=\"700\" height=\"478\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10a-noled.jpg 700w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10a-noled-300x205.jpg 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10a-noled-130x90.jpg 130w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/a><\/li>\n<li>Step over the call to HAL_GPIO_WritePin() and observe how an LED turns on:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10b-led.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-514\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10b-led.jpg\" alt=\"10b-led\" width=\"700\" height=\"510\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10b-led.jpg 700w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10b-led-300x219.jpg 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/a><\/li>\n<li>Now step into the HAL_Delay() function and again into HAL_GetTick(). Observe that the tick count is stored in the global uwTick variable:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10-tick.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-515\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10-tick.png\" alt=\"10-tick\" width=\"695\" height=\"605\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10-tick.png 695w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/10-tick-300x261.png 300w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/a><\/li>\n<li>Add it to Code Map via context menu and look for functions referencing it:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/11-refs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-516\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/11-refs.png\" alt=\"11-refs\" width=\"695\" height=\"606\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/11-refs.png 695w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/11-refs-300x262.png 300w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/a><\/li>\n<li>You will see that it is used modified by HAL_IncTick() function:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/12-reffuncs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-517\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/12-reffuncs.png\" alt=\"12-reffuncs\" width=\"695\" height=\"606\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/12-reffuncs.png 695w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/12-reffuncs-300x262.png 300w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/a><\/li>\n<li>Now we will observe how the value of uwTick changes over time. Open the Live Variables window via Debug-&gt;Windows,add uwTick there and enable plotting:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/13-dynamics.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-518\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/13-dynamics.png\" alt=\"13-dynamics\" width=\"695\" height=\"606\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/13-dynamics.png 695w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/13-dynamics-300x262.png 300w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/a><\/li>\n<li>You can click the Pause icon to freeze the graph and explore the values. Ensure that the value goes up by 1000 roughly each second:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/14-values.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-520\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/14-values.png\" alt=\"14-values\" width=\"695\" height=\"604\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/14-values.png 695w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/14-values-300x261.png 300w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/a>Note that polling the values may have a latency of a few milliseconds, so don&#8217;t expect microsecond precision in the graph.<\/li>\n<li>You can now stop debugging and open VisualGDB Project Properties on the Embedded Frameworks page to add\/remove references to various STM32F7 frameworks (e.g. the STM32 USB library):<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/15-frameworks.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-521\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/15-frameworks.png\" alt=\"15-frameworks\" width=\"614\" height=\"586\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/15-frameworks.png 614w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/15-frameworks-300x286.png 300w\" sizes=\"(max-width: 614px) 100vw, 614px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to develop a simple program for the STM32F7 devices using Visual Studio and VisualGDB. Before you<\/p>\n","protected":false},"author":1,"featured_media":519,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89],"tags":[53,61],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/503"}],"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=503"}],"version-history":[{"count":3,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/503\/revisions"}],"predecessor-version":[{"id":524,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/503\/revisions\/524"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media\/519"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}