{"id":4385,"date":"2018-11-19T16:14:38","date_gmt":"2018-11-20T00:14:38","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=4385"},"modified":"2018-11-19T17:04:21","modified_gmt":"2018-11-20T01:04:21","slug":"debugging-rtx-based-projects-with-visualgdb","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/keil\/rtx\/","title":{"rendered":"Debugging RTX-based projects with VisualGDB"},"content":{"rendered":"<p>This\u00a0tutorial shows how to create a basic project using the Keil compiler and the RTX OS using VisualGDB. We will create a basic &#8220;Blinking LED&#8221; project for the STM32F4Discovery board and will show to to view the\u00a0state of the threads using\u00a0the RTX thread plugin. Before you begin, install VisualGDB 5.4 Preview 10 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\/2018\/11\/01-prjname.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4386\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/01-prjname.png\" alt=\"01-prjname\" width=\"941\" height=\"653\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/01-prjname.png 941w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/01-prjname-300x208.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/01-prjname-392x272.png 392w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/01-prjname-130x90.png 130w\" sizes=\"(max-width: 941px) 100vw, 941px\" \/><\/a><\/li>\n<li>Proceed with the default settings on the first page:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/05\/02-msbuild.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4369\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/05\/02-msbuild.png\" alt=\"02-msbuild\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/05\/02-msbuild.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/05\/02-msbuild-300x235.png 300w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>On the next page select your Keil toolchain and the device you want to target:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/02-device.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4387\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/02-device.png\" alt=\"02-device\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/02-device.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/02-device-300x235.png 300w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a>If the toolchain does not appear, follow <a href=\"https:\/\/visualgdb.com\/tutorials\/arm\/keil\/\">this tutorial<\/a> to create a basic project first.<\/li>\n<li>Keil-based projects are always created empty, so\u00a0press &#8220;Next&#8221; in the Sample Selection page:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/03-sample.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4388\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/03-sample.png\" alt=\"03-sample\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/03-sample.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/03-sample-300x235.png 300w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>On the Debug Method page select\u00a0the debug method you want to use with your board:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/04-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4389\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/04-debug.png\" alt=\"04-debug\" width=\"886\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/04-debug.png 886w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/04-debug-300x235.png 300w\" sizes=\"(max-width: 886px) 100vw, 886px\" \/><\/a><\/li>\n<li>Press &#8220;Finish&#8221; to create the project. VisualGDB will create an empty MSBuild-based project using the selected Keil compiler:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/05-empty.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4390\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/05-empty.png\" alt=\"05-empty\" width=\"1097\" height=\"784\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/05-empty.png 1097w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/05-empty-300x214.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/05-empty-1024x732.png 1024w\" sizes=\"(max-width: 1097px) 100vw, 1097px\" \/><\/a><\/li>\n<li>If you are using the Custom edition of VisualGDB or higher, you can automatically add the\u00a0RTX project template and all necessary components from the Keil packs using the Keil Components page of VisualGDB Project Properties. Select\u00a0your board in the &#8220;Board Support&#8221; field, then check\u00a0the following components:\n<ul>\n<li>Board Support -&gt; LED<\/li>\n<li>CMSIS -&gt; RTOS -&gt; Keil RTX5<\/li>\n<li>CMSIS -&gt; RTOS2 -&gt; Source<\/li>\n<li>Device-&gt;STN32Cuce HAL -&gt; GPIO<\/li>\n<\/ul>\n<p><a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/06-components.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4391\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/06-components.png\" alt=\"06-components\" width=\"955\" height=\"656\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/06-components.png 955w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/06-components-300x206.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/06-components-130x90.png 130w\" sizes=\"(max-width: 955px) 100vw, 955px\" \/><\/a>Once you select the components listed above, VisualGDB will automatically discover their dependencies and will suggest referencing them\u00a0automatically.<\/li>\n<li>Press &#8220;OK&#8221;.\u00a0VisualGDB will check the\u00a0newly referenced packages for template files and will suggest\u00a0copying them to the project. Select the templates\u00a0shown below and click &#8220;OK&#8221;:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/07-templates.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4392\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/07-templates.png\" alt=\"07-templates\" width=\"586\" height=\"426\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/07-templates.png 586w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/07-templates-300x218.png 300w\" sizes=\"(max-width: 586px) 100vw, 586px\" \/><\/a><\/li>\n<li>VisualGDB will add the necessary files to your project, so you will be able to build it:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/08-project.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4393\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/08-project.png\" alt=\"08-project\" width=\"1097\" height=\"784\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/08-project.png 1097w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/08-project-300x214.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/08-project-1024x732.png 1024w\" sizes=\"(max-width: 1097px) 100vw, 1097px\" \/><\/a><\/li>\n<li>Replace\u00a0the contents of the main.c file with <a href=\"https:\/\/github.com\/sysprogs\/tutorials\/blob\/master\/visualgdb\/keil\/LEDBlink\/main.c\">this<\/a>. It will create 2\u00a0parallel threads, each one controlling one on-board LED. Build the project and press F5 to start debugging:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/09-run.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4394\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/09-run.png\" alt=\"09-run\" width=\"1097\" height=\"784\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/09-run.png 1097w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/09-run-300x214.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/09-run-1024x732.png 1024w\" sizes=\"(max-width: 1097px) 100vw, 1097px\" \/><\/a><\/li>\n<li>Check that both on-board LEDs are blinking and set a\u00a0breakpoint in one of the thread functions. Once the breakpoint triggers, open the Debug-&gt;Windows-&gt;Threads window:<br \/>\n<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/10-threads.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4395\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/10-threads.png\" alt=\"10-threads\" width=\"1097\" height=\"784\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/10-threads.png 1097w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/10-threads-300x214.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/10-threads-1024x732.png 1024w\" sizes=\"(max-width: 1097px) 100vw, 1097px\" \/><\/a><\/li>\n<li>Visual Studio will display the currently running RTX threads in the Threads window.\u00a0Switch to the other thread to see that it is waiting in the <strong>osDelay()<\/strong> function:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/11-thread2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4396\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/11-thread2.png\" alt=\"11-thread2\" width=\"1097\" height=\"784\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/11-thread2.png 1097w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/11-thread2-300x214.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2018\/11\/11-thread2-1024x732.png 1024w\" sizes=\"(max-width: 1097px) 100vw, 1097px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This\u00a0tutorial shows how to create a basic project using the Keil compiler and the RTX OS using VisualGDB. We will<\/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,147,175],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/4385"}],"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=4385"}],"version-history":[{"count":2,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/4385\/revisions"}],"predecessor-version":[{"id":4417,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/4385\/revisions\/4417"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=4385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=4385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=4385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}