|
|||||||||||
Technical Support Support Resources
Product Information |
C51: In-System Flash Programming (Part 1)Information in this article applies to:
QUESTIONI am writing a program that downloads a new program version into the Flash memory of my target system. I have a function that handles downloading and writing to the Flash and then restarts my target. I want to copy this function from Flash to RAM and execute it there. Is it possible to do this with the C51 tools? ANSWERYes, it is possible to implement this using the PK51 Professional Developer's Kit. The linker features required are implemented only in the LX51 Extended Linker. The following example copies one C program function from ROM to RAM and executes it. A complete example is available in the attachment section of the article. SROM Memory ClassThe SROM class is a special code class created by the linker for segments that are stored in one location and executed from another. You must define a memory space for the SROM class and you must specify which segments (functions) are a part of this class. Before you invoke any SROM code segments, you must first copy them from ROM to RAM. The SROM.H header file contains macros you may use to obtain the storage address, execution address, and segment length for the SROM class. Use the memcpy function to copy the SROM class to RAM. Project Files
SROM.HThis header file defines a number of macros you can use to access information about the SROM class.
SROM.CThis source file...
PFLASH.CThe following function is stored in ROM (in the SROM class) and executes from RAM.
Linker DirectivesThe execution and storage addresses for the SROM class are defined in µVision in the Options for Target - LX51 locate tab. The flash function in PFLASH.C is stored in SROM but is linked for execution at address 0x2000. Several linker parameters are required to do this:
This tells the linker to locate the SROM class in CODE memory in the 1000h-1FFFh address range.
This tells the linker to link the ?PR?FLASH?PFLASH segment for execution at address 0x2000 but stored anywhere in the SROM space. Space is reserved at 0x2000 for length of the SROM class. After linking, you may check the map file to make sure the linker produced the expected results. Be sure to look in the ACTIVE MEMORY CLASSES OF MODULE section for the address range of SROM:
Check the MEMORY MAP OF MODULE section for the flash function:
Check the PUBLIC SYMBOLS OF MODULE section for the flash function SROM symbols:
Executing from RAMThe RAM memory you copy the flash function to must be von-Neumann wired. Simulating the ProjectThe following debugger script is required to map the von Neumann memory for read, write, and execution:
See the Attached Files section below to download this example project. MORE INFORMATION
SEE ALSO
ATTACHED FILESRequest the files attached to this knowledgebase article. Last Reviewed: Thursday, February 25, 2021 | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.