avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] start a bootloader


From: Torsten Mohr
Subject: [avr-gcc-list] start a bootloader
Date: Fri, 29 Jul 2005 12:51:17 +0200
User-agent: KMail/1.8

Hi,

i have continuous problems with my bootloader, maybe somebody
can give me some hints?

I have the bootloader and the normal application as two separate
programs, the application at 0x0000, the bootloader at 0x1e000.
This all happens in an ATMega128.

The reset vector is in the bootloader, it first detects if there
is a valid application.  If it finds a valid application, it starts
it by asm("jmp 0x00").

When the application receives a special command (via USB), it
starts the bootloader.  This part seems to fail.

The application can read the function pointer of a "bootloader
start address" at a fixed address.  It reads this address correctly
and starts the bootloader:

asm("\tijmp\n":: "z" ((uint16_t)(fbl_start_fptr/2)))

With a special port setting done at that address i'm pretty
sure the correct address was called.  At this start address
i need to re-initialise the stack and set up the environment
for the bootloader:

void fbl_starter(void) __attribute__((naked));
void fbl_starter(void) {
  SPL = (__stack)&0xFF;
  SPH = (__stack)>>8;

  PORTF = 0xa5; // << this can be seen at the port

  asm("\tijmp\n":: "z" ((uint16_t)(fbl_main)));
  // i also tried to just call fbl_main() as a function
}


This is how the bootloader normally starts up:
int main(void) {
  app_check();

  if(app_type > 0) {
    asm("\tjmp 0x00\n");
  }

  fbl_main();

  return 0;
}

So there are the two ways (via main and via fbl_starter) to
start the bootloader.  One way works fine, the other not.

Can anybody tell me why?


Best regards,
Torsten.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]