{"id":2745,"date":"2017-05-26T09:46:46","date_gmt":"2017-05-26T16:46:46","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=2745"},"modified":"2017-05-26T10:30:08","modified_gmt":"2017-05-26T17:30:08","slug":"developing-firmware-for-nodemcu-with-visual-studio","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/esp8266\/nodemcu\/","title":{"rendered":"Developing firmware for NodeMCU with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to use VisualGDB to create a basic C++ WiFi HTTP server running on the NodeMCU platform.We will program and debug it via the on-board USB-to-UART connection using the GDB stub included in the ESP8266 SDK.<\/p>\n<p>Before you begin, install VisualGDB 5.2 or later.<\/p>\n<ol>\n<li>Start Visual Studio and open the VisualGDB Embedded Project Wizard:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/01-prjname2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2746\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/01-prjname2.png\" alt=\"01-prjname\" width=\"941\" height=\"653\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/01-prjname2.png 941w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/01-prjname2-300x208.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/01-prjname2-392x272.png 392w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/01-prjname2-130x90.png 130w\" sizes=\"(max-width: 941px) 100vw, 941px\" \/><\/a><\/li>\n<li>Proceed with the default project type:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/02-prjtype1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2747\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/02-prjtype1.png\" alt=\"02-prjtype\" width=\"822\" height=\"642\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/02-prjtype1.png 822w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/02-prjtype1-300x234.png 300w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/a><\/li>\n<li>On the next page select the ESP8266 toolchain and proceed with the regular ESP8266 device. Ensure the &#8220;Enable UART GDB Stub&#8221; checkbox is checked:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/03-device4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2748\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/03-device4.png\" alt=\"03-device\" width=\"822\" height=\"642\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/03-device4.png 822w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/03-device4-300x234.png 300w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/a><\/li>\n<li>On the Sample Selection page select &#8220;HTTP Server (RTOS SDK)&#8221; and click &#8220;next&#8221;:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/04-rtos.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2749\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/04-rtos.png\" alt=\"04-rtos\" width=\"822\" height=\"642\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/04-rtos.png 822w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/04-rtos-300x234.png 300w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/a><\/li>\n<li>Connect the board to a USB port on your computer:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/board1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2757\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/board1.jpg\" alt=\"board\" width=\"800\" height=\"368\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/board1.jpg 800w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/board1-300x138.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/li>\n<li>Open Device Manager and locate the port number corresponding to the NodeMCU board:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/05-comport.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2750\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/05-comport.png\" alt=\"05-comport\" width=\"781\" height=\"572\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/05-comport.png 781w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/05-comport-300x220.png 300w\" sizes=\"(max-width: 781px) 100vw, 781px\" \/><\/a><\/li>\n<li>Go back to the VisualGDB Project Wizard and choose &#8220;Bootloader + GDB Stub&#8221; as the debug method. Specify the COM port that corresponds to the board and check the &#8220;Do not show the &#8216;reset to bootloader&#8217; message&#8221; checkbox. Ensure that &#8220;Bootloader reset delay&#8221; is set to 50 msec:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/06-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2751\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/06-debug.png\" alt=\"06-debug\" width=\"822\" height=\"642\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/06-debug.png 822w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/06-debug-300x234.png 300w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/a><strong>Warning: if your debug settings do not show the &#8220;Initialization Data File&#8221; setting, you are using an old ESP8266 toolchain that is not compatible with NodeMCU. In this case please update your toolchain via Tools-&gt;Manage VisualGDB Packages.<\/strong><\/li>\n<li>Press &#8220;Finish&#8221; to generate the project. Ensure it builds without errors:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/07-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2752\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/07-build.png\" alt=\"07-build\" width=\"1008\" height=\"633\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/07-build.png 1008w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/07-build-300x188.png 300w\" sizes=\"(max-width: 1008px) 100vw, 1008px\" \/><\/a><\/li>\n<li>Press F5 to start debugging. VisualGDB will automatically restart your NodeMCU board into the bootloader mode and program it over UART:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/08-program.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2753\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/08-program.png\" alt=\"08-program\" width=\"1008\" height=\"633\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/08-program.png 1008w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/08-program-300x188.png 300w\" sizes=\"(max-width: 1008px) 100vw, 1008px\" \/><\/a><\/li>\n<li>Once the programming is complete, the firmware will start and display the IP address of the HTTP server:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/09-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2754\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/09-debug.png\" alt=\"09-debug\" width=\"1008\" height=\"633\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/09-debug.png 1008w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/09-debug-300x188.png 300w\" sizes=\"(max-width: 1008px) 100vw, 1008px\" \/><\/a><\/li>\n<li>Connect to the &#8220;ESP8266_VisualGDB_RTOS&#8221; WiFi network and open the IP address of the board in your browser: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/10-hello.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2755\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/10-hello.png\" alt=\"10-hello\" width=\"931\" height=\"458\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/10-hello.png 931w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/10-hello-300x148.png 300w\" sizes=\"(max-width: 931px) 100vw, 931px\" \/><\/a><\/li>\n<li>Congratulations! Your NodeMCU works. Try setting a breakpoint in the ServerTask() function where it parses the HTTP request sent by the browser and refresh the page. The breakpoint will hit and you will be able to step through your firmware:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/11-bkpt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2756\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/11-bkpt.png\" alt=\"11-bkpt\" width=\"1008\" height=\"633\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/11-bkpt.png 1008w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/05\/11-bkpt-300x188.png 300w\" sizes=\"(max-width: 1008px) 100vw, 1008px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to use VisualGDB to create a basic C++ WiFi HTTP server running on the NodeMCU platform.We<\/p>\n","protected":false},"author":1,"featured_media":2759,"comment_status":"closed","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"footnotes":""},"categories":[142],"tags":[100],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/2745"}],"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=2745"}],"version-history":[{"count":2,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/2745\/revisions"}],"predecessor-version":[{"id":2760,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/2745\/revisions\/2760"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media\/2759"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=2745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=2745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=2745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}