avrdudes / avrdude

AVRDUDE is a utility to program AVR microcontrollers
GNU General Public License v2.0
756 stars 139 forks source link

Flash pagesize of ATtiny20 #919

Closed stefanrueger closed 2 years ago

stefanrueger commented 2 years ago

Fun fact of the day about the flash pagesize of ATtiny20

MCUdude commented 2 years ago

What a mess! Wonder what the actual pagesize is...

BTW did you know that the AT42QT1070 is actually just an ATtiny20 under the hood? The AT42QT2120 is just an ATtiny40.

stefanrueger commented 2 years ago

No, ... demonstrating neatly the fluid boundary between hardware and software.

I know that there are a few ATA chips out there that have multiple ICs integrated in one, eg, ATA5505, ATA6616C, ATA6617C, ATA664251 all containing the ATtiny87/167. That's documented, though, in the datasheet and could have been guessed by the same signature.

What a mess! Wonder what the actual pagesize is...

Ah, yes, at least SPM_PAGESIZE probably does not matter as I don't think as the ATtiny20 even has the spm opcode.

I wonder whether there may be legitimately more than one page size in some models.

For example the ATtiny1634 has a 4-page spm erase only. Saves 96 bytes for the internal load page buffer (and requires attention to that detail in the bootloader).

mcuee commented 2 years ago

The datasheet says that Page Size is 16 words. Maybe that is why avrdude uses 16? Ref: https://ww1.microchip.com/downloads/en/devicedoc/atmel-8235-8-bit-avr-microcontroller-attiny20_datasheet.pdf

No, that is not correct. For example ATtiny40 datasheets says 32 words and avrdude uses 64. http://ww1.microchip.com/downloads/en/DeviceDoc/atmel-8263-8-bit-avr-microcontroller-tinyavr-attiny40_datasheet.pdf

As a hardware engineer, I tend to think the datasheet should be the right document to use.

Of course we can also check with Microchip to see what is the right one if really needed.

stefanrueger commented 2 years ago

This is an observation just for the fun of it. I am guessing (but do not know) that the page size doesn't matter for this part. It's programmed by TPI (no page size needed), has no spm opcode (no page size needed), so each instance - including the data sheet(?!) - made up its own favourite number.

I stumbled upon that gem when I compared the signature bytes and main characteristics of the parts as known to avrdude, avr-gcc 4.8.1 to bleeding edge 12.1.0, ATDF files and some selected data sheets when the sources didn't concur. Wanted to know

I wanted something in a bootloader that would tell AVRDUDE what the flash size, the EEPROM size, the page size and the number of interrupts the part has. Concluded, I better use something else (and shorter) than the signature... And then I also found out that the ATtiny1634 has a 4-page spm erase, which means that the bootloader really needs to tell AVRDUDE exactly which part it's on so AVRDUDE's bootloader programmer can help iron out the quirks of Microchips mcu families.

MCUdude commented 2 years ago

If the correct flash page size for the ATtiny20 is currently unknown, but it doesn't really matter when uploading anyways, can't we just close this issue as "not planned"?

stefanrueger commented 2 years ago

Closing as not really a bug, more like a curiosity