Atmega328p-au USB to UART programing issue

Hi there,

I have built this on a custom PCB of mine.

First to test things, I've uploaded a compiled blink sketch (hex) file using avrdude + Usbasp device through the ICSP conenctor.
For the sketch I use Arduino Uno board.
LED is blinking as expected (blinking time).
So I assumed all is fine with the board.

void setup() {
  pinMode(A0, OUTPUT);  //STATE led
}

void loop() {
  digitalWrite(A0, HIGH);
  delay(1000);                  
  digitalWrite(A0, LOW); 
  delay(1000);                  
}

Next I test uploading a sketch through the serial connection on my pcb.
So first loaded the UNO Opti bootloader through ICSP (no errors).

"D:\Arduino\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CD:\Arduino\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -patmega328p -cusbasp -Pusb -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "D:\Arduino\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbasp
avrdude: Warning: cannot open USB device: Function not implemented
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: auto set sck period (because given equals null)
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3F:
avrdude: load data lock data from input file 0x3F:
avrdude: input file 0x3F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0xFD"
avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFD:
avrdude: load data efuse data from input file 0xFD:
avrdude: input file 0xFD contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xDE"
avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDE:
avrdude: load data hfuse data from input file 0xDE:
avrdude: input file 0xDE contains 1 bytes
avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
"D:\Arduino\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CD:\Arduino\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -patmega328p -cusbasp -Pusb "-Uflash:w:D:\Arduino\Arduino15\packages\arduino\hardware\avr\1.8.6/bootloaders/optiboot/optiboot_atmega328.hex:i" -Ulock:w:0x0F:m

avrdude done.  Thank you.


avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "D:\Arduino\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbasp
avrdude: Warning: cannot open USB device: Function not implemented
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: auto set sck period (because given equals null)
avrdude: reading input file "D:\Arduino\Arduino15\packages\arduino\hardware\avr\1.8.6/bootloaders/optiboot/optiboot_atmega328.hex"
avrdude: writing flash (32768 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 32768 bytes of flash written
avrdude: verifying flash memory against D:\Arduino\Arduino15\packages\arduino\hardware\avr\1.8.6/bootloaders/optiboot/optiboot_atmega328.hex:
avrdude: load data flash data from input file D:\Arduino\Arduino15\packages\arduino\hardware\avr\1.8.6/bootloaders/optiboot/optiboot_atmega328.hex:
avrdude: input file D:\Arduino\Arduino15\packages\arduino\hardware\avr\1.8.6/bootloaders/optiboot/optiboot_atmega328.hex contains 32768 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 32768 bytes of flash verified
avrdude: reading input file "0x0F"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x0F:
avrdude: load data lock data from input file 0x0F:
avrdude: input file 0x0F contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude done.  Thank you.

I then connected my CP2102 USB to UART converter.
5v -> 5v
GND -> GND
TX -> RX
RX -> TX
DTR -> DTR

Compiled the same sketch and upload.
Seems that part is not working.
Any suggestions to what I might be doing wrong here?

FQBN: arduino:avr:uno
Using board 'uno' from platform in folder: D:\Arduino\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: D:\Arduino\Arduino15\packages\arduino\hardware\avr\1.8.6

Detecting libraries used...
D:\Arduino\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -ID:\Arduino\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -ID:\Arduino\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard C:\Users\dinesha\AppData\Local\arduino\sketches\D4F2A79E064BF0DA2BD9A84759B163AC\sketch\test1.ino.cpp -o nul
Generating function prototypes...
D:\Arduino\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -ID:\Arduino\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -ID:\Arduino\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\standard C:\Users\dinesha\AppData\Local\arduino\sketches\D4F2A79E064BF0DA2BD9A84759B163AC\sketch\test1.ino.cpp -o C:\Users\dinesha\AppData\Local\Temp\3020802470\sketch_merged.cpp
D:\Arduino\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\dinesha\AppData\Local\Temp\3020802470\sketch_merged.cpp
Compiling sketch...
"D:\\Arduino\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-ID:\\Arduino\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\cores\\arduino" "-ID:\\Arduino\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.6\\variants\\standard" "C:\\Users\\dinesha\\AppData\\Local\\arduino\\sketches\\D4F2A79E064BF0DA2BD9A84759B163AC\\sketch\\test1.ino.cpp" -o "C:\\Users\\dinesha\\AppData\\Local\\arduino\\sketches\\D4F2A79E064BF0DA2BD9A84759B163AC\\sketch\\test1.ino.cpp.o"
Compiling libraries...
Compiling core...
Using precompiled core: C:\Users\dinesha\AppData\Local\arduino\cores\arduino_avr_uno_7dde9ed41cf15046db55de4adb358865\core.a
Linking everything together...
"D:\\Arduino\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\\Users\\dinesha\\AppData\\Local\\arduino\\sketches\\D4F2A79E064BF0DA2BD9A84759B163AC/test1.ino.elf" "C:\\Users\\dinesha\\AppData\\Local\\arduino\\sketches\\D4F2A79E064BF0DA2BD9A84759B163AC\\sketch\\test1.ino.cpp.o" "C:\\Users\\dinesha\\AppData\\Local\\arduino\\sketches\\D4F2A79E064BF0DA2BD9A84759B163AC/..\\..\\cores\\arduino_avr_uno_7dde9ed41cf15046db55de4adb358865\\core.a" "-LC:\\Users\\dinesha\\AppData\\Local\\arduino\\sketches\\D4F2A79E064BF0DA2BD9A84759B163AC" -lm
"D:\\Arduino\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\\Users\\dinesha\\AppData\\Local\\arduino\\sketches\\D4F2A79E064BF0DA2BD9A84759B163AC/test1.ino.elf" "C:\\Users\\dinesha\\AppData\\Local\\arduino\\sketches\\D4F2A79E064BF0DA2BD9A84759B163AC/test1.ino.eep"
"D:\\Arduino\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -R .eeprom "C:\\Users\\dinesha\\AppData\\Local\\arduino\\sketches\\D4F2A79E064BF0DA2BD9A84759B163AC/test1.ino.elf" "C:\\Users\\dinesha\\AppData\\Local\\arduino\\sketches\\D4F2A79E064BF0DA2BD9A84759B163AC/test1.ino.hex"

"D:\\Arduino\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\\Users\\dinesha\\AppData\\Local\\arduino\\sketches\\D4F2A79E064BF0DA2BD9A84759B163AC/test1.ino.elf"
Sketch uses 1718 bytes (5%) of program storage space. Maximum is 32256 bytes.
Global variables use 186 bytes (9%) of dynamic memory, leaving 1862 bytes for local variables. Maximum is 2048 bytes.
"D:\Arduino\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CD:\Arduino\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v  -patmega328p -carduino "-PCOM5" -b115200 -D "-Uflash:w:C:\Users\dinesha\AppData\Local\arduino\sketches\D4F2A79E064BF0DA2BD9A84759B163AC/test1.ino.hex:i"

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "D:\Arduino\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM5
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x62
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x62
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x62
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x62
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x62
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x62
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x62
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x62
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x62
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x62

avrdude done.  Thank you.

Failed uploading: uploading error: exit status 1

Thanks.

TX and RX are incorrect on the schematic.

2 Likes

Are RX and TX supposed to be reversed?

TX -> RX
RX -> TX

@rlsieben

ohhh silly me...
apologies for wasting forum time for this silly mistake of mine.
workng perfectly fine now after swaping the TX and RX.

thanks @jremington for pointing this out.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.