Some mounth ago we do same things. We use an Atmel AT91M55800A and an
external flash wich don't have busy pin. When i program the flash it
hangs up, so i have to run flash write code from ram.
We used the easiest way, copy all the functions/need run in ram/ from
flash to ram, make new ponter to it, and call the new function to
write flash.
the code:
void (* flash_write) (uint32, uint8);
__arm
void flash_write_(uint32 addr, uint8 data) {
flash_raw_write(0x555,0xF0);//RESET
flash_specstart_seq();
flash_raw_write(0x555,0x00A0);
flash_raw_write(addr,data);
flash_datapoll();
}
void copy_fv_init(void *init) {
to=(uint32*)init;
}
__arm
void* copy_fv(void *from_addr,int wordcount) {
int i;
//uint16 *from=(uint16*)(((uint8*)from_addr)-1);
uint32 *from=(uint32*)(((uint32*)from_addr));
void *start=(void *)to;
for (i=0; i<wordcount; i++) {
*to=*from;
to++,from++;
}
return start;
}
...
flash_write=(void (*)(uint32,uint8))copy_fv((void*)&flash_write_,120);
...
copy_fv_init sets the start addr. where the function will be placed.
copy_fv copy the function, with 120word/it can be determine
exactly,but it won't need for us/
a call:
flash_write(FLASH_FAT_BASE+r_addr,data);
It works fine! But we buy a flash that have busy output, and connect
it to externel wait pin of the ARM, so we don't have to run in ram
when writeing flash.
Good Luck!
OKEB
from HUNGARYMessage
Re: Execute Code in RAM?
2005-03-11 by zs_gaspar
Attachments
- No local attachments were found for this message.