<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.ethernut.de/nutwiki/index.php?action=history&amp;feed=atom&amp;title=Hardware%2FEIR%2FOpenOCD%2FConvent</id>
		<title>Hardware/EIR/OpenOCD/Convent - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.ethernut.de/nutwiki/index.php?action=history&amp;feed=atom&amp;title=Hardware%2FEIR%2FOpenOCD%2FConvent"/>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Hardware/EIR/OpenOCD/Convent&amp;action=history"/>
		<updated>2026-04-28T22:50:11Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://www.ethernut.de/nutwiki/index.php?title=Hardware/EIR/OpenOCD/Convent&amp;diff=396&amp;oldid=prev</id>
		<title>Harald: Created page with &quot;&lt;div id=&quot;content&quot;&gt;  = OpenOCD for AT91SAM7SE - Part 8 =  This is part 8 of our OpenOCD for AT91SAM7SE tutorial.  == OpenOCD Script Conventions ==  So far we h...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Hardware/EIR/OpenOCD/Convent&amp;diff=396&amp;oldid=prev"/>
				<updated>2017-07-13T09:04:28Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;div id=&amp;quot;content&amp;quot;&amp;gt;  = OpenOCD for AT91SAM7SE - Part 8 =  This is part 8 of our &lt;a href=&quot;/nutwiki/index.php?title=Openocd.html&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Openocd.html (page does not exist)&quot;&gt;OpenOCD for AT91SAM7SE tutorial&lt;/a&gt;.  == OpenOCD Script Conventions ==  So far we h...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;div id=&amp;quot;content&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= OpenOCD for AT91SAM7SE - Part 8 =&lt;br /&gt;
