Debugging

From Arctic Core - the open source AUTOSAR embedded platform

Jump to: navigation, search

This article describes the different debugger setups that have been used to debug Arctic Core on target platforms.

Contents

PLS UDE

Getting Started

UDE Desktop uses workspace for organizing your work. The idea is get your work on a particular CPU or project up and running quickly once setup.

So:

  1. Select New Workspace
  2. Enter a suiteable name
  3. When "Select Target Configuration" appears a suitable CPU should appear. Select it and press "OK"

Debugging:

  1. Menu->File->"Load Program"
  2. Select the *.elf you want to debug.
  3. Now the Flash Programming Tool appears
  4. Press "Program All"
  5. Press "Exit" twice.

Tip: To avoid some clicking when programming. In the "Flash Programming Tool" (Menu->Tools->FLASH programming)

  1. Press "General".
  2. Check the "After download ..." and "Automatically Close...".
  3. Press "OK"

The useful debugger windows are split into 4 menus, Menu->Debug, Menu->Show, Menu->View and "Menu->Window->Project Workspace"

To get a good overview enable "Menu->Window->Project Workspace"

Memory Window

At a first glance the memory window cannot display memory from a symbol address, but it can!. If SELECT_CONSOLE=TTY_RAMLOG is used, open the memory window (Menu->Views->Memory Window) click on an address. You should now be able to edit the address. Enter "&ramlog" and you should now be able to look at the ramlog

Terminal

Terminal support for UDE will be added shortly to arc repositories. Once it's up enable with:

SELECT_CONSOLE=TTY_UDE

Lauterbach T32 Simulator

Getting started

  1. Get the debugger from http://www.lauterbach.com:
    1. Click on Demo download on the right menu and then on the Download link.
    2. Download Simulator for PowerPC".
    3. Extract the *.zip file to directory of choice.
  2. Start the debugger:
    1. Run t32ppc.exe
    2. Don't care about the example being loaded.
    3. Select MENU->run batchfile. Choose the start.cmm file under <projdir>/tools/t32
    4. A new menu called Autosar will now appear
  3. Select MENU->Autosar->Change config
    • A dialog will now appear that lets you select from targets available to you.
    • You should also select the root directory of your project.
  4. Select MENU->Autosar->Load
    • A dialog now opens to let you choose the *.elf file you want to load.
    Example: The examples/simple .elf ends up in <projdir>/examples/simple/obj_mpc551xsim.
  5. Select MENU->Autosar->Restore layout.
  6. You are now ready do press the Go button. Text should now start scrolling in the terminal window.

Using the terminal

To enable support for the terminal you must set SELECT_CONSOLE to TTY_T32 in your environment ( project->properties->C/C++ build->Environment,) and rebuild.

