5Am186™     CC Flash Memory Driver
             CodeKit™ Software                                      Embedded Processor ...
Am186™ CC Flash Memory Driver CodeKit™ Software                                       V1.0 –September 17, 1998

1.3    Fil...
Am186™ CC Flash Memory Driver CodeKit™ Software                                    V1.0 –September 17, 1998

1.5     Setti...
Am186™ CC Flash Memory Driver CodeKit™ Software                                            V1.0 –September 17, 1998
Step 3...
Am186™ CC Flash Memory Driver CodeKit™ Software                                                       V1.0 –September 17, ...
Upcoming SlideShare
Loading in …5

Am186 ™ CC Flash Memory Driver CodeKit ™ Software


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Am186 ™ CC Flash Memory Driver CodeKit ™ Software

  1. 1. 5Am186™ CC Flash Memory Driver CodeKit™ Software Embedded Processor Division V1.0 - September 17, 1998 Readme File : Version 1.0 –September 17, 1998 1 Overview This CodeKit™ software contains a flash memory driver for the AMD Am186™ CC communications controller. It contains routines to identify, write to, and erase flash memory. It also includes a sample application that stores sentences in the flash memory for later retrieval. IMPORTANT: By loading this software or any portion thereof, you agree to all of the terms of the License Agreement in the file LICENSE.PDF. Do not use this software until you have carefully read and agreed to terms and conditions in the Agreement. If you do not agree to the terms of the Agreement, do not use this software or any portion thereof. For support: e-mail epd.support@amd.com or call 1-800-222-9323 1.1 Tool and System Requirements The following target hardware and tools are required to build and execute this CodeKit software. ITEM DESCRIPTION Target Hardware Am186CC/CH/CU Customer Development Platform (CDP) Rev 1.0 or Rev 1.1 (the CDP’ Router/ISDN Development Module is not required) s Monitor AMD E86MON™ V3.32 (or newer) Workstation Operating System Windows 95, 98, or NT Tool Suite Microsoft® Visual C++ V1.52 Compiler* Microsoft C/C++ Optimizing Compiler Version 8.00c Linker* Microsoft Segmented Executable Linker Version 5.60.339 Dec 5 1994 * Note the compiler and linker are part of the Visual C++ V1.52 tool suite. 1.2 Installing the CodeKit Software This CodeKit software is delivered as a self-extracting executable file. Double-click on the EXE file and a directory called C:AMDCK000201 is created. The CK000201 directory contains the entire contents of the flash memory driver CodeKit software. Advanced Micro Devices – Embedded Processor Division Page 1 of 5
  2. 2. Am186™ CC Flash Memory Driver CodeKit™ Software V1.0 –September 17, 1998 1.3 Files and Directories The EXE file contains the following files in a single directory. FILE DESCRIPTION AM186CC.H Standard register defines for the Am186CC controller. BUILDIT.BAT A batch file that builds the CodeKit software. CLEANIT.BAT A batch file that cleans up intermediate files after a build. ENVIRON.BAT A batch file that sets up the build environment. FLASH.C The lowest level flash library functions. FLSHDEMO.HEX The sample program in Intel Hex format. MAIN.C The sample application code. MAKEHEX.EXE An executable file that converts an EXE program into a HEX file for downloading into the target board using the E86MON software. NOVRAM.C Functions to handle storing and retrieving blocks of memory in flash. NOVRAM.H Header file for NOVRAM.H. NVDRVR.C Interface code between FLASH.C and NOVRAM.C. NVDRVR.H Header file for NVDRVR.H. README.DOC This document in Microsoft Word 97 Format. README.PDF This document in Adobe Acrobat PDF Format. STDINCS.H A header file with standard typedefs and structures. 1.4 Setting Up the Build Environment Before the CodeKit software is built, the build environment needs to be set up. To do this, run the ENVIRON.BAT command file. This sets up the following environment variables. This batch file assumes that the tools have been installed in their default locations on the C: drive. ENV Variable Setting TOOLROOTDIR C:MSVC INCLUDE C:MSVCINCLUDE LIB C:MSVCLIB Advanced Micro Devices – Embedded Processor Division Page 2 of 5
  3. 3. Am186™ CC Flash Memory Driver CodeKit™ Software V1.0 –September 17, 1998 1.5 Setting Up the Target Hardware This CodeKit expects 512 Kbyte of DRAM and 512 Kbyte of Flash memory to be installed on the CDP. None of the SRAM chip select jumpers at JP10 should have jumpers on them. 1.6 Building the CodeKit Software Building this CodeKit is very simple: 1. Execute the ENVIRON.BAT file to set up your environment. 2. Execute the BUILDIT.BAT file. This builds the FLSHDEMO.HEX file. This can then be downloaded to the target hardware. NOTE: The MAKEHEX.EXE utility converts an EXE file into a HEX file. The version of MAKEHEX.EXE you have is matched to a version of the E86MON software. If you have problems loading your HEX file using the E86MON software on the target board, please contact our support team for a correct version of E86MON. Note they will need to know what version of E86MON is loaded on your board. For help with MAKEHEX.EXE, run MAKEHEX with no arguments. 1.7 Loading the Code You need some kind of terminal program like Hyperterminal (on Windows 95 or NT). The following steps show you how to connect to an Am186CC/CH/CU CDP using COM1 on your PC and Hyperterminal: Step 1: Connect a NULL MODEM CABLE from COM1 of your PC to either of the serial ports on your Am186CC CDP. Step 2: Run Hyperterminal and create a new connection directly to COM1. Advanced Micro Devices – Embedded Processor Division Page 3 of 5
  4. 4. Am186™ CC Flash Memory Driver CodeKit™ Software V1.0 –September 17, 1998 Step 3: Click the “Configure… ” button to set the baud rate and other communications parameters to 115200 baud, 8 data bits, no parity, 1 stop bit and Xon/Xoff flow control. Step 4: Reset the target board, wait a second or two, then press the “ (either upper or lower case). The A” E86MON software (running on the target board) detects the baud rate and issues a prompt, like this: 1 Step 5: This step loads the program into RAM. If you reset the board, you have to load it again . Select “ Send Text File” from the “Transfer”menu. (Note this is a basic ASCII file transfer. In other words, the file is sent as is with no protocol, just as if you could type it in really fast.) In the resulting dialog box, select the FLSHDEMO.HEX file. The file transfer begins. After it is finished, your terminal window looks something like this: Step 6: To execute the program, use the ” (for GO) command. The program will now run. G” 2 The Code The demo application records a short string inputted by the user into the flash memory. The next time the program is brought up, the string is retrieved from the flash and displayed. The user can then change the string again. The messages are stored in blocks in the flash. The flash memory cannot be overwritten without being erased first, and each erase must erase a full 64 Kbyte sector, which is a slow process. Each time a new message is written to flash, it is written below the previous message. When the sector is full, or when the blocks touch other data in flash that need to be preserved 1 See the E86MON™ Software User’ Manual, order #21891, for instructions on how to load programs into flash. s Advanced Micro Devices – Embedded Processor Division Page 4 of 5
  5. 5. Am186™ CC Flash Memory Driver CodeKit™ Software V1.0 –September 17, 1998 (such as a monitor program), the preserved data is written to DRAM, the flash sector is erased, and the message and preserved data are written back to flash. This reduces the number of erases that are necessary. 2.1 The MAIN Code The main() function begins calling the nvInitialize() function, which checks the flash for previous messages and creates a default message if there were none. It then prints out the retrieved message and prompts the user to enter a new one. Finally, it reads the new message into a NovRam structure and writes it to flash by calling nvWrite(). 2.2 The NOVRAM Code Novram.c contains the functions that manipulate the blocks of memory used to store and retrieve information in flash. Each NovRam structure includes the stored string and a checksum to test for successful retrievals. nvInitialize() calls nvDvrInitalize() to initialize the flash device and then nvRead() to read the data from flash. nvRead() calls nvDvrRead() to actually read the data from flash, and then calculates the checksum. If the message was corrupted during retrieval, or no message was found, nvRead() clears the NovRam structure and replaces the message with a default message. It then writes the default message back to flash with nvWrite(). nvWrite() calculates the checksum for the message, stores it in the NovRam structure, and passes the NovRam structure to nvDvrWrite() to write the bytes to flash. 2.3 The NVDRVR Code The Nvdrvr.c code handles finding and retrieving data blocks from the flash, and locating empty blocks in flash to record new messages. It also handles the process of writing preserved data to DRAM when erasing a sector. nvDrvrInit() assumes that the flash.c code might be running out of flash and copies it into DRAM in case the flash memory needs to be erased. It then calls the copy of FindFlash() in DRAM to locate the flash memory and initialize it. nvDvrRead() searches for the most recent memory block by starting at the top of the flash sector and searching flash in CHUNKSIZE blocks. When it finds a block that has been written with an unwritten block below it, it knows it has found the most recent message and copies it into a buffer. nvDvrWrite() performs a similar process of looking for empty blocks. When it finds an empty block, it checks to see if the next block is also empty. If it isn’ nvDvrWrite() knows that the t, sector is almost full and decides to erase it. It copies the preserved data into DRAM, erases the sector using FlashErase(), and then calls ProgramFlash() to finally write the data into flash. 2.4 The FLASH Code The Flash.c code handles writing and reading the data to flash. FindFlash() searches the memory space for a flash device. When it finds ones, it tries to identify the flash device and match its ID to one of the code’ known IDs. FlashErase() shuts off the timers, to avoid having unexpected interrupts s disturbing the bus timing, and sends the commands to the flash to erase it. ProgramFlash() shuts down the timers, and writes the data into the flash. More information about the code is supplied in the inline documentation. Trademarks © 1998 Advanced Micro Devices, Inc. All rights reserved. AMD, the AMD logo, and combinations thereof are trademarks of Advanced Micro Devices, Inc. Am186, CodeKit, and E86MON are trademarks of Advanced Micro Devices, Inc. Microsoft is a registered trademark of Microsoft. All other product names are for identification purposes only and may be trademarks of their respective companies. Advanced Micro Devices – Embedded Processor Division Page 5 of 5