{"id":9053,"date":"2026-01-29T12:58:50","date_gmt":"2026-01-29T20:58:50","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=9053"},"modified":"2026-01-29T12:58:50","modified_gmt":"2026-01-29T20:58:50","slug":"targeting-the-risc-v-core-on-raspberry-pi-pico-2","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/raspberry\/pico\/risc_v\/","title":{"rendered":"Targeting the RISC-V core on Raspberry Pi Pico 2"},"content":{"rendered":"<p>This tutorial shows how to build and debug projects for the RISC-V core on the Raspberry Pi 2 (RP2350). We will show how to create a basic project, configure the debugging settings, and will use VisualGDB&#8217;s Chronometer to analyze the cycle counts of individual code lines, so you can compare performance between the ARM and RISC-V cores.<\/p>\n<p>Before you begin, install VisualGDB 6.1 or later.<\/p>\n<ol>\n<li>Start Visual Studio and open the VisualGDB&#8217;s Raspberry Pi Pico project wizard:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/01-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9054\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/01-newprj.png\" alt=\"\" width=\"1014\" height=\"675\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/01-newprj.png 1014w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/01-newprj-300x200.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/01-newprj-768x511.png 768w\" sizes=\"(max-width: 1014px) 100vw, 1014px\" \/><\/a><\/li>\n<li>Enter the name and location for your project:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/02-prjname.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9055\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/02-prjname.png\" alt=\"\" width=\"1014\" height=\"675\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/02-prjname.png 1014w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/02-prjname-300x200.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/02-prjname-768x511.png 768w\" sizes=\"(max-width: 1014px) 100vw, 1014px\" \/><\/a><\/li>\n<li>Targeting the RISC-V core requires using the toolchain shipped by the Raspberry Pi developers, so make sure you select that option in the toolchain selector:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/04-getsdk.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9056\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/04-getsdk.png\" alt=\"\" width=\"856\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/04-getsdk.png 856w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/04-getsdk-300x243.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/04-getsdk-768x622.png 768w\" sizes=\"(max-width: 856px) 100vw, 856px\" \/><\/a>If you are using the PicoSDK Code extension, VisualGDB will automatically pick up the tools\/SDKs installed by it. If not, click the &#8220;Install Raspberry Pi Pico SDK&#8221; link to view the versions available for download.<\/li>\n<li>Select the SDK version you would like to download. The package icon means that the Raspberry Pi foundation has published pre-built tools (e.g. picotool) for that version:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/05-download.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9057\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/05-download.png\" alt=\"\" width=\"786\" height=\"588\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/05-download.png 786w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/05-download-300x224.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/05-download-768x575.png 768w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/a>You can also clone an arbitrary Github tag and use it as an SDK, but you would need to setup tools like the toolchain\/picotool manually.<\/li>\n<li>Press &#8220;OK&#8221;. VisualGDB will automatically load the list of the dependencies from the PicoSDK VS Code extension, and will download the necessary tools:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/06-progress.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9058\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/06-progress.png\" alt=\"\" width=\"856\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/06-progress.png 856w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/06-progress-300x243.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/06-progress-768x622.png 768w\" sizes=\"(max-width: 856px) 100vw, 856px\" \/><\/a>If you have previously downloaded them using VS Code, VisualGDB will simply reuse the existing tools.<\/li>\n<li>Select the latest SDK in the SDK selector, pick the board that is based on the Pico 2 chip (RP2350) and make sure the RISC-V core is selected:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/07-sdk-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9070\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/07-sdk-1.png\" alt=\"\" width=\"856\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/07-sdk-1.png 856w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/07-sdk-1-300x243.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/07-sdk-1-768x622.png 768w\" sizes=\"(max-width: 856px) 100vw, 856px\" \/><\/a><\/li>\n<li>Pick a sample you would like to clone. In this tutorial we will clone the simplest &#8220;Blinking LED&#8221; sample:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/08-sample.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9060\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/08-sample.png\" alt=\"\" width=\"856\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/08-sample.png 856w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/08-sample-300x243.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/08-sample-768x622.png 768w\" sizes=\"(max-width: 856px) 100vw, 856px\" \/><\/a><\/li>\n<li>Finally, select the debug method. The RISC-V core can only be debugged using the Raspberry Pi&#8217;s own fork of OpenOCD, so make sure you have selected <strong>OpenOCD (PicoSDK) <\/strong>and the <strong>Debugged Device<\/strong> explicitly mentions RISC-V:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/09-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9061\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/09-debug.png\" alt=\"\" width=\"856\" height=\"693\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/09-debug.png 856w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/09-debug-300x243.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/09-debug-768x622.png 768w\" sizes=\"(max-width: 856px) 100vw, 856px\" \/><\/a><\/li>\n<li>Press&#8221;Finish&#8221;to generate the project. You can use the Disassembly view in the Embedded Memory Explorer to verify that the code is using RISC-V instructions:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/10a-disasm.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9062\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/10a-disasm.png\" alt=\"\" width=\"1288\" height=\"812\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/10a-disasm.png 1288w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/10a-disasm-300x189.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/10a-disasm-1024x646.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/10a-disasm-768x484.png 768w\" sizes=\"(max-width: 1288px) 100vw, 1288px\" \/><\/a><\/li>\n<li><strong>WARNING!<\/strong> If this is the first time you are running RISC-V firmware on your Raspberry Pi, the RISC-V cores won&#8217;t be running, and hence the debugging will fail! To fix this, you would need to first program the RISC-V image into the board using the bootloader. Hold the BOOTSEL button on the board, and re-plug it into the USB port. Make sure it appears as a disk drive:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/10-boot.png\"> <img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9063\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/10-boot.png\" alt=\"\" width=\"893\" height=\"593\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/10-boot.png 893w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/10-boot-300x199.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/10-boot-768x510.png 768w\" sizes=\"(max-width: 893px) 100vw, 893px\" \/><\/a><\/li>\n<li>Right-click on the project node in Solution Explorer (with the Raspberry Pi icon) and select &#8220;Program FLASH Memory&#8221;:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/11a-program.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9064\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/11a-program.png\" alt=\"\" width=\"1288\" height=\"812\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/11a-program.png 1288w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/11a-program-300x189.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/11a-program-1024x646.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/11a-program-768x484.png 768w\" sizes=\"(max-width: 1288px) 100vw, 1288px\" \/><\/a><\/li>\n<li>Select your Pico device in the list and press OK:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/11-program.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9065\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/11-program.png\" alt=\"\" width=\"786\" height=\"443\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/11-program.png 786w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/11-program-300x169.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/11-program-768x433.png 768w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/a><\/li>\n<li>The FLASH memory will get programmed and the RP2350 will restart in the RISC-V mode. You can now press F5 in Visual Studio to begin debugging it:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/12-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9066\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/12-debug.png\" alt=\"\" width=\"1288\" height=\"812\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/12-debug.png 1288w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/12-debug-300x189.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/12-debug-1024x646.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/12-debug-768x484.png 768w\" sizes=\"(max-width: 1288px) 100vw, 1288px\" \/><\/a><\/li>\n<li>Just like the ARM CPUs, RISC-V supports background memory reads, so you can use the <a href=\"https:\/\/visualgdb.com\/documentation\/livevars\/\">Live Watch<\/a> window to view global variables in real time without stopping the target:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/13-live.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9067\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/13-live.png\" alt=\"\" width=\"1288\" height=\"812\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/13-live.png 1288w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/13-live-300x189.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/13-live-1024x646.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/13-live-768x484.png 768w\" sizes=\"(max-width: 1288px) 100vw, 1288px\" \/><\/a><\/li>\n<li>RISC-V also supports instruction counters. You can enable it via the Chronometer configuration in <strong>VisualGDB Project Properties -&gt; Embedded Debug Tweaking<\/strong> (Custom edition or higher):<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/14-chrono.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9068\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/14-chrono.png\" alt=\"\" width=\"887\" height=\"561\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/14-chrono.png 887w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/14-chrono-300x190.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/14-chrono-768x486.png 768w\" sizes=\"(max-width: 887px) 100vw, 887px\" \/><\/a><\/li>\n<li>Now you can see how many cycle counts it took to do a step, or reach another breakpoint, so you can fine-tune and optimize your code:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/15-timing-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9071\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/15-timing-1.png\" alt=\"\" width=\"1288\" height=\"812\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/15-timing-1.png 1288w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/15-timing-1-300x189.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/15-timing-1-1024x646.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/15-timing-1-768x484.png 768w\" sizes=\"(max-width: 1288px) 100vw, 1288px\" \/><\/a><\/li>\n<li>If you would like to use <a href=\"https:\/\/github.com\/raspberrypi\/picotool\">picotool<\/a> to directly control your device (e.g. reboot it into ARM\/RISC-V mode), you can use the <strong>View-&gt;VisualGDB Smart Terminal<\/strong> command. It will open a <a href=\"https:\/\/visualgdb.com\/documentation\/terminal\/\">terminal window<\/a> with the PicoSDK build environment pre-loaded, and will remember the command and directory history for each individual project:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/16-picotool.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9072\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/16-picotool.png\" alt=\"\" width=\"1288\" height=\"812\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/16-picotool.png 1288w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/16-picotool-300x189.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/16-picotool-1024x646.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2025\/09\/16-picotool-768x484.png 768w\" sizes=\"(max-width: 1288px) 100vw, 1288px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to build and debug projects for the RISC-V core on the Raspberry Pi 2 (RP2350). We<\/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":[43,151],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/9053"}],"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=9053"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/9053\/revisions"}],"predecessor-version":[{"id":9073,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/9053\/revisions\/9073"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=9053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=9053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=9053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}