I've soldered my ATMega328p-au to a SMD to DIP board, and I've connected pins like this:
USB | ATMega
RX —> TX
TX —> RX
5v —-> 5v
GND -> GND
and GND –> button –> RESET
My USB-TTL converter doesn't have a DTR pin. But, I tried programming my Arduino UNO with it. I hold RESET pin on my Arduino UNO, click upload and release the button. It works.
When I do the same with ATMega, avrdude / Arduino IDE gives me this output:
~$ sudo avrdude -c arduino -p atmega328p -P /dev/ttyUSB0 -U flash:w:blink.hex
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
...
avrdude: stk500_recv(): programmer is not
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
avrdude done. Thank you.
Same error with -c avrisp
and on Arduino IDE.
1) Do I need something special for first time, like burning a bootloader? I read that I can flash it without burning bootloader, so I don't think that's the case.
2) Also I saw a lot of people using crystal and capacitor for flashing. Is it necessary? Because I don't have crystal.
3) If I can flash it without a bootloader and without a crystal, what am I doing wrong?
Thanks!
Edit:
It appears I needed a ISP programmer. Even though I tried it with ISP programmer it did not work. I connected a 16MHz crystal and I successfully programmed it!
Best Answer
The ATmega328 comes from factory without any boot loader. There are several ways to flash it (either fully or just a bootloader), but UART upload through the RxD and TxD pins isn't one of these.
The simplest way to upload initial software is using the built-in ISP interface through the MISO/MOSI/SCK pins. You need a programmer for that, which may be as simple as some GPIOs from a Raspberry Pi. It's also possible to repurpose an Arduino as the programmer.
Choose your poison, avrdude has to support it, that's the limitation.