{"id":6552,"date":"2020-07-29T21:13:29","date_gmt":"2020-07-30T04:13:29","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=6552"},"modified":"2020-07-29T22:01:43","modified_gmt":"2020-07-30T05:01:43","slug":"developing-tms570-projects-with-visual-studio","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/ti\/tms570\/","title":{"rendered":"Developing TMS570 Projects with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to create, build and debug a basic project for the TMS570LS1224 microcontroller using Visual Studio and VisualGDB. Before you begin, follow <a href=\"https:\/\/visualgdb.com\/tutorials\/arm\/ti\/halcogen\/\">this tutorial<\/a> to generate an SDK using TI HALCoGen and convert it into VisualGDB and install the latest ARM toolchain and the OpenOCD package.<\/p>\n<p><strong>WARNING: The TMS570LS1224 device shown in this tutorial is a Big-Endian device and requires an ARM toolchain with prebuilt Big Endian libraries. As of July 2020, the only toolchain build compatible with TMS570LS1224 is <a href=\"https:\/\/gnutoolchains.com\/arm-eabi\/\">gcc-9.3.1-r2<\/a>.<\/strong><\/p>\n<ol>\n<li>Start Visual Studio and locate the VisualGDB Embedded Project Wizard:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/01-wizard.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6511\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/01-wizard.png\" alt=\"\" width=\"966\" height=\"624\" \/><\/a><\/li>\n<li>Pick the name and location of your project: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/01-prjname.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6553\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/01-prjname.png\" alt=\"\" width=\"1024\" height=\"680\" \/><\/a><\/li>\n<li>Press &#8220;Create&#8221; to launch the VisualGDB-specific part of the wizard. Proceed with\u00a0 the default <strong>&#8220;New -&gt; Embedded Binary -&gt; MSBuild&#8221;<\/strong> settings: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/02-msbuild-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6554\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/02-msbuild-1.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>On the next page select the TMS570LS1224PGE device. If it doesn&#8217;t appear, make sure you have generated an SDK with HALCoGen and imported it into VisualGDB per <a href=\"https:\/\/visualgdb.com\/tutorials\/arm\/ti\/halcogen\/\">this tutorial<\/a>:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/03-device.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6555\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/03-device.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>On the next page select a sample project you would like to use. In this tutorial we will demonstrate the FreeRTOS-based sample, so select it from the list. You can specify the port\/pin of any on-board LED at the bottom of the page, or simply proceed with the default settings: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/04-port.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6556\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/04-port.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>Connect your board to the USB port. VisualGDB will automatically detect the XDS110 interface on the <strong>LAUNCHXL2-TMS57012<\/strong> board and will locate the OpenOCD device script. Make sure you explicitly select the JTAG interface:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/05-debug-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6557\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/05-debug-1.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>Press the Test button to verify the debugger connection:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/06-tested.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6558\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/06-tested.png\" alt=\"\" width=\"786\" height=\"593\" \/><\/a><\/li>\n<li>Press &#8220;Finish&#8221; to generate the project. Build it by pressing Ctrl-Shift-B:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/07-built-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6559\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/07-built-1.png\" alt=\"\" width=\"1234\" height=\"860\" \/><\/a><\/li>\n<li>OpenOCD does not support programming the TMS570 FLASH memory, so we will need to use the TI FLASH memory programming tool instead. Locate the DSLite executable in the CodeComposer directory and run it with the following arguments:\n<pre class=\"\">DSLite flash -f &lt;full path to the ELF file&gt; --config=&lt;full path to the config file&gt;<\/pre>\n<p>A config file is automatically created by CodeComposer together with a new project. See the last steps of <a href=\"https:\/\/visualgdb.com\/tutorials\/arm\/ti\/halcogen\/\">this tutorial<\/a> for details. <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/08-programmed.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6560\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/08-programmed.png\" alt=\"\" width=\"979\" height=\"218\" \/><\/a><\/li>\n<li>Once the memory is programmed, the on-board LED will begin blinking:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/led.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6565\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/led.jpg\" alt=\"\" width=\"1200\" height=\"538\" \/><\/a><\/li>\n<li>Now we will show how to debug the board. Go to Visual Studio and press F5 to begin debugging. VisualGDB may warn that the stack location is not writable:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/09-stack.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6561\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/09-stack.png\" alt=\"\" width=\"1234\" height=\"860\" \/><\/a><\/li>\n<li>This happens because the <strong>_estack<\/strong> symbol generated by HALCoGen does not point to the actual end of stack. To fix this, locate the linker script in the BSP directory:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/script.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6567\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/script.png\" alt=\"\" width=\"1005\" height=\"661\" \/><\/a><\/li>\n<li>Then edit the <strong>_estack<\/strong> symbol to point at the end of the CPU_STACK region:\u00a0 <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/10-stack2-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6566\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/10-stack2-1.png\" alt=\"\" width=\"1234\" height=\"860\" \/><\/a><\/li>\n<li>To make sure you can set breakpoints in the FLASH memory and debug the program from the very beginning, add the following lines to the <strong>Startup GDB Commands<\/strong> field in Debug Settings:\n<pre class=\"\">mon gdb_breakpoint_override hard\r\nset $pc = 0<\/pre>\n<p>The first command forces all breakpoints to be hardware breakpoints, and the second one forcibly jumps to the reset vector at the beginning of the debug session: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/11-bkpt-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6563\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/11-bkpt-2.png\" alt=\"\" width=\"1005\" height=\"661\" \/><\/a><\/li>\n<li>Now you will be able to debug the program as usual: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/12-task.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6564\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/12-task.png\" alt=\"\" width=\"1234\" height=\"860\" \/><\/a><\/li>\n<li>You can automate FLASH memory programming with DSLite by adding it as a custom pre-debug action:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/cmd.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6568\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/cmd.png\" alt=\"\" width=\"1445\" height=\"679\" \/><\/a><\/li>\n<li>VisualGDB will then automatically launch it before the debug session. You can find the output from it in View-&gt;Output-&gt;VisualGDB Launcher Output:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/launcher.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6569\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/07\/launcher.png\" alt=\"\" width=\"1234\" height=\"860\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to create, build and debug a basic project for the TMS570LS1224 microcontroller using Visual Studio and<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89],"tags":[53,59,220],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/6552"}],"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=6552"}],"version-history":[{"count":5,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/6552\/revisions"}],"predecessor-version":[{"id":6574,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/6552\/revisions\/6574"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=6552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=6552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=6552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}