Difference between revisions of "Flameman/knxlpc2348"

From eLinux.org
Jump to: navigation, search
(doc)
(Common problems and Gotchas)
Line 1,092: Line 1,092:
 
=== Common problems and Gotchas ===
 
=== Common problems and Gotchas ===
  
 +
=== Interesting links ===
  
 +
http://ics.nxp.com/support/documents/microcontrollers/?scope=LPC2000&type=appnote
  
 
=== Tips & Tricks ===
 
=== Tips & Tricks ===

Revision as of 03:07, 25 June 2011

For more interesting projects done by Flameman, be sure to check out his project index

lnxlpc2348-Flameman

Note

I'm developing for this board, the wiki page will be improved soon

feel free to contact me (see the contact below)

Introduction

The Target-goal of this page is

  • make the board able to boot it
  • have appeal with it

also ported to LPC2103 ARM7TDMI-S CPU

People you could contact if you need help

  • flameman, i'm currently use this board for a project, email
    • email flamemaniii@gmail.com
  • you ... if you want ;-)

About this project

About the board

Overview

The board consists of:

  • CPU arm7 philips/nx lpc2348-12Mhz nxlpc2348-user-man.pdf
  • RAM onchip 512KB
  • LAN spi-to-ethernet ENC28J60
  • UART RS232
  • LCD spi lcd attached to pcd8544
  • POWER 3.3V
  • System PCB xxx cm x xxx cm
  • RTC the real time clock chip inside the cpu

Memory Locations

memory map of the board will be added as soon as possible


addr begin addr end area
... ?? ram, userspace


Open questions


...

Problems

...

Images of the board

Nxlpc2348-mobo.jpg



About

what/where

About firmware

About devtools

tool

flashing with openOCD

OpenOCD created by Dominic Rath is a gdb-server and flash-utility for ARM-Controllers. It supports ARM7 and ARM9 controllers. Wiggler-type and FTDI2232-based devices can be used as hardware-interfaces. Supported host-plattforms are Linux/Unix-systems or MS-Windows-systems (native and cygwin).

Michael Fischer has created a page on which he describes how OpenOCD can be used together with the GNU-debugger (gdb, Insight-gdb, ddd etc.). The following section will describe methods how to use the flash-programming functionality in OpenOCD.

OpenOCD is under heavy development and it's difficult to keep this page up to date. But the developers maintain a documentation. If you are building OpenOCD yourself you can create the document with make pdf. Some tools are needed to create it (I use MiKTeX). Read esp. the chapter Deprecated/Removed Commands of the document if you get error-messages when using the configuration/scripts shown below. Flash-programming with OpenOCD

OpenOCD supports flash programming on NXP/Philips LPC2000, Atmel AT91SAM7 and ST STR7 ARM7-controllers (version SVN100). Flash-programming can be done by accessing the OpenOCD-telnet-server but I prefer a method where the flash programming is automated. This is very convenient when working with make. If everything is setup correctly a simple make program will transfer the binary-code into the flash-memory.

Installing OpenOCD on a MS-Windows-System The methodes described in this small introduction have been tested in a Windows 2000 system with a Wiggler-type JTAG-interface (Olimex ARM-JTAG) and a FTDI2232-based hardware (i.e. JTAGKEY, WINARM-JTAG). The usage of OpenOCD is basicly the same on Linux/Unix-systems.

   You can get the latest OpenOCD source-code from the berliOS SVN-system and compile and install it yourself. For MS-Windows Michael Fischer provides a precompiled version which includes a setup-software. Links are available from my ARM-projects page (see Links). Sometimes I update a binary for MS-Windows too, see my WinARM page
   On "modern" MS-Windows-systems like NT, 2000 or XP a special driver must be installed for Wiggler-type hardware interface. This driver is called giveio and is included in the binary distribution from Michael Fischer. The setup-software will ask you if the driver should be installed. But it can also be installed lateron with install-giveio.bat (Administrator priviledges needed for installation only). For FTDI FT2232 based interfaces like the ones from Amontec, Olimex, Signalyzer and myevertool.de the FTDI-drivers must be installed. M. Fischer's package includes the drivers for some devices (the main difference is the VID/PID the "real" hardware-drivers are those available from FTDI with additional inf-files).

Basicly three files are needed for an automated flash-programming:

   openocd.exe itself (giveio has to be installed when using a Wiggler-type hardware on Win32-systems, the FTDI driver has to be installed when using FT2232-based hardware). Michael Fischer decided to create two binaries one for Wiggler-type hardware connected to the parallel-port and one for FT2232-based devices.
   a config-file with definitions of the hardware-interface (i.e. a Wiggler-type interface) and the target-controller
   a script-file with the flash-commands

Writing NXP/Philips LPC2000 internal flash-memory

All files mentioned in this section are available for download (see below). A simple example-application is also included in the file archive. Target-controller is a NXP LPC2138 on a Keil LPC2130-board. But the basic method can be used for all LPC2000 controllers after minimal changes.

In addition to the three files basicly needed for the automated flash programming I have added some small "glue"-files to make configuration and usage a little easier.

The first file openocd_install_info.cmd is simple "batch-file" to set some variables. All cmd-files are made for MS Windows OS but Unix-Users will get the idea how to create own "shell-scripts". The locations of the OpenOCD binaries and the used JTAG-interface are given in the file:

rem - rem Modify this to the installed OpenOCD-binaries rem The following is for the precompiled binaries from Michael Fischer rem with sources from OpenOCD SVN-version 100 installed on a rem PC running Windows-2000 (german) rem - set OOCD_INSTALLDIR=C:\Programme\openocd-2006re100\bin set OOCD_BIN_FTDI=%OOCD_INSTALLDIR%\openocd-ftd2xx.exe set OOCD_BIN_PP=%OOCD_INSTALLDIR%\openocd-pp.exe

