{"id":1475,"date":"2016-02-12T23:42:34","date_gmt":"2016-02-13T07:42:34","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=1475"},"modified":"2016-02-13T00:04:56","modified_gmt":"2016-02-13T08:04:56","slug":"creating-a-basic-http-server-with-stm32f7-discovery","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/stm32\/lwip\/","title":{"rendered":"Creating a basic HTTP server with STM32F7-Discovery"},"content":{"rendered":"<p>This tutorial shows how to create a very basic HTTP server project with the STM32F7-Discovery board using the lwIP library and VisualGDB. Before you begin, install Visual Studio and VisualGDB 5.1 or later.<\/p>\n<ol>\n<li>Start Visual Studio and open the VisualGDB Embedded Project Wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/01-newprj1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1476\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/01-newprj1.png\" alt=\"01-newprj\" width=\"786\" height=\"443\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/01-newprj1.png 786w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/01-newprj1-300x169.png 300w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/a><\/li>\n<li>Proceed with the default &#8220;new embedded binary&#8221; setting:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/02-binary.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1477\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/02-binary.png\" alt=\"02-binary\" width=\"738\" height=\"565\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/02-binary.png 738w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/02-binary-300x230.png 300w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/a><\/li>\n<li>On the next page of the wizard select the ARM toolchain and choose the STM32F746NG device used on the STM32F7-Discovery board. If you are using a different board, you would need to copy the hardware setup functions from the examples for that board (more details in the end of this tutorial).<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/03-device.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1478\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/03-device.png\" alt=\"03-device\" width=\"738\" height=\"565\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/03-device.png 738w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/03-device-300x230.png 300w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/a><\/li>\n<li>On the Sample Selection page choose the &#8220;HTTP Server&#8221; example and press &#8220;Next&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/04-http.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1479\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/04-http.png\" alt=\"04-http\" width=\"738\" height=\"565\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/04-http.png 738w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/04-http-300x230.png 300w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/a><\/li>\n<li>Finally select a debug method that works with your board. For most STM32 boards you can simply select OpenOCD and plug the board in to get the settings auto-detected:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/05-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1480\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/05-debug.png\" alt=\"05-debug\" width=\"738\" height=\"565\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/05-debug.png 738w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/05-debug-300x230.png 300w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/a><\/li>\n<li>Press &#8220;Finish&#8221; to generate your project. Build it with Ctrl-Shift-B:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/06-build1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1481\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/06-build1.png\" alt=\"06-build\" width=\"1002\" height=\"690\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/06-build1.png 1002w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/06-build1-300x207.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/06-build1-130x90.png 130w\" sizes=\"(max-width: 1002px) 100vw, 1002px\" \/><\/a><\/li>\n<li>Ensure the on-board ST-Link is connected to your computer and that the Ethernet port is connected to a network with a valid DHCP server:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/board.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1487\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/board.jpg\" alt=\"board\" width=\"800\" height=\"710\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/board.jpg 800w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/board-300x266.jpg 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/li>\n<li>Start debugging by pressing F5. Observe how the board reports the IP address it gets via the semihosting window:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/07-got-ip.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1482\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/07-got-ip.png\" alt=\"07-got-ip\" width=\"1002\" height=\"690\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/07-got-ip.png 1002w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/07-got-ip-300x207.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/07-got-ip-130x90.png 130w\" sizes=\"(max-width: 1002px) 100vw, 1002px\" \/><\/a><\/li>\n<li>Open your browser and go to the address of the board:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/08-browser.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1484\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/08-browser.png\" alt=\"08-browser\" width=\"541\" height=\"215\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/08-browser.png 541w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/08-browser-300x119.png 300w\" sizes=\"(max-width: 541px) 100vw, 541px\" \/><\/a><\/li>\n<li>Set a breakpoint after the call to the netconn_recv() and refresh the page in your browser. Hover the mouse over the <strong>inbuf<\/strong> variable to find out the address of the payload buffer:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/08a-rqaddr.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1483\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/08a-rqaddr.png\" alt=\"08a-rqaddr\" width=\"1004\" height=\"691\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/08a-rqaddr.png 1004w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/08a-rqaddr-300x206.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/08a-rqaddr-130x90.png 130w\" sizes=\"(max-width: 1004px) 100vw, 1004px\" \/><\/a><\/li>\n<li>Copy the payload buffer address to the Memory window to see the contents of the request received from the browser:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/09-request.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1485\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/09-request.png\" alt=\"09-request\" width=\"1002\" height=\"690\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/09-request.png 1002w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/09-request-300x207.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/09-request-130x90.png 130w\" sizes=\"(max-width: 1002px) 100vw, 1002px\" \/><\/a><\/li>\n<li>Now we will quickly go through the components used by the server example. The project relies on the STM32 HAL library, FreeRTOS library for multi-threading support and the lwIP library for the network functionality. You can add and remove references to these frameworks via VisualGDB Project Properties:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/10-frameworks.png\"> <img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1486\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/10-frameworks.png\" alt=\"10-frameworks\" width=\"753\" height=\"583\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/10-frameworks.png 753w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/10-frameworks-300x232.png 300w\" sizes=\"(max-width: 753px) 100vw, 753px\" \/><\/a>You can configure various settings of those frameworks by editing\u00a0stm32f7xx_hal_conf.h, FreeRTOSConfig.h and\u00a0lwipopts.h.<\/li>\n<li>The central point of the application is the MainThread() function. It calls the netconn API functions such as netconn_accept() that are similar to the normal socket functions. You can use the Code Map provided by the Clang IntelliSense to quickly visualize the relations between the functions:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/codemap.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1489\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/codemap.png\" alt=\"codemap\" width=\"666\" height=\"238\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/codemap.png 666w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/02\/codemap-300x107.png 300w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><\/a><\/li>\n<li>If you want to target a different board, you need to replace the SystemClock_Config() function in the main file and the entire ethernetif.c file with the ones from an Ethernet example for your board. Note that ethernetif.c files from non-RTOS examples are not compatible with the RTOS-based examples.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to create a very basic HTTP server project with the STM32F7-Discovery board using the lwIP library<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[116,117,61],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1475"}],"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=1475"}],"version-history":[{"count":6,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1475\/revisions"}],"predecessor-version":[{"id":1494,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1475\/revisions\/1494"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=1475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=1475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=1475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}