Showing posts with label cygwin. Show all posts
Showing posts with label cygwin. Show all posts

Tuesday, August 2, 2011

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

Creating ARM Executable and Linkable Format Files

With the GNU ARM Toolchain installed, enter the following two lines in the terminal.


arm-elf-as --gdwarf2 -mcpu=arm7tdmi -o FILENAME.o FILENAME.s 
arm-elf-ld -o FILENAME.elf FILENAME.o


Where FILENAME.s is the name of your ARM assembly code file.

A few quick notes: the parameter 'gdwarf2' is used to maintain debugging information inside the file. It will come in handy when using arm-elf-gdb. The mcpu parameter tells the assembler what architecture the file is to be targeted towards.

Alternatively, copy the following code (EDIT: and replace the three indents on lines 21, 24, and 28 with tabs!), and save it as 'makefile' in the same directory as the .s file. Anytime you need to create an ELF file using filename.s, simply type 'make filename.elf'.

Download makefile

#
# Makefile for ARM Projects
# Author: S Hodgson
# Date: July 2011
#
# Usage: make filename.elf
#   i.e. if helloworld.s is the ARM assembly code,
#        execute 'make helloworld.elf'
#

# Linker and Assembler
LD      = arm-elf-ld
AS      = arm-elf-as

# Flags
DBGFLAG = --gdwarf2
ARCH    = -mcpu=arm7tdmi

# Create Files
%.elf : %.o
    $(LD) -o $@ $^

%.o : %.s
    $(AS) $(DBGFLAG) $(ARCH) -o $@ $^

# Clean - Warning: Removes ALL object and elf files
clean:
    rm -rf *.o *.elf



Edit: As Patrick pointed out, the indentation MUST be tabs, not spaces...