[solved] BOOTRST erratic behavior with atmega 88

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am currently trying to install a bootloader on an atmega88PA.
So far, the bootloader works fine, it is installed in boot zone and load in flash my application program.

Problem is that at power on, sometimes to bootloader is called (as it should), sometimes the application is directly called without going through the bootloader.

I configured in such a way that bootloader is always called at power on , or at reset. Fuse BOOTRST has been programmed, and flash size for boot loader set to 1024, start address in the linker set to 0xC00.

I don't understand what could be the explanation of this erratic behavior. Why isn't the booloader code always run at power on ?

Any idea ?
Thanks

Last Edited: Sun. Sep 18, 2011 - 08:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Fuse BOOTRST has been programmed,

In that case there's no question the bootloader will be entered every time. But your mention of 0xC00 and the word "linker" is interesting. If by "linker" you mean you are using GCC tools then the boot address is 0x1800 which is the byte equivalent of word address 0xC00

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Tell us exactly what your fuse values are.

I would guess that you have set the BOOTSZ bits differently. Have you linked the bootloader to run at byte address 0x1800?

Avr-gcc uses byte addresses. The avr uses words for its location counter.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The internal power on reset works not reliable. :!:

Power must fall down to almost 0.0V and then it must rise fast and monotonic.

Thus the BOR should be enabled always. :!:

Peter

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks guys for your help.
This is the command used for compile and link:

avr-gcc -g -Wall -O2 -mmcu=atmega88p -DF_CPU=16000000L   '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=2' -DBAUD_RATE=19200   -c -o ATmegaBOOT_168.o ATmegaBOOT_168.c
avr-gcc -g -Wall -O2 -mmcu=atmega88p -DF_CPU=16000000L   '-DMAX_TIME_COUNT=F_CPU>>4' '-DNUM_LED_FLASHES=2' -DBAUD_RATE=19200 -Wl,--section-start=.text=0x0c00 -o ATmegaBOOT_168_atmega88.elf ATmegaBOOT_168.o 
avr-objcopy -j .text -j .data -O ihex ATmegaBOOT_168_atmega88.elf ATmegaBOOT_168_atmega88.hex

Changing section-start to 0x1800 gives an error:

/usr/bin/avr-ld: address 0x264c of ATmegaBOOT_168_atmega88.elf section `.text' is not within region `text'

Danni, what do you mean by BOR, is it BOD level ? If yes, then it is set to 4.3V, but it does not solve.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Changing section-start to 0x1800 gives an error:

0xC00 is wrong, 0x1800 is right but obviously the whole bootloader needs to be under 2K. Your error says you are over by 0x64C=1612 bytes so you have some serious trimming work to do.

How on earth have you managed to make a bootloader THAT complex?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, this is the arduino bootloader... :D
You are right, 3362 bytes will not fit in atmega 88...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Well, this is the arduino bootloader..

But it's nowhere near that big. Have you made a fundamental error such as building -O0 or something? (though I see -O2 above).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I used their makefile.
Now I removed some #ifdef in the code and changed -O2 to -Os.
It fits, and bootloader works *much* better.
Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I am currently trying to install a bootloader on an atmega88PA.
... this is the arduino bootloader...
... I used their makefile.

Um, none of the current Arduino bootloaders HAS support for ATmega88 in "their makefile"

The version of "optiboot" here should have it, and it should work (but it's a 500 byte bootloader, and may be missing features that you want.) https://github.com/WestfW/Arduino