Known problems

  • Sometimes the debugger hangs on terminal output (it's in the function t32_writebyte()). Just start the debugger again and it should work. If you have re-compiled your code you probably have to press the term button.

iSYSTEM winIDEA

Getting started

  1. Install winIDEA according to the iSYSTEM instuctions.
  2. Start the debugger.
    1. Create a workspace in a folder of choice.
    2. Add the Arctic Core, and your own, source folders to Alternate project files search directories under Debug --> Debug Options... --> Directories.
    3. Setup your debugger hardware under Hardware --> Hardware... and Hardware --> Emulation Options....
    4. Add your built .elf file in Debug --> Files For Download.... Select Program Header / Physical when prompted for Load Code from.
    5. Download to target, Debug --> Download.
  3. Connecting the terminal:
    1. Our Arctic Core project must be configured for use with the winIDEA shared memory terminal. This is done by setting SELECT_CONSOLE = TTY_WINIDEA in build_config.mk in your project.
    2. In winIDEA, show the terminal by selecting View --> Terminal
    3. Click Options in the terminal window and select Debugger in the top drop-down on the Terminal-tab
    4. Go to Hardware --> Options and select Shared memory as Connection type.

Known problems

  • Using winIDEA build 9.9.91 there is a problem with stepping through code that only seems to occur when SPE is enabled on the target CPU (observed on MPC5567). The symptom is that the contents of GPR r31 is corrupted by the debugger on each step operation. This issue is not seen on build 9.9.60.
  • When using the on-chip debugger on the iSystem MPC5517 Board via USB there sometimes is a problem when starting from reset. Somehow the reset state makes the BAM (Boot Assist Module) cause exceptions. Since the exception vectors are in their reset state we end up executing "random" code. For some reason this makes the debugger unable to stop the cpu, resulting in the winIDEA error message "Could not stop CPU".

KEIL uVision3

Company [1]

For this debugger use MSYS instead: Building#MSYS

Assuming you have your project in eclipse this is a guide to just load the *.elf and start debugging.

  1. Start up uVision3
  2. MENU->Project->New uVison project.
    1. Create it in the root of your project in eclipse.
    2. Select the right device.
    3. Don't copy the startup project
  3. Right click on "Target1". Select properties.
    1. On the "output" tab. Name the executable "examples\tiny\obj_et_stm32_stamp\simple.elf"
    2. On "Debug" tab (left side is simulator and right side hardware debugger) press the "Use" button for target debugger.
  4. MENU->Flash->Download.
  5. MENU->Debug->Start/Stop debug session.

Known problems

  1. The elf reader seems to miss debug information in some files. You can set a breakpoint in a file but when you step all you get it disassembly.
    By re-arranging the object files in the makefile you can probably get the debug information and step back.
  2. Clicking on files in the symbol view does not work.
    For some reason KEIL does not take the path from the object file but tries to imagine up some path of it's own. No solution for this.


Wind River Probe

These instructions apply for PowerPC targets.

  1. Make sure that CPU registers are initialized. Wind River provides default register setup files that can be used.
  2. Configure the CF option SB to be IHBC instead of SB. This configures the emulator to use hardware breakpoints for step and stop events.
  3. Make sure to use a correct binary file when programming flash. As of Arctic Core 2.5 you can add build-bin-y = LightControl.bin to your Arctic Core makefile to produce such a file.

Raisonance

For this debugger use MSYS instead: Building#MSYS

Assuming you have your project in eclipse this is a guide to just load the *.elf and start debugging.

Company [2]

  1. MENU->File->New Project
    1. Change "Type" to: Existing appliction to be debugged
    2. Select Processor:
    3. Click the "..." so select the *.elf you just built from <project dir>/binaries
    4. Press CTRL+D

Using GDB and OpenOCD

It is possible to debug your application from within Arctic Studio. The following steps are necessary to create a working setup:

  • Install MSYS [3]
  • Install MinGW
  • Make sure that /etc/fstab points /mingw to your MinGW installation path.
  • Install libusb [4]
    • In Windows Vista, the installation needs to be run in Windows XP SP2 compatible mode, and as an administrator. Create a shortcut to your installation file to achieve these settings.
  • After installation of libusb, make sure that gcc/libusb.a is in msys's and mingw's library path.
  • Make sure that libusb's usb.h is in the include path for mingw and msys.
  • Download and unpack OpenOCD [5]
  • Configure, build and install OpenOCD with Raisonance support:
./configure --enable-rlink && make && make install
  • While compiling, in Arctic Studio, install Zylin [6], using the update site URL at [7].


In order to debug an application, you first need to launch openocd with the proper configuration. An example for stm32 would be:

openocd -f interface/rlink.cfg -f board/stm32f10x_128k_eval.cfg

OpenOCD will now host a GDB server on port 3333. To verify that it is working, try connecting to it from gdb:

arm-none-eabi-gdb
(gdb) target remote localhost:3333
Remote debugging using localhost:3333

Next, create a debug configuration in Arctic Studio:

  • Zylin Embedded debug (Native)
  • Project: (your project name)
  • C/C++ Application: (path to your .elf)
  • Debugger: arm-none-eabi-gdb
  • Initialize commands:
set debug remote 1
set remotetimeout 60
# Connect to OpenOCD, running on port 3333.
# Change localhost to whatever host it is running at.
target remote localhost:3333

# Reset MCU
monitor reset init
monitor sleep 40
# Erase flash
monitor stm32x mass_erase 0
monitor sleep 200
# Load the new application
monitor flash write_image C:/Projects/mecu/objs/mecu.elf
monitor sleep 200
# Verify that it loaded correctly 
monitor verify_image C:/Projects/mecu/objs/mecu.elf
monitor sleep 200
# Reset and halt, await `run'
monitor reset halt
  • Run commands:
# can be empty

Next up, just hit the debug button and you should be all set. Hit F8 to start running the code.