Upload bigger than 28.800bytes does't complete?

Hi I'm using the ATMEGA328P-PU running at 8Mhz at protoboard..

Even trying to upload sketches within limit (30.720 bytes) the upload doesn't complete

There are no errors about sketch size durring compilation etc.

While compilation::
Binary sketch size: 30.580 bytes (of a 30.720 byte maximum)

While upload (after 15 seconds):
avrdude: verification error, first mismatch at byte 0x7000
0xe1 != 0xff
avrdude: verification error; content mismatch

Weird, because when I removed some function for testing purpose, and reach as low as 28.600 bytes, the sketch uploads normally.

This is my bootloader:
##############################################################
atmega328bb.name=ATmega328 na protoboard (8 MHz clock interno)
atmega328bb.upload.protocol=arduino
atmega328bb.upload.maximum_size=30720
atmega328bb.upload.speed=57600
atmega328bb.bootloader.low_fuses=0xE2
atmega328bb.bootloader.high_fuses=0xD8
atmega328bb.bootloader.extended_fuses=0x07
atmega328bb.bootloader.path=atmega
atmega328bb.bootloader.file=ATmegaBOOT_168_ATMEGA328_pro_8MHz.hex
atmega328bb.bootloader.unlock_bits=0x3F
atmega328bb.bootloader.lock_bits=0x0F
atmega328bb.build.mcu=atmega328p
atmega328bb.build.f_cpu=8000000L
atmega328bb.build.core=arduino:arduino
atmega328bb.build.variant=standard

Any idea?

tks a lot

I don't know the details, but I understand it's possible to select how much program memory is available for the bootloader versus the sketch. I think this is defined by the fuse settings. Is it possible that the board has a bootloader and fuse settings installed that make less space available for the sketch than you have indicated in your boards.txt? I notice that the error occurred on a nice round hex number which is the sort of thing you'd expect if you were just overflowing the space available for storing that sketch.

There was a famous optiboot bug that hit at about that file size (long ago fixed.)
http://code.google.com/p/arduino/issues/detail?id=380&can=1&q=optiboot
I don't remember ever hearing about a similar problem in atmegaboot, and it's logic should be different enough that it doesn't have exactly the same error, but it could be related.
You could load up optiboot instead; it is known to be fixed, and is 1.5k shorter as well...

Pretty much all my clone Mega 2560's had this problem. Replacing the bootloader was the fix.

With regards to the bootloader, I'm not sure what the original one was, it just didn't work. Never had the problem on an Uno though ( rare for such a large sketch ). Either way replacing the bootloader can't hurt.