Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: GCC and selfflash-routine from RAM !?
PostPosted: Tue Jun 15, 2004 3:47 pm 
Offline

Joined: Tue Jun 15, 2004 3:17 pm
Posts: 1
Location: Germany (29497 Woltersdorf)
Hallo and at first a compliment to the bort admins for this Forum :!:

i have a little problem with my EB40A (AT91R40008), i need to programm my flash (AT9BV1614A) at runtime an i don't know how. I have already read the examples from ARM but i dosen's find any useful code for my problem.

I have already found then "lib_flash_at49.c" etc. but these functions work in the flash which i want to flash :?

Does somebody have already a solution for this problem ?
Or any code to copy a completely function to ram an exec. this function ? :wink:

At last, excuse for my bad english, i'm just a stupid german computer scientist :oops:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 15, 2004 4:35 pm 
Offline

Joined: Fri Mar 19, 2004 7:10 pm
Posts: 8
Hi,

If you are using ARM Developer suite (ADS1.2) you can load any function into RAM. Read the chapter about scatter loading.

With gcc it is also done via the linker control file.

Joe


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 15, 2004 8:47 pm 
Offline
User avatar

Joined: Tue Mar 09, 2004 3:38 pm
Posts: 17
Hi yaron and Joe,

Firstly, tanks a lot concerning your remark on the at91 Forum bord. I was glad to hear that :wink:
Regarding your issue depends on your debug means and the on-board software.
- The good news is if you have an ICE interface, as said Joe, you have to download the Atmel library under the AN in the Atmel web site and extract the dedicated project from this one,
- If you have the initial software in the the Flaskh memory (the Atmel's software), it embeds a flash up loader,
-The bad news is your flash is blank and you have not any ICE Interface... OoPSSSSSSS, anything more :x
For the last case, the free tools and a equivalent wiggler that should do the trick (wiggler is only parrallel buffer). About the free tools, i advise you to read a german book referered in RESOURCES (it is not pub, just for your information).

Just one question: Who is the avatar picture ??

All the best for your study and good luck

_________________
- Administrator of AT91 Forum -

Best Regards


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 15, 2004 11:24 pm 
Offline

Joined: Thu Mar 25, 2004 12:10 am
Posts: 126
Location: Germany
Hi yaron,
if you use a gcc compiler, you have to create a separate section for your flash routines, located in RAM. You have to use the ELF - file format (arm-elf-gcc) for doing this :-).
This functions are copied into the ram area if they are needed. I use a separate copy function for this.
Because you can't call this functions directly from ROM area (there is a 24 Bit jump limit), you can use a function table (located in ROM).

To tell the compiler that the flash routines are not in ROM use the following syntax:

int RamFlashEraseBlock(unsigned long adr) __attribute__((section(".ram")));
int RamFlashEraseBlock(unsigned long adr)
{
}
This tells the compiler to put the function RamFlashEraseBlock into the section RAM.

The function table looks like:
const int (*RAM_FUNC[])(unsigned long, ...) __attribute__ ((section(".text"))) =
{
(void*)&RamFlashEraseBlock,
:
:
};

To call the function use:
RAM_FUNC[0] (0);

The parameter 0 is interpreded by this function.

HINT: If you are inside a RAM function you can call other RAM functions direct. Do not use the table, because this table is located in flash, which could be erased.

Now you need an entry for the section RAM in the linker script like this:
.text 0x000000000 : { _rom_start = .; *(.text) *(.rodata) *(.glue_7) *(.glue_7t) *(.rodata.str1.4)} > rom
. = ALIGN(4);
_text_end = .;
. = 0x100000
.ram . : AT (_text_end)
{ _ram_start = .; *(.ram); _ram_end = .;} > ram

This will locate the ram-function at the end of the _text section (using the linker variable _text_end). The ram functions are now located in ROM, but they will linked for the address 0x10000.
To use it, you will generate a copy function, like this:

copy:
STMFD sp!, {r2, r3, r4, lr}
adr r0, LC0
ldmia r0, {r2, r3, r4} @ r2 - _ram_start / r3 - _ram_end / r4 - _text_end
2:
ldr r0, [r4], #4
str r0, [r2], #4
cmp r2, r3
blt 2b
LDMFD sp!, {r2, r3, r4, pc} @ return

LC1:
.long _ram_start
.long _ram_end
.long _text_end


You can also use a C copy routine. Declare the linker variables as EXTERN and use the address operator for getting the correct values.

I hope this helps :-).

Best regards, Edi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: