{"id":918,"date":"2015-09-18T19:44:18","date_gmt":"2015-09-19T02:44:18","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=918"},"modified":"2015-09-18T19:48:01","modified_gmt":"2015-09-19T02:48:01","slug":"importing-projects-from-coocox-coide-to-visual-studio","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/coocox\/","title":{"rendered":"Importing projects from CooCox CoIDE to Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to import an embedded project from Eclipse-based CooCox CoIDE to Visual Studio, build and debug it with VisualGDB. We will import a project created for the STM32F4Discovery board and show how to setup build and use the peripheral driver libraries provided by ST.<\/p>\n<ol>\n<li>Create a project with CooCox CoIDE, add references to the GPIO module and put the following code into the main source file:\n<pre class=\"\">#include &lt;stm32f4xx_gpio.h&gt;\r\n#include &lt;stm32f4xx_rcc.h&gt;\r\n\r\nvoid Delay()\r\n{\r\n\u00a0\u00a0 \u00a0int i;\r\n\u00a0\u00a0 \u00a0for (i = 0; i &lt; 1000000; i++)\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0asm(\"nop\");\r\n}\r\n\r\nint main()\r\n{\r\n\u00a0 GPIO_InitTypeDef GPIO_InitStructure;\r\n\r\n\u00a0 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);\r\n\r\n\u00a0 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;\r\n\r\n\u00a0 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;\r\n\u00a0 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;\r\n\u00a0 GPIO_Init(GPIOD, &amp;GPIO_InitStructure);\r\n\r\n\u00a0 for (;;)\r\n\u00a0 {\r\n\u00a0\u00a0 \u00a0\u00a0 GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_SET);\r\n\u00a0\u00a0 \u00a0\u00a0 Delay();\r\n\u00a0\u00a0 \u00a0\u00a0 GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_RESET);\r\n\u00a0\u00a0 \u00a0\u00a0 Delay();\r\n\u00a0 }\r\n}<\/pre>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/01-project.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-919\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/01-project.png\" alt=\"01-project\" width=\"807\" height=\"760\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/01-project.png 807w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/01-project-300x283.png 300w\" sizes=\"(max-width: 807px) 100vw, 807px\" \/><\/a><\/li>\n<li>Run the &#8220;tree \/f&#8221; command from the project directory to get an overview of the source files included in the project:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/01a-tree.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-920\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/01a-tree.png\" alt=\"01a-tree\" width=\"677\" height=\"534\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/01a-tree.png 677w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/01a-tree-300x237.png 300w\" sizes=\"(max-width: 677px) 100vw, 677px\" \/><\/a>The most important about the file layout is that the header files are located in cmsis, cmsis_boot and cmsis_lib\/include subdirectories. We will need to specify this later when we get the project to build under Visual Studio.<\/li>\n<li>Launch Visual Studio and start the VisualGDB Embedded Project Wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/02-embwiz.png\"> <img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-921\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/02-embwiz.png\" alt=\"02-embwiz\" width=\"800\" height=\"518\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/02-embwiz.png 800w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/02-embwiz-300x194.png 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/li>\n<li>Select &#8220;Import a project built with command-line tools -&gt; Generate a Makefile&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/03-import.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-922\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/03-import.png\" alt=\"03-import\" width=\"702\" height=\"571\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/03-import.png 702w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/03-import-300x244.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a><\/li>\n<li>Select your ARM toolchain and pick the device from the list:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/04-device.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-923\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/04-device.png\" alt=\"04-device\" width=\"702\" height=\"626\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/04-device.png 702w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/04-device-300x268.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a><\/li>\n<li>Specify the directory with your CoIDE project so that VisualGDB can import files from it:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/05-dir.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-924\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/05-dir.png\" alt=\"05-dir\" width=\"702\" height=\"626\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/05-dir.png 702w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/05-dir-300x268.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a><\/li>\n<li>Select OpenOCD as the debug method. If your Discovery board is plugged in, VisualGDB will detect it automatically. Otherwise, select the programming interface from the list or press &#8220;Detect&#8221; to try detecting it again:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/06-ocd.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-925\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/06-ocd.png\" alt=\"06-ocd\" width=\"702\" height=\"626\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/06-ocd.png 702w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/06-ocd-300x268.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a><\/li>\n<li>Press Finish to create the project. By default it will use the new STM32 HAL library. As the CoIDE projects include the files from the ST libraries, this would cause a conflict. To avoid it, open VisualGDB Project Properties, go to the Embedded Frameworks page and remove references to all frameworks:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/07-refs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-926\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/07-refs.png\" alt=\"07-refs\" width=\"799\" height=\"781\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/07-refs.png 799w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/07-refs-300x293.png 300w\" sizes=\"(max-width: 799px) 100vw, 799px\" \/><\/a><\/li>\n<li>Go to the Makefile settings page and specify the relative paths to the directories containing .h files in the Include Directories field:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/08-includes.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-927\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/08-includes.png\" alt=\"08-includes\" width=\"794\" height=\"798\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/08-includes.png 794w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/08-includes-150x150.png 150w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/08-includes-298x300.png 298w\" sizes=\"(max-width: 794px) 100vw, 794px\" \/><\/a><\/li>\n<li>Remove the startup file used by VisualGDB as the CoIDE includes its own startup file:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/09-startup1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-936\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/09-startup1.png\" alt=\"09-startup\" width=\"699\" height=\"665\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/09-startup1.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/09-startup1-300x285.png 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><\/li>\n<li>Try building your project. If VisualGDB shows errors related to the assert function, edit the stm32f4xx.h to include the stm32f4xx_conf.h file:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/10-bkpt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-935\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/include.png\" alt=\"include\" width=\"699\" height=\"664\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/include.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/include-300x285.png 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><\/li>\n<li>Press F10 to step into the main() function:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/10-bkpt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-929\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/10-bkpt.png\" alt=\"10-bkpt\" width=\"699\" height=\"665\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/10-bkpt.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/10-bkpt-300x285.png 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a>Once the debugging starts, you can step through the function or press F5 to resume debugging.<\/li>\n<li>Once you verify that the program works as expected, stop debugging by pressing Shift-F5. Now we will remove the files that CoIDE copied from the STM32 libraries and replace them with references to the VisualGDB STM32 library. This will ensure that the files will be stored in one central location shared between the projects and that updating them to newer versions automatically affects all related projects. First, remove the files from the cmsis, cmsis_boot and cmsis_lib subdirectories:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/11-removestartup1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-937\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/11-removestartup1.png\" alt=\"11-removestartup\" width=\"699\" height=\"664\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/11-removestartup1.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/11-removestartup1-300x285.png 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><\/li>\n<li>Then add a reference to the Legacy Peripheral Library framework via VisualGDB Project Properties:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/12-system.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-931\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/12-system.png\" alt=\"12-system\" width=\"794\" height=\"798\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/12-system.png 794w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/12-system-150x150.png 150w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/12-system-298x300.png 298w\" sizes=\"(max-width: 794px) 100vw, 794px\" \/><\/a><\/li>\n<li>Finally, clear the Include Directories field on the Makefile Settings page:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/13-incl.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-932\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/13-incl.png\" alt=\"13-incl\" width=\"794\" height=\"798\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/13-incl.png 794w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/13-incl-150x150.png 150w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/13-incl-298x300.png 298w\" sizes=\"(max-width: 794px) 100vw, 794px\" \/><\/a><\/li>\n<li>Now you can build your project again. Instead of the files copied by CoIDE, it will use the shared files provided by VisualGDB:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/14-periph.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-933\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/14-periph.png\" alt=\"14-periph\" width=\"699\" height=\"664\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/14-periph.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/14-periph-300x285.png 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><\/li>\n<li>Press F10 to step into it and then hit F5 to continue debugging and validate that it is working as before:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/15-main.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-934\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/15-main.png\" alt=\"15-main\" width=\"699\" height=\"664\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/15-main.png 699w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/15-main-300x285.png 300w\" sizes=\"(max-width: 699px) 100vw, 699px\" \/><\/a><\/li>\n<li>You can also delete the files in cmsis, cmsis_boot and cmsis_lib directories from the disk, as they do not participate in build anymore:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/delfiles.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-938\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/delfiles.png\" alt=\"delfiles\" width=\"696\" height=\"482\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/delfiles.png 696w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/delfiles-300x208.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/delfiles-392x272.png 392w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/09\/delfiles-130x90.png 130w\" sizes=\"(max-width: 696px) 100vw, 696px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to import an embedded project from Eclipse-based CooCox CoIDE to Visual Studio, build and debug it<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[41,61],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/918"}],"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=918"}],"version-history":[{"count":2,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/918\/revisions"}],"predecessor-version":[{"id":940,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/918\/revisions\/940"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}