[Top][All Lists]

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

Re: [avr-gcc-list] start a bootloader

From: Parthasaradhi Nayani
Subject: Re: [avr-gcc-list] start a bootloader
Date: Fri, 29 Jul 2005 05:38:07 -0700 (PDT)

Hello Torsten Mohr,

I had tested a small bootloader and it worked OK,
though I tested only twice. My bootloader also starts
at the same address 0x1e000. The way I implemented is
slightly different from what is given here. Control
goes to bootloader after reset and here an I/O pin is
sampled to see if the loader is to be executed or the
application to be executed. The jump to application is
done through 'C' call. A pointer to a function is
declared and this pointer is initialised to 000 and
this function is called instead of the asm statement.

In order to reduce the size of the bootloader if I
adjust the SP or skip the statup code the code does
not work. I do not know if this will give you some
cursor on how to crack the problem. 


--- Torsten Mohr <address@hidden> wrote:

> 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.
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden

Start your day with Yahoo! - make it your home page 

reply via email to

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