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

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

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


From: Mudiaga Obada
Subject: Re: [avr-gcc-list] start a bootloader
Date: Fri, 29 Jul 2005 15:05:00 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716

> 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
> }

If fbl_starter() is already in the bootloader section, you should just
call fbl_main(). Your ijmp will not work because 1) you are forgetting
to convert fbl_main from byte to word address and 2) fbl_main needs more
that 16-bits to be above 0x1E000 and avr-gcc + avr-ld will only give you
16-bit pointers.


You problem is very like after fbl_main() is entered. Posibble reasons
could be because your are skipping crt0 and your hardware ist not been
reset when you enter fbl_main().

When a bootloader is written in C, I prefer to do a hardware reset when
going from BLS to AL. Write to some fixed RAM location from application
section, then reset. After reset the bootloader checks wherether to run
in bootloader mode in the .init3 section, store the result in a variable
in the .noinit section which the bootloader main() checks.







reply via email to

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