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

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

[avr-gcc-list] Re: bootloader / flash coding / avr


From: E. Weddington
Subject: [avr-gcc-list] Re: bootloader / flash coding / avr
Date: Thu, 22 May 2003 06:52:11 -0600


Reza Naima wrote:

> Eric,
>
> Thanks for the file.  I've modified the code that comes with MegaLoad
> (originally IAR-CC) to compile with avr-gcc, and trying to use that as my
> bootloading system.  However, I've been running into some problems and I was
> hoping you might be able to help.
>
> First off, my test code is setup with a main() function that will invoke
> the bootloader() function.  If the bootloader() function is not at
> 0x1E000 (I'm also using that ATmega128 with BOOTZ1=0 and BOOTZ0=0), then
> it seems to work fine.  If the function is relocated to 0x1E000, then it
> doesn't work.  Nor does it work on a reset (BOOTRST = 0).
>
> A friend suggested that the problem is that if it's just the function
> that's located at 0x1e000, then upon reset, the stack pointer/etc is not
> going to be initalized, and thus the bootloader will not work.  However,
> by simply calling the function, it still fails.  Any thoughts?  I've
> tried putting the bootloader code in main(), and relocating the entire
> text section to 0x1e000 (avr-gcc ... -Ttext 0x1E000), but that doesn't
> seem to help at all.
>
> Any advice would be greatly appreciated.
>
> Thanks,
> Reza
>
> p.s. I'm attaching the relevant files if you get a chance to look at
> 'em.  I'm planning on releasing the bootloader code to the public via
> GPL when I'm done.  It is currently setup to use the FTDI's usb<->serial
> converter chip to do it's I/O.
>

1. I would seriously consider NOT licensing it under GPL unless you have to. 
The BSD license is
less restrictive, and that way other people can use it freely in commercial 
products without
having to give away other parts of their code.

2. All the functions that are called in your bootloader() need to have 
BOOTLOADER_SECTION placed
after their prototypes. This means you need to write prototypes for TxChar, 
RxChar, flushUSB.
Also, any variables that are needed for the bootloader, also need to placed 
under
BOOTLOADER_SECTION, such as usb_boot_dev. Everything in the bootloader must be 
"self-contained"
and put into the "bootloader memory" (NRWW); you shouldn't make any calls that 
reference the RWW
memory that you're trying to modify. Sorry that this really isn't documented 
anywhere yet.

3. sbi will be deprecated soon. Use direct access instead: MCUCR |= SRE; As 
long as you have
optimization turned on, GCC will generate the correct instructions.

4. boot_mem_read() will not be a part of the final bootloader support API. 
There is a new
pgmspace.h API in the avr-libc CVS that provides better read functionality. 
Replace it with
pgm_read_byte().

5. Try testing just writing to the flash first, without doing the 
communications, using some
test data and getting just that part working. Then adding the comms stuff. I 
have gotten a
bootloader working at 0x1E000 with a mega128.

Eric



reply via email to

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