[En-Nut-Discussion] ethernut 3.1d running software in flash + bootloader

Andre Riesberg andre at riesberg-net.de
Thu May 17 16:26:23 CEST 2012


Andrea Cannavicci schrieb:
> Good morning,
>
> I need support for Ethernut 3.1d.
>
> Usually I have a bootloader loaded in flash that download the application
> from TFTP or Flash and load it in RAM, then jump to addres 0 and execute it.
>
> My application now is becaming too large and doesn't fit in RAM. I need to
> move the application in flash and run it in flash also.
>
> I know and successfully tested compilation option to run application in
> flash memory but in this way I have to flash it at flash address 0 and I
> lose the chance to upgrade my application using a bootloader.
>
> I'd like to have:
>
> -          Bootloader stored in flash from flash start address (0x10 0000
> 0000 after remapping).
>
> -          Application stored and running in flash from a base address that
> I can decide (example 0x10 1000 0000 after remapping)
>
> Until now we use bootloader to write application in Flash, when board start
> the bootloader copy application in ram  and then branch with BX assembler
> inline instruction to execute it.
>
> I'd like to do something similar without copying the application in RAM but
> starting it directly jumping to  the assigned address in flash, because (as
> I said before) the application became to big and the RAM is too low to run
> it.
>
>
>
> To maintain the possibility to upgrade the application using a bootloader
> via ethernet I'd like also to jump back to bootloader when  the application
> will receive a "software upgrade" command.
>
>
>
> We try some example with in line assembler but without success.
>
> Could someoone help me and send me same example or hint?
>
>
>
> Thank you in advance for your precious help
>
>
>
> Best regards
>
>
>
>
>
> *Andrea Cannavicci*
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>
>   


Hello Andrea,

you want to use the „bx“ instruction so you have some kind of ARM CPU. I 
use a board like the elektor internet radio with a ARM7.
My bootloader load the application from SD-Card and place it SDRAM, then 
execute the „Upgrade“ function.

uint32 RAMFUNC WriteFlash(uint32 *flash,uint32 *data,uint32 size)
{
outr(MC_FMR,0x00490200);
uint16 i,j;
for (i = 0;i < (size + 255) / 256;i++) {
uint8 retryCount = 0;
Retry:
while (!(inr(MC_FSR) & 1)) _NOP();
for (j = 0;j < 64;j++) flash[j] = data[j];
outr(MC_FCR,MC_KEY | MC_FCMD_WP | (MC_PAGEN_MASK & (uint32) flash));
while (!(inr(MC_FSR) & 1)) _NOP();
for (j = 0;j < 64;j++)
if (flash[j] != data[j]) {
if (retryCount++ < 16) goto Retry;
for(;;);
}
flash += 64;
data += 64;
}
for (;;) outr(RSTC_CR,0xA5000007);
}

void Upgrade(uint32 *data,uint32 size)
{
uint32 *flash = (uint32*) 0x00100000; // Change it!

printf("\n\n");
printf(" --------------------------------- \n");
printf("| Dusty Bootloader for ARM7 V1.0d |\n");
printf(" --------------------------------- \n");
printf("\nStart writing flash 0x%08lX with %ld bytes...\n",(uint32) 
flash,size);

NutEnterCritical();

WriteFlash(flash,data,size);
// Fire the watchdog now!
}

Be sure that RAMFUNC is defined correctly! Look into the map file or get 
the address of WriteFlash an print it.
I hope this help.

Greeting
André





More information about the En-Nut-Discussion mailing list