{"id":115,"date":"2014-03-25T20:29:08","date_gmt":"2014-03-25T20:29:08","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=115"},"modified":"2017-08-07T12:18:39","modified_gmt":"2017-08-07T19:18:39","slug":"arm-openocd","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/openocd\/","title":{"rendered":"Configuring OpenOCD for JTAG debugging"},"content":{"rendered":"<p>This tutorial explains various OpenOCD settings and shows how to configure it to use your JTAG programmer and board.<\/p>\n<p>Before you begin please follow <a href=\"https:\/\/visualgdb.com\/tutorials\/arm\/stm32\/f4_discovery\/\">this tutorial <\/a>to setup a basic VisualGDB project with OpenOCD.<\/p>\n<ol>\n<li>Open your project, right-click on the project node in Solution Explorer select &#8220;VisualGDB Project Properties&#8221; and open the &#8220;Debug Settings&#8221; page:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/01-overview.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2995\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/01-overview.png\" alt=\"01-overview\" width=\"896\" height=\"609\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/01-overview.png 896w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/01-overview-300x204.png 300w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/a><\/li>\n<li>OpenOCD is configured by selecting device and interface configuration scripts (located under %LOCALAPPDATA%\\VisualGDB\\EmbeddedDebugPackages\\com.sysprogs.arm.openocd\\share\\openocd\\scripts) that contain the low-level device parameters. VisualGDB maintains a database of common device types and will automatically find the correct OpenOCD script for most of the common device types:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/finetune.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2997\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/finetune.png\" alt=\"finetune\" width=\"897\" height=\"620\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/finetune.png 897w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/finetune-300x207.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/finetune-392x272.png 392w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/finetune-130x90.png 130w\" sizes=\"(max-width: 897px) 100vw, 897px\" \/><\/a><\/li>\n<li>\u00a0If you are debugging a rare device that is not automatically recognized by VisualGDB, you can check the &#8220;Show raw OpenOCD scripts&#8221; checkbox and specify a script file manually:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/05-device.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2998\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/05-device.png\" alt=\"05-device\" width=\"896\" height=\"609\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/05-device.png 896w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/05-device-300x204.png 300w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/a><\/li>\n<li>If you are using one of the common debug adapters (e.g. ST-Link or Olimex FT2232-based adapters), VisualGDB will automatically recognize it once you plug it into the USB port, will install the necessary drivers and select the corresponding OpenOCD interface script. You can also configure the script manually by switching from Device View to Debug Method View:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/02-methods.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2999\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/02-methods.png\" alt=\"02-methods\" width=\"896\" height=\"609\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/02-methods.png 896w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/02-methods-300x204.png 300w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/a><\/li>\n<li>Interface script selection works the same way as the device script selection letting you pick either a common debug interface, or a specific OpenOCD script:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/03-method2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3000\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/03-method2.png\" alt=\"03-method2\" width=\"896\" height=\"609\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/03-method2.png 896w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/03-method2-300x204.png 300w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/a><\/li>\n<li>If you are experimenting with OpenOCD settings, we recommend quickly testing them by pressing the &#8220;Test&#8221; button. VisualGDB will run OpenOCD without actually programming your project and will attempt connecting to it and querying the target registers:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/06-test.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3001\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/06-test.png\" alt=\"06-test\" width=\"896\" height=\"613\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/06-test.png 896w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/06-test-300x205.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/06-test-130x90.png 130w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/a><\/li>\n<li>VisualGDB can recognize common statements inside the OpenOCD scripts and let you edit them via GUI (a temporary copy of the script will be created when debugging). E.g. you can enable the &#8220;Connect under reset&#8221; mode or change the SWD\/JTAG frequencies used before and after configuring the target clock:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/07-reset.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3002\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/07-reset.png\" alt=\"07-reset\" width=\"896\" height=\"609\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/07-reset.png 896w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/07-reset-300x204.png 300w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/a><\/li>\n<li>If you are familiar with OpenOCD commands, you can tweak the exact command line used by VisualGDB to launch OpenOCD by expanding the &#8220;Advanced settings&#8221; view:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/08-advanced.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3003\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/08-advanced.png\" alt=\"08-advanced\" width=\"896\" height=\"619\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/08-advanced.png 896w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/08-advanced-300x207.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/08-advanced-392x272.png 392w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/08-advanced-130x90.png 130w\" sizes=\"(max-width: 896px) 100vw, 896px\" \/><\/a>Any changes you make here will be preserved when you use the rest of the GUI. E.g. if you change the debugged device, VisualGDB will update the &#8220;-f target\/&#8230;&#8221; command, but keep the rest of the commands before and after it unchanged.<\/li>\n<li>Once your debugging session is active you can execute various OpenOCD commands by typing &#8220;mon &lt;command&gt;&#8221; in the GDB Session window. E.g. type &#8220;mon help&#8221; to let OpenOCD print information about supported commands. Note that the information will be shown in both OpenOCD pane and the GDB Session pane:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/09-monhelp1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3005\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/09-monhelp1.png\" alt=\"09-monhelp\" width=\"1069\" height=\"759\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/09-monhelp1.png 1069w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/09-monhelp1-300x213.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2014\/03\/09-monhelp1-1024x727.png 1024w\" sizes=\"(max-width: 1069px) 100vw, 1069px\" \/><\/a><\/li>\n<li>To learn more about OpenOCD please read the <a href=\"http:\/\/openocd.sourceforge.net\/doc\/pdf\/openocd.pdf\"> OpenOCD user manual<\/a>.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial explains various OpenOCD settings and shows how to configure it to use your JTAG programmer and board. Before<\/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,60],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/115"}],"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=115"}],"version-history":[{"count":2,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/115\/revisions"}],"predecessor-version":[{"id":3006,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/115\/revisions\/3006"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}