rem The used interface either FTDI(=WinARM-JTAG, JTAGKEY etc.) or PP(="Wiggler") set OOCD_INTERFACE=FTDI rem set OOCD_INTERFACE=PP

OpenOCD is called from openocd_go_flash.cmd:

@echo off call openocd_install_info.cmd

if %OOCD_INTERFACE% == PP goto LAB_PP if %OOCD_INTERFACE% == FTDI goto LAB_FTDI echo ERROR - set interface in openocd_install_info goto LAB_END


LAB_FTDI

set OOCD_EXE=%OOCD_BIN_FTDI% set OOCD_CFG=openocd_lpc2138_flash_ftdi.cfg goto LAB_DOIT


LAB_PP

set OOCD_EXE=%OOCD_BIN_PP% set OOCD_CFG=openocd_lpc2138_flash_wiggler.cfg


LAB_DOIT

rem set OOCD_DBG=-d 1

%OOCD_EXE% %OOCD_DBG% -f %OOCD_CFG%


LAB_END

rem pause

As you can see the script just calls the "install-info" so set the configuration-variables after that it calls the OpenOCD-binary with the config-file for the used (configured) JTAG-hardware.

The files openocd_lpc2138_flash_ftdi.cfg and openocd_lpc2138_flash_wigger.cfg are basicly the same and just differ in the interface-defintion-section. Here just the configuration for FTDI FT2232-based hardware is shown. The configuration-file for Wiggler-type hardware can be found in the file-archive. In the content listed below you will notice that the jtag_speed has been set to 3, this has been found out by "try and error", the settings 0,1 and 2 did not work form me with a JTAGKEY and WinARM-JTAG (in the cfg for the Wiggler-hardware jtag_speed 0 has been used and worked reliably).

  1. Flash LPC2138 memory using openocd
  2. and a FTDI FT2232-based JTAG-interface
  3. created by Martin Thomas
  4. based on information from Dominic Rath
  1. daemon configuration

telnet_port 4444 gdb_port 3333

  1. interface

interface ft2232 ft2232_device_desc "Amontec JTAGkey A" ft2232_layout jtagkey ft2232_vid_pid 0x0403 0xcff8 jtag_speed 3 jtag_nsrst_delay 200 jtag_ntrst_delay 200

  1. use combined on interfaces or targets that can't set TRST/SRST separately

reset_config trst_and_srst srst_pulls_trst

  1. jtag scan chain
  2. format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)

jtag_device 4 0x1 0xf 0xe

  1. target configuration

daemon_startup reset

  1. target
  2. target arm7tdmi

target arm7tdmi little run_and_init 0 arm7tdmi-s_r4 run_and_halt_time 0 30

  1. flash-options LPC2138

target_script 0 reset openocd_lpc2138_flash.script working_area 0 0x40000000 0x4000 nobackup

  1. LPC2138 @ 12MHz / 0x7D000 from 500*1024 (not 512!)
    1. up to version SVN188:

flash bank lpc2000 0x0 0x7D000 0 0 lpc2000_v2 0 12000 calc_checksum

    1. from Version SVN189:
  1. flash bank lpc2000 0x0 0x7D000 0 0 0 lpc2000_v2 12000 calc_checksum


  1. For more information about the configuration files, take a look at:
  2. http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger

The file openocd_lpc2138_flash.script includes the commands which are called on reset (since reset_and_init is given as parameter for target).

  1. The following commands will be executed on
  2. reset (because of run_and_init in the config-file)
  3. - wait for target halt
  4. - erase memory
  5. - flash content of file main.bin into target-memory
  6. - shutdown openocd
  7. created by Martin Thomas
  8. http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects
  9. based on information from Dominic Rath

arm7_9 dcc_downloads enable wait_halt sleep 10 poll flash probe 0


  1. erase first bank only:

flash erase 0 0 0

  1. erase all banks:
  2. flash erase 0 0 26
  3. if flash erase is not longer available in your OpenOCD-version use
  4. flash erase_sector

flash write 0 main.bin 0x0

  1. flash write is deprecated and my not be available in your OpenOCD-version, update to:
  2. flash write_binary 0 main.bin 0x0
  3. flash write_binary is deprecated and my not be available in your OpenOCD-version, update to:
  4. flash write_bank 0 main.bin 0x00
  5. also check flash write_image which can be uses together with flash auto_erase on

reset run sleep 10 shutdown

An example for a program-target (make program) in the makefile. Make shure the file main.bin is in "raw-binary" format (objcopy format-option binary):

program: $(TARGET).$(IMGEXT) @echo @echo "Programming with OPENOCD" openocd_go_flash.cmd

The example is a small program for a NXP LPC2138 on Keil LPC2138 evaluation board. But it should be rather portable and can be used for other NXP-controllers with minor modifications. Souce-code, linker-scripts, makefile and OpenOCD-config/-script are included. [Download] (zip, timestamp 20061013) NXP LPC23xx/24xx

Newer versions of OpenOCD offer TCL-scripting. The following configuration uses scripting and will not work with older versions of OpenOCD. Please read the comments below for further information.

  1. OpenOCD configuration for LPC23xx/LPC24xx
  2. Martin Thomas 8/2008
  3. tested with:
  4. - OpenOCD SVN971 (MinGW)
  5. - LPC2378
  6. - Olimex LPC2378-STK
  7. - Amontec JTAGKey
  1. Interface/"cable"
  2. either
    1. script interface/jtagkey.cfg
  3. or
    1. interface ft2232
    2. ft2232_device_desc "Amontec JTAGkey A"
    3. ft2232_layout jtagkey
    4. ft2232_vid_pid 0x0403 0xcff8
  4. or pass through command line with -f or -c
  1. slow and verbose during init:

debug_level 3 fast disable jtag_speed 100

  1. delays on reset lines

