Analog Devices ee166 Application Notes

Engineer To Engineer Note EE-166
Technical Notes on using Analog Devices' DSP components and development tools
=
Contributed by G.Ouellette June 10, 2002
Introduction
Using external memory to store program code and data in overlays is a good way to reduce DSP system costs. Many applications efficiently run using overlays from SDRAM. To reduce system cost further, program code and data can be placed off chip in a boot EPROM or FLASH.
This note discusses the concept of EPROM overlay partitions ADSP-21065L DSP.
The following topics and examples are discussed:
Contact our technical support by phone: (800) ANALOG-D or e-mail: dsp.support@analog.com Or visit ou r on-line resources http://www.analog.com/dsp
as well as the information necessary for the overlay manager routine to load the overlays. The information provided by the linker includes the following constants:
_ov_startaddress_N _ov_endaddress_N _ov_size_N _ov_word_run_size_N _ov_word_live_size_N _ov_runtimestartaddress_N
Where N = the Overlay ID
and http://www.analog.com/dsp/EZAnswers
• Overview of Memory Overlays
• Overview of Overlay Manager
• Overview of Boot Kernel
• EPROM Overlay Example All of the code segments used in the following discussion
are segments from the example program that appears at the end of this note.
Overview of Memory Overlays
Memory overlays provide support for applications whose code is too long to fit into internal memory of the processor. Program instructions and data are partitioned and stored in external memory until they are required for program execution. The partitions are referred to as memory overlays and the routines that call and execute them overlay managers.
Instructions can be placed in external memory ("live" space) and transferred, when needed, to internal memory ("run" space) for execution. Several overlays can be “run” (or execute) in a common location in internal memory, but only one can be in run space at a time. Overlay support is provided by the linker and is partially designed by the user in the linker description file (LDF). The LDF provides the linker with the direction on how to configure the overlays
Each overlay has a word size and an address associated with it, which the overlay manager uses to determine where the overlay resides and where it is executed.
Along with providing constants, the linker redirects overlay symbol references within your code to the overlay manager routine using a p rocedure l inkage table (PLIT ). The PLIT is essentially a jump table that executes user-defined code, and then jumps to the overlay manager. The linker replaces an overlay symbol reference (function call) with a jump to a location in the PLIT. The programmer defines the PLIT in the linker description file (LDF).
Overview of Overlay Manager
The overlay manager is a user defined routine that is responsible for loading a referenced overlay function into internal memory (run time space). This is done with the aid of the linker -generated const ants and the PLIT commands. The linker-generated constants tell the overlay manager the address of the live overlay, where the overlay resides for execution, and the number of words in the overlay. The PLIT commands tell the overlay manager such information as which overlay is required and the run time address of the referenced symbol.
Copyright 2002, Analog Devices, Inc. All rights reserved. Analog Devices assumes no responsibility for customer p ro d uc t d e s ign o r t he us e or a pp lic a t ion o f c us to mer s ’ p ro d uc ts o r for any infringements of p at ent s o r rights of o the rs w hich ma y res ult fro m Analog De vice s a ss ist anc e. All trad emark s a nd logos are property of their respective holders. Information furnished by Analog Devices Applications and Development Tools Engineers is believed to be accurate and reliable, however no responsibility is a ssumed by Analo g Devices regarding the technical accuracy and topicality of the content provided in all Analog Devices’ Engineer-to-Engineer Notes.
=
Overview of Boot Kernel
The ADSP-21065L is configured by default to load 256 words of 48-bit width (instruction size) after reset by DMA. DMA channel 8 is initialized for the ADSP­21065L. The ADSP-21065L DMA settings for EPROM booting can be taken from table 1.
DMA Channel 8 ADSP-21065L SYSCON 0x0000 0020 II6 IIEP0 0x8000 IM6 IMEP0 0x1 C6 CEP0 0x100 EI6 EIEP0 0x8000 0000* EM6 EMEP0 0x1 DMAC6 ECEP0 0x600 IRQ Vector 0x8040 * 0x20000 for Rev 0.1
Table 1. DMA settings for EPROM booting
After RESET, the core processor is held in an IDLE mode until 256 words have been loaded in. The core processor will start execution of the just loaded boot kernel.
Beginning from Start_Loader some required registers are set, external memory accesses are setup and wait states are initialized. Having completed the set-up, the DMA engine is used to fetch 48-bit words from the EPROM.
Having determined the offset to find the start address of the boot section for this processor, the DMA parameters are set up to read data word by word. Each 48-bit word is transferred into address 0x8004 for dispatching. As the image in the EPROM contains program memory code sections and data memory sections, a 16-bit initialization tag is placed before each block. The initialization headers are organized as shown below:
Tag Number Initialization Type 0 0x0 FINAL INIT 1 0x1 ZERO DM16 2 0x2 ZERO DM32 3 0x3 ZERO DM40 4 0x4 INIT DM16 5 0x5 INIT DM32
6 0x6 INIT DM40 7 0x7 ZERO PM16 8 0x8 ZERO PM32 9 0x9 ZERO PM40 10 0xA ZERO PM48 11 0xB INIT PM16 12 0xC INIT PM32 13 0xD INIT PM40 14 0xE INIT PM48
Table 2. Section Initialization Headers
Any initialization of 48-bit PM memory uses a write with the PX register set to zero. The kernel enters a loop, which reads one 48-bit word from the EPROM and writes the appropriate width value to memory.
EPROM Overlay Example
The tools shipped with VisualDSP aren't currently equipped to handle EPROM overlays. When trying to specify the live location of the overlay in EPROM space (0x8000 0000), the linker generates an error. The linker isn't capable of determining the live address on the EPROM because it is user defined.
To work around this limitation, the kernel has been modified. Any initialization of 48-bit PM memory (INIT PM48), the kernel performs a check to identify if the 48-bit PM data is to be loaded into 48-bit external memory. Following this, a check has been added to determine if the external memory is in fact in EPROM space (0x8000
0000). However, as noted above, the linker is unable to generate the live location of the overlay in EPROM space. It is up to the programmer to alert the kernel of the presence of a EPROM overlay.
As an example, the kernel has been modified as follows:
pm48_init: r13 = 0x20000; r13=r3-r13; if ge jump pm48_externalMemoryInit;
I8=R3; LCNTR=R2,DO pm48_init_loop UNTIL LCE; CALL read_PROM_word (DB); NOP; NOP;
pm48_init_loop: PM(I8,M14)=PX; JUMP read_boot_info;
pm48_externalMemoryInit: I0=R3;
EE-166: ADSP-2106x EPROM Overlay Support with VisualDSP++ 2.0 Page 2 of 11
BTST R3 by 0x17; IF sz JUMP pm48_loop;
/**** EPROM Overlay ****/ prom_ovrly:
R9=DM(EIEP0); DM(I2,M6)=R9; R8=0x6; R8=R2*R8(SSI); R9=R8+R9; DM(EIEP0)=R9; JUMP read_boot_info; /* read boot info */
Listing 1. Modified Kernel Example
Following pm48_init, the kernel performs a comparison to determine whether the 48-bit word is to reside in external PM memory. It checks to see if the location is larger than the first external memory location of the ADSP-21065L (0x0002 0000). If the data is indeed to be resident in external memory, a jump to pm48_externalMemoryInit is executed.
A check is performed to determine if the data is to reside in EPROM memory.
The following code segment from the LDF used in the example configures the overlay live address:
MEMORY { isr_tabl {
TYPE(PM RAM) START(0x00008000) END(0x000080FF) WIDTH(48) }
pm_code { TYPE(PM RAM) START(0x00008100) END(0x000087ff) WIDTH(48) }
pm_data { TYPE(PM RAM) START(0x00009000) END(0x000097ff) WIDTH(32) }
pm_idat { TYPE(PM RAM) START(0x00009800) END(0x00009fff) WIDTH(32) }
dm_data { TYPE(DM RAM) START(0x0000C000) END(0x0000Cfff) WIDTH(32) }
dm_rdat { TYPE(DM RAM) START(0x0000D000) END(0x0000Dfff) WIDTH(32) }
ovl_code { TYPE(PM RAM) START(0x00820000) END(0x00FFFFFF) WIDTH(48) }
} // End MEMORY
Listing 2. LDF Overlay Example
=
The overlay declaration in Listing 2 configures the overlay’s live address to be somewhere in external memory, ovl_code, starting at 0x00820000.
In this example, to determine if the data is to reside in EPROM memory, the kernel tests for the presence of a set bit in location 0x17 of the 48-bit external memory address.
pm48_externalMemoryInit: I0=R3; BTST R3 by 0x17; IF sz JUMP pm48_loop;
If the test fails, a jump to pm48_loop is executed and the kernel places the data into external memory at the address specified. If the test passes, the overlay is assumed to have a live address in EPROM space. At this stage, the kernel performs several steps to overcome the limitations of the linker.
/**** EPROM Overlay ****/ prom_ovrly:
R9=DM(EIEP0); DM(I2,M6)=R9; R8=0x6; R8=R2*R8(SSI); R9=R8+R9; DM(EIEP0)=R9; JUMP read_boot_info; /* read boot info */
The current external DMA index points to the live location of an overlay in external memory. For this example, its live location is in the EPROM. This address is copied from the EIEP0 and replaces the liveAddresses location in DM memory. If this was the first overlay, the contents of liveAddresses[1] would be replaced by the contents of EIEP0.
The programmer must be aware that the location of the table of liveAddresses in DM memory must be kno wn in advance and loaded into I2. The current overlay manager delivered with the tools initializes the liveAddresses to begin at location 0xC000 in DM memory. Due to this, I2 is initialized to 0xC000 at the start of the loader kernel.
The index register, I2, is incremented to the next liveAddresses in DM memory in preparation for the next EPROM overlay live address.
Since the overlay is to remain resident on the EPROM, the external port DMA index, EIEP0, needs to be adjusted to point to the next location following the overlay segment.
R8=0x6; R8=R2*R8(SSI); R9=R8+R9; DM(EIEP0)=R9;
The data register, R2, has been previously loaded with the number of words in the overlay segment. Each word is 48­bits long, but is packed into 8-bits on the EPROM. Thus the number of words in the segment must be multiplied by 6 and added to the current value in EIEP0 to advance the
EE-166: ADSP-2106x EPROM Overlay Support with VisualDSP++ 2.0 Page 3 of 11
external index to the address following the current overlay segment.
The following example is intended to help explain a method to perform EPROM overlays so you can get started on your own applications.
References:
ADSP-21065L SHARC USER'S MANUAL EE-66 'Using Memory Overlays' EE-56 ' Tips & Tricks on the ADSP-2106x EPROM and
HOST bootloader'
=
EE-166: ADSP-2106x EPROM Overlay Support with VisualDSP++ 2.0 Page 4 of 11
Loading...
+ 7 hidden pages