> -----Original Message-----
> From:
> [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> org] On Behalf Of Patrick Mahoney
> Sent: Monday, August 20, 2007 4:01 PM
> To: [email protected]
> Subject: [avr-libc-dev] Problem writing to flash - atmega644
>
> 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.ht
> ml#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 ) );
>

I believe this is in the docs (I don't have access to them at the moment)
but you should NEVER call library routines from your bootloader. This means
memset, and printf. Those library routines will be in your application space
that you are probably trying to overwrite...

Eric Weddington




_______________________________________________
AVR-libc-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-libc-dev

Reply via email to