{"id":1146,"date":"2015-10-08T16:53:05","date_gmt":"2015-10-08T23:53:05","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=1146"},"modified":"2015-10-08T16:53:05","modified_gmt":"2015-10-08T23:53:05","slug":"developing-firmware-for-stm32l4-devices-with-visual-studio","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/stm32\/stm32l4\/","title":{"rendered":"Developing firmware for STM32L4 devices with Visual Studio"},"content":{"rendered":"<p>This tutorial hows how to create a project for the STM32L4-Nucleo board using VisualGDB and debug it with OpenOCD.<\/p>\n<p>If you have already used VisualGDB with OpenOCD, update your OpenOCD package to 0.9.0r3 or later via Tools-&gt;Embedded Tools Manager.<\/p>\n<ol>\n<li>Start Visual Studio and launch the VisualGDB Embedded project wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/01-emb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1147\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/01-emb.png\" alt=\"01-emb\" width=\"786\" height=\"478\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/01-emb.png 786w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/01-emb-300x182.png 300w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/a><\/li>\n<li>Select &#8220;Create a new project -&gt; Embedded binary&#8221; on the first page:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/02-binary.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1148\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/02-binary.png\" alt=\"02-binary\" width=\"688\" height=\"565\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/02-binary.png 688w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/02-binary-300x246.png 300w\" sizes=\"(max-width: 688px) 100vw, 688px\" \/><\/a><\/li>\n<li>Select the ARM toolchain and pick the STM32L476 device from the STM32L4-Nucleo board:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/03-stm32l4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1149\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/03-stm32l4.png\" alt=\"03-stm32l4\" width=\"688\" height=\"609\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/03-stm32l4.png 688w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/03-stm32l4-300x266.png 300w\" sizes=\"(max-width: 688px) 100vw, 688px\" \/><\/a><\/li>\n<li>Proceed with the default LEDBlink sample and select the GPIOA &#8211; 5 as the LED port:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/04-gpio.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1150\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/04-gpio.png\" alt=\"04-gpio\" width=\"688\" height=\"609\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/04-gpio.png 688w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/04-gpio-300x266.png 300w\" sizes=\"(max-width: 688px) 100vw, 688px\" \/><\/a><\/li>\n<li>Select OpenOCD as the debug method. If the STM32L4xx device is not auto-detected, you are not using the latest OpenOCD package. You can install the latest one via Tools-&gt;Embedded Tools Manager:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/05-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1151\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/05-debug.png\" alt=\"05-debug\" width=\"688\" height=\"609\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/05-debug.png 688w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/05-debug-300x266.png 300w\" sizes=\"(max-width: 688px) 100vw, 688px\" \/><\/a><\/li>\n<li>Click &#8220;Test OpenOCD Settings&#8221; to check the connection between OpenOCD and the board:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/06-test.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1152\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/06-test.png\" alt=\"06-test\" width=\"686\" height=\"608\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/06-test.png 686w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/06-test-300x266.png 300w\" sizes=\"(max-width: 686px) 100vw, 686px\" \/><\/a><\/li>\n<li>Once the connection is tested, click &#8220;Finish&#8221; to create the project. Then press Ctrl-Shift-B to build it:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/07-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1153\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/07-build.png\" alt=\"07-build\" width=\"751\" height=\"605\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/07-build.png 751w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/07-build-300x242.png 300w\" sizes=\"(max-width: 751px) 100vw, 751px\" \/><\/a><\/li>\n<li>Set a breakpoint on the first call to HAL_GPIO_WritePin() and press F5 to start debugging. VisualGDB will automatically program your firmware and start debugging:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/08-break.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1154\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/08-break.png\" alt=\"08-break\" width=\"751\" height=\"606\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/08-break.png 751w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/08-break-300x242.png 300w\" sizes=\"(max-width: 751px) 100vw, 751px\" \/><\/a><\/li>\n<li>You can use normal Visual Studio debugging features, view various hardware registers via the Hardware Registers pane and explore the code via Code Map:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/09-regs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1155\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/09-regs.png\" alt=\"09-regs\" width=\"751\" height=\"604\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/09-regs.png 751w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/09-regs-300x241.png 300w\" sizes=\"(max-width: 751px) 100vw, 751px\" \/><\/a><\/li>\n<li>Step over the call to HAL_GPIO_WritePin(). Observe how the green LED on the board turns on:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/led_on.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1158\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/led_on.jpg\" alt=\"led_on\" width=\"700\" height=\"529\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/led_on.jpg 700w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/led_on-300x227.jpg 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/a><\/li>\n<li>Once you step over the other call to HAL_GPIO_WritePin(), the LED wil turn off:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/led_off1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1159\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/led_off1.jpg\" alt=\"led_off\" width=\"674\" height=\"496\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/led_off1.jpg 674w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/led_off1-300x221.jpg 300w\" sizes=\"(max-width: 674px) 100vw, 674px\" \/><\/a><\/li>\n<li>Press Shift-F5 to stop debugging. You can edit various project properties (e.g. add the FreeRTOS framework) by right-clicking on it in Solution Explorer and selecting VisualGDB Project Properties:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/10-rtos.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1156\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/10-rtos.png\" alt=\"10-rtos\" width=\"634\" height=\"536\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/10-rtos.png 634w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/10-rtos-300x254.png 300w\" sizes=\"(max-width: 634px) 100vw, 634px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial hows how to create a project for the STM32L4-Nucleo board using VisualGDB and debug it with OpenOCD. If<\/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,64,61],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1146"}],"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=1146"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1146\/revisions"}],"predecessor-version":[{"id":1160,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1146\/revisions\/1160"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=1146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=1146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=1146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}