{"id":6109,"date":"2020-06-11T08:51:19","date_gmt":"2020-06-11T15:51:19","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=6109"},"modified":"2020-06-11T08:51:19","modified_gmt":"2020-06-11T15:51:19","slug":"targeting-mcuxpresso-based-nxp-devices-with-visual-studio","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/nxp\/mcuxpresso\/","title":{"rendered":"Targeting MCUXpresso-based NXP devices with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to use VisualGDB to target modern NXP devices based on the MCUXpresso SDK. We will target the multi-core <strong>LPC55S69<\/strong> device and will show how to import the following parameters from the MCUXpresso ecosystem:<\/p>\n<ul>\n<li>The MCUXpresso SDK that provides the header files and linker scripts for the device<\/li>\n<li>Various device-specific examples from the SDK<\/li>\n<li>The debug configuration for the LPC-Link probe using the low-level tools from the MCUXpresso IDE<\/li>\n<\/ul>\n<p>Before you begin, install VisualGDB 5.5 or later. If you are planning to use the on-board LPC-Link probe, also install the MCUXpresso IDE so that we could import the debug settings from it.<\/p>\n<ol>\n<li>Start Visual Studio and open the VisualGDB Embedded Project Wizard:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/01-newprj-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6110\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/01-newprj-4.png\" alt=\"\" width=\"966\" height=\"624\" \/><\/a><\/li>\n<li>Pick a name and location for your project, then press &#8220;Create&#8221;: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/02-name-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6111\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/02-name-2.png\" alt=\"\" width=\"966\" height=\"624\" \/><\/a><\/li>\n<li>Proceed with the default settings (Create a new project -&gt; Embedded Binary -&gt; MSBuild):<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/03-msb-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6112\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/03-msb-1.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>On the next page of the wizard, select your NXP device. VisualGDB will automatically load the list of devices from the online MCUXpresso database, however you would need to download the SDK manually and import it into VisualGDB: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/04-getsdk.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6113\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/04-getsdk.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>Go to the online <a href=\"https:\/\/mcuxpresso.nxp.com\/en\/select\">MCUXpresso SDK builder<\/a> and generate an SDK for your device. Make sure you select the <strong>GCC ARM Embedded<\/strong> toolchain:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/getsdk.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6127\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/getsdk.png\" alt=\"\" width=\"1187\" height=\"869\" \/><\/a><\/li>\n<li>Unpack the SDK into any location on your computer and click &#8220;Import&#8221; in the VisualGDB&#8217;s wizard. Once the SDK is imported, the devices from it will appear in the regular device list. Select your device and click &#8220;Next&#8221; to continue:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/05-core0.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6114\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/05-core0.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>Importing the SDK will automatically convert the MCUXpresso examples in a format compatible with VisualGDB. Select &#8220;<strong>MCUXpresso Samples<\/strong>&#8221; on the next page and pick a sample you would like to clone: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/06-sample.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6115\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/06-sample.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>Finally, we will configure the debug settings. If you would like to use the on-board LPC-Link debug probe, make sure you have installed MCUXpresso and can launch a debug session with it: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/08-menu.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6117\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/08-menu.png\" alt=\"\" width=\"1702\" height=\"679\" \/><\/a>This will automatically generate the configuration files for the LPC-Link debug stack that could be used by both MCUXpresso IDE and VisualGDB.<\/li>\n<li>Select your LPC-Link instance on the Debug Method page of the wizard and enter the path to MCUXpresso IDE directory. If the device list does not show the device you are debugging, click &#8220;Import debug configuration&#8221;:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/07-missing.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6116\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/07-missing.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a>Then, locate the MCUXpresso workspace directory:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/09-workspace.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6118\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/09-workspace.png\" alt=\"\" width=\"559\" height=\"489\" \/><\/a>The generated debug configurations are be stored in the <strong>.mcuxpressoide_packages_support<\/strong> subdirectory inside the workspace directory.<\/li>\n<li>Once you import the debug configurations in VisualGDB, it will copy them under <strong>%LOCALAPPDATA%\\VisualGDB\\RedLinkDebugPackage<\/strong>, so you won&#8217;t need to keep the original MCUXpresso projects anymore. Click &#8220;Test&#8221; to test the LPC-Link debug setup:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/10-test.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6119\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/10-test.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>VisualGDB will launch the gdb stub used by the MCUXpresso IDE and will verify that it can connect to the target:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/11-tested.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6120\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/11-tested.png\" alt=\"\" width=\"786\" height=\"593\" \/><\/a>If the tool does not connect, make sure it works with the MCUXpresso IDE and try restarting the <strong>RedLink server<\/strong> using the button below the MCUXpresso directory setting.<br \/>\nIf you are using a different debug probe (e.g. Segger J-Link), you do not need to install the MCUXpresso IDE, or import any debug-specific settings.<\/li>\n<li>Click &#8220;Finish&#8221; to finally create the project. Once it is created, build it by pressing Ctrl-Shift-B:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/12-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6121\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/12-build.png\" alt=\"\" width=\"1183\" height=\"759\" \/><\/a><\/li>\n<li>Press F5 to begin debugging. VisualGDB will program the FLASH memory and will launch the target. You can use the Live Watch window to observe what the firmware is doing without setting any breakpoints, or pausing it. E.g. you can see the list of FreeRTOS tasks, tick count, and other parameters:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/13-live.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6122\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/13-live.png\" alt=\"\" width=\"1183\" height=\"759\" \/><\/a><\/li>\n<li>In this tutorial we are debugging a <strong>virtual COM port<\/strong> example that will appear in the device manager once you start the debug session. Go to the Raw Terminal page of VisualGDB Project Properties and select its COM port in the list: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/14-vcp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6123\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/14-vcp.png\" alt=\"\" width=\"1183\" height=\"759\" \/><\/a><\/li>\n<li>Then restart the debug session and use the terminal window in Visual Studio to send some data to the board and observe how it&#8217;s echoed back. You can either use the Live Watch mode to observe the state of the program in real-time, or set breakpoints and utilize the regular watch\/locals windows: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/15-send.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6124\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/15-send.png\" alt=\"\" width=\"1183\" height=\"759\" \/><\/a><\/li>\n<li>If your board requires special debugging setup, you can tweak the command line used by VisualGDB to launch the RedLink gdb server. Locate the command line in the MCUXpresso IDE debug log (search the <strong>gdb traces<\/strong> log for &#8220;<strong>-target-select<\/strong>&#8220;):<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/16-cmdline.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6125\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/16-cmdline.png\" alt=\"\" width=\"1183\" height=\"759\" \/><\/a>Then expand the <strong>Advanced Settings<\/strong> view in VisualGDB Project Properties. You can modify the command line template used by VisualGDB to match the arguments passed by the MCUXpresso IDE:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/17-vgdbcmd.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6126\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2020\/05\/17-vgdbcmd.png\" alt=\"\" width=\"1040\" height=\"669\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to use VisualGDB to target modern NXP devices based on the MCUXpresso SDK. We will target<\/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":[208,207],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/6109"}],"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=6109"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/6109\/revisions"}],"predecessor-version":[{"id":6128,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/6109\/revisions\/6128"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=6109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=6109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=6109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}