jtag_nsrst_delay 200 jtag_ntrst_delay 200

  1. use combined on interfaces or targets that can't set TRST/SRST separately

reset_config trst_and_srst srst_pulls_trst

  1. jtag scan chain

jtag_device 4 0x1 0xf 0xe

  1. target settings

target arm7tdmi little 0 arm7tdmi-s_r4

  1. scipts/macros/user commands - this is TCL (variant JIM):

proc mt_internal_rc {} { jtag_khz 100 reset run sleep 100 reset halt wait_halt 2 # PLL disconnect PLLCON mww 0xE01FC080 0x01 mww 0xE01FC08C 0xAA mww 0xE01FC08C 0x55 # PLL disable PLLCON mww 0xE01FC080 0x00 mww 0xE01FC08C 0xAA mww 0xE01FC08C 0x55 # no prescaler CCLKCFG mww 0xE01FC104 0x00 # internal RC CLKSRCSEL mww 0xE01FC10C 0x00 #### main oscil. CLKSRCSEL #### mww 0xE01FC10C 0x01 # remap to internal flash mww 0xE01FC040 0x01 sleep 100 jtag_khz 500 flash probe 0 }

proc mt_flash_bin {IMGFILE OFFSET} { mt_internal_rc flash write_image erase $IMGFILE $OFFSET sleep 100 verify_image $IMGFILE $OFFSET sleep 100 }

proc mt_flash {IMGFILE} { mt_internal_rc flash write_image erase $IMGFILE sleep 100 verify_image $IMGFILE sleep 100 }

  1. mthomas - note taken from the lpc2148 file in the OpenOCD target library:
  2. NOTE!!! LPCs need reset pulled while RTCK is low. 0 to activate
  3. JTAG, power-on reset is not enough, i.e. you need to perform a
  4. reset before being able to talk to the LPC2148, attach is not
  5. possible.

proc target_0_post_reset {} { # Force target into ARM state soft_reset_halt # do not remap 0x0000-0x0020 to anything but the flash mwb 0xE01FC040 0x01 }


  1. working area in RAM

working_area 0 0x40000000 0x10000 nobackup

  1. flash bank lpc2000 <base> <size> 0 0 [calc_checksum]
  2. n.b.: the target is switched to the internal RC (nom. 4MHz)
  3. before flashing with the supplied commands so this is the frequency
  4. given as parameter

flash bank lpc2000 0x0 0x7d000 0 0 0 lpc2000_v2 4000 calc_checksum


gdb_flash_program enable

init

fast enable jtag_khz 500 debug_level 1


interface/jtagkey.cfg is a file from the OpenOCD "library". OpenOCD startes searching files on directory level "above" openocd.exe on MS Windows systems (default configuration). So if openocd.exe is located for example in C:\myutils\emb\bin\ the file jtagkey.cfg should be located in C:\myutils\emb\interface\. If you do not have the file at hand, you may uncomment the interface lines in the configuration file given above.

Once OpenOCD is attached with:

openocd.exe -f interface/jtagkey.cfg -f openocd.cfg

flash programming can be done via telnet-interface with:

mt_flash <elf-file/hex-file>

or

mt_flash_bin <bin-file> <offset>

From the command-line/makefile just use

openocd.exe -f interface/jtagkey.cfg -f openocd.cfg -c "mt_flash img.elf/.hex" -c "reset run" -c shutdown

Of cause any other interface-file from the interface-library, a self written interface-file or a interface-section in the openocd.cfg can be configured too when using other interfaces like for example a "Wiggler". But I have just tested with the cable from Amontec.

Also note that my user-defined commands for flashing do include a verify command. This will fail if OpenOCD has calculated the checksum at flash-address 0x00000014 on-the-fly during flash-programming because of the option calc_checksum given at the bank defintion and the value in the load-image (hex, elf, bin file) does not match the calculated value. Verification failure can be avoided by setting the correct checksum in the assembler-code (.word <checksum> at "reserved" entry in table) so load-image and flash-content after write will match. I do not recomment to remove the calc_checksum option or to disable verify because the target will not start from flash after reset if the checksum at 0x14 is invalid and problems during flash-programming may not be detected.

My settings for a Debug-Configuration with flash-memory-update in Eclipse using the "Eclipse C/C++ GDB Hardware Debugging" plugin (that's _not_ Zylin's plugin):

Initialisation Commands:

target remote localhost:3333 monitor debug_level 2 monitor mt_internal_rc load compare-sections monitor soft_reset_halt set mem inaccessible-by-default off monitor debug_level 0

Run Command

stepi

Tested with Eclipse 3.4, CDT 5.0, C/C++ GDB Hardware Debugging 5.0, OpenOCD SVN971 (Win32/MinGW), arm-none-eabi-gdb 6.8 from Codesourcery G++ lite for ARM Q3/2007, Amontec JTAGKey, NXP LPC2378 and Olimex LPC-2378-STK.

BTW: the Target Managment Terminal is a useful Eclipse-plugin which offers serial-communication and telnet from inside Eclipse (a "View"). Can be used to communicate with OpenOCD and for "printf-debugging" via UART. Make sure to install the RXTX End-User Runtime from COM-port access on Win32. Writing Atmel AT91SAM7S internal flash-memory

The files and setup needed to write the internal flash-memory of an AT91SAM7 controller are basicly the same as described in the previous section. The file-archive includes all needed files together with some example code (download link below). According to a message in the OpenOCD-forum the procedure can also be used to program AT91SAM7X256/AT91SAM7XC256.

The example is prepared to be used with the precompiled OpenOCD binaries from Michale Fischer (link below). and includes a set of files to make usage and configuration as easy as possible (hopefully).

The first file openocd_install_info.cmd is simple "batch-file" to set some variables. All cmd-files are made for MS Windows OS but Unix-Users will get the idea how to create own "shell-scripts". The locations of the OpenOCD binaries and the used JTAG-interface are given in the file:

rem - rem Modify this to the installed OpenOCD-binaries rem The following is for the precompiled binaries from Michael Fischer rem with sources from OpenOCD SVN-version 100 installed on a rem PC running Windows-2000 (german) rem - set OOCD_INSTALLDIR=C:\Programme\openocd-2006re100\bin set OOCD_BIN_FTDI=%OOCD_INSTALLDIR%\openocd-ftd2xx.exe set OOCD_BIN_PP=%OOCD_INSTALLDIR%\openocd-pp.exe

rem The used interface either FTDI(=WinARM-JTAG, JTAGKEY etc.) or PP(="Wiggler") set OOCD_INTERFACE=FTDI rem set OOCD_INTERFACE=PP

OpenOCD is called from openocd_go_flash.cmd:

@echo off call openocd_install_info.cmd

if %OOCD_INTERFACE% == PP goto LAB_PP if %OOCD_INTERFACE% == FTDI goto LAB_FTDI echo ERROR - set interface in openocd_install_info goto LAB_END


LAB_FTDI

set OOCD_EXE=%OOCD_BIN_FTDI% set OOCD_CFG=openocd_at91sam7s_flash_ftdi.cfg goto LAB_DOIT


LAB_PP

set OOCD_EXE=%OOCD_BIN_PP% set OOCD_CFG=openocd_at91sam7s_flash_wiggler.cfg


LAB_DOIT

rem set OOCD_DBG=-d 3

%OOCD_EXE% %OOCD_DBG% -f %OOCD_CFG%


LAB_END

rem pause

As you can see the script just calls the "install-info" so set the configuration-variables after this it calls the OpenOCD-binary with the config-file for the used (configured) JTAG-hardware.

The files openocd_at91sam7s_flash_ftdi.cfg and openocd_at91sam7s_flash_wigger.cfg are basicly the same and just differ in the interface-defintion-section. Here just the configuration for FTDI FT2232-based hardware. The configuration-file for Wiggler-type hardware can be found in the file archive.

  1. Flash AT91SAM7S memory using openocd
  2. and a FTDI FT2232-based JTAG-interface
  3. created by Martin Thomas
  4. based on information from Dominic Rath
  1. daemon configuration

telnet_port 4444 gdb_port 3333

  1. interface

interface ft2232 ft2232_device_desc "Amontec JTAGkey A" ft2232_layout jtagkey ft2232_vid_pid 0x0403 0xcff8 jtag_speed 0 jtag_nsrst_delay 200 jtag_ntrst_delay 200

  1. use combined on interfaces or targets that can't set TRST/SRST separately

reset_config srst_only srst_pulls_trst

  1. jtag scan chain
  2. format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)

jtag_device 4 0x1 0xf 0xe

  1. target configuration

daemon_startup reset

  1. target
  2. target arm7tdmi

target arm7tdmi little run_and_init 0 arm7tdmi run_and_halt_time 0 30

  1. flash-options AT91

target_script 0 reset openocd_at91sam7s_flash.script working_area 0 0x00200000 0x4000 nobackup flash bank at91sam7 0 0 0 0 0

  1. For more information about the configuration files, take a look at:
  2. http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger

The file openocd_at91sam7s_flash.script includes the commands which are called on reset (since reset_and_init is given as parameter for target). The register-writes to init "ecr" have been found in the openocd-package. I have just adapted them to the default frequency used on most boards for USB-compatiblity when using the AT91SAM7S-series. If you use another target and it does not work for you just remove the lines starting with mww.

  1. The following commands will be executed on
  2. reset (because of run_and_init in the config-file)
  3. - halt target
  4. - init ecr
  5. - flash content of file main.bin into target-memory
  6. - shutdown openocd
  7. created by Martin Thomas
  8. http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects
  9. based on information from Dominic Rath

halt sleep 10

  1. Init - taken form the script openocd_at91sam7_ecr.script

mww 0xfffffd44 0x00008000 # disable watchdog mww 0xfffffd08 0xa5000001 # enable user reset mww 0xfffffc20 0x00000601 # CKGR_MOR : enable the main oscillator sleep 10 mww 0xfffffc2c 0x00481c0e # CKGR_PLLR: 96.1097 MHz sleep 10 mww 0xfffffc30 0x00000007 # PMC_MCKR : MCK = PLL / 2 ~= 48 MHz sleep 10 mww 0xffffff60 0x003c0100 # MC_FMR: flash mode (FWS=1,FMCN=60)

  1. arm7_9 force_hw_bkpts enable # program resides in flash
  1. AT91SAM7 flash command-"batch"
  2. adapted by Martin Thomas based on information from Dominic Rath - Thanks

arm7_9 dcc_downloads enable sleep 10 poll flash probe 0 flash write 0 main.bin 0x0

  1. flash write is deprecated and my not be available in your OpenOCD-version, update to:
  2. flash write_binary 0 main.bin 0x0
  3. flash write_binary is deprecated and my not be available in your OpenOCD-version, update to:
  4. flash write_bank 0 main.bin 0x00
  5. also check flash write_image which can be uses together with flash auto_erase on

reset run sleep 10 shutdown

An example for a program-target (make program) in the makefile. Make shure the file main.bin is in "raw-binary" format (objcopy format-option binary):

program: $(TARGET).$(IMGEXT) @echo @echo "Programming with OPENOCD" openocd_go_flash.cmd

The example is a small program for an AT91SAM7S64 or AT91SAM7S256 on an Atmel AT91SAM7-EK or OX SAM7-EK evaluation-board. Souce-code, linker-scripts, makefile and OpenOCD-config/-script are included. [Download] (zip, timestamp 20061013)

If the lockbits are set (i.e. if SAM-BA has been used before) they have to be cleared with the flash protect command. Start OpenOCD (see openocd_go_debug.cmd in the archive), connect to OpenOCD by telnet (telnet localhost 4444) and use the command flash info 0 to determine the number of lockbits (output after lockbits:, i.e. 16). Unprotect with the command flash protect 0 0 <number of lockbits-1> off (i.e. flash protect 0 0 15 off).

Manual erase of the flash should be done for the complete flash. Use the command flash erase 0 0 <number of sections-1> (i.e. flash erase 0 0 15). Usualy it's not needed to erase manualy since the SAM7 flash-programming-functions in OpenOCD already do this automaticly during flash write.

For those who use an AT91SAM7X controller: I have got an e-mail from David Jander: [...]The AT91SAM7X introduced bootloader selection via NVM-bits in flash. An empty part (or one that has been erased using the ERASE pin), will programm fine with OpenOCD using your instructions (adjusting the obvious bits for SAM7X), but the application will never run! That is because NVM-bit2 (boot selection) has to be set. AFAIK this can only be done using SAM-BA (the proprietary ATMEL tool) right now, since OpenOCD doesn't support NVM bits yet (please correct me if I'm wrong... I whish I was).[...]. David has not been wrong when he wrote his e-mail. But the situation has changed in the meantime. Later versions of OpenOCD offer a command to set/clear NVM-bits. This has been confirmed by Uwe Bonnes for the SVN-Version 90/31.8.2006. The command is at91sam7 gpnvm <num> <bit> <set|clear> where <num> is the flash-bank number as given in the config-file, <bit> and <set|clear> is obvious. Example: at91sam7 gpnvm 0 2 set. Verify the state of the gpnvm-bits after a manual flash erase. Writing ST STR71x internal flash-memory

