[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] ATmega64 boot code blues
From: |
Theodore A. Roth |
Subject: |
Re: [avr-gcc-list] ATmega64 boot code blues |
Date: |
Wed, 30 Jun 2004 12:53:59 -0700 (PDT) |
On Wed, 30 Jun 2004, Richard Ziemerink wrote:
> Hi,
>
> I am trying to write a bootloader for the ATmega64 using avrgcc. As a
> small test to see if I could change the program memory I tried out the
> following code:
> [code]
>
> #include <avr/interrupt.h>
> #include <avr/boot.h>
> #include <avr/io.h>
>
> int main(void)
> {
> #define ADDRESS 0x1000UL
>
> // debug pin
> DDRE = 0xff;
> PORTE = 0xff;
>
> // Erase page.
> boot_page_erase((unsigned long)ADDRESS);
> while(boot_rww_busy())
> {
> boot_rww_enable();
> }
>
> // Write data to buffer a word at a time. Note incrementing address
> // by 2. SPM_PAGESIZE is defined in the microprocessor IO header
> file.
> for(unsigned long n = 0; n < SPM_PAGESIZE; n += 2)
> {
> boot_page_fill(ADDRESS + n, n);
> }
>
> // Write page.
> boot_page_write((unsigned long)ADDRESS);
> while(boot_rww_busy())
> {
> boot_rww_enable();
> }
>
> for(;;)
> {
> PORTE ^= 0xff;
> }
>
> return 0;
> }[/code]
>
> The code is located at address 0x7C00, and the following values have
> been set
>
> BOOTSZ = 01
> BOOTST = 0
> No lock bits have been set.
>
> I have verfied that the program is running by looking at the toggling
> of PORTE.
>
> I would expect the program memory to change, but when I read the memory
> back via the ISP port all memory values except the values where the
> booloader is located equals 0xff..
>
> Could anybody please point out what I am doing wrong here? I have run
> out of ideas and would appreciate some input.
You might be interested in this:
http://lists.gnu.org/archive/html/avr-libc-dev/2004-02/msg00053.html
There's a link in that message to another one that might be related to
you problem.
You might also want to have a look at the boot.h file in cvs head. The
example there has been updated.
---
Ted Roth
PGP Key ID: 0x18F846E9
Jabber ID: address@hidden