Engineer-to-Engineer Note EE-280 Technicl notes on using Anlog Devices DSPs, processors nd development tools Visit our Web resources http://www.nlog.com/ee-notes nd http://www.nlog.com/processors or e-mil processor.support@nlog.com or processor.tools.support@nlog.com for technicl support. In-Circuit Flsh Progrmming on ADSP-2106x SHARC Processors Contributed by Jeynthi Jegdeesn Rev 2 Mrch 19, 2007 Introduction Modern embedded processor systems re equipped with non-voltile memory devices such s EPROM or flsh memories. This provides n esy wy to lter reprogrm memory with new content to correct problems in the current firmwre or to enhnce system cpbilities. With the dvent of flsh memories, it is now possible to sve dt permnently nd updte it when necessry without removing the component from the system. Flsh memories re lso n sset in systems tht need to sve dt during power outge or brownout. The processor cn store its code/dt contents from voltile internl memory to n externl, non-voltile memory, nd on revivl of the system, rewrite the old informtion bck to the processor. ADSP-2106x SHARC processors cn be booted from single 8-bit-wide memory device like EPROM, EEPROM, or flsh. This EE-Note provides the detils of interfcing the flsh to the externl port on ADSP-2106x processors. It lso demonstrtes progrmming the in-circuit flsh with two pproches. The first pproch uses the flsh progrmmer driver, which works with the VisulDSP++ Flsh Progrmmer utility. The flsh progrmmer driver code is provided to demonstrte how the flsh on the EZ-KIT Lite bord cn be progrmmed for PROM booting. The flsh progrmmer driver code in the ssocited.zip file is provided for the ADSP-21065L EZ-KIT Lite bord. The flsh progrmmer driver code cn be used to progrm the M29W040B 512-KB flsh vilble from STMicroelectronics. The sme code cn be modified for ll the other ADSP-2106x processors. The second exmple code is flsh progrmmer ppliction tht progrms the boot imge into the flsh directly. The exmple code in the ssocited.zip file is vilble for the ADSP- 21061 processor, nd the sme code cn be modified for the other processors. In-Circuit Flsh Progrmming on SHARC Processors (EE-223) [5] discusses progrmming the flsh on ADSP-2116x, ADSP-2126x, ADSP- 2136x, nd ADSP-2137x SHARC processors. Hrdwre Interfce The flsh memory must be interfced to the BMS spce of the processor for booting from the flsh. The ddress bus, dt bus, BMS# nd RD# signls must be connected s shown in Figure 1. Dt lines D23:16 of the ADSP-21060, ADSP-21061, nd ADSP-21062 processors must be connected to dt lines D7:0 of the flsh. For ADSP- 21065L processors, dt lines D7:0 must be connected to dt lines D7:0 of the flsh. The number of ddress lines depends on the size of the flsh. To progrm the flsh, the WR# signl of the processor must to be connected to the WE# signl of the flsh s shown in Figure 2. Copyright 2005-2007, Anlog Devices, Inc. All rights reserved. Anlog Devices ssumes no responsibility for customer product design or the use or ppliction of customers products or for ny infringements of ptents or rights of others which my result from Anlog Devices ssistnce. All trdemrks nd logos re property of their respective holders. Informtion furnished by Anlog Devices pplictions nd development tools engineers is believed to be ccurte nd relible, however no responsibility is ssumed by Anlog Devices regrding technicl ccurcy nd topiclity of the content provided in Anlog Devices Engineer-to-Engineer Notes.
Flsh Interfce on the ADSP- 21065L EZ-KIT Lite Bord The EPROM on the ADSP-21065L EZ-KIT Lite bord is mpped to the BMS spce of the ADSP- 21065L processor. Refer to Figure 1. ADSP-21065L Figure 1. EEPROM interfce on the ADSP-21065L EZ-KIT Lite bord The EPROM socket provided on the ADSP- 21065L EZ-KIT Lite bord cnnot be used for the flsh s is. Figure 2 shows the connections between the flsh nd the ADSP-21065L EZ- KIT Lite bord. ADSP-21065L A17-0 D7-0 /BMS /RD A17-0 D7-0 /BMS /RD /WR Figure 2. ADSP-21065L flsh interfce EPROM (M27V201) A17-0 Q7-0 /E /G FLASH (M29W040B) A17-0 D7-0 /E (Pin 22) /G (Pin 24) /W (Pin 31) The /WR signl of the ADSP-21065L EZ-KIT Lite must be connected to the /W signl of the flsh on the EZ-KIT Lite bord. Flsh Progrmmer Driver The flsh progrmmer driver files included in the ssocited.zip file progrms the input.ldr file into the flsh. The flsh progrmmer driver is used with the VisulDSP++ Flsh Progrmmer utility. To progrm the flsh, the flsh progrmmer driver is loded into memory initilly. After loding it into memory, the flsh progrmmer driver: Alloctes memory to hold the input.ldr file contents Initilizes the sector's strt nd end ddresses for the GUI Resets the flsh nd verifies the device ID The input.ldr file is lso loded into the memory using the Flsh Progrmmer utility. After loding it, the flsh progrmmer driver: Erses the flsh Writes the contents of input.ldr into flsh Verifies the dt The flsh progrmmer driver uses the following functions to write to nd red from the flsh: WriteFlsh RedFlsh The /BMS signl is used s the chip select signl for the flsh. This signl is sserted low by setting the BSO (boot select override) bit of the SYSCON register before ccessing the flsh. When the BSO bit is set, externl port DMA ccesses cn enble the /BMS signl only. The flsh progrmmer driver uses DMA chnnel 9 to write to nd red from the flsh. The WriteFlsh nd RedFlsh functions set the BSO bit of the SYSCON register nd initite n externl port DMA using chnnel 9. After inititing the DMA trnsfer, the processor wits in idle mode for the trnsfer to end. Once the trnsfer ends, the processor comes out of idle mode nd reset the BSO bit of the SYSCON register for norml ccesses. In-Circuit Flsh Progrmming on ADSP-2106x SHARC Processors (EE-280) Pge 2 of 8
Progrmming the Flsh The flowchrt of Figure 3 shows the steps to progrm code into flsh using the Flsh Progrmmer utility. Strt Generte the User_Appliction.ldr file using the VisulDSP++ loder utility Lod the Flsh Progrmmer driver into the internl memory Lod the User_Appliction.ldr file into the internl memory Erse the Flsh Progrm the Flsh with the User_Appliction.ldr file End Figure 3. Using the flsh progrmmer driver The 21065LEZFlsh.c file vilble with the flsh progrmmer driver contins generic flsh progrmming lgorithm. The blink project files, which toggle the ADSP-21065L processor's flgs nd blinks the LEDs on the EZ-KIT Lite bord, re used s n exmple. Build nd test user_ppliction.dpj to progrm the user ppliction into the flsh. Then generte user_ppliction.ldr with the VisulDSP++ loder. The flsh progrmmer driver nd the dt from the user_ppliction.ldr file re loded into internl memory using the Flsh Progrmmer. The flsh progrmmer driver uses the dt loded into internl memory from the user_ppliction.ldr file. It erses the flsh nd then progrms the flsh with the new dt. Once the user ppliction is vlidted, it cn then be progrmmed into the flsh. The exmple code contins the Blink.dxe nd Blink.ldr files, which cn be used to progrm the flsh. The Blink.exe file cn be loded nd tested on the EZ-KIT Lite bord. Then the Blink.ldr file cn be progrmmed into the flsh. The following two steps describe the genertion of the loder file using the VisulDSP++ tools nd how to progrm the flsh for the user ppliction using the flsh progrmmer driver. The flsh cn lso be progrmmed using the Flsh Progrmmer ppliction provided with this EE-Note. For the Flsh Progrmmer ppliction, the user_ppliction.ldr file is used s prt of the internl memory. The ppliction erses the flsh initilly, nd then reds the user_ppliction.ldr contents from internl memory nd progrms the flsh. Step 1. Crete the PROM Boot Imge Use the VisulDSP++ loder utility to generte the boot-imge for the user ppliction code. To generte the loder file, select Loder file s the output file type in the Project Options dilog box for user_ppliction.dpj (Figure 4). The Flsh Progrmmer utility ccepts the dt in hexdeciml formt. For the flsh progrmmer project the loder file must be generted with ASCII formt. The user_ppliction.ldr file is generted by selecting Hex s the boot formt s shown in Figure 5. When the project is built using the Rebuild Project commnd (vi Build menu or toolbr button), the user_ppliction.ldr file is generted. In-Circuit Flsh Progrmming on ADSP-2106x SHARC Processors (EE-280) Pge 3 of 8
Figure 4. Configuring loder file vi the Project Options dilog box Figure 5. Selecting hex formt for the PROM boot In-Circuit Flsh Progrmming on ADSP-2106x SHARC Processors (EE-280) Pge 4 of 8
Step 2. Using the Flsh Progrmmer Utility Invoke the Flsh Progrmmer utility from the VisulDSP++ Tools menu. Specify the following options, s follows: 1. Click the Driver tb. Click the Browse ( ) button next to the Lod Driver button (Figure 6) nd select the pth for the flsh progrmmer driver file. 2. Click the Lod Driver button to lod the flsh progrmmer driver into memory. After loding the driver into internl memory, Success: Driver loded is displyed in the Messge center. The mnufcturer s code, device code, nd prt description of the flsh re displyed. 3. Click the Progrmming tb. Click the browse ( ) button under Dt File (Figure 7) nd select the pth for the generted user_ppliction.ldr file. 4. Click the Progrm button to progrm the flsh with the user_ppliction.ldr file. When the flsh progrmming is completed, Success: Ersed sector(s) nd Success: Progrm complete re displyed in the Messge center. Figure 6. Flsh Progrmmer loding the flsh progrmmer driver file In-Circuit Flsh Progrmming on ADSP-2106x SHARC Processors (EE-280) Pge 5 of 8
Figure 7. Flsh Progrmmer loding the loder file for user ppliction Step 2b. Using the Flsh Progrmmer Appliction 1. Generte the loder file for the user ppliction for PROM boot with ASCII formt. 2. Copy the flsh progrmmer exmple code project files provided with the ssocited.zip file. 3. Copy the generted loder (user_ppliction.ldr) file to the folder where the flsh progrmmer project is plced. 4. Rebuild the flsh progrmmer project files nd lod the ppliction. 5. Run the ppliction to progrm the flsh. This ppliction erses the flsh nd progrms it with the contents of user_ppliction.ldr file. Booting from Flsh Memory Pins 2 nd 3 of jumper JP6 must be shorted in order to boot from the flsh on the ADSP- 21065L EZ-KIT Lite bord. If the jumper is not connected, the code boots from the flsh. After progrmming the code on the flsh, pplying power reset cuses boot from the flsh. The Blink exmple code cn be booted from the flsh nd verified. Progrm the flsh with the Blink.ldr file using the Flsh Progrmmer utility. When the power reset is pplied to the bord, the Blink exmple code boots from the flsh nd toggles the LEDs on the EZ-KIT Lite bord. In-Circuit Flsh Progrmming on ADSP-2106x SHARC Processors (EE-280) Pge 6 of 8
Modifying the Flsh Progrmmer Driver for Different Flsh Prts The flsh progrmmer driver vilble with this EE-Note is implemented for STMicroelectronics M29W040B flsh device. The code cn be modified for other flsh devices. The flsh progrmmer driver clls the following functions in the given sequence: GetSectorStrtEnd() SetupForFlsh() GetCodes() ErseFlsh() or ErseBlock() WriteDt() UnlockFlsh() The following device-dependnt functions must be modified: ResetFlsh() ErseFlsh() ErseBlock() GetCodes() UnlockFlsh() GetSectorStrtEnd() GetSectorNumber() The GetSectorStrtEnd() nd the GetSectorNumber() functions depend on the number of sectors nd the sector size on the device. The NUM_SECTORS cn be modified with the vilble sectors. The AFP_SectorSize cn be modified with the sector size. If the flsh hs vrible sector size, the GetSectorNumber() nd GetSectorStrtEnd() function implementtion must be modified. Listing 1 shows the UnlockFlsh() function. The commnds used in this function my vry from device to device nd must be modified. ERROR_CODE UnlockFlsh() { int flsh_ddress; /* Write commnds to unlock the flsh. */ flsh_ddress = 0x5555; flsh_dt = 0x; WriteFlsh( flsh_ddress, &flsh_dt); flsh_ddress = 0x2; flsh_dt = 0x55; WriteFlsh( flsh_ddress, &flsh_dt); flsh_ddress = 0x5555; flsh_dt = 0x0; WriteFlsh( flsh_ddress, &flsh_dt); return NO_ERR; } Listing 1. UnlockFlsh() function Summry With miniml hrdwre modifiction to the EZ- KIT Lite bord, the bord's flsh cn be progrmmed esily. The flsh progrmmer driver files nd the flsh progrmmer ppliction cn be modified for different flsh devices. Softwre Code The source codes for the flsh progrmmer driver nd for the flsh progrmmer ppliction re supplied in the.zip file ssocited with this EE- Note. In-Circuit Flsh Progrmming on ADSP-2106x SHARC Processors (EE-280) Pge 7 of 8
References [1] ADSP-21065L SHARC DSP User s Mnul. Rev 2.0, July 2003. Anlog Devices, Inc. [2] ADSP-2106x SHARC Processor User s Mnul. Rev 2.1, Mrch 2004. Anlog Devices, Inc. [3] ADSP-21065L EZ-KIT Lite Evlution System Mnul. Rev 2.0, Jnury 2003. Anlog Devices, Inc. [4] ADSP-21061 EZ-KIT Lite Evlution System Mnul. Rev 3.0, Jnury 2003. Anlog Devices, Inc. [5] In-Circuit Flsh Progrmming on SHARC Processors (EE-223). Rev 2, Februry 2007, Anlog Devices Inc. Document History Revision Rev 2 Mrch 19, 2007 by Jeynthi Jegdeesn Rev 1 December 15, 2005 by Jeynthi Jegdeesn Description Generlized the EE-Note for ll ADSP-2106x processors nd chnged the title from In-circuit Flsh Progrmming on ADSP-21065L SHARC EZ-KIT Lite Bords to In-Circuit Flsh Progrmming on ADSP-2106x SHARC Processors. Merged with the contents from Writing to Flsh Memory on the ADSP-2106x (EE- 3), Interfcing Byte Progrmmed FLASH Memory to the ADSP-2106x SHARC series (EE-55), nd In-System-Progrmming (ISP) of ADSP-2106x boot-imges into FLASH Memories (EE-117). Initil relese for the ADSP-21065L processor. In-Circuit Flsh Progrmming on ADSP-2106x SHARC Processors (EE-280) Pge 8 of 8