Bootloader for atemega8u2 for mega328 work with 8u2 and atmega16-16 main?

Hi

I am developing a board and looking to use a atmega16-16 due to its increase in I/O.
I have got a bootloader work for the atmega16 via an ICSP, but I am having trouble
using the atmega8u2 to program my atmega16.

I used the flip program to load the uno hex file onto the atmega8u2
Arduino IDE sees the chip as an uno and has assigned it a port
I upload my sketch and get the error

avrdude: stk500_getsync(): not in sync: resp=0x25 when I connect the TX and RX without a 1k resistor inbetween

and

avrdude: stk500_getsync(): not in sync: resp=0x30 when I connect the TX and RX lines with a 1k resistor inbetween

Any thoughts would be amazing

You have a bootloader on the atmega 16. Correct? Do you have a atmega16 boards.txt entry? You will need that to upload to it with the Arduino IDE.

Isaac thanks for the response

I have this for my boards.txt entry

atmega16.name=ATmega16 @ 16 MHz
atmega16.upload.using=arduino:arduinoisp
atmega16.upload.maximum_size=14336
atmega16.upload.speed= 19200
#atmega16.upload.protocol=arduino

Start-up time PWRDWN/RESET: 16K CK/14 CK + 65 ms; [CKSEL=1111 SUT=11]

Brown-out detection level at VCC=4 V; [BODLEVEL=100]

Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

Serial program downloading (SPI) enabled; [SPIEN=0]

Boot Flash section size=128 words Boot start address=$1F80; [BOOTSZ=11]

atmega16.bootloader.low_fuses=0x7F
atmega16.bootloader.high_fuses=0xD7

atmega16.bootloader.extended_fuses=0x07

atmega16.bootloader.path=atmega16
atmega16.bootloader.file=atmega16.hex

atmega16.bootloader.unlock_bits=0x3F
atmega16.bootloader.lock_bits=0x2F

atmega16.build.mcu=atmega16
atmega16.build.f_cpu=16000000L
atmega16.build.core=arduino:arduino
atmega16.build.variant=standard

I guess my concern and lack of understanding is about the how the 8u2 functions. Will it
blindly send data via the UART or do I need to specify my model of the atmega in some way.

Eric

The 8u2 will send whatever you throw at it. Maybe you have the wrong baud rate. Try 115200 and 57600, and maybe 38400.

Hi Isaac,

I have done some trail and error. I have proven that I can upload a sketch with a serial.print command through icsp and see it outputted through an arduino I use as a COM bridge, but when I hook up my onboard usb-uart I just get nonsense in my serial monitor. I can see something which is a start, which makes me think its the baud rate, but why would the arduino 8u2 bootloader I flashed onto my 8u2 be a different baud rate then the 16u2 bootloader I have on my arduino?

A separate problem I am having is neither my onboard usb-uart 8u2 or the 16u2 on my arduino can program my chip via uart.

Any thoughts would be great.

Thanks
Eric

99% of USB-UART converters can use different baud rates, so don't think of that as a problem. If the 8u2 on the Uno is working and the other one isn't, then maybe it is configured as something else. Try reflashing the firmware with FLIP.

I discovered my error was with my baud rates. I am not sure if its the bootloader for the UART to serial mirco or on the main mirco's side, but there was a 8X difference in my baud rates. I have read this to be a common problem in serial communication situations, it took my this long to figure it out....

either way success!

Thanks
Eric

Sounds like the fuses were not burned to change the system clock divide by 8 fuse to not have the divide by 8 used ( divide by 8 is factory default). I've done that to myself lots of times.

CrossRoads -

Thanks for that comment, I forget exactly what was driving that divide by 8 deal. After doing some quick digging I figured out the typical FUSE setting to address the divide by 8 phenomenon is called the "CKDIV8" bit. I am confused I see for the atmega48 and the attiny this is bit no. 7 of the lower fuse.

Attached are the tables describing the fuses for the ATMEGA16 and I don't see this bit labeled on either table.

Any thoughts?

Thanks
Eric

I just realized that my fuses are correct on my Atmega16 but factory default on the 8U2 I am using for UART to Serial...

The 8u2 has the CKDIV8 bit

Boot Flash section size=128 words Boot start address=$1F80; [BOOTSZ=11]

:
atmega16.bootloader.file=atmega16.hex

What bootloader are you using? 256-byte bootloaders are pretty uncommon!

I followed this guy's walkthrough from an old thread and let the arduino IDE make one for me.

so my BOOTSZ fuse bits need some more thought...

That guy's walkthrough doesn't make a bootloader. It guides you through using the Burn Bootloader function of the IDE to upload a do-nothing sketch while setting the fuses. So you have no bootloader, basically a blank chip with the fuses set.