The basic approach is the same as already presented for the other targets.

The configuration-file - here for an FT2232-based device connected to a STR710:

  1. mthomas 8/2007
  1. daemon configuration

telnet_port 4444 gdb_port 3333

  1. interface - FT2232-based JTAG device

interface ft2232 ft2232_device_desc "Amontec JTAGkey A" ft2232_layout jtagkey ft2232_vid_pid 0x0403 0xcff8 jtag_speed 0 jtag_nsrst_delay 200 jtag_ntrst_delay 200

    1. interface - Wiggler-Type JTAG-device
    2. interface parport
    3. parport_port 0x378
    4. parport_cable wiggler
    5. jtag_speed 0
    6. jtag_nsrst_delay 20
    7. jtag_ntrst_delay 20
  1. use combined on interfaces or targets that can't set TRST/SRST separately

reset_config trst_and_srst srst_pulls_trst

  1. jtag scan chain
  2. format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)

jtag_device 4 0x1 0xf 0xe

  1. target configuration

daemon_startup reset

  1. target
  2. target arm7tdmi

target arm7tdmi little run_and_init 0 arm7tdmi run_and_halt_time 0 30

target_script 0 reset openocd_str710_flash.script

  1. flash-configuration STR710FZ2/STR711FR2:
  2. internal flash at address 0x40000000 size 256kB (0x40000)
  3. internal ram at address 0x20000000 size 64kB (0x10000)
  4. a 16kB working area inside RAM:

