Changes

Jump to: navigation, search
Starting a debug session
The target has to be configured to mount the root file system over NFS. Please refer to [https://wiki.dave.eu/index.php/BELK/BXELK_Quick_Start_Guide#Target_configuration_for_the_development_stage_.28net_nfs.29|this link] for more details.
The example project associated with this application note should be located copied in this directory of the host machine: <code>/bora/rfs/belk-4.0.0/home/root/hello</code>. This directory is seen by the target machine as <code>/home/root/hello</code>.
Please note that you need to change the permissions of the directory <code>/bora/rfs/belk-4.0.0/home/root/hello</code> in order to allow the user <code>dvdk</code> to access it without any restrictions:
drwxr-xrwx 4 root root 4096 Jun 12 14:55 hello/
</pre>
 
 
After completing this step, you should see these files:
[[File:BELK-AN-009-tree.png|center|thumb|600px|Files of the example project]]
==The example project==
The example makes use of a simple <code>Makefile</code> for cross-building. This <code>Makefile</code> can be used either to build the application manually or to build it automatically as part of a VSCode-controlled debugging session.
The following image shows the files that the VSCode workspace consists of.  [[File:BELK-AN-009-workspace.png|thumb|center|600px|VSCode workspace]]
**This script is invoked by VSCode to
***Build the program for the embedded target
***Start a remote debug session.Kill the gdbserver instance running on the target
*<code>cross-build.sh</code>
**This script is invoked in turn by <code>remote-debugging.sh</code>. The final command that triggers the actual building process is <code>make hello</code>, that is the same command used to build the program manually.
*<code>start-gdbserver-loop.sh</code>**This script is invoked by <code>remote-debugging.sh</code> to start only once on the target side; it guarantees that there is always a <code>running instance of the gdbserver</code> instance on the target.
*<code>.gdbinit</code>
**In includes initialization scripts that are run by <code>/home/dvdk/bora/sdk/belk-4.0.0/sysroots/x86_64-petalinux-linux/usr/bin/arm-xilinx-linux-gnueabi/arm-xilinx-linux-gnueabi-gdb</code> upon startup. For more details, please see [http://man7.org/linux/man-pages/man5/gdbinit.5.html this page].
****This is used to cross build the application on the host machine and to debug it on the target machine
*<code>tasks.json</code>
**In this file , two tasks are defined:
***<code>native build</code>
****This is used to build the program for the host target. In this case, an explicit command is run (<code>gcc -g -o hello.x86 hello.c</code>)
***<code>build and start remote debugging</code>
****As stated before, this task invokes the <code>remote-debugging.sh</code> script.
==Starting a debug session==
In practice, once the target is up and running and the example project was copied onto the host machine as stated previously, follow these steps to start a cross-debugging session.
*Open the VSCode workspace
*Go to the ''Terminal'' panel and open an ssh connection to the target machine
**Once logged, execute the <code>start-gdbserver-loop.sh</code> script as shown in the following image.
 
==Starting a debug session==
In practice, once the target is up and running and the example project was copied onto the host machine, follow these steps to start a cross-debugging session:
*Open the VSCode workspace
*Select the <code>(gdb) Cross launch</code> configuration
*Click on the green ''Start Debugging'' or select the ''Debug->Start Debugging'' menu item. Alternatively, press F5. You should see something like the following picture. It is worth remembering that the scripts take care of killing any <code>gdbserver</code> instance running on the target before starting a new debugging session. This allows starting it with just one click.
4,650
edits

Navigation menu