I am currently working on a project that is based on a design quite similar to the MCF52259 Evaluation Board. I need to test the Mini-FlexBus external RAM interface. I'm using a MR2A16ACYS35 512K byte MRAM attached to the Mini-FlexBus for external storage.
The Mini-FlexBus has been properly initialized and I have verified that we can successfully read and write to the MRAM using a routine written in C that utilizes direct pointer addressing. I have modified our linker control file adding the proper addressing and segment names and verified that the map file properly reflects the modifications after building our application.
# Sample Linker Command File for CodeWarrior for ColdFire
KEEP_SECTION {.vectortable}
# Memory ranges
MEMORY {
vectorrom (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
cfmprotrom (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000020
code (RX) : ORIGIN = 0x00000500, LENGTH = 0x0007FB00
vectorram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400
userram (RWX) : ORIGIN = 0x20000400, LENGTH = 0x0000C900
xram (RW) : ORIGIN = 0x80000000, LENGTH = 0x0007FFFF
}
SECTIONS {
# Heap and Stack sizes definition
___heap_size = 0x1000;
___stack_size = 0x1000;
# MCF52259 Derivative Memory map definitions from linker command files:
# __IPSBAR, __RAMBAR, __RAMBAR_SIZE, __FLASHBAR, __FLASHBAR_SIZE linker
# symbols must be defined in the linker command file.
# Memory Mapped Registers (IPSBAR= 0x40000000)
___IPSBAR = 0x40000000;
# 64 Kbytes Internal SRAM
___RAMBAR = 0x20000000;
___RAMBAR_SIZE = 0x0000FFFF;
# 512 KByte Internal Flash Memory
___FLASHBAR = 0x00000000;
___FLASHBAR_SIZE = 0x00080000;
# 512 KByte External RAM Memory
___XRAMBAR = 0x80000000;
___XRAMBAR_SIZE = 0x0007FFFF;
___SP_AFTER_RESET = ___RAMBAR + ___RAMBAR_SIZE - 4;
.userram : {} > userram
.code : {} > code
.vectorram : {} > vectorram
.xram : {} > xram
I need to store selected variables in this section of memory using a manner similar to how variables are stored in Flash memory using a keyword to preface the variable name that will force the linker to store the variable in a MRAM location as opposed to the internal SRAM of the device. Does anyone have an example of how to do this? My external MRAM is labeled (see above) as "xram."
Go over to the CodeWarrior forums and search for "attribute" and "section".
We're using CodeSourcery, and it looks like this:
#define FAST __attribute((section(".fast"))) #define MEM_SECTION_USB __attribute((section(".usb"))) MEM_SECTION_USB uint8_t g_vnSuUsbNcMem[SU_HEAPSIZE];
Tom
Thank you for the info Tom.
I also found this post on the CodeWarrior forum:
https://community.freescale.com/message/80820#80820
that illustrates how CodeWarrior accomplishes the task. I'm assuming that the linker definitions are still required. I'm going to try this out to see if it works for me.
The previous example didn't work for me. I checked the map file and the xram section exists at the address specified in the linker command file but the compiler can't resolve the address of the declared variable. I used:
EXT_RAM unsigned char myExtData = 5;
The map file is still showing a 0 length for the xram section meaning the variable never got created.