working_area 0 0x2000C000 0x4000 nobackup

    1. up to version SVN188:
    2. flash bank str7x <base> <size> 0 0 <variant> <target#>

flash bank str7x 0x40000000 0x00040000 0 0 STR71x 0

    1. from Version SVN189:
    2. flash bank str7x <base> <size> 0 0 <target#> <variant>
  1. flash bank str7x 0x40000000 0x00040000 0 0 0 STR71x
    1. possible variants: STR71x STR73x STR75x


The "reset"-script:

  1. The following command wills be executed on
  2. reset (because of run_and_init in the config-file)
  3. - wait for target halt
  4. - erase memory
  5. - flash content of file main.bin into target-memory
  6. - shutdown openocd
  7. created by Martin Thomas 8/2007
  8. http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects
  9. based on information from Dominic Rath

arm7_9 dcc_downloads enable wait_halt sleep 10 poll flash probe 0

  1. STR710FZ2 erase all banks:
  2. flash erase 0 0 9
  3. STR710FZ2 erase first 5 banks (0-4)

flash erase 0 0 4

  1. if flash earse is not available in your OpenOCD-version use
  2. flash erase_sector but also read the documentation on
  3. flash auto_erase which can be used together with flash write_image

flash write 0 main.bin 0x0

  1. flash write may not be available in your OpenOCD-version
  2. alternative: flash write_binary (flash write_binary <bank-num> <file> <offset>)
  3. flash write_binary 0 main.bin 0x0
  4. flash write_binary may not be available in your OpenOCD-version
  5. alternatives: flash write_bank or flash write_image
  6. syntax: flash write_image <file> [offset] [type] where type can
  7. be ihex, bin, elf or s19
  8. flash write_bank flash-bank bin-filename offset
  9. i.e. flash write_bank 0 main.bin 0x0

reset run sleep 10 shutdown

You may have to "unprotect" the flash using the flash protect command thru the telnet-interface once. Please read the Flash-Programming Application-Note available from st.com!

Currently I just provide a small example-package with demonstrates how the internal flash of a STR710 can be programmed using OpenOCD. You can download the demo-package including the OpenOCD configuration, programming-script and a small example-application here. The method has been tested with the ST STR710 evaluation-board. Programming external CFI flash-memories

OpenOCD also suppots programming of external flash memories. The following example has been created for an STMicro STR710 controller and has been tested with the external flash-memory ST M28W320B (4Mbytes) as on the STR710 evaluation-board. But the approach is rather general and should be easily portable to other targets.

rem Filename: openocd_setup.cmd

