{"id":4160,"date":"2018-09-26T20:11:12","date_gmt":"2018-09-27T03:11:12","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=4160"},"modified":"2019-02-27T12:28:06","modified_gmt":"2019-02-27T20:28:06","slug":"developing-esp8266-arduino-projects-with-visual-studio","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arduino\/esp8266\/","title":{"rendered":"Developing ESP8266 Arduino Projects with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to develop Arduino projects for ESP8266-based boards. We will create a basic &#8220;Blinking LED&#8221; project for the NodeMCU board and will show how to debug it with the built-in GDB stub.<\/p>\n<p><strong>Warning: the ESP8266 Arduino core uses settings that\u00a0are incompatible with reliable JTAG debugging and the GDB stub debugging is not fully supported unless you are using the ESP8266 Arduino Core v2.5.0 or later. Please ensure you are using the latest Arduino Core.<\/strong><\/p>\n<p>Before you begin, install VisualGDB 5.4 or later.<\/p>\n<ol>\n<li>Start Visual Studio and open the VisualGDB Arduino Project Wizard:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/08\/01-prjname1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4161\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/08\/01-prjname1.png\" alt=\"01-prjname\" width=\"941\" height=\"541\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/08\/01-prjname1.png 941w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/08\/01-prjname1-300x172.png 300w\" sizes=\"(max-width: 941px) 100vw, 941px\" \/><\/a><\/li>\n<li>Select &#8220;Create a new &#8216;Blinking LED'&#8221; project:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/08\/02-blink1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4162\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/08\/02-blink1.png\" alt=\"02-blink\" width=\"856\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/08\/02-blink1.png 856w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/08\/02-blink1-300x243.png 300w\" sizes=\"(max-width: 856px) 100vw, 856px\" \/><\/a><strong>Warning: if you are importing an existing Arduino project,\u00a0it will not automatically insert\u00a0the ESP8266 gdb stub code into it. Please test the debugging functionality with a new project\u00a0as shown in\u00a0this tutorial before proceeding to import existing projects.<\/strong><\/li>\n<li>On the next page select your ESP8266-based\u00a0board. If the ESP8266 core is not installed, VisualGDB will suggest installing it automatically:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/08\/03-board.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4163\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/08\/03-board.png\" alt=\"03-board\" width=\"856\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/08\/03-board.png 856w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/08\/03-board-300x243.png 300w\" sizes=\"(max-width: 856px) 100vw, 856px\" \/><\/a><\/li>\n<li>Once the board is selected,\u00a0ensure it is plugged into the USB port and\u00a0select its COM port at the bottom of the page:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/boards.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4575\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/boards.png\" alt=\"\" width=\"856\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/boards.png 856w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/boards-300x243.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/boards-768x622.png 768w\" sizes=\"(max-width: 856px) 100vw, 856px\" \/><\/a><\/li>\n<li>Finally select the debug method. As the ESP8266 Arduino core configures the chip in a way that prevents JTAG debugging from working, the only supported debug method is the ESP8266 GDB stub. Select it in the &#8220;Debug using&#8221; field and press &#8220;Finish&#8221; to generate the project:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4576\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/debug.png\" alt=\"\" width=\"856\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/debug.png 856w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/debug-300x243.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/debug-768x622.png 768w\" sizes=\"(max-width: 856px) 100vw, 856px\" \/><\/a><\/li>\n<li>VisualGDB will generate a\u00a0project based on the Advanced Arduino Project Subsystem. As you have selected an ESP8266-based\u00a0board,\u00a0the project will contain the code necessary to\u00a0debug it with the ESP8266 gdb stub:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/01-prj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4579\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/01-prj.png\" alt=\"\" width=\"1329\" height=\"807\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/01-prj.png 1329w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/01-prj-300x182.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/01-prj-768x466.png 768w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/01-prj-1024x622.png 1024w\" sizes=\"(max-width: 1329px) 100vw, 1329px\" \/><\/a><\/li>\n<li>If you get an error message about the missing GDBSTUB_BREAK_ON_INIT macro, set it as shown below:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/02-init.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4580\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/02-init.png\" alt=\"\" width=\"916\" height=\"557\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/02-init.png 916w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/02-init-300x182.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/02-init-768x467.png 768w\" sizes=\"(max-width: 916px) 100vw, 916px\" \/><\/a><\/li>\n<li>Set a breakpoint in the loop() function and press F5 to start debugging:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/03-bp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4581\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/03-bp.png\" alt=\"\" width=\"1329\" height=\"807\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/03-bp.png 1329w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/03-bp-300x182.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/03-bp-768x466.png 768w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/03-bp-1024x622.png 1024w\" sizes=\"(max-width: 1329px) 100vw, 1329px\" \/><\/a><\/li>\n<li>Once the breakpoint hits, you will be able to step through your code as usual:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/04-trigger.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4582\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/04-trigger.png\" alt=\"\" width=\"1329\" height=\"807\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/04-trigger.png 1329w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/04-trigger-300x182.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/04-trigger-768x466.png 768w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/04-trigger-1024x622.png 1024w\" sizes=\"(max-width: 1329px) 100vw, 1329px\" \/><\/a>If you are not able to set breakpoints in the code while it is running, ensure that you are using the latest ESP8266 Arduino core (2.5.0 or later).<\/li>\n<li>If gdb refuses to connect to the gdb stub, double-check the baud rate setting on the Debug Settings page of VisualGDB Project Properties. If you are not sure what baud rate is used by the stub, try connecting to your board&#8217;s COM port with different baud rates (e.g. using <a href=\"http:\/\/smartty.sysprogs.com\/\">SmarTTY<\/a>) and resetting it. If the baud rate is correct, you should see the &#8220;$T05#b9&#8221; text indicating that the stub is waiting for gdb to connect:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/stub.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4583\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/stub.png\" alt=\"\" width=\"674\" height=\"440\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/stub.png 674w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/09\/stub-300x196.png 300w\" sizes=\"(max-width: 674px) 100vw, 674px\" \/><\/a>If you don&#8217;t see this text, try choosing a different baud rate and restarting the board.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to develop Arduino projects for ESP8266-based boards. We will create a basic &#8220;Blinking LED&#8221; project for<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[169],"tags":[170,100],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/4160"}],"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=4160"}],"version-history":[{"count":4,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/4160\/revisions"}],"predecessor-version":[{"id":4584,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/4160\/revisions\/4584"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=4160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=4160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=4160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}