Table of Contents |
---|
HTML |
---|
<style> .toc-macro {position: static !important;} </style> <style> .toc-macro {width: 80% !important;} </style> <style> .toc-macro {float: none !important;} </style> |
...
...
Now we are ready to debug. Click Run -> Run Configurations, then select (double click) on C/C++ Remote Application, you can leave the default name or choose what you want.
Then click "New" button (corresponding to Connection), choose "SSH", then "OK":
Give the connection a name and specify the target IP address. User should be root. There's only one last field to configure in the "Run Configurations": Remote Absolute File Patch for C/C++ Application", click on Browse and leave the default path, then click OK. Please notice that in order to connect and debug openssh, sftp-server and gdbserver must be installed on the target. You can do this by adding following packages in local.conf file in yocto.
...
To debug, instead, you have to adjust one more parameter. Select "Debug" from the drop down list (instead on "Run"). Then click on the gear corresponding to "Hello World Debug" (or the name you gave):
Switch to the Debugger Tab and select the cross GDB included in the SDK, aarch64-poky-linux-gdb:
Note: If an error pops up when trying to modify the debug configuration, then you need to add a new "Launch Target". Normally it should not be strictly needed but without at least a target it may not work. At this point you should be able to debug by simply clicking on the "bug" icon, the binary will be downloaded into the target and run under GDB control":
...
into Location (URI). Then by clicking next, the Branch Selection window appears, select both "master" and "rz_g2l" (default). Then you are prompted to choose a destination folder, choose where the repository will be cloned and click Next. Now we want to import the project using another wizard, so we have to click on "Show other specialized import wizards".
When the other import wizard window appears, select from the C/C++ category, "Existing Code as Makefile Project" and click Next. Browse to the code location where you cloned the repository, select the folder (Open) and finally select "Cross GCC" before clicking Finish:
You should now have the project cloned from the repository, on the master branch and imported as a Makefile project.
The master branch is the branch you want to use to build the Flash Writer for RZ/G2E-N-M-H. Of course you would need to setup the build environment for your target in a similar way as explained above for the RZ/G2L. Assuming you did so, we just have to make sure the correct board is selected during the build. To do so, right click on the project name -> Properties and then select C/C++ Build. Uncheck "Use default build command" and add:
You can now build, you should see the message:
...
To build the RZ/G2L Flash Writer we need to checkout the corresponding branch. Right click on the project -> Team -> Switch To -> Other. Then from the "Remote Tracking" choose the rz_g2l branch, click "Check Out...":
And finally "Check out Commit". A warning about the "Detached HEAD" will appear, you can ignore and click close. Alternatively, and recommended if you want to make changes, you can "Create Branch" window appears, leave it as is and click on "Finish". We need to select the right make command, so right click on the project name -> Properties and then select C/C++ Build. Uncheck "Use default build command" and add/modify BOARD=RZG2L_SMARC_PMIC. The message
...
Please follow the instructions given in in this page on how to set-up, build and launch OpenOCD for the RZ targets. There is a specific OpenOCD plugin but it is not installed by default with Eclipse. In order to install it, go to Help -> Install New Software. Then select "All Available Sites" and in the filter type "openocd" and hit enter.
Select the plugin and install, at the end of the installation process an Eclipse restart is required.
Right click on the project -> Debug As -> Debug Configurations, a new option should be available: "GDB OpenOCD Debugging". Create a new configuration, leave the "Main" tab with the default values and switch to the "Debugger" tab. Here is where you have to configure the link to the OpenOCD executable and the config options, as well as the right GDB executable:
Adapt to your own paths. The OpenOCD config options for RZ/G2L are:
...
Do not forget to modify the GDB executable name with the environment variable ${CROSS_COMPILE}. Then switch to the "Startup" tab and configure as per below:
Here below the Initialization Commands:
...
If everything is set properly by clicking on the "bug" icon, OpenOCD is started automatically, code and symbols loaded automatically and therefore you should end up in being able to debug.
Note: Remove All Breakpoints if something unexpected happens during the launch.
...
Similarly to Flash Writer and as much useful, Arm Trusted Firmware BL2 can be debugged using OpenOCD and the dedicated plugin. It is assumed that the plugin is already installed and the repository is already cloned, imported in Eclipse (see previous sections). To build Arm Trusted Firmware in Eclipse with the debug symbols you need to configure the custom build arguments (right click on the project -> Properties -> C/C++ Build -> Behavior tab:
And these are the build arguments specifically for RZ/G2L (no security, no OP-TEE):
...
Also the way the debug configuration is created is identical to previous section, the only difference resides in the "Startup" tab":
Here below the Initialization Commands:
...
It is important to highlight the importance of the rwatch -l *0x11020A00
initialization command: this configures a watchpoint on a read access to the physical address 0x11020A00, that is the LSI Mode Signal Register (SYS_LSI_MODE). The least significant three bits (STAT_MD_BOOT[2:0]) indicate the terminal state of the external terminal MD_BOOT[2:0], that are updated at the rising edge of PRST#. The RZ ATF custom code checks this bit field to determine what kind of boot mode is and configures the MPU resources accordingly. This is done in the rz_io_setup()
function in the plat_storage.c
file. Normally by clinking on the "go" button, if there's no other issue before, the watchpoint is hit:
Note: Remove All Breakpoints if something unexpected happens during the launch.
...
We need to create a debug configuration for BL31, similarly to what is explained in the previous sections:
The "Continue" box is also checked (barely visible in the screenshot).
...
Then, finally the debug session looks like:
Note: Remove All Breakpoints if something unexpected happens during the launch.
...
u-boot can be imported (see Flash Writer section for more details) and built using Eclipse. Assuming it is already configured properly for the target device, the toolchain is properly set up before running Eclipse, then the only configuration needed is for the custom build arguments (right click on the project -> Properties -> C/C++ Build -> Behavior tab:
Let's create the debug configuration, Main tab:
Then Startup tab:
As explained in the previous section the Initialization Commands depend on the boot media. If the boot media is QSPI they are:
...
Finally, hitting the "bug" icon:
Note: Remove All Breakpoints if something unexpected happens during the launch.
...
RZ/Five does not use Arm Trusted Firmware and the first boot loader is u-boot SPL (more information information here).
You can clone the u-boot repository, select the right branch and build in a similar way explained in the previous sections, the only difference is that a different toolchain is required. Assuming u-boot and u-boot SPL are built correctly, you can create a debug configuration in the same way as described before:
Project name chosen: renesas-u-boot-cip-riscv.
Config options reported here:
-f /home/micbis/renesas/repos/tools/openocd/installdir/bin/../share/openocd/scripts/interface/jlink.cfg -c "set SOC G2L" -f /home/micbis/renesas/repos/tools/openocd/installdir/bin/../share/openocd/scripts/target/renesas_rz_five.cfg
And finally startup tab:
Initialization Commands:
...
Once saved, if everything goes fine, u-boot-spl can be debugged by clicking on the bug icon in Eclipse, leading to something similar to the following screenshot:
...
Import the blinky project in the newly created workspace: File -> Import -> General -> Projects from Folder or Archive. Select the archive file downloaded previously by clicking on Archive. Deselect the top of the two projects displayed and click Finish:
You should be able to build the project without errors (33 warnings). You have to create a debug configuration, right click on the project, Debug As -> Debug Configurations. Select GDB OpenOCD Debugging (you need the OpenOCD plugin as per previous section) and create a new debug configuration by clicking on the leftmost icon. Leave the "Main" tab as per default and switch to the "Debugger" tab. You may want to deselect "Start OpenOCD locally", since OpenOCD will be started manually. Then in the "GDB Client Setup" part use the ${CROSS_COMPILE} as prefix, change the port number to 3334 and finally change the command (important) "set mem inaccesible-by-default" to "on" :
Move to the Startup tab and modify the fields as per below:
Do not click on Debug, just save and close, it is time to launch OpenOCD "manually" and load the Cortex-M33 binary via Cortex-A55.
...
Now the Cortex-M33 is stopped at the secure reset vector, you can switch to Eclipse again and click on the debug icon to connect to the Cortex-M33 OpenOCD gdbserver:
Note: If you get error below while launching eclipse, make sure libncurses5 and libncursesw5 are installed in your system.
...
Refer To learn how to debug the Linux kernel using Eclipse, please refer to this page.