rem set OOCD_INSTALLDIR=C:\Programme\openocd-2006re100\bin rem set OOCD_EXE=%OOCD_INSTALLDIR%\openocd-ftd2xx.exe rem set OOCD_EXE=%OOCD_INSTALLDIR%\openocd-pp.exe

set OOCD_INSTALLDIR=C:\WinARM\utils\OpenOCD set OOCD_EXE=%OOCD_INSTALLDIR%\openocd.exe

rem The used interface either FTDI(=WinARM-JTAG, JTAGKEY etc.) or PP(="Wiggler") set OOCD_INTERFACE=ftdi rem set OOCD_INTERFACE=pp

set OOCD_TARGET=str710 rem set OOCD_OPT=-d 2 set OOCD_OPT=

set OOCD_DBG_CONFIG=openocd_dbg_%OOCD_TARGET%_%OOCD_INTERFACE%.cfg set OOCD_FLASH_CONFIG=openocd_flash_%OOCD_TARGET%_%OOCD_INTERFACE%.cfg set OOCD_FLASH_CFI_CONFIG=openocd_flash_cfi_%OOCD_INTERFACE%.cfg

@echo off rem Filename: openocd_start_flash_cfi.cmd

call openocd_setup.cmd

rem start %OOCD_EXE% %OOCD_OPT% -f %OOCD_FLASH_CFI_CONFIG% %OOCD_EXE% %OOCD_OPT% -f %OOCD_FLASH_CFI_CONFIG%

rem pause

  1. Filename: openocd_flash_cfi_ftdi.cfg
  2. mthomas 5/2007
  1. daemon configuration

telnet_port 4444 gdb_port 3333

  1. interface

interface ft2232 ft2232_device_desc "Amontec JTAGkey A" ft2232_layout jtagkey ft2232_vid_pid 0x0403 0xcff8 jtag_speed 0 jtag_nsrst_delay 200 jtag_ntrst_delay 200

  1. use combined on interfaces or targets that can't set TRST/SRST separately

reset_config trst_and_srst srst_pulls_trst

  1. jtag scan chain
  2. format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)

jtag_device 4 0x1 0xf 0xe

  1. target configuration

daemon_startup reset

  1. target
  2. target arm7tdmi

target arm7tdmi little run_and_init 0 arm7tdmi run_and_halt_time 0 30

target_script 0 reset openocd_flash_cfi.script

  1. flash-configuration STR710:
  2. internal flash at address 0x40000000 size 256kB (0x40000)
  3. internal ram at address 0x20000000 size 64kB (0x10000)
  4. STR710 eval-board:
  5. external flash at address 0x60000000 size 4096kB (0x400000) EMI-Bank0
  1. a 16kB working area inside RAM:

working_area 0 0x2000C000 0x4000 nobackup

    1. up to version SVN188:
    2. flash bank str7x 0 0
  1. flash bank str7x 0x40000000 0x00040000 0 0 STR71x 0
    1. from Version SVN189:
    2. flash bank str7x 0 0
  2. flash bank str7x 0x40000000 0x00040000 0 0 0 STR71x
    1. possible variants: STR71x STR73x STR75x
  1. several banks can be configured here but is only define one to avoid
  2. confusion, here for the external CFI flash on the STR710 eval-board:

flash bank cfi 0x60000000 0x400000 2 2 0

  1. For more information about the configuration files, take a look at:
  2. http://openfacts.berlios.de/index-en.phtml?title=Open+On-Chip+Debugger
  1. Filename: openocd_flash_cfi.script
  2. The following command wills be executed on
  3. reset (because of run_and_init in the config-file)
  4. - wait for target halt
  5. - erase memory
  6. - flash content of file main.bin into target-memory at offset 0
  7. - shutdown openocd
  8. created by Martin Thomas
  9. http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects
  10. based on information from Dominic Rath
  11. *** PRELIMINARY ***

arm7_9 dcc_downloads enable wait_halt sleep 10 poll flash probe 0

  1. external CFI flash unprotect and erase first
  2. 5 banks (0-4) (40kB)

flash protect 0 0 4 off flash erase 0 0 4

  1. new OpenOCD versions: flash erase_sector

flash write 0 main.bin 0x0

  1. flash write is deprecated but still available. Alternatives:
  2. (1) same syntax as flash write  : flash write_binary 0 main.bin 0x0
  3. syntax: flash write_binary
  4. new OpenOCD versions: flash write_bank 0 main.bin 0x0
  5. (2) can handle different formats: flash write_image main.bin 0x0 bin
  6. syntax: flash write_image [offset] [type] where type can
  7. be ihex, bin, elf or s19


sleep 10 reset run sleep 10 shutdown

Starting openocd_start_flash_cfi.cmd will first execute openocd_setup.cmd to read in the general setup (OpenOCD install-path, used interface etc.) and set some environment variables. These variables are used to determine the paramater for openocd.exe which is called by the openocd_start_flash_cfi.cmd too. Both cmd-files are made for MS-Windows OS but can be easily ported to Unix/Linux "shell-scripts". OpenOCD will start and read the openocd_flash_cfi_ftdi.cfg script and after initalisiation of the JTAG-interface it will reset the target ARM and process the commands listed in the openocd_flash_cfi.script file. The cfg-file is currently prepared for a JTAGkey (or the compatible WinARM-JTAG) but can be easily adapted to other FTDI2232-based interfaces or parallel-port interfaces ("Wigglers") by modifing the interface-section in the cfg-file. Examples on this and other pages may serve as templates.

[Download] a zip-archive which includes the cmd-, cfg- and script-files together with an example-application source-code

And yes, the described method can be used to install uClinux on the STR710 eval-board (I have tested this "here"). The bootloader available in the Code-Package for ST's application-note AN2119 "Getting Started with uClinux for STR71x" can be uploaded to the external flash using OpenOCD. Create the OpenOCD configuration- and reset-script "on the fly"

