[Top][All Lists]

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

Re: [avr-gcc-list] re-initialising an ATMega128 as much as possible (sta

From: Torsten Mohr
Subject: Re: [avr-gcc-list] re-initialising an ATMega128 as much as possible (start a bootloader)
Date: Sun, 14 Aug 2005 21:34:21 +0200
User-agent: KMail/1.8


thanks for your hints.

Yes, i've read that mail you mention.  And i do something
similar for starting my bootloader and also posted that
solution here in this list.

On a different platform i also use a "magic value" variable
in an uninitialised memory location to test for the reset

I don't want to do that here because i don't like these
"magic value" solutions.  Also, the initialisation requirements
of the bootloader and the application are not too different.

There's always the theoretical chance that uninitialised RAM
contains that magic number.  But as it is possible to test
if the last reset was a watchdog reset, i may change my mind.

It is a nice idea to switch the interrupt vectors between
bootloader and application, i did not do this before.

Best regards,

> If I may ask, why go through such trouble? Instead of trying to
> "un-initialise as much of the micro as possible", why not reset and
> initial as little of the micro as needed?
> On 29.07.2005 I posted a response to you on this list about how you
> could pass information between the application and bootloader after
> reseting with the WDT. I wonder if you read it...
> I am attaching my bootloader entry/exit code with the hope that you
> could use it to solve your bootloader issues. The trick is the magic
> number thing - which you could extend for other things.
> Here's how to use the code:
> First you set your fuses so that the microcontroller starts with the
> bootloader after each reset.
> In your bootloader's main() you do
>       if (bootloader_disabled()) {
>               /* run application */
>               __asm__ volatile("ijmp": : "z" (0));
>       }
>       /* switch to bootloader interrupt vector */
>       MCUCR = _BV(IVCE);
>       MCUCR = _BV(IVSEL);
>       /* run bootloader */
> To exit your bootloader (after timeout or programmer command), you do
>       cli();
>       /* switch to application interrupt vector */
>       MCUCR = _BV(IVCE);
>       MCUCR = 0;
>       bootloader_disable();
>       reset_now();
> To go from application to bootloader
>       bootloader_start();
> Regards,
> Mudiaga Obada
> Torsten Mohr wrote:
> > i program an ATMega128, there's a bootloader at 0x1e000
> > and a normal application at 0x00000.
> >
> > When the application starts the bootloader, it does that
> > by directly jumping into it.
> >
> > In the bootloader i'd like to un-initialise as much of
> > the micro as possible, i think it is not possible to
> > initialise everything the same way as after a real reset.

reply via email to

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