[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Startup code
From: |
Dmitry |
Subject: |
Re: [avr-gcc-list] Startup code |
Date: |
Wed, 30 Jan 2002 18:02:01 +0300 |
>From your bootloader code you can jump to init procedure:
void __attribute__ ((section(".bootloader"))) RunBootloader(void)
{
// My Bootcode
asm volatile("jmp _real_init_"); // should be the last line.
}
I am not sure if you need some frame space in your boot loader code. If you do
not, it would be better if you add __attribute__((naked)) to your
RunBootloader().
If you need it - I am not sure if the hardware initializes a stack pointer or
something. If it does not, you have to initialize it first and try something
like:
void __attribute__ ((section(".bootloader"))) __attribute__((naked))
RunBootloader(void)
{
// initialize frame pointer and stack pointer
// stack pointer will be re-initialized in main
asm volatile("
ldi r28,lo8(__stack - %0)
ldi r29,hi8(__stack - %0)
out __SP_H__,r29
out __SP_L__,r28 "
:: "i"((unsigned int)FRAME_SIZE_REQUIRED));
// now if you want to disable WDT
asm volatile("
ldi r18, lo8(__init_wdtcr__)
wdr
out %0, r18"
:: "I"(WDTCR));
// other registers likewise (see gcrt1.S in libc)...
// your bootloader code
asm volatile("jmp _real_init_"); // should be the last line.
}
hope it helps,
Dmitry.
On Wed, 30 Jan 2002 15:17:26 +0200
Pieter Potgieter <address@hidden> wrote:
> void __attribute__ ((section(".bootloader"))) RunBootloader(void)
> {
>
> // My Bootcode
>
> }
>
> Ok I got this far:
> The bootloader section is located at address 0x1FC00 by the linker.
> The fuse bit in the mega128 is set to jump to the bootloader address.
>
> Question :
> Are there any startup code or registers that needs to be initialised in the
> RunBootloader() procedure? Because the normal startup code is only executed
> when the mega starts executing from address 0x0000.
>
> IOW what startup code is neccessary for the mega to start executing from an
> address?
>
> Regards
> Pieter Potgieter.
>
>
>
> avr-gcc-list at http://avr1.org
>
*********************************************************************
("`-''-/").___..--''"`-._ (\ Dimmy the Wild UA1ACZ
`6_ 6 ) `-. ( ).`-.__.`) Enterprise Information Sys
(_Y_.)' ._ ) `._ `. ``-..-' Nevsky prospekt, 20 / 44
_..`--'_..-_/ /--'_.' ,' Saint Petersburg, Russia
(il),-'' (li),' ((!.-' +7 (812) 314-8860, 5585314
*********************************************************************
avr-gcc-list at http://avr1.org