Here a approach to create the needed configuration-script and the reset-script which inlcude the flash-programming command "on the fly" in a makefile.

The following file uses the makefile-syntax. Basicly it's a makefile but it gets included from the application's makefile. I have choosen this approach since including everything in a single makefile would be a little confusing. This example demonstrates the setup to flash the internal flash-memory of an STMicrosystems STR710 but can be adapted to other targets easily. The content of the file oocd_flashing.mk:

  1. Hey Emacs, this is a -*- makefile -*-
  2. Auto-create OpenOCD cfg and script
  3. by Martin Thomas, Kaiserslautern, Germany
  4. eversmith(at)heizung-thomas(dot)de
  5. Example for STR710 internal flash
  6. THIS HAS BEEN TESTED WITH OPENOCD 207(something...)
  7. in newer versions of OpenOCD some commands are not
  8. longer available and have been replaced

OOCD_comment=for STR710 internal flash

ifndef OOCD_load_image OOCD_load_image=main.bin $(warning OOCD_load_image not defined - using default $(OOCD_load_image) ) endif

  1. filename for the OpenOCD-config:

OOCD_CFG=oocd.cfg

  1. filename for the OpenOCD-reset-script:

OOCD_SCRIPT=oocd.script

  1. Location OpenOCD executeables
  2. for my precompiled package - all in one

OOCD_INSTALLDIR=./OpenOCD/ OOCD_BIN_FTDI=$(OOCD_INSTALLDIR)/openocd.exe OOCD_BIN_PP=$(OOCD_INSTALLDIR)/openocd.exe

  1. for Michael Fischers precompiled package (separat)
  2. OOCD_INSTALLDIR=C:/Programme/openocd-2006re100/bin
  3. OOCD_BIN_FTDI=$(OOCD_INSTALLDIR)/openocd-ftd2xx.exe
  4. OOCD_BIN_PP=$(OOCD_INSTALLDIR)/openocd-pp.exe
  1. JTAG hardware interface
    1. Type

OOCD_INTERFACE=FTDI

  1. OOCD_INTERFACE=PARPORT

ifeq ($(OOCD_INTERFACE),FTDI) OOCD_BIN=$(OOCD_BIN_FTDI) else OOCD_BIN=$(OOCD_BIN_PP) endif

    1. settings FT2232 based devices

OOCD_ft2232_device_desc=Amontec JTAGkey A OOCD_ft2232_layout=jtagkey OOCD_ft2232_vid_pid=0x0403 0xcff8

    1. settings for parport devices ("Wigglers")

OOCD_parport_port=0x378" OOCD_parport_cable=wiggler"

  1. JTAG speed and reset-delay settings

OOCD_jtag_speed=0

    1. in [ms]:

OOCD_jtag_nsrst_delay=200 OOCD_jtag_ntrst_delay=200 OOCD_run_and_halt_time="0 30"

OOCD_reset_config=trst_and_srst srst_pulls_trst

  1. OOCE_reset_config="srst_only srst_pulls_trst"

OOCD_jtag_device="4 0x1 0xf 0xe" OOCD_daemon_startup=reset OOCD_target=arm7tdmi little run_and_init 0 arm7tdmi

  1. OOCD_target=arm7tdmi little run_and_init 0 arm7tdmi-s_r4

OOCD_target_script=0 reset $(OOCD_SCRIPT)

OOCD_working_area_start=0x2000C000 OOCD_working_area_size=0x4000 OOCD_working_area=0 $(OOCD_working_area_start) \ $(OOCD_working_area_size) nobackup

OOCD_bank=0

OOCD_flash_bank_pref=str7x OOCD_flash_bank_start=0x40000000 OOCD_flash_bank_size=0x00040000

  1. for OpenOCD up to SVN188:

OOCD_flash_bank_suf=0 0 STR71x 0

  1. from SVN189:
  2. OOCD_flash_bank_suf=0 0 0 STR71x

OOCD_flash_bank=$(OOCD_flash_bank_pref) $(OOCD_flash_bank_start) \ $(OOCD_flash_bank_size) $(OOCD_flash_bank_suf)

OOCD_cfg_opt_line1="" OOCD_cfg_opt_line2="" OOCD_cfg_opt_line3=""

OOCD_script_pre1=arm7_9 dcc_downloads enable OOCD_script_pre2=wait_halt OOCD_script_pre3=sleep 10 OOCD_script_pre4="" OOCD_script_pre5=""

OOCD_script_flash_probe=flash probe $(OOCD_bank)

  1. optional after probe before erase (unprotect etc.)

OOCD_script_optprep1="" OOCD_script_optprep2=""

OOCD_script_flash_erase_first=0 OOCD_script_flash_erase_last=4 OOCD_script_flash_erase=flash erase $(OOCD_bank) \ $(OOCD_script_flash_erase_first) $(OOCD_script_flash_erase_last)

    1. new versions
    2. OOCD_script_flash_erase=flash erase_sector $(OOCD_bank) \
    3. $(OOCD_script_flash_erase_first) $(OOCD_script_flash_erase_last)

OOCD_script_flash_write_offset=0

  1. using the deprecated flash write command:

OOCD_script_flash_write=flash write $(OOCD_bank) \ $(OOCD_load_image) $(OOCD_script_flash_write_offset)

  1. "new" command:
  2. OOCD_script_flash_write=flash write_binary $(OOCD_bank) \
  3. $(OOCD_load_image) $(OOCD_script_flash_write_offset)
  1. even "newer" command
  2. OOCD_script_flash_write=flash write_bank $(OOCD_bank) \
  3. $(OOCD_load_image) $(OOCD_script_flash_write_offset)


