{"id":118,"date":"2014-11-10T16:31:22","date_gmt":"2014-11-10T16:31:22","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=118"},"modified":"2014-11-10T16:31:22","modified_gmt":"2014-11-10T16:31:22","slug":"arm-standalone","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/standalone\/","title":{"rendered":"Using Stand-alone Embedded VisualGDB Projects"},"content":{"rendered":"\n<p>This tutorial shows how to convert an Embedded VisualGDB project into a stand-alone project. Unlike normal projects that reference common BSP files (e.g. driver libraries), the stand-alone projects are self-contained and hence can be fully modified without affecting other projects. Stand-alone projects are supported since VisualGDB 4.3.<\/p>\n<p>We will first create a basic project for the STM32F4Discovery board using the HAL library and then convert it to a stand-alone project and replace the HAL library with the older peripheral driver library. <\/p>\n<ol>\n<li>Create a new project using the VisualGDB Embedded Project Wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/01-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/01-newprj.png\" alt=\"01-newprj\" width=\"700\" height=\"435\" \/><\/a><\/li>\n<li>Select &#8220;Embedded binary&#8221; on the first page:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/02-binary.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/02-binary.png\" alt=\"02-binary\" width=\"702\" height=\"571\" \/><\/a><\/li>\n<li>Select your device on the next page:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/03-device.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/03-device.png\" alt=\"03-device\" width=\"702\" height=\"571\" \/><\/a><\/li>\n<li>As we will be heavily modifying the main source file to remove references to the HAL library, you can proceed with the default sample settings:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/04-sample.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/04-sample.png\" alt=\"04-sample\" width=\"702\" height=\"571\" \/><\/a><\/li>\n<li>Select the debugging method you want to use:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/05-openocd.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/05-openocd.png\" alt=\"05-openocd\" width=\"702\" height=\"571\" \/><\/a><\/li>\n<li>Once you press &#8220;Finish&#8221;, VisualGDB will create a new project using the STM32F4 HAL library:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/06-hal.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/06-hal.png\" alt=\"06-hal\" width=\"699\" height=\"644\" \/><\/a><\/li>\n<li>We will now convert it to a stand-alone project and replace the HAL library with the old peripheral drivers.<br \/> Copy the legacy STM32F4 files from <strong> %LOCALAPPDATA%\\VisualGDB\\EmbeddedBSPs\\arm-eabi\\com.sysprogs.arm.stm32\\STM32F4xxxx<\/strong> to a different folder (e.g. <strong>c:\\projects\\STM32F4xxxx<\/strong>). Then open VisualGDB Project Properties, press the &#8220;Convert to stand-alone project&#8221; and select &#8220;Remove references to BSP files&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/07-standalone.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/07-standalone.png\" alt=\"07-standalone\" width=\"700\" height=\"589\" \/><\/a><\/li>\n<li>We will now add the references to the legacy files manually. First reference all include directories from the legacy package that contain .h files:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/08-includes.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/08-includes.png\" alt=\"08-includes\" width=\"700\" height=\"660\" \/><\/a><\/li>\n<li>The add the contents of the <strong> STM32F4xx_StdPeriph_Driver\\src<\/strong> folder as well as the <strong>startup_stm32f4xx.c<\/strong> and the <strong> system_stm32f4xx.c<\/strong> files to Additional Sources and specify the linker script matching your device:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/09-src.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/09-src.png\" alt=\"09-src\" width=\"700\" height=\"660\" \/><\/a><\/li>\n<li>If you try building your project now, the STM32 header file will report an error because the device type definitions of the legacy driver library are incompatible with the ones retained from the HAL project:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/10-error.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/10-error.png\" alt=\"10-error\" width=\"699\" height=\"606\" \/><\/a><\/li>\n<li>Go to VisualGDB Project Properties and replace the <strong>STM32F407xx<\/strong> definition with <strong> STM32F40_41xxx:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/11-macro.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/11-macro.png\" alt=\"11-macro\" width=\"693\" height=\"653\" \/><\/a><\/strong><\/li>\n<li>Finally replace the contents of the main file with an equivalent depending on the legacy API:\n<pre>#include&lt;stm32f4xx_gpio.h&gt;\r\n#include&lt;stm32f4xx_rcc.h&gt;\r\n\r\nvoid Delay()\r\n{\r\n   int i;\r\n   for (i = 0; i &lt; 1000000; i++)\r\n   asm(\"nop\");\r\n}\r\n\r\nint main()\r\n{\r\n    GPIO_InitTypeDef GPIO_InitStructure;\r\n\r\n    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);\r\n\r\n    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;\r\n\r\n    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;\r\n    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;\r\n    GPIO_Init(GPIOD, &amp;GPIO_InitStructure);\r\n\r\n   for (;;)\r\n    {\r\n        GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_SET);\r\n        Delay();\r\n        GPIO_WriteBit(GPIOD, GPIO_Pin_12, Bit_RESET);\r\n        Delay();\r\n    }\r\n}<\/pre>\n<\/li>\n<li>Now you can build and debug your project as usual:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/12-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/standalone\/12-debug.png\" alt=\"12-debug\" width=\"699\" height=\"606\" \/><\/a><\/li>\n<\/ol>\n<p>Let&#8217;s summarize the differences of a stand-alone project compared to a normal project:<\/p>\n<ul>\n<li>Stand-alone project does not depend on any VisualGDB-maintained files (unless specified explicitly)<\/li>\n<li>You can freely modify the startup files, peripheral drivers, etc. Only the projects explicitly using the files in the same location will be affected, while the normal projects using files from %LOCALAPPDATA% will remain unchanged.<\/li>\n<li>You cannot use the GUI to conveniently change the MCU of a stand-alone project, instead you need to modify various compiler settings directly.<\/li>\n<\/ul>\n<p><\/root><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to convert an Embedded VisualGDB project into a stand-alone project. Unlike normal projects that reference common<\/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":[53],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/118"}],"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=118"}],"version-history":[{"count":0,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/118\/revisions"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}