Thursday, August 4, 2011

Set Breakpoints in arm-elf-gdb

Breakpoints allow you to run your program up to a desired point.

Set Breakpoint

In arm-elf-gdb, to set a breakpoint use the break command, which can be abbreviated to just b, followed by a label, address, or line number in the .s file. 
Examples
break _start
b main
b 0x8004
b 17 (set breakpoint at line 17 of the original assembly file)
Check Breakpoints


To find all breakpoints, type info breakpoint. Again, abbreviations can be used to execute the equivalent i b

Run Until Breakpoint is Reached


The command continue will run the program until the next breakpoint. c will perform the same function.

Further Debugging in arm-elf-gdb

Here are a few quick words on using GDB, with particular reference to ARM files.

Inspect Registers
To have a look at a particular register, use the command print $[register_name]
For example,
print $r0
print $r1
print $pc
print can be abbreviated to p
p $r0
p $r1
p $pc

Change Register Values
Use the command print $[register_name] = [value]
For example,
print $r0 = 10
print $r1 = 0x20
print $pc = _start
Again, the abbreviation p can be used in place of print

Formatting Output
Format can be specified by using /[symbol] after the print command. Possible symbols are:
a for address
x for hexadecimal
d for signed decimal
u for unsigned decimal
o for octal
t for binary ('two')
c for character
f for floating point
For example
print/a $pcprint/x $r0p/c $r1p/t $cpsr 
(Use the last command to check the NZCV and interrupt flags)

Wednesday, August 3, 2011

Online Assembler and Checker for UNSW ELEC2142

Update: Sept 21, 2011

I think all students are finished with this, so I am taking it down. If it's a problem, email me!

Tuesday, August 2, 2011

Debugging ARM files with DDD (Simulation)

DDD is a graphical front-end to a variety of debuggers, including arm-elf-gdb.


Installation
In Ubuntu, install by running sudo apt-get install ddd 
For OS X, you can try your luck over here.
Usage
With the GNU ARM tools installed, in the terminal run ddd --debugger arm-elf-gdb &
Click File -> Open Program. Select your ELF file (that was assembled with --gdwarf2).
In the GDB console (the bottom pane), type
(gdb) target sim 
(gdb) load
(gdb) start 
You can view the registers by clicking Source -> Registers.
You can now step through the program, set breakpoints, and perform most other functions that GDB is capable of.


Debugging ARM files with arm-elf-insight (Simulation)

Insight is a graphical user interface for gdb, available for use in Cygwin on Windows. Installation is fairly straight-forward.

Usage

Open Cygwin.
  1. Assemble and link a .s file, ensuring the '--gdwarf2' option is used.
  2. Run arm-elf-insight.exe
  3. Click File -> Open, and select the ELF file.
  4. Click Run -> Run, or click the running man icon.
  5. Select 'Simulator' as the Target, and click OK.





  6. Click 'Yes'.
  7. For embedded systems debugging, it is good to open both the registers and memory windows under the View menu.
  8. Step through the program, observing changes in the registers and memory contents. If using flash-v1.s, pay attention to the memory changes at 0x10000000.

Monday, August 1, 2011

Installing GNU ARM Toolchain (Windows)

To install the GNU ARM toolchain in Windows, you will need Cygwin, a tool that lets you use a lot of Unix stuff.

Installing Cygwin
To install, download and run setup.exe. You won't need to select any packages yet, unless you are a UNSW ELEC2142 student. In this case, install the following packages:
make (under 'Devel')
expect (under 'Interpreters')
(If you have already installed Cygwin without these packages, just run setup.exe again.)
Installing the GNU ARM Toolchain

Download the latest Windows toolchain from http://gnuarm.com/. At time of writing, that means grabbing this file.

Run this file, and accept all defaults.

If you launch Cygwin, and type arm-elf- and then hit 'Tab' twice, you should see a list of 24 executable files.

That's all, folks!