OOCD_script_suf1=reset run OOCD_script_suf2=sleep 10 OOCD_script_suf3="" OOCD_script_suf4="" OOCD_script_suf5=""

  1. Additonal options passed to the OpenOCD executable
  2. OOCD_OPTIONS=-d 2

OOCD_OPTIONS=

  1. oocd_program: oocd_programprepare oocd_programdoit

oocd_programprepare: @echo "Generating OpenOCD config ($(OOCD_comment))..." @echo "# generated OpenOCD config (M. Thomas's generator)" > $(OOCD_CFG) @echo "# $(OOCD_comment)" >> $(OOCD_CFG) @echo "telnet_port 4444" >> $(OOCD_CFG) @echo "gdb_port 3333" >> $(OOCD_CFG)

ifeq ($(OOCD_INTERFACE),FTDI) @echo "interface ft2232" >> $(OOCD_CFG) @echo "ft2232_device_desc \"$(OOCD_ft2232_device_desc)\"" >> $(OOCD_CFG) @echo "ft2232_layout $(OOCD_ft2232_layout)" >> $(OOCD_CFG) @echo "ft2232_vid_pid $(OOCD_ft2232_vid_pid)" >> $(OOCD_CFG) else @echo "interface parport" >> $(OOCD_CFG) @echo "parport_port $(OOCD_parport_port)" >> $(OOCD_CFG) @echo "parport_cable $(OOCD_parport_cable)" >> $(OOCD_CFG) endif @echo "jtag_speed $(OOCD_jtag_speed)" >> $(OOCD_CFG) @echo "jtag_nsrst_delay $(OOCD_jtag_nsrst_delay)" >> $(OOCD_CFG) @echo "jtag_ntrst_delay $(OOCD_jtag_ntrst_delay)" >> $(OOCD_CFG)

@echo "reset_config $(OOCD_reset_config)" >> $(OOCD_CFG) @echo "jtag_device $(OOCD_jtag_device)" >> $(OOCD_CFG) @echo "daemon_startup $(OOCD_daemon_startup)" >> $(OOCD_CFG) @echo "target $(OOCD_target)" >> $(OOCD_CFG) @echo "target_script $(OOCD_target_script)" >> $(OOCD_CFG) @echo "working_area $(OOCD_working_area)" >> $(OOCD_CFG) @echo "flash bank $(OOCD_flash_bank)" >> $(OOCD_CFG) @echo "$(OOCD_cfg_opt_line1)" >> $(OOCD_CFG) @echo "$(OOCD_cfg_opt_line2)" >> $(OOCD_CFG) @echo "$(OOCD_cfg_opt_line3)" >> $(OOCD_CFG)

@echo "Generating OpenOCD script ($(OOCD_comment))..." @echo "# generated OpenOCD reset-script (M. Thomas's generator)" > $(OOCD_SCRIPT) @echo "# $(OOCD_comment)" >> $(OOCD_SCRIPT)

@echo "$(OOCD_script_pre1)" >> $(OOCD_SCRIPT) @echo "$(OOCD_script_pre2)" >> $(OOCD_SCRIPT) @echo "$(OOCD_script_pre3)" >> $(OOCD_SCRIPT) @echo "$(OOCD_script_pre4)" >> $(OOCD_SCRIPT) @echo "$(OOCD_script_pre5)" >> $(OOCD_SCRIPT)

@echo "$(OOCD_script_flash_probe)" >> $(OOCD_SCRIPT)

@echo "$(OOCD_script_optprep1)" >> $(OOCD_SCRIPT) @echo "$(OOCD_script_optprep2)" >> $(OOCD_SCRIPT)

@echo "$(OOCD_script_flash_erase)" >> $(OOCD_SCRIPT) @echo "$(OOCD_script_flash_write)" >> $(OOCD_SCRIPT)

@echo "$(OOCD_script_suf1)" >> $(OOCD_SCRIPT) @echo "$(OOCD_script_suf2)" >> $(OOCD_SCRIPT) @echo "$(OOCD_script_suf3)" >> $(OOCD_SCRIPT) @echo "$(OOCD_script_suf4)" >> $(OOCD_SCRIPT) @echo "$(OOCD_script_suf5)" >> $(OOCD_SCRIPT)

@echo "shutdown" >> $(OOCD_SCRIPT)

oocd_programdoit: @echo "Flashing with OpenOCD ($(OOCD_comment))..." $(OOCD_BIN) $(OOCD_OPTIONS) -f $(OOCD_CFG)

As you can see everything can be configured in this file. The program-target in the projects makefile looks like this:

  1. set the load-file name to be used (i.e. if target=main,
  2. the load-file programmed with openocd is main.bin)

OOCD_load_image=$(TARGET).bin

  1. include the OpenOCD "file-generator" targets

include oocd_flashing.mk

  1. the applications program target
  2. on make program first the load-file gets build thru the dependency,
  3. then the OpenOCD configuration-script and reset-script gets created
  4. by calling the oocd_programprepare target defined in oocd_flashing.mk
  5. and finaly OpenOCD gets called thru the oocd_programdoit target as
  6. defined in oocd_flashing.mk

program : $(TARGET).bin oocd_programprepare oocd_programdoit

  1. This could be used to just start the programming without creating the files
  2. (i.e. if they have already been created by a previous run and the
  3. setup has not been changed (comment the previous program target line an
  4. uncomment the following:
  5. program : $(TARGET).bin oocd_programdoit

An example with all needed files can be found here.



doc

arm7 Books

Unofficial Bug List

Common problems and Gotchas

Interesting links

http://ics.nxp.com/support/documents/microcontrollers/?scope=LPC2000&type=appnote

Tips & Tricks

App

ucOS/2 for keil

  • early ported, it is running 2 tasks

freeRTOS for keil

  • early ported, it is running demo tasks


bareboard

  • rtc
  • webserver tcp/ip
  • convert the nx board into "usb-memory"