avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] Problem writing to flash - atmega644


From: Patrick Mahoney
Subject: [avr-libc-dev] Problem writing to flash - atmega644
Date: Mon, 20 Aug 2007 18:00:43 -0400

Greetings,

My setup is the following:
      - Atmega644 uC.
        - avr-libc 1.6
        - gcc 4.2.0

I am having an issue trying to have a bootloader write to flash.

I am using the boot_program_page routine taken 'verbatim' from the
avrlibc docs:
http://www.nongnu.org/avr-libc/user-manual/group__avr__boot.html#g7249d1
2e06789cd306583abf7def8176

I would expect the following code to blank all of flash. Yet it doesn't
happen, since the routine completes and returns as if nothing had
happened. The application runs perfectly after reset/reboot.

--------------------

void  __attribute__((section (".bootloader"))) CopyMemory(void){

    int i;
    char buffer[ 256 ];

    memset( buffer , '\0' , 256 );
    for( i=0 ; i<256 ; i++ ){
        boot_program_page( i , buffer );
    }

    printf("GET_LOW_FUSE_BITS = %x \r\n " ,boot_lock_fuse_bits_get(
GET_LOW_FUSE_BITS ) );
    printf("GET_LOCK_BITS = %x \r\n ", boot_lock_fuse_bits_get(
GET_LOCK_BITS ) );
    printf("GET_EXTENDED_FUSE_BITS = %x \r\n ", boot_lock_fuse_bits_get(
GET_EXTENDED_FUSE_BITS ) );
    printf("GET_HIGH_FUSE_BITS = %x \r\n ", boot_lock_fuse_bits_get(
GET_HIGH_FUSE_BITS ) );

}

--------------------

The lock bits / fusee bytes are all ok, as the printout suggests:

        GET_LOW_FUSE_BITS = fd
        GET_LOCK_BITS = ff
        GET_EXTENDED_FUSE_BITS = fe
        GET_HIGH_FUSE_BITS = 1f

( no memory protection & address@hidden )

Both routines are located in the BLS as avr-nm tool confirms:

        $nm
        (...)
        00007e00 T boot_program_page
        00007e76 T CopyMemory

A funny thing is that the routine execution causes no apparent delay,
leading me to think that the spm instruction aborts very quickly on a
failed condition.

Any help would be appreciated.

Best regards.



Patrick Mahoney




reply via email to

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