Problem programming internal flash with a file .bin (52235EVB + CW7.0)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problem programming internal flash with a file .bin (52235EVB + CW7.0)

2,258 次查看
fjoli
Contributor I
Hello,

I'm trying to program the internal flash of the 52235EVB with a file .bin of an application which is in a extern flash memory.

The part of the program (the bootloader) which do that is between the adress 0x36000 and 0x40000 of the internal flash.

I succeed to erase the internal flash beetween 0x00 and 0x36000 and then stay in the bootloader and I saw that all the memory I want to erase was at 0xFFFFFFFF so for this step it is ok.

Then I program the internal flash it means that I read the data of the file .bin which is in the external flash memory and then I write it in the flash memory.

For the moment I'm just trying to program the same data that there was in the beginning so the file .bin which is in the external memory in the file of the application.

But I don't succeed to program all the file .bin in the internal flash.

When I put a breakpoint after programming the flash I saw that I don't succeed to program all the flash and I saw that there is not what there was before in the beginning of the internal flash.

I saw in the forum that I can't erase or program flash from the flash but when I erase and program a part of flash which is not used it is ok.

I tryied to copy the bootloader in the RAM to execute it in  the RAM but I don't succeed.

Can somebody help me about this ?

Thanks

Fabien
标签 (1)
0 项奖励
回复
5 回复数

818 次查看
Karion
Contributor I
and I am having problems to use the emg_web_uploader

Failed to connect to ip address: 192.168.1.99
Connect failed: unknown error 10060>

but, I have flashed the ColdFire_Lite to my M52235EVB and its running fine, i ping it, do all the things... but when i try to use this tool i get fail.
My network connection is ok.

thx
Karion

0 项奖励
回复

818 次查看
fjoli
Contributor I
Karion I think that you post your message in the wrong thread.
0 项奖励
回复

818 次查看
RichTestardi
Senior Contributor II
Hi,
 
These two posts *might* help:
 
 
In the first post I run a "flash copy" function from RAM to reprogram the flash I used to be running from.
 
In the second post I run the "flash write" routines from flash to program the "other half" of flash.
 
-- Rich
0 项奖励
回复

818 次查看
fjoli
Contributor I
Hello Rich

I have already test your functions in the second post you mention but it does'nt work.
I succeed to write a file .bin in the internal flash memory but when I make a software reset there is an : " Exception vector name: Adresse error".
I don't understand why.
I have checked the internal memory and there is the data I wan to copy but there is this error.

Have an idea why it doesn't work ?

Could explain me something about your code in the first post you mentionned ?
First what is "RAM_CODE_PAGE" I think it is the adress of the RAM but is there any problem with the data in RAM ? do you need to erase the RAM before to copy the code in RAM ?

For my application, I need to use all the flash so I have put the new code I want to program in an external memory flash and then I want to program the code I read in the external flash in the internal flash.
so my problem is that I need to use more than one function
Can I put more than one function in the RAM ?
Can I use data which are in RAM during I am programming the flash ?

Last question Which file it is better to use to reprogram the flash .bin or .s19 ? I saw that the data in .s19 file are in text mode but there is the information of the adress but I can't see in the .bin if there is information about adress.

Thanks for your help.

Fabien




Message Edited by fjoli on 2008-07-24 02:13 PM
0 项奖励
回复

818 次查看
RichTestardi
Senior Contributor II
Hello Fabien,
 
If you want to send me an e-mail at rich@testardi.com, I can send you full source files...  I'm working on a website now to publish this stuff, so I'm happy to share it in the meantime.  Cmag got the functions to work fine here: http://forums.freescale.com/freescale/board/message?board.id=CFCOMM&message.id=4353#M4353 so I am pretty sure they are good.
 
> but when I make a software reset there is an : " Exception vector name: Adresse error".
 
Does the error occur even before you enable interrupts?  If so, then I'd suggest looking at the first two 32 bit words of your default VBR (at address 0), where your initial SP and PC are stored...  Note that once you are running, your code might move the VBR to RAM (but those words are not read again).
 
> First what is "RAM_CODE_PAGE"
 
It is just a 2k byte buffer anywhere in RAM.  It can be smaller than 2k bytes for this purpose (just big enough to hold the memcpy()'d function), but I use it for other purposes as well.
 
> do you need to erase the RAM before to copy the code in RAM ?
 
Nope, the memcpy() will overwrite it.  Note that you should be able to step into the RAM copy of the function just fine with the debugger and see what it is doing.  That function has to be carefully constructed to not generate "relocations", since it is running from a different address (in RAM) than where it was compiled/linked (in FLASH) for...  So the function cannot call other functions, for example (you can use #defines to essentially inline other functions, however).
 
> For my application, I need to use all the flash so I have put the new code I
> want to program in an external memory flash and then I want to program
> the code I read in the external flash in the internal flash.
> so my problem is that I need to use more than one function
 
Ah, you have to use more than one function because you need to read the external flash via SPI?  Yes, that makes it harder.  You might be able to use "position independent code", either from a #pragma or from the compiler options, but I have never done this.  The problem is that by default, a function call will use an absolute address...  So if foo() calls boo(), and you copy both foo() and boo() to RAM, when you run foo(), it will call the *original* boo(), in FLASH, rather than the one in RAM -- and the copy in flash might have been obliterated already by the update...  You might be able to also patch the assembly language, but that is a lot of work as well...
 
I would probably suggest you try putting all the functions you want to use (including flash and SPI functions) in a single file, in the order they are referenced, and asking the compiler to explicitly inline them all...  That *might* give you one huge function with no relocations -- you can use the "disassemble" option on the source file in the project pane to test this...  Or you can do #define ugliness (by using #defines to implement your SPI functions) to make the whole thing one real function -- that will work, but it may be ugly...
 
> Can I use data which are in RAM during I am programming the flash ?
 
Yes, since RAM data won't change addresses even if you copy the functions to RAM...  Be really careful to make sure that you disable interrupts before transferring control to the RAM functions, as that will wreak havoc on things if you do not...
 
> Which file it is better to use to reprogram the flash .bin or .s19 ?
 
I use the s19 file and I can mail you functions that parse it as well...  The format is well documented here: http://en.wikipedia.org/wiki/S-record
 
-- Rich
 
0 项奖励
回复