Forums

Temporary call Atmel bootloader

Started by Juergen Loh November 22, 2004
Hi,

I'm using a AT89C51ED2.  Sometimes the application needs to start the Atmel
ISP bootloader, e.g. to enable re-programming the flash.  Normally this is
done by the following API procedure:

    void __api_start_bootloader (void)
    {
        __api_wr_BSB (0xFF);
        __api_wr_SBV (0xFC);
        // stop application peripherals
        T2CON=0x00;
        TL2=0x00;
        TH2=0x00;
        BDRCON=0x00;
        TCON=0x00;
        SCON = 0x00;
        TMOD = 0x00;
        PCON = 0x00;
        TCON = 0x00;
        EA = 0;
        MAP_BOOT;
        __API_JMP_BOOTLOADER();
    }

The problem ist the writing of 0xFF to BSB, because it inhibits the start of
my application on the next reboot.  I'm looking for a way of starting the
bootloader without the need of modifying the BSB.  Simply commenting out the
"__api_wr_BSB()" line is not possible, because then the bootloader
immediately returns to the application.

Any idea?

J�rgen


Juergen Loh schrieb:

> I'm using a AT89C51ED2. Sometimes the application needs to start the Atmel > ISP bootloader, e.g. to enable re-programming the flash. Normally this is > done by the following API procedure: > > void __api_start_bootloader (void) > { > __api_wr_BSB (0xFF); > __api_wr_SBV (0xFC); > // stop application peripherals > T2CON=0x00; > TL2=0x00; > TH2=0x00; > BDRCON=0x00; > TCON=0x00; > SCON = 0x00; > TMOD = 0x00; > PCON = 0x00; > TCON = 0x00; > EA = 0; > MAP_BOOT; > __API_JMP_BOOTLOADER(); > } > > The problem ist the writing of 0xFF to BSB, because it inhibits the start of > my application on the next reboot. I'm looking for a way of starting the > bootloader without the need of modifying the BSB. Simply commenting out the > "__api_wr_BSB()" line is not possible, because then the bootloader > immediately returns to the application.
What is the address defined for __API_JMP_BOOTLOADER? -- Dipl.-Ing. Tilmann Reh Autometer GmbH Siegen - Elektronik nach Ma�. http://www.autometer.de
Hi Tilmann,

you wrote:

> What is the address defined for __API_JMP_BOOTLOADER?
#define __API_JMP_BOOTLOADER (*((const void(code*)(void)) 0xF800 )) J�rgen
Juergen Loh schrieb:

>> What is the address defined for __API_JMP_BOOTLOADER? > > #define __API_JMP_BOOTLOADER (*((const void(code*)(void)) 0xF800 ))
I think the entry point for the boot loader is FC00h. At least it always was for the RD2, and AFAIK the loader is the same. But then, unless you jump to the soft boot entry at FC03h (which checks BSB and SBV), the boot loader should immediately start (with the automatic baud rate detection). -- Dipl.-Ing. Tilmann Reh Autometer GmbH Siegen - Elektronik nach Ma�. http://www.autometer.de
Juergen Loh schrieb:

> The problem ist the writing of 0xFF to BSB, because it inhibits the start of > my application on the next reboot. I'm looking for a way of starting the > bootloader without the need of modifying the BSB. Simply commenting out the > "__api_wr_BSB()" line is not possible, because then the bootloader > immediately returns to the application.
Another thought: what if ENBOOT (in AUXR1) is not set, unless you have set the BSB? -- Dipl.-Ing. Tilmann Reh Autometer GmbH Siegen - Elektronik nach Ma�. http://www.autometer.de
Hallo Tilmann,

> Another thought: what if ENBOOT (in AUXR1) is not set, unless you have > set the BSB?
IMHO not a good idea, because if ENBOOT is 0, there is not boot loader mapped to the code space. Tsch�s, J�rgen
Hallo Tilmann,

sorry for my late reply.  I had to stay in bed with fever for some days.
:-(

> I think the entry point for the boot loader is FC00h.
The ED2 data sheet says that the boot loader's address is from F800 to FFFF. And the boot process diagram says that the boot ROM is started at F800 at startup.
> But then, unless you jump to the soft boot entry at FC03h (which > checks BSB and SBV), the boot loader should immediately start > (with the automatic baud rate detection).
Yes the boot loader starts, but it immediately returns to the application program at 0000 if BSB is 00. Is there any documentation of the boot loader's entry points like FC03 as you mentioned? Tsch�s, J�rgen