0
\$\begingroup\$

I've soldered my ATMega328p-au to a SMD to DIP board, and I've connected pins like this:
enter image description here

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!

\$\endgroup\$
  • \$\begingroup\$ this question is unclear 3) If I can flash it without a bootloader and without a crystal, what am I doing wrong? \$\endgroup\$ – jsotola Jul 8 '18 at 20:24
  • 1
    \$\begingroup\$ You cannot program at ATmega via an asynchronous serial connection as shown unless it has a bootloader, something it would not have from the factory unless you specifically paid extra for one sold with that. There are some "USB-serial" converters with secondary synchronous modes which can be used for ISP, but the wiring you show does not do that, and it's unclear if the PL-2303 supports this with any wiring. \$\endgroup\$ – Chris Stratton Jul 8 '18 at 20:33
  • 2
    \$\begingroup\$ You do not need crystal or capacitors, but you do need ISP programmer. You can use your existing Arduino for this. Technically it should be possible to flash any program this way, not only bootloader (I never tried this), but flashing a bootloader will make everything else much simpler afterwards. \$\endgroup\$ – Maple Jul 8 '18 at 20:47
  • 1
    \$\begingroup\$ @Maple - actually if a crystal is required or not depends on the existing fuse settings. If at factory defaults using the internal oscillator it would not be required, but if previously configured to use an external crystal or clock it would be. This is because the ISP signals are re-sampled by the MCU clock, not used directly to drive the internals. \$\endgroup\$ – Chris Stratton Jul 8 '18 at 20:50
  • \$\begingroup\$ @ChrisStratton Default fuse settings on ATMega328P are for 1MHz internal clock. The title says "my new ATMega328p" \$\endgroup\$ – Maple Jul 8 '18 at 20:53
4
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Some USB-serial converter chips from FTDI, CH34x etc can also operate ISP, but it requires different wiring than shown, and it's not clear that the PL2303 can do that. Also many distributors even beyond the hobby realm do sell the ATMega328p with a bootloader, but charge extra for it. \$\endgroup\$ – Chris Stratton Jul 8 '18 at 20:35
  • \$\begingroup\$ Thanks. So I need a bootloader for flashing like I tried. With an ISP programmer, I can either burn a bootloader, or just flash it. Thanks a lot! \$\endgroup\$ – sh4dowb Jul 8 '18 at 22:00
  • \$\begingroup\$ I'm getting this error with Arduino as ISP, avrdude: Device signature = 0xff0000 . Googling that error told me that it might need a external crystal. But comments above said default fuse settings are 1 MHz internal clock. Any ideas? \$\endgroup\$ – sh4dowb Jul 8 '18 at 22:54
  • \$\begingroup\$ So … you have connected your USB-RS232 adapter to your Arduino, then put the ISP programmer firmware into the Arduino, then made the additional connections from your Arduino to MISO/MOSI/SCK/RESET of your blank ATmega328, then used avrdude -c arduino -p atmega328p \$\endgroup\$ – Janka Jul 8 '18 at 23:17
  • \$\begingroup\$ @Janka I've connected Arduino with USB cable (plugged to its USB-B port), uploaded ArduinoISP, made ICSP connections, and clicked Upload Using Programmer. \$\endgroup\$ – sh4dowb Jul 9 '18 at 0:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.