Flash Programming with 5212/5213 Question

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Flash Programming with 5212/5213 Question

3,780件の閲覧回数
JimMcP
Contributor I
I notice examples of Flash Programming.
////////////////////////////////////
This example:

#define IPSFLASH(x) (*(long*)(0x44000000 + (x)))

int runInRam(char cmd, long *addr, long val)
{
CFMSTAT = PVIOL | ACCERR;
IPSFLASH(addr)=val;
CFMCMD=cmd;
CFMSTAT=CBEIF;
while(!(CFMSTAT & (CCIF|PVIOL|ACCERR)));
return CFMSTAT & (PVIOL|ACCERR);
}

void runEND(void) {} // leave this immediately after runInRam

int flashProg(long *dest,long *src,int n)
{
char buf[200];
int(*ramCopy)(char,long,long) = (int(*)(char,long,long))buf;
memcpy(buf,(void*)runInRam, (char*)runEND - (char*)runInRam);

while(n--)
{
if(ramCopy(CMDPROG, dest++. *src++)) return -1;
}

return 0;
}
//////////////////////////////////

I know the function runInRam has to run in RAM. My question is how is the ramCopy function defined.

Thanks,
ラベル(1)
0 件の賞賛
返信
5 返答(返信)

1,703件の閲覧回数
J2MEJediMaster
Specialist I
Attached is a Tech Note 288 that describes how to copy code from Flash into RAM. The function is not the same as the one you're using here, but perhaps it will give you ideas of how to implement the function. Or, you can revise the code to support the copy function in the tech note. HTH.

---Tom
0 件の賞賛
返信

1,703件の閲覧回数
Nouchi
Senior Contributor II
Hi,

If you don't care to know, how does the flash works, you can use cfm_flash routines.
You can find their in dBug monitor source files here (cfm_flash.c):
http://www.freescale.com/files/netcomm/software/app_software/dbug_rom_monitors/M5213EVB_DBUG_SRC.zip
And you have just to use this function to flash:

Code:
int cfm_flash_program(ADDRESS dest, ADDRESS src, int bytes, int erase, void (*func)(void), void (*putchar)(char))

 
Emmanuel
0 件の賞賛
返信

1,703件の閲覧回数
JimMcP
Contributor I
Thanks for you replies...

I will take a look at that zip file BugMan...


I was looking at tn228.pdf. I don't what version of CodeWarrior that technical note was used on. But there is no PRM file. It uses the LCF (link) file. For instance,

/////////
SECTIONS

ROM_IMAGE = READ_ONLY 0xF000 TO 0xF2FF RELOCATE_TO 0x200;
////////
There is no RELOCATE TO in the CodeWarrior 6.0. What is equivalent to it.

And what is equivalent to this...
///////////
PLACEMENT

ToCopyToRAM INTO ROM_IMAGE
////////////


#pragma CODE_SEG ToCopyToRAM
int runInRam(....) {
.............
}
#pragma CODE_SEG DEFAULT
0 件の賞賛
返信

1,703件の閲覧回数
J2MEJediMaster
Specialist I
Linker command files can have several different extensions, depending upon the Codewarrior product you're using. I've seen .lcf, .cmd, and .prm. So, the Tech Note (which is old) is talking about a linker command file. RELOCATE_TO might be an old command used to copy ROM constants (or code, in this case) to RAM. For the Coldfire linker command, you can use the the WRITE command. For more information, consult the Linker section of the CodeWarrior ColdFire Build Tools Reference Manual, p. 129, the section on ROM-RAM copying. The reference manual is the Coldfire_Build_Tools_Reference.pdf file, which can be found the the Help directory of your ColdeFire CodeWarrrior installation.

---Tom
0 件の賞賛
返信

1,703件の閲覧回数
Nouchi
Senior Contributor II
Hi,

There's two CodeWarrior family, one's for 8/16bits MCU which is a (formerly) Hiware technology and use .PRM files with hiwave debugger, and other for 32bits and DSP's devices and use LCF files with integrated debugger. (IMHO hiwave is easier to use an more efficient).

regards,
Emmanuel
0 件の賞賛
返信