AT91Bootstrap Debugging with Eclipse for Linux
Introduction
The
Eclipse has become the de-facto industry standard environment host for embedded development.
The embedded cross-development with Eclipse environment via a JTAG target connection is shown below.
- The Eclipse IDE is the framework into which the other necessary tools are integrated.
- Eclipse itself includes an editor, project manager and debugger interface.
- The GNU ARM Plug-Ins is intended for the embedded cross-development which C/C++ language used.
- The Zylin / CDT Plug-Ins allow the Eclipse debugger to connect to a remote target via debug connection.
- The GNU Tools provide the assembler, compiler, linker and other code-generation utilities.
- The JLink GDB Server is a remote server for the GDB, and the GDB Server translates the GDB commands into the JLink commands.
- The Atmel SAM-ICE™ is a JTAG emulator designed for Atmel SAM3, SAM7, SAM9, SAMA ARM-based microcontrollers, including the ThumbŪ mode.
- AT91SAM-EK boards is the evaluation board for AT91SAM chips.
This page describes how to we construct cross-development environment based on the open-source Eclipse IDE and GNU toolsets under Ubuntu 10.04.4 LTS.
Setup Cross-Development Environment
Download the toolchain software package( e.g. arm-2009q3-68-arm-none-eabi-i686-pc-linux-gnu.tar.bz2) from the Sourcery website.
Decompress the file directly in the work directory(e.g. ~/opt ).
To set environment variable "PATH", modify ~/.bashrc.
$ export PATH=[INSTDIR]/bin:$PATH
To verify the cross toolchain installed properly, please type the following command.
$ arm-none-eabi-gcc -v
Download
J-Link software & documentation pack for Linux from the
Segger website (i.e. JLink_Linux_V462a.tgz).
Decompress the file directly in the working directory.
Before launching
JLink GDB Server, please do the following steps referring to README.txt:
$ sudo apt-get update
$ sudo apt-get install libusb-dev
- Copy the jlink libray to the system library folder.
$ sudo cp libjlinkarm.so.* /usr/lib
- Copy 45-jlink.rules to /etc/udev/rules.d/
$ sudo cp 45-jlink.rules /etc/udev/rules.d/
* To verify the JLink GDB Server installed properly, type the following command to start the JLink GDB Server.
$ sudo ./StartJLinkGDBServer.sh
If the following message displays, it indicate the JLink GDB Server intall successfully.
Note: The root permission is need to excute
the JLink GDB Server.
Now the JLink GDB Server is ready to run.
Download
Eclipse IDE for C/C++ Developers for Linux from the
Eclipse website.
Decompress the file directly in the working directory (e.g. ~/eclipse) then type the following command to run Eclipse. No installation procedure is required.
$ ./eclipse
The used Eclipse version is:
Juno Service Release 2
There are two ways to install the Plug-Ins.
The first way is to update directly from the corresponding website using the Eclipse standard update mechanism, this is recommended way.
The second way is to first download the Plug-Ins package from respective website, and then install it.
Install GNU ARM C/C++ Plug-Ins
To made the cross compilation possible, install the Eclipse Plug_Ins called
GNU ARM Eclipse Plug-ins.
Adopt the second way to install this Plug-Ins.
First download the Plug-Ins software package from the
GNU ARM Eclipse Plug-in website. (i.e. org.eclipse.cdt.cross.arm.gnu_0.5.4.201202210114.zip)
Then install this package, open menu
Help ->
Install New Software…, press
Add... button, the
Add Repository dialog will display.
Then press
Archive... to select the zip package.
Select the
GNU ARM C/C++ Development Support item and press the
Next button.
Install Zylin Embedded CDT Plug-Ins
Adopt the first way to install this Plug-Ins
To install the Zylin Embedded CDT Plug-Ins, open the menu
Help –>
Install New Software… then copy this URL
http://opensource.zylin.com/zylincdt in the
Work with field then type enter.
Select the
Zylin Embedded CDT item and press the
Next button
Check the Plug-Ins Installation
To verify the Plug-Ins Installation, open menu
Help ->
About Eclipse, the
About Eclipse Dialog will display, press the
Installation Details button, you will see the Installed Software.
Create and Build Project
- Open the menu File -> New -> Makefile Project with Exiting Code .
- Input a Project Name (e.g. at91bootstrap)
- Press the Browse button to locate the Exiting Code Location
- Select the toolchains ARM Linux GCC (Sourcery G++ Lite) and press the Finish button
Open the menu
Project ->
Build Project to build the select project.
Note:
- Before building the project, the configuration MUST be done under command line. e.g., for at91sam9g20ek
$ make mrproper && make at91sam9g20eknf_uboot_defconfig
- Change the CONFIG_LINK_ADDR from "0x00000" to "0x300000" in the file ".config".
Configure Debug Configuration and Debug
Open the menu
Run ->
Debug Configuration..., the
Create, manage, and run configuration Dialog wil display.
Select
Zylin Embedded debug(Native) to configure the debug configuration.Input the Name, e.g. at91bootstrap_configuration.
- Switch to the Tab Main.
- Select Project by clicking Browse... button,
- Select C/C++ Application by clicking Search Project... button, e.g. "binaries/at91sam9g20ek-nandflashboot-uboot-3.5.3-rc1.elf"
- Switch to the Tab Debugger
- Select Embedded GDB in Debugger drop down list.
- Select GDB debugger by clicking Browse... button, e.g. select "[INSTDIR]/bin/arm-none-eabi-gdb"
- Set GDB command file to blank.
- Select Standard in GDB command set drop down list
- Select mi in Protocol drop down list
- Switch to the Tab Commands.
- Please input the following command in the 'Initialize' commands edit box.
target remote localhost:2331
monitor reset
load
- Then click Apply button to finish the debug configuration.
You also could change the JLink GDB Server parameters to the suitable value.
e.g. change the following parameters
VerifyDownload=1
InitialSpeed=5
Speed=5
UseAdaptive=1
More information, please refer to
http://www.segger.com/jlink-gdb-server.html
* To start debug, You should start the JLink GDB Server first.
$ sudo ./StartJLinkGDBServer.sh
- To debug the project, Open the menu Run -> Debug Configuration..., the Create, manage, and run configuration Dialog will display, then press Debug button to start debug.
The successfully downloading image is shown below, the PC point to the first statement.
the JLink GDB Server log message is shown in the left, the Eclipse Debug Perspective in the right.
Now you could debug the project, as shown below.