OOCD Starter

Hubert Högl, 2008-05-04, ZIP Archive oocd-starter-1.zip

This page is referenced from the first Embedded Projects Journal.

This is a demo for the Olimex SAM7-P64 board which has an Atmel AT91SAM7S64 controller. I am using a free ARM toolchain (gcc, as, gdb) from Codesourcery and the OpenOCD ARM debugger.

The lower (blue) USB connector is only for the power supply of the board. At the top left is the JTAG adaptor (soon available from http://embedded-projects.net. The adaptors RS-232 connector is hand-wired with the left RS-232 connector of the board (pins 2, 3 and 5 are connected straigth trough). On the right side is a push button which I added to port bit PA0.

  1. Compile the Sources (after toolchain installation)
    cd src
    make
    cp main.elf ../bin    
    
  2. Connect the JTAG adaptor. I am using an adaptor containing a FT2232 device from FTDIChip. The layout in the OpenOCD configuration file is set to oocdlink. It also has a serial port connector which is available on device /dev/ttyUSB1. This adaptor will soon be available at Embedded Projects shop. Alternatively you can also use an Amontec JTAGkey-Tiny or an Olimex ARM-USB-OCD or ARM-USB-TINY.

  3. Run OpenOCD
    sudo openocd -f oocd/sam7s-oocdlink.cfg
    
    OpenOCD writes log messages on the screen which depend on the "log level". If you do not specify a log level with the -d option the level 2 is set. Typical log output is contained in oocd/oocd-log-sample.txt.

  4. Run picocom terminal program
    hhoegl@egg:oocd-starter$ sudo picocom -b 9600 /dev/ttyUSB1
    Password:
    picocom v1.4
    
    port is        : /dev/ttyUSB1
    flowcontrol    : none
    baudrate is    : 9600
    parity is      : none
    databits are   : 8
    escape is      : C-a
    noinit is      : no
    noreset is     : no
    nolock is      : no
    send_cmd is    : ascii_xfr -s -v -l10
    receive_cmd is : rz -vv
    
    Terminal ready
    

  5. Starting GDB
    hhoegl@egg:oocd-starter$ arm-none-eabi-gdb -x init.gdb
    GNU gdb 6.4.50.20060226-cvs
    Copyright (C) 2006 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB.  Type "show warranty" for details.
    This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-none-eabi".
    0x00000220 in ?? ()
    add symbol table from file "bin/main.elf" at
            .text_addr = 0x200000
    Loading section .text, size 0x3c14 lma 0x200000
    Loading section .rodata, size 0x10 lma 0x203c14
    Loading section .data, size 0x20 lma 0x203c24
    Start address 0x200000, load size 15428
    Transfer rate: 64755 bits/sec, 302 bytes/write.
    (gdb) c
    Continuing.
    
    After the program starts, the string Hello World appears in the picocom terminal window. Typing subsequent 't' characters makes the yellow LED on the board go on and off.

    To exit gdb enter Ctrl-C (stops program execution) and type exit.

  6. Starting Telnet (optional)
    hhoegl@egg:oocd-starter$ telnet localhost 4444
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    Open On-Chip Debugger
    > 
    
    The exit command quits the telnet interface. A list of telnet commands is here.

    The OpenOCD telnet interface can easily be controlled by a program. An example written in the Python language is sam7-oocd-telnet.py.

Automatic startup of multiple console windows with screen

You must have the GNU screen utility installed (http://www.gnu.org/software/screen). Directory screen contains all the necessary files.
  1. Change directory to screen/.
  2. Edit CONFIG.sh to your individual pathes and settings.
  3. Enter command ./screenide. At the bottom of the current console you will find a status line with a lot of new windows.
  4. Navigate between the screen windows with
        C-z \    quit all windows
        C-z p    previous window
        C-z n    next window
        C-z <n>  go to window <n>
        C-z '    enter window name or number
        C-z "    show window list
        C-z ?    show key bindings
        C-z k    kill current window
        C-z C    clear window
        C-z c    create a new shell window
        C-z A    enter a name for current window
    
    Here are some screen shots: menu, Emacs, gdb, OpenOCD, Shell, Telnet, UART.

Additional Information


Hubert Högl, <Hubert.Hoegl@hs-augsburg.de>
Last modified: Mon May 5 11:31:54 2008