{"id":7807,"date":"2022-04-15T20:36:00","date_gmt":"2022-04-16T03:36:00","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=7807"},"modified":"2022-04-15T20:36:00","modified_gmt":"2022-04-16T03:36:00","slug":"targeting-arm-based-renesas-devices-with-visual-studio","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/renesas\/","title":{"rendered":"Targeting ARM-based Renesas devices with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to use VisualGDB to create, build and debug a basic project for the ARM-based Renesas devices. We will use the <a href=\"https:\/\/www.renesas.com\/us\/en\/products\/microcontrollers-microprocessors\/ra-cortex-m-mcus\/ek-ra2e1-evaluation-kit-ra2e1-mcu-group\">EK-RA2E1<\/a> board featuring the <strong>R7FA2E1A92DFM<\/strong> microcontroller and will show how to change various parameters of the Renesas software framework and let VisualGDB regenerate the configuration files.<\/p>\n<p>Before you begin, install VisualGDB 5.6R5 or later.<\/p>\n<ol>\n<li>Start Visual Studio and locate the VisualGDB Embedded Project Wizard:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/01-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7808\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/01-newprj.png\" alt=\"\" width=\"1024\" height=\"680\" \/><\/a><\/li>\n<li>Specify the name and location for your project: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/02-prjname.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7809\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/02-prjname.png\" alt=\"\" width=\"1024\" height=\"680\" \/><\/a><\/li>\n<li>Proceed with the default settings on the next page (Create a new project -&gt; Embedded Application). As the Renesas software framework is relatively complex, we recommend using the Advanced CMake project subsystem that has been specifically optimized to handle frameworks of this scale:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/03-cmake.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7810\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/03-cmake.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>On the next page pick the ARM toolchain and select your device from the list. If this is the first time you are creating a project for an ARM-based Renesas device, VisualGDB will suggest automatically installing the BSP:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/04-getbsp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7811\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/04-getbsp.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>Once the BSP has been installed, select the device you would like to target and press &#8220;Next&#8221;: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/05-installed.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7812\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/05-installed.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>The next page of the wizard allows selecting a sample project. The Renesas BSP contains 2 types of example projects:\n<ol style=\"list-style-type: upper-alpha;\">\n<li>A very basic <strong>LEDBlink<\/strong> example that requires manually selecting the I\/O port.<\/li>\n<li>The &#8216;<strong>blinky<\/strong>&#8216; samples taken from the original Renesas SDK. They can automatically pick up the LED locations for the development boards featuring the following devices:\n<ul>\n<li>R7FA4W1AD2CNG<\/li>\n<li>R7FA2A1AB3CFM<\/li>\n<li>R7FA2E1A92DFM<\/li>\n<li>R7FA2L1AB2DFP<\/li>\n<li>R7FA4E10D2CFM<\/li>\n<li>R7FA4M1AB3CFP<\/li>\n<li>R7FA4M2AD3CFP<\/li>\n<li>R7FA4M3AF3CFB<\/li>\n<li>R7FA6E10F2CFP<\/li>\n<li>R7FA6M1AD3CFP<\/li>\n<li>R7FA6M2AF3CFB<\/li>\n<li>R7FA6M3AH3CFC<\/li>\n<li>R7FA6M4AF3CFB<\/li>\n<li>R7FA6M5BH3CFC<\/li>\n<li>R7FA6T1AD3CFP<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>If you are using one of the Renesas development boards with the devices listed above, select any of the <strong>blinky<\/strong> samples. If not, we advise starting with the basic <strong>LEDBlink<\/strong> example. <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/06-blinky.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7813\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/06-blinky.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><strong>Warning:<\/strong> if you create a <strong>blinky<\/strong> project for a device that is not listed above, you would need to copy (and edit) the LED definitions from one of the supported devices.<\/li>\n<li>Connect your board to the USB port. Most Renesas development boards come with an on-board Segger J-Link, so VisualGDB will be able to automatically detect and configure it: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/07-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7814\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/07-debug.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>Press &#8220;Finish&#8221; to create the project. Then build it by pressing Ctrl-Shift-B. The build should succeed out without any further modifications: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/08-hal_entry.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7815\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/08-hal_entry.png\" alt=\"\" width=\"1383\" height=\"874\" \/><\/a>Note that the &#8220;unknown&#8221; section in the memory explorer corresponds to the <strong>ID_CODE<\/strong> region and can be ignored.<\/li>\n<li>Set a breakpoint around the call to <strong>R_BSP_PinWrite()<\/strong> and press F5 to begin debugging. Once the breakpoint hits, try stepping over the call and observing how the corresponding PORT registers are changed:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/09-regs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7816\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/09-regs.png\" alt=\"\" width=\"1383\" height=\"874\" \/><\/a><strong>Warning:<\/strong> if the program doesn&#8217;t start correctly first time, try pressing the reset button in the GDB Session window, or starting the debug session again.<\/li>\n<li>If you resume the program now, all the on-board LEDs should be continuously blinking:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/board.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7823\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/board.jpg\" alt=\"\" width=\"1297\" height=\"1132\" \/><\/a><\/li>\n<li>Note that the Renesas projects consist of 3 key parts:\n<ol>\n<li>Reusable components (e.g. I\/O port driver, board support package) derived from the original Renesas SDK<\/li>\n<li>Configuration files generated based on the current project settings<\/li>\n<li>Actual project-specific code that can be edited<\/li>\n<\/ol>\n<p><a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/10-structure-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7822\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/10-structure-1.png\" alt=\"\" width=\"1393\" height=\"935\" \/><\/a><\/li>\n<li>Open the Embedded Frameworks page of VisualGDB Project Properties. It allows referencing various frameworks (derived from the components in the original SDK) and changing their configuration. Try changing the mode of the pin P000 to <strong>GPIO (high)<\/strong>:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/11-framework.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7818\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/11-framework.png\" alt=\"\" width=\"1181\" height=\"853\" \/><\/a><\/li>\n<li>VisualGDB will suggest automatically regenerating the affected configuration files (<strong>pin_data.c<\/strong> in this example). Proceed with the regeneration: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/12-regen.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7819\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/12-regen.png\" alt=\"\" width=\"1393\" height=\"935\" \/><\/a> Note how the initialization line corresponding to <strong>BSP_IO_PORT_00_PIN_00<\/strong> got automatically <a href=\"https:\/\/github.com\/sysprogs\/tutorials\/commit\/5151406eba549f5964deab33cee62f23f3d4edfa#diff-0e8be4714edcd4e2bf65f8bddc8402adad35329fdf5e1716c1be28edb81992df\">updated<\/a>.<\/li>\n<li>Open the Embedded Frameworks page again and referenced the <strong>A\/D Converter<\/strong> framework:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/13-adc.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7820\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2022\/04\/13-adc.png\" alt=\"\" width=\"1181\" height=\"853\" \/><\/a>Once you press OK or Apply, VisualGDB will <a href=\"https:\/\/github.com\/sysprogs\/tutorials\/commit\/58e12df3cd2efa0df1cce29f3abdf54bbe75264a\">automatically insert<\/a> the corresponding declarations and initialization code into the generated files.<br \/>\n<strong>Warning:<\/strong> as of BSP 3.3.0, only once instance of each peripheral (e.g. ADC0) is configurable via the Embedded Frameworks GUI. Additional instances can be configured by copying the initialization code manually.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to use VisualGDB to create, build and debug a basic project for the ARM-based Renesas devices.<\/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],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7807"}],"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=7807"}],"version-history":[{"count":3,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7807\/revisions"}],"predecessor-version":[{"id":7825,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7807\/revisions\/7825"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=7807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=7807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=7807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}