is sketch loaded at address 0 or at high address on UNO?

I may have an UNO board with a bad chip.

I can upload sketch with a compiled size up to 28k just fine (28672 bytes). Anything above that the upload fails.

Binary sketch size: 30092 bytes (of a 32256 byte maximum)

avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64
avrdude: stk500_cmd(): programmer is out of sync

I know it is likely my ATmega328 chip is bad, but I am just curious as to where sketch is loaded in the address space of the cpu. Or to phrase the question another way, what address is the bootloader loaded.

does the R2 bootloader take 512bytes or 1024 bytes? either way, it should leave 31744 bytes for sketch space right?

Thanks
Jerry

I did some more reading.
It appears the standard bootloader uses 2k of memory, and the optiboot uses 512 bytes (the readme claims it uses 1.5k less, hence I am assuming the standard bootloader uses 2k).

since I got a non R3 UNO, then the maximum sketch size I can upload is 30720 bytes right?

with ethernet+sd taking up about 26k of space, that leaves hardly any space left to do even just slightly complex routine.

I know it is likely my ATmega328 chip is bad,

And I know that it is more likely that your chip is just fine. The bootloader does occupy high memory. The sketch loads starting from low memory (but not starting a 0 as there are interrupt vectors and other users of the lowest addresses).

The boards.txt file contains the maximum loaded memory size for the various Arduino board models:

For Uno board: uno.upload.maximum_size=32256

For Duemilanove board: atmega328.upload.maximum_size=30720

The difference is due to the smaller bootloader used in the Uno board.

Lefty

Thanks for the reply.

My sketch size is less than 30720 and I get the error. As far as I can tell, using trial and error, my upload fails if size greater than 28672 bytes.

Are all UNO boards, including clones, use the 512 byte optiboot bootloader?
How about chips sold by adafruit which claims to have their own bootloader, does that take up 2k or 512 bytes?

doughboy:
Thanks for the reply.

My sketch size is less than 30720 and I get the error. As far as I can tell, using trial and error, my upload fails if size greater than 28672 bytes.

Are all UNO boards, including clones, use the 512 byte optiboot bootloader?

I believe so

How about chips sold by adafruit which claims to have their own bootloader, does that take up 2k or 512 bytes?

I think the Uno's bootloader is the only 512 byte size, all other arduino type bootloaders for the 328p chip use 2K, at least that is my understanding.
Lefty

thanks for the clarification.

I ordered the chip from adafruit. I confirmed it comes with the 2k bootloader (since it is based on ATmegaBOOT and not optiboot), I could use that chip on my UNO and use it as AVR ISP right? since original UNO chip comes with the 512 byte bootloader and cannot be used as an AVR ISP programmer according to this

NOTE: Currently, you cannot use an Arduino Uno as an ISP programmer because the optiboot bootloader does not support this sketch. A revision for this is in progress.

or is it possible to use UNO with 512byte bootloader as AVR ISP now?