&lt;br /&gt;
This is part 8 of our [[openocd.html|OpenOCD for AT91SAM7SE tutorial]].&lt;br /&gt;
&lt;br /&gt;
== OpenOCD Script Conventions ==&lt;br /&gt;
&lt;br /&gt;
So far we have stored our complete configuration in a local file named openocd.cfg, which is loaded by OpenOCD automatically, if it exists.&lt;br /&gt;
&lt;br /&gt;
In this part we will split this configuration into several files to make it a bit more re-usable. OpenOCD allows to include external configuration files into our local configuration. So we may re-write openocd.cfg to something like&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;add_script_search_dir [/usr/share/openocd/scripts]&lt;br /&gt;
source [find interface/turtelizer2.cfg]&lt;br /&gt;
source [find board/eir.cfg]&amp;lt;/pre&amp;gt;&lt;br /&gt;
where &amp;lt;code&amp;gt;board/eir.cfg&amp;lt;/code&amp;gt; further includes the CPU configuration by using&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;source [find target/at91sam7se512.cfg]&amp;lt;/pre&amp;gt;&lt;br /&gt;
Actually OpenOCD provides a number of prepared configuration scripts, which you may use for your specific configuration. We will also discuss the conventions used in these scripts.&lt;br /&gt;
&lt;br /&gt;
=== Separating Adapter Configurations ===&lt;br /&gt;
&lt;br /&gt;
Obviously, it will make a lot of sense to move adapter specific configurations into a separate configuration file. It allows to use the same target board with different JTAG adapters. However, the devil is in the details. Let's take a look to the reset configuration as an example. We defined&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;reset_config srst_only&amp;lt;/pre&amp;gt;&lt;br /&gt;
which is perfect when using Turtelizer 2 Rev-B with the EIR board, because neither of them provides the TAP reset signal nTRST. However, Turtelizer 2 Rev-C does provide it, and the same is true for Ethernut 5. The following table shows, that the reset configuration can't be clearly assigned to the adapter or the board, because it depends on both.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!  &lt;br /&gt;
! Turtelizer 2.0B&lt;br /&gt;
! Turtelizer 2.0C&lt;br /&gt;
|-&lt;br /&gt;
| EIR&lt;br /&gt;
| srst_only&lt;br /&gt;
| srst_only&lt;br /&gt;
|-&lt;br /&gt;
| Ethernut 5&lt;br /&gt;
| srst_only&lt;br /&gt;
| trst_and_srst&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The OpenOCD manual states, that &amp;lt;code&amp;gt;reset_config&amp;lt;/code&amp;gt; belongs to the board configuration. That doesn't make much sense either, because in most cases this is CPU specific. In very rare cases the board may not route the nTRST signal to the JTAG connector, although it's available on the CPU. Fact is, that in the official OpenOCD distribution &amp;lt;code&amp;gt;reset_config&amp;lt;/code&amp;gt; is provided in about 75 board configurations, but also, against the stated rule, in nearly 50 CPU configurations. This includes the configuration for the AT91SAM7SE, which is even wrongly specified, as far as I can say:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;reset_config srst_only srst_pulls_trst ;# This is incorrect, do not use!&amp;lt;/pre&amp;gt;&lt;br /&gt;
As explained, nTRST doesn't matter for the AT91SAM7SE and we can painlessly fulfill the rule, assigning it to the board configuration. So, the following lines are left for our adapter configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;interface ft2232&lt;br /&gt;
ft2232_layout turtelizer2&lt;br /&gt;
ft2232_device_desc &amp;amp;quot;Turtelizer JTAG/RS232 Adapter&amp;amp;quot;&lt;br /&gt;
ft2232_vid_pid 0x0403 0xbdc8&amp;lt;/pre&amp;gt;&lt;br /&gt;
Again, you may have to replace &amp;lt;code&amp;gt;interface ft2232&amp;lt;/code&amp;gt; by &amp;lt;code&amp;gt;interface turtle&amp;lt;/code&amp;gt; when using the Turtelizer support package.&lt;br /&gt;
&lt;br /&gt;
Also note, that the last line, specifying VID and PID, is not really required. When using more than one Turtelizer concurrently on the same PC, you must create a separate configuration file for each of them and additionally declare the unique serial number of the individual adapter in each file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;ft2232_serial &amp;amp;lt;serial number&amp;amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Separating CPU and Board Configurations ===&lt;br /&gt;
&lt;br /&gt;
Without question, separating CPU and board specific configuration has the advantage, that we can re-use CPU configurations for other boards which are based on the same CPU. Again, some configuration items may not be clearly assignable to either the CPU or the board.&lt;br /&gt;
&lt;br /&gt;
Definitely, the reset-init event handler and all the procedures called from within this handler belong to the board configuration. Other board may use&lt;br /&gt;
&lt;br /&gt;
* different crystals (eir_init_clock)&lt;br /&gt;
* different or no SDRAM (eir_init_sdram)&lt;br /&gt;
* the memory bus pins for GPIO (eir_init_membus)&lt;br /&gt;
&lt;br /&gt;
As discussed above, we will also assign the reset configuration to the board. Here is the resulting file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;reset_config srst_only&lt;br /&gt;
adapter_khz 8&lt;br /&gt;
&lt;br /&gt;
sam7se512.cpu configure -event reset-init { eir_init }&lt;br /&gt;
&lt;br /&gt;
# Initialize the EIR board.&lt;br /&gt;
#&lt;br /&gt;
proc eir_init {} {&lt;br /&gt;
        eir_init_clock&lt;br /&gt;
&lt;br /&gt;
        # Minimum ICE cycle time is 102ns (9800 kHz)&lt;br /&gt;
        adapter_khz 9800&lt;br /&gt;
        arm7_9 dcc_downloads enable&lt;br /&gt;
        arm7_9 fast_memory_access enable&lt;br /&gt;
&lt;br /&gt;
        eir_init_membus&lt;br /&gt;
        eir_init_sdram&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Initialize the EIR clocks.&lt;br /&gt;
#&lt;br /&gt;
# The board uses an 18.432MHz crystal.&lt;br /&gt;
# Let the CPU run at 48MHz.&lt;br /&gt;
#&lt;br /&gt;
proc eir_init_clock {} {&lt;br /&gt;
&lt;br /&gt;
        # Enable main oscillator.&lt;br /&gt;
        #&lt;br /&gt;
        # Start-up time of 6 x 8 slow clocks.&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xfffffc20 0x00000601       ;# CKGR_MOR&lt;br /&gt;
        sleep 2&lt;br /&gt;
&lt;br /&gt;
        # Configure the PLL.&lt;br /&gt;
        #&lt;br /&gt;
        # 18.432MHz * (72 + 1) / 14 = 96MHz&lt;br /&gt;
        #&lt;br /&gt;
        # Divider 14 (0x0e)&lt;br /&gt;
        # Start-up time of 28 (0x1c) slow clocks&lt;br /&gt;
        # Multiplier 72 (0x48)&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xfffffc2C 0x00481c0e       ;# CKGR_PLLR&lt;br /&gt;
        sleep 1&lt;br /&gt;
&lt;br /&gt;
        # Select PLL clock and divide it by 2&lt;br /&gt;
        #&lt;br /&gt;
        # 96MHz / 2 = 48MHz&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xfffffc30 0x00000007       ;# PMC_MCKR&lt;br /&gt;
        sleep 1&lt;br /&gt;
&lt;br /&gt;
        # 1 wait for read, 2 waits for write&lt;br /&gt;
        # We have 48 master clocks in 1us&lt;br /&gt;
        mww 0xffffff60 0x00480100       ;# MC_FMR&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Initialize external memory bus.&lt;br /&gt;
#&lt;br /&gt;
proc eir_init_membus {} {&lt;br /&gt;
        # Enable address bus (A0, A2-A11, A13-A17) at PIO B&lt;br /&gt;
        mww 0xfffff674 0x0003effd ;# PIOB_BSR&lt;br /&gt;
        mww 0xfffff604 0x0003effd ;# PIOB_PDR&lt;br /&gt;
&lt;br /&gt;
        # Enable 16 bit data bus at PIO C&lt;br /&gt;
        mww 0xfffff870 0x0000ffff ;# PIOC_ASR&lt;br /&gt;
        mww 0xfffff804 0x0000ffff ;# PIOC_PDR&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# Initialize the EIR SDRAM.&lt;br /&gt;
#&lt;br /&gt;
# EIR uses Samsung K4S511632D-UC75 SDRAM:&lt;br /&gt;
# Organization: 32M x 16&lt;br /&gt;
# 8k rows, 1k columns&lt;br /&gt;
# 20ns row precharge time&lt;br /&gt;
# 45ns min. and 100us max. row active time&lt;br /&gt;
#&lt;br /&gt;
# MCK cycle is 20ns when running at 48MHz.&lt;br /&gt;
#&lt;br /&gt;
proc eir_init_sdram {} {&lt;br /&gt;
&lt;br /&gt;
        # Enable SDRAM control at PIO A&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xfffff474 0x3f800000 ;# PIOA_BSR&lt;br /&gt;
        mww 0xfffff404 0x3f800000 ;# PIOA_PDR&lt;br /&gt;
&lt;br /&gt;
        # Enable SDRAM chip select&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffff80 0x00000002 ;# EBI_CSA&lt;br /&gt;
&lt;br /&gt;
        # Set SDRAM characteristics in configuration register.&lt;br /&gt;
        # At 48MHz 1 cycle is about 21ns.&lt;br /&gt;
        #&lt;br /&gt;
        # 0x00000003 NC: Number of column bits&lt;br /&gt;
        # 0x00000002 10 bits, 1k columns&lt;br /&gt;
        #&lt;br /&gt;
        # 0x0000000C NR: Number of row bits&lt;br /&gt;
        # 0x00000008 13 bits, 8k rows&lt;br /&gt;
        #&lt;br /&gt;
        # 0x00000010 NB: Number of banks&lt;br /&gt;
        # 0x00000010 4 banks&lt;br /&gt;
        #&lt;br /&gt;
        # 0x00000060 CAS: CAS latency&lt;br /&gt;
        # 0x00000040 2 cycles&lt;br /&gt;
        #&lt;br /&gt;
        # 0x00000780 TWR: Write recovery delay&lt;br /&gt;
        # 0x00000100 2 cycles&lt;br /&gt;
        #&lt;br /&gt;
        # 0x00007800 TRC: Row cycle delay&lt;br /&gt;
        # 0x00002000 4 cycles&lt;br /&gt;
        #&lt;br /&gt;
        # 0x00078000 TRP: Row precharge delay&lt;br /&gt;
        # 0x00020000 4 cycles&lt;br /&gt;
        #&lt;br /&gt;
        # 0x00780000 TRCD: Row to column delay&lt;br /&gt;
        # 0x00100000 2 cycles&lt;br /&gt;
        #&lt;br /&gt;
        # 0x07800000 TRAS: Active to precharge delay&lt;br /&gt;
        # 0x01800000 3 cycles&lt;br /&gt;
        #&lt;br /&gt;
        # 0x78000000 TXSR: Exit self refresh to active delay&lt;br /&gt;
        # 0x20000000 4 cycles&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffffb8 0x2192215a ;# SDRAMC_CR&lt;br /&gt;
        sleep 10&lt;br /&gt;
&lt;br /&gt;
        # Issue 16 bit SDRAM command: NOP&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffffb0 0x00000011 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
&lt;br /&gt;
        # Issue 16 bit SDRAM command: Precharge all&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffffb0 0x00000012 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
&lt;br /&gt;
        # Issue 8 auto-refresh cycles&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
&lt;br /&gt;
        # Issue 16 bit SDRAM command: Set mode register&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffffb0 0x00000013 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000014 0xcafedede&lt;br /&gt;
&lt;br /&gt;
        # Set refresh rate count ???&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffffb4 0x00000013 ;# SDRAMC_TR&lt;br /&gt;
&lt;br /&gt;
        # Issue 16 bit SDRAM command: Normal mode&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffffb0 0x00000010 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000180&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
Configuration of the TAP, the debug target and the internal flash memory are definitely CPU related.&lt;br /&gt;
&lt;br /&gt;
Defining a work area is a problem, though. By using internal RAM, we may assign it to the CPU. However, it depends on the firmware that is running on the board, how much RAM we have available and whether we should assign the lower or the upper part.&lt;br /&gt;
&lt;br /&gt;
While a work area is not mandatory, it is essential for user experience, because it significantly improves the JTAG data transfer. The suggestion is to define it in the CPU configuration. If it interferes with running firmware, it may be overridden in a user configuration file.&lt;br /&gt;
&lt;br /&gt;
This will give us the following CPU configuration for the AT91SAM7SE512:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;jtag newtap sam7se512 cpu -irlen 4 -expected-id 0x3f0f0f0f&lt;br /&gt;
target create sam7se512.cpu arm7tdmi -chain-position sam7se512.cpu&lt;br /&gt;
sam7se512.cpu configure -work-area-phys 0x00206000 -work-area-size 0x4000&lt;br /&gt;
&lt;br /&gt;
flash bank sam7se512.flash.0 at91sam7 0 0 0 0 sam7se512.cpu 0 0 0 0 0 0 0 18432&lt;br /&gt;
flash bank sam7se512.flash.1 at91sam7 0 0 0 0 sam7se512.cpu 1 0 0 0 0 0 0 18432&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Defining Tcl Variables ===&lt;br /&gt;
&lt;br /&gt;
In part 4 of the tutorial it had been pointed out, that using a script language in configuration files allows us to define procedures for event based configurations. Another, more obvious advantage is to be able to define variables. They are not really required, so far we didn't use any.&lt;br /&gt;
&lt;br /&gt;
However, variables will make code easier maintainable. For example, at many places we are referring to the chip name &amp;lt;code&amp;gt;sam7se512&amp;lt;/code&amp;gt;. Putting this name into a variable, which is used throughout the configuration instead of the literal name, would make changing it much easier. You may now ask: Why would someone want to do this? Indeed, there are several reasons.&lt;br /&gt;
&lt;br /&gt;
The most likely reason to modify the chip name is a board, which contains two AT91SAM7SE512 chips. If we put&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;if { [info exists CHIPNAME] } {&lt;br /&gt;
   set _CHIPNAME $CHIPNAME&lt;br /&gt;
} else {&lt;br /&gt;
   set _CHIPNAME sam7se512&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
into our board configuration file, then the variable _CHIPNAME will be &amp;lt;code&amp;gt;sam7se512&amp;lt;/code&amp;gt; by default. Using _CHIPNAME instead of &amp;lt;code&amp;gt;sam7se512&amp;lt;/code&amp;gt; in the remaining configuration will allow us, to use the same CPU configuration file for both CPUs.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;set CHIPNAME sam7se512.0&lt;br /&gt;
source [find target/at91sam7se512.cfg]&lt;br /&gt;
set CHIPNAME sam7se512.1&lt;br /&gt;
source [find target/at91sam7se512.cfg]&amp;lt;/pre&amp;gt;&lt;br /&gt;
Side note: Those of you, who are even less familiar with Tcl than I am, may get confused now. Let me explain. CHIPNAME and _CHIPNAME are different variable names. If you want to refer to the contents of a variable, you add a dollar sign in front. For example, $CHIPNAME will be replaced by the contents of the variable CHIPNAME.&lt;br /&gt;
&lt;br /&gt;
Almost all existing scripts use a kind of standard set of variables. Several variables are also explained in the OpenOCD manual. Thus, it is a good idea to follow this convention, even if we didn't need any of them to get our local configuration up and running.&lt;br /&gt;
&lt;br /&gt;
Here we present our final CPU configuration file. You should name it &amp;lt;code&amp;gt;at91sam7se512.cfg&amp;lt;/code&amp;gt; and store it in subdirectory &amp;lt;code&amp;gt;target&amp;lt;/code&amp;gt; of the OpenOCD installation directory, when running Windows, or &amp;lt;code&amp;gt;/usr/share/openocd/scripts&amp;lt;/code&amp;gt; on most Linux PCs. Most probably this file already exists and you should make a backup copy first. Anyway, if you compare the existing file with the one we developed during our tutorial, you won't find many differences. And if you find any, you will be able now to decide, which one is better.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;# ATMEL sam7se512&lt;br /&gt;
# Example: the &amp;amp;quot;Elektor Internet Radio&amp;amp;quot; - EIR&lt;br /&gt;
# http://www.ethernut.de/en/hardware/eir/index.html&lt;br /&gt;
&lt;br /&gt;
if { [info exists CHIPNAME] } {&lt;br /&gt;
   set _CHIPNAME $CHIPNAME&lt;br /&gt;
} else {&lt;br /&gt;
   set _CHIPNAME sam7se512&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if { [info exists ENDIAN] } {&lt;br /&gt;
   set _ENDIAN $ENDIAN&lt;br /&gt;
} else {&lt;br /&gt;
   set _ENDIAN little&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if { [info exists CPUTAPID] } {&lt;br /&gt;
   set _CPUTAPID $CPUTAPID&lt;br /&gt;
} else {&lt;br /&gt;
   set _CPUTAPID 0x3f0f0f0f&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# JTAG Test Access Point&lt;br /&gt;
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID&lt;br /&gt;
&lt;br /&gt;
# JTAG Debug Target&lt;br /&gt;
set _TARGETNAME $_CHIPNAME.cpu&lt;br /&gt;
target create $_TARGETNAME arm7tdmi -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm7tdmi&lt;br /&gt;
&lt;br /&gt;
# OpenOCD Work Area&lt;br /&gt;
$_TARGETNAME configure -work-area-phys 0x00200000 -work-area-size 0x4000 -work-area-backup 0&lt;br /&gt;
&lt;br /&gt;
# Flash Memory Banks&lt;br /&gt;
set _FLASHNAME $_CHIPNAME.flash&lt;br /&gt;
flash bank $_FLASHNAME.0 at91sam7 0 0 0 0 $_TARGETNAME 0 0 0 0 0 0 0 18432&lt;br /&gt;
flash bank $_FLASHNAME.1 at91sam7 0 0 0 0 $_TARGETNAME 1 0 0 0 0 0 0 18432&amp;lt;/pre&amp;gt;&lt;br /&gt;
And here we have the final board configuration file for the Elektor Internet Radio. This one should be named &amp;lt;code&amp;gt;eir.cfg&amp;lt;/code&amp;gt; and stored in subdirectory &amp;lt;code&amp;gt;boards&amp;lt;/code&amp;gt;. Again, keep any exiting file as a backup.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;# Elector Internet Radio Board&lt;br /&gt;
# http://www.ethernut.de/en/hardware/eir/&lt;br /&gt;
&lt;br /&gt;
source [find target/at91sam7se512.cfg]&lt;br /&gt;
&lt;br /&gt;
# Target events&lt;br /&gt;
#&lt;br /&gt;
$_TARGETNAME configure -event reset-init { eir_init }&lt;br /&gt;
&lt;br /&gt;
adapter_khz 200&lt;br /&gt;
&lt;br /&gt;
# Initialize the EIR board.&lt;br /&gt;
#&lt;br /&gt;
proc eir_init {} {&lt;br /&gt;
        eir_init_reset&lt;br /&gt;
        eir_init_clock&lt;br /&gt;
&lt;br /&gt;
        # Minimum ICE cycle time is 102ns (9800 kHz)&lt;br /&gt;
        adapter_khz 5000&lt;br /&gt;
        arm7_9 dcc_downloads enable       ;# Enable faster DCC downloads&lt;br /&gt;
        arm7_9 fast_memory_access enable&lt;br /&gt;
        #jtag_khz 9800&lt;br /&gt;
&lt;br /&gt;
        eir_init_sdram&lt;br /&gt;
#       flash probe 0&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Initialize the EIR reset logic.&lt;br /&gt;
#&lt;br /&gt;
proc eir_init_reset {} {&lt;br /&gt;
&lt;br /&gt;
        # Disable watchdog&lt;br /&gt;
        mww 0xfffffd44 0x00008000       ;# WDT_MR&lt;br /&gt;
&lt;br /&gt;
        # Enable user reset&lt;br /&gt;
        mww 0xfffffd08 0xa5000001       ;# RSTC_MR&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Initialize the EIR clocks.&lt;br /&gt;
#&lt;br /&gt;
# The board uses an 18.432MHz crystal.&lt;br /&gt;
# Let the CPU run at 48MHz.&lt;br /&gt;
#&lt;br /&gt;
proc eir_init_clock {} {&lt;br /&gt;
&lt;br /&gt;
        # Enable main oscillator.&lt;br /&gt;
        #&lt;br /&gt;
        # Start-up time of 6 x 8 slow clocks.&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xfffffc20 0x00000601       ;# CKGR_MOR&lt;br /&gt;
        sleep 2&lt;br /&gt;
&lt;br /&gt;
        # Configure the PLL.&lt;br /&gt;
        #&lt;br /&gt;
        # 18.432MHz * (72 + 1) / 14 = 96MHz&lt;br /&gt;
        #&lt;br /&gt;
        # Divider 14 (0x0e)&lt;br /&gt;
        # Start-up time of 28 (0x1c) slow clocks&lt;br /&gt;
        # Multiplier 72 (0x48)&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xfffffc2C 0x00481c0e       ;# CKGR_PLLR&lt;br /&gt;
        sleep 1&lt;br /&gt;
&lt;br /&gt;
        # Select PLL clock and divide it by 2&lt;br /&gt;
        #&lt;br /&gt;
        # 96MHz / 2 = 48MHz&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xfffffc30 0x00000007       ;# PMC_MCKR&lt;br /&gt;
        sleep 1&lt;br /&gt;
&lt;br /&gt;
        # 1 wait for read, 2 waits for write&lt;br /&gt;
        # We have 48 master clocks in 1us&lt;br /&gt;
        mww 0xffffff60 0x00480100       ;# MC_FMR&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Initialize the EIR SDRAM.&lt;br /&gt;
#&lt;br /&gt;
# EIR uses Samsung K4S511632D-UC75 SDRAM:&lt;br /&gt;
# Organization: 32M x 16&lt;br /&gt;
# 8k rows, 1k columns&lt;br /&gt;
# 20ns row precharge time&lt;br /&gt;
# 45ns min. and 100us max. row active time&lt;br /&gt;
#&lt;br /&gt;
# MCK cycle is 20ns when running at 48MHz.&lt;br /&gt;
#&lt;br /&gt;
proc eir_init_sdram {} {&lt;br /&gt;
&lt;br /&gt;
        # Enable address and data bus&lt;br /&gt;
        #&lt;br /&gt;
        eir_init_membus&lt;br /&gt;
&lt;br /&gt;
        # Enable SDRAM control at PIO A&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xfffff474 0x3f800000 ;# PIOA_BSR&lt;br /&gt;
        mww 0xfffff404 0x3f800000 ;# PIOA_PDR&lt;br /&gt;
&lt;br /&gt;
        # Enable SDRAM chip select&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffff80 0x00000002 ;# EBI_CSA&lt;br /&gt;
&lt;br /&gt;
        # Set SDRAM characteristics in configuration register.&lt;br /&gt;
        # At 48MHz 1 cycle is about 21ns.&lt;br /&gt;
        #&lt;br /&gt;
        # 0x00000003 NC: Number of column bits&lt;br /&gt;
        # 0x00000002 10 bits, 1k columns&lt;br /&gt;
        #&lt;br /&gt;
        # 0x0000000C NR: Number of row bits&lt;br /&gt;
        # 0x00000008 13 bits, 8k rows&lt;br /&gt;
        #&lt;br /&gt;
        # 0x00000010 NB: Number of banks&lt;br /&gt;
        # 0x00000010 4 banks&lt;br /&gt;
        #&lt;br /&gt;
        # 0x00000060 CAS: CAS latency&lt;br /&gt;
        # 0x00000040 2 cycles&lt;br /&gt;
        #&lt;br /&gt;
        # 0x00000780 TWR: Write recovery delay&lt;br /&gt;
        # 0x00000100 2 cycles&lt;br /&gt;
        #&lt;br /&gt;
        # 0x00007800 TRC: Row cycle delay&lt;br /&gt;
        # 0x00002000 4 cycles&lt;br /&gt;
        #&lt;br /&gt;
        # 0x00078000 TRP: Row precharge delay&lt;br /&gt;
        # 0x00020000 4 cycles&lt;br /&gt;
        #&lt;br /&gt;
        # 0x00780000 TRCD: Row to column delay&lt;br /&gt;
        # 0x00100000 2 cycles&lt;br /&gt;
        #&lt;br /&gt;
        # 0x07800000 TRAS: Active to precharge delay&lt;br /&gt;
        # 0x01800000 3 cycles&lt;br /&gt;
        #&lt;br /&gt;
        # 0x78000000 TXSR: Exit self refresh to active delay&lt;br /&gt;
        # 0x20000000 4 cycles&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffffb8 0x2192215a ;# SDRAMC_CR&lt;br /&gt;
        sleep 10&lt;br /&gt;
&lt;br /&gt;
        # Issue 16 bit SDRAM command: NOP&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffffb0 0x00000011 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
&lt;br /&gt;
        # Issue 16 bit SDRAM command: Precharge all&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffffb0 0x00000012 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
&lt;br /&gt;
        # Issue 8 auto-refresh cycles&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
        mww 0xffffffb0 0x00000014 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000000&lt;br /&gt;
&lt;br /&gt;
        # Issue 16 bit SDRAM command: Set mode register&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffffb0 0x00000013 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000014 0xcafedede&lt;br /&gt;
&lt;br /&gt;
        # Set refresh rate count ???&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffffb4 0x00000013 ;# SDRAMC_TR&lt;br /&gt;
&lt;br /&gt;
        # Issue 16 bit SDRAM command: Normal mode&lt;br /&gt;
        #&lt;br /&gt;
        mww 0xffffffb0 0x00000010 ;# SDRAMC_MR&lt;br /&gt;
        mww 0x20000000 0x00000180&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
Last not least our final configuration for the Turtelizer 2, to be placed in &amp;lt;code&amp;gt;interface/turtelizer2.cfg&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;coding&amp;quot;&amp;gt;#&lt;br /&gt;
# egnite Turtelizer 2&lt;br /&gt;
#&lt;br /&gt;
# http://www.ethernut.de/en/hardware/turtelizer/index.html&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
# Replace with&lt;br /&gt;
#interface turtle&lt;br /&gt;
# when using the Turtelizer support package&lt;br /&gt;
interface ft2232&lt;br /&gt;
&lt;br /&gt;
ft2232_device_desc &amp;amp;quot;Turtelizer JTAG/RS232 Adapter&amp;amp;quot;&lt;br /&gt;
ft2232_layout turtelizer2&lt;br /&gt;
ft2232_vid_pid 0x0403 0xbdc8&amp;lt;/pre&amp;gt;&lt;br /&gt;
The last part will give you a few usage examples. Although it focuses on Nut/OS applications, you may find it generally useful.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Harald</name></author>	</entry>

	</feed>