J-Link Commander Tutorial
Summary
The SEGGER J-Link Commander is a command line interface to the J-Link Debug Probe that allows total control over the probe. The nature of an IDE or graphical user interface is such that usually only the most popular functions are given controls through the IDE. In order to access and control beyond what is provided through the IDE, you must invoke the J-Link commander command line utility.
1
Complete the Simple Programming Example
Before experimenting with the J-Link Commander, ensure your system is properly configured by following the steps in the Simple Programming Example tutorial. Once you have confirmed that your system is working, then proceed through the following steps. The same source project is used for all tutorials.
J-Link Commander is only supported over the 4-wire JTAG interface. You must switch the type of communication from the default 2-wire to 4-wire in order for the J-Link Commander to communicate to the J-Link Debug Probe. Instructions for switching between communications types can be found on the JTAG Communication Method page.
2
Invoke J-Link Commander
When the Drivers/Utilities/Documents package was installed, a shortcut or alias for J-Link should have been installed on your desktop. If it wasn't, you can invoke the it directly from the installed folder:
For Windows®, the default location is:
C:\Program Files (x86)\SEGGER\JlinkARM_Vxxxx\Jlink.exe
For MAC® OS X®, the default location is:
Applications/SEGGER/Jlink/JLinkEXE
Due to the nature of USB communications, it is possible to communicate to the J-Link Debug Probe through both MPLAB® X IDE and J-Link Commander. This means that we can erase through one interface (e.g. J-Link Commander), then program with the other (e.g. MPLAB X IDE) without having to exit either program.
Upon invoking J-Link Commander, you should see a window similar to the one below:
4
Halt
After successfully following the steps to program the target device, your Explorer16 should be blinking four LEDs. This step will use the J-Link Commander to start and stop the execution.
- Enter h after the J-Link> prompt. Blinking will stop and the status of the PIC32 registers will be displayed.
- Enter g after the J-Link> prompt and blinking will resume.
The figure below illustrates the results of these commands:
5
View Execution Memory
The next step in this tutorial is to use J-Link Commander to erase the target device. Ultimately, we will want to confirm that the PIC32 has been erased. MPLAB X IDE provides an easy means of viewing the Execution Memory both before and after erasing.
The first step is to program the device by clicking the Make And Program Device icon, then follow these steps to view the program memory within MPLAB X IDE:
- From the toolbar, open the memory window by clicking Window > PIC Memory Views > Execution Memory.
- Click on the blue, downward-facing arrow in the left margin of the execution memory window to open the Go To dialog box.
- From the Go To dialog box, select Memory Region > Program Memory > Go To.
- Note that the program memory contains code as illustrated below:
6
Erase the Device
Erasing is one of those functions that cannot be done directly through MPLAB X IDE. Fortunately, it is easily done through the J-Link Commander. Before issuing the erase command, the J-Link needs to be told which device is in use. Follow the steps below to erase the target and confirm that it is erased:
1. Enter device ? after the J-Link> prompt. A new dialog box will open. Select the target manufacturer and device.
Click OK and the dialog box will close, the J-Link will reconnect and status information will be displayed:
2. Enter erase after the J-Link> prompt. The device will erase and status information will be displayed. Note that the LEDs will stop blinking but may still be illuminated. Erasing the memory will not clear the LEDs. In order to clear the LEDs, reset the PIC32 by entering r after the J-Link> prompt.
7
Confirm That Execution Memory Has Been Erased
Because the device was erased outside of MPLAB X IDE, we must import the memory from the PIC32 into MPLAB in order to confirm that the program memory was erased. To do this, click the Read Device Memory icon, then follow these steps to view the program memory within MPLAB X IDE:
- From the toolbar, open the memory window by clicking Window > PIC Memory Views > Execution Memory.
- Click on the blue downward facing arrow in the left margin of the execution memory window to open the Go To dialog box.
- From the Go To dialog box, select Memory Region > Program Memory > Go To.
- Note that the program memory now contains 0xFFFFFFFFs wich is the erased state.
Success
The SEGGER J-Link Commander utility provides a lot of capability not available directly through the MPLAB X IDE plugin. In addition to the J-Link Commander utility, there are a number of other utilities that SEGGER provides that are not treated here.