Remote Debugging using the JLink - MatthewMArnold/taproot GitHub Wiki

The remote debugging interface allows you to connect and deploy code to a robot mounted MCB without having to physically connect your computer to the MCB. Furthermore, we can utilize debugging tools (live and breakpoint based) to more easily debug a robot as it moves around and not have to have your computer connected to the robot.

This guide will describe one setup option that we use. In this setup, a J-Link is connected to the MCB. The J-Link is then connected to a Raspberry Pi. The Raspberry Pi and J-Link are mounted to the robot along side the MCB. The Raspberry Pi is wifi enabled and has the J-Link tools loaded onto it. The Pi runs a J-Link server, and you can connect to this server on your computer using Ozone or directly through the command line.

Setting up a remote debugging environment

The setup is described extensively in the following guide: https://blog.feabhas.com/2019/07/using-a-raspberry-pi-as-a-remote-headless-j-link-server/. This setup guide can be followed directly with a few minor additions described below.

  • I have tried this setup with a Raspberry Pi 3. If you use a different model there is no guarantee this will work, so I recommend using a Raspberry Pi 3.

  • The guide says to use the Raspbian Lite OS. This can be downloaded from here: https://downloads.raspberrypi.org/raspbian_lite_latest.

  • You will have to install the OS on a micro SD card. If you have never done this before, this video will help you get started.

  • The guide says to manually setup wifi and ssh via the command line. You can instead do this using the Raspberry Pi Imager when you are loading the OS onto the micro SD card. To do so, after opening up the Raspberry Pi Imager, type Ctrl + Shift + X. This will open up the Advanced options menu. Make sure your Advanced options menu is configured identically to the images below.

    Write a password for the Raspbbery Pi in the "Password" section above and then note the password down here. Preferably use the same password as is used in the linked document.

    NOTE: After flashing the SD card and putting it in Pi, the pi should connect to wifi ~20 seconds after powering on (give it 30 to be safe). If it doesn't seem like it's connecting (you can verify by checking the router), then try following this guide instead (replacing SSID and password etc. as appropriate). It doesn't require reflashing the SD card which is nice (you just need to add some files to the SD card)

  • When installing the J-Link utilities, since the Pi is configured to connect to the router that we use to run the RoboMaster referee server on, which is not connected to the internet, you will have to download JLink_Linux_arm.tgz to your computer and then scp it onto the Pi. Once you have downloaded JLink_Linux_arm.tgz, open a terminal, navigate to where you downloaded the .tgz file, and run scp JLink_Linux_arm.tgz <Pi Name>@<IP Address>:~/.

  • Finally, configure the Pi's /etc/rc.local file to run the server automatically after the Pi boots. Open /etc/rc.local with a text editor and add the following line:

    /home/pi/JLink_Linux_V760c_arm/JLinkRemoteServerCLExe -Port 19020 &

    Save the file and reboot the Pi. The Pi is now configured correctly.

After setting up the Pi to perform remote debugging, you must install the Pi on the robot. Refer to the following wiring diagram when connecting the Pi to the MCB.

Note: In the image above, pins 2 and 6 on the Pi are the power and ground pins, respectively. Refer to the pinout diagram below for where these pins are located on the Pi.

Using an existing remote debugging environment

If the steps taken the above section have been taken and a remote debugging environment is installed on a robot, there are a few steps that must be taken to use it. To connect to the remote debugger, we will use Ozone. As such, your computer should have Ozone installed on it. To do so, perform the following steps:

  1. Power up the robot. If you have installed the Raspberry Pi correctly, the Pi will receive power from the MCB and will boot on robot start.

  2. Connect your computer to the same network as what the Pi is connected to. If you followed the above guide, the Pi will be connected via wifi to the router that the RoboMaster referee system server uses. The password to connect to the RoboMaster server is 12345678.

  3. Open Ozone. Follow the Ozone tutorial here to set up Ozone correctly.

    Important: The one step that is different to connect to the remote J-Link server is that you must change the Host Interface from "USB" to "IP". Additionally, in the "IP Address" field, type the IP Address of the Pi that is running the remote server (refer to the table listing "Pi Name", "Robot", and "IP Address" to determine which IP address you should use).

  4. After setting up your Ozone project, you should be able to debug normally as if you had a J-Link connected to your computer. You can deploy code to the robot and use all the tools that the J-Link/Ozone has to offer.

SSHing into the Raspberry Pi

Once the Raspberry Pi has booted (this may take a minute or two), if you are having trouble connecting, you can debug the Pi from your computer via ssh.

  1. To do this, you must know the IP address of the Pi that you would like to connect to. The table below shows the IP address of each configured Pi.

    Pi Username Robot IP Address
    Zoe ?? 192.168.1.10
    Elmo 2022 Soldier 192.168.1.14
    Oscar 2021 Soldier 192.168.1.17

    If you ever need to double check a Pi's IP addresses connect to the router and check attached devices (router login info is taped to the router).

    To connect to the Pi, in a terminal run ssh pi@<IP Address>. You will be prompted for the password, which can be found here.

⚠️ **GitHub.com Fallback** ⚠️