How to use emIDE


Debugging with emIDE and J-Link

Debugger settings

To debug your application with J-Link, the J-Link software & documentation pack has to be installed. It can be downloaded at http://www.segger.com/jlink-software.html.
When a new version of the J-Link software was installed press JLink -> Run the JLink-plugin configuration from the emIDE menu to make sure it uses the latest version.
Check JLink -> Start GDBServer on Debug and JLink -> Start GDBServer on Debug in the menu.

At Project -> Properties... -> Debugger the GDB (Server) settings for your target and application can be changed.
Specify the device name as used in the device list and set up the connection. When running GDB Server on the same machine as emIDE, the IP address should be localhost.
The GDB commands after connection has to contain at least load and can be used for target initialization, like resetting the target, setting up SWO or semihosting output and initialize external flash. A list of available GDB Server commands can be found in the GDB Server manual, which is part of the J-Link software, the available GDB commands can be found in the GDB documentations.


Commands, shortcuts and buttons

All commands for debugging your application are available in the Debug menu.
The most important commands are also available from the debugger toolbar and via shortcuts. Following a list of those commands:

Description Button Shortcut
Start debugging Start debugging F5
Run to cursor Run to cursor Ctrl-F10
Next line in the code Step to next line F10
Step into the function Step into function F11
Step out Step out of function Shift-F11
Next instruction (in assembler) Step to next instruction Alt-F10
Step into instruction Step into instruction Alt-F11
Break the debugger Break debugging ---
Stop the debugger Stop debugging Shift-F5
Reset the target Reset the target ---

The debugging windows

CPU Registers

The CPU Registers window shows the current CPU register values. Recently changed registers are highlighted in three levels.

The CPU Registers window also allows you to modify the values of the registers.

More about the CPU Registers window ...

Memory dump

The memory window reads the memory from the target device and updates it, when the target is halted.
You can click on the memory area and scroll through the memory, or use the 'up' and 'down' buttons. You can also enter an address and click 'Go To', to directly jump to this memory location.

More about the Memory window ...

Breakpoints

The Breakpoints window shows you the currently set breakpoints.
A breakpoint can be set in the source code, by clicking on the area, right of the line number, by pressing F9 to set a breakpoint at the current cursor line or right-clicking on a line and selecting toggle breakpoint. The breakpoints are marked with a red dot right of the line number.
emIDE does not limit the number of breakpoints. With J-Link the Unlimited Flash Breakpoints can be used. A license for this feature is included in the J-Link EDU.

Locals

The locals window shows the local variables and the arguments of the current function (if any).

Peripheral Registers

The Peripheral Registers window will show you all device specific registers, and their values.
The registers are grouped by the corresponding peripherals, which can be expanded to show the registers.
The recently changed registers are highlighted like the CPU registers.

More about the Peripheral Registers window ...

Disassembly

In the disassembly window, you can see the assembly code from the target of the current function.
When the mixed mode is activated, you can also see the source code lines corresponding to the disassembly.
The current PC location is highlighted.
To step in the disassembly use 'Step (into) instruction' (ALT+F10/ALT+F11).

Watches

With the Watches window, you can view the values of variables and expression.
To watch a variable, you can either

  • Right-click on the variable or expression in the source code and select '<Watch variable>'
  • Mark the variable or expression in the source code and drag and drop it to the Watches window
  • Enter the name of the variable or expression in a new line of the watches window.

The display of a variable can be modified via Right-click -> Properties. The value of the variables can be changed by clicking on them and enter the new value.

Call stack

The Call stack window shows the upper calling functions of the current function.