Custom made PCB ATmega328p-au issues

Good morning,

I have created my own PCB (can provide eagle files if needed) that holds a ATmega328p-au, a FTDI header, ISP header, nRF24l01 module and a screw terminal for a switch. I have no soldered on the nRF module yet as this is my 3rd board in the process of troubleshooting my issues. I can burn the fuses (E2, DA, 06), the bootloader (ATmegaBOOT_168_atmega328_pro8MHz.hex) and even upload a sketch through the ‘upload through programmer’ option. However the issue lies with that i can’t upload via FTDI.

My current setup of the board is that i have my reset line as follows:
VCC(3v) → 10k pullup resistor → RESET PIN

I also have a DTR line of:

DTR Header → 0.1uF cap → RESET PIN

The board itself is very minimal at the moment while I’m trying to troubleshoot my issues. I have soldered everything in place apart from the RF module (which doesn’t stop any connections getting to the board) and the screw terminal for my switch.

The steps that i have taken so far:

  1. Replaced 0.1uF cap with 4.7uF.
  2. Moved the DTR cap closer to the header rather than the reset pin.
  3. Routed the DTR line external to the board to eliminate any cases of shorting in the PCB manufacturing process.
  4. Attempted to use different fuse settings (lowering clock, using external crystal) but still nothing, reverted back to my desired fuse settings.

I’m getting various different error codes coming through arduino IDE but i enabled verbose debugging and this is just one of the error reports that i get:

Sketch uses 450 bytes (1%) of program storage space. Maximum is 30,720 bytes.
Global variables use 9 bytes of dynamic memory.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM10 -b57600 -D -Uflash:w:C:\Users\DESKTO~1\AppData\Local\Temp\build69c6046e7b3922c68746d72bc5989b9b.tmp/sketch_mar02a.ino.hex:i 

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM10
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
         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 : Arduino
         Description     : Arduino

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0xfc
         Hardware Version: 1999519514

If you guys would like a physical photograph of my board then please ask, i do not mind uploading one :slight_smile:

HominiSwitchNode1.0Rev2_Sch.pdf (44.9 KB)

HominiSwitchNode1.0Rev2_Brd.pdf (32.2 KB)

Print a PDF of the eagle schematic or grab a decent screen image and post it here if you can please.

I have added the two files to my original post above here. Thank you :)

A quick glance and the schematic seems okay. The fuse settings your burning do not match the defaults in the boards.txt for a 8Mhz ATmega328

pro328.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328

pro328.upload.protocol=arduino
pro328.upload.maximum_size=30720
pro328.upload.speed=57600

pro328.bootloader.low_fuses=0xFF
pro328.bootloader.high_fuses=0xDA
pro328.bootloader.extended_fuses=0x05
pro328.bootloader.path=atmega
pro328.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
pro328.bootloader.unlock_bits=0x3F
pro328.bootloader.lock_bits=0x0F

pro328.build.mcu=atmega328p
pro328.build.f_cpu=8000000L
pro328.build.core=arduino
pro328.build.variant=standard

Once you have uploaded a simple counting sketch using the programmer (this will delete the bootloader) can you see it's serial output in the serial monitor when you disconnect the programmer and use FTDI instead?

you're right with the fuses, that is why i change them in the boards.txt and even tried making my own entry in boards.txt. I change the fuses and burn the bootloader. I then use avrdudess to check the fuse settings, they're fine. Then i attempt my upload and thats when i get the errors.

I get my serial monitor output when i tried the 'upload with programmer', however i will attempt what you suggested and post my findings in the next hour.

pro328.upload.speed=57600

AFAIK, the default ATmegaBOOT_168_atmega328_pro8MHz.hex bootloader runs at 19200bps, not 57600. Sparkfun may use a different bootloader that operates at the higher rate...

westfw: pro328.upload.speed=57600

AFAIK, the default ATmegaBOOT_168_atmega328_pro8MHz.hex bootloader runs at 19200bps, not 57600. Sparkfun may use a different bootloader that operates at the higher rate...

How come that the unedited version of boards.txt has those settings of 57600? o.O My initial thoughts were that it was trying to upload at a speed that is not right for the chip/bootloader. However, i updated my arduino environment and those settings were there in the new version of the file....

EDIT: From a quick inspection of the .c file for the ATmegaBOOT_168_atmega328_pro8MHz.hex bootloader C file, I found that unless stated it sets the BAUD_RATE to 19200. However, i have changed the boards.txt file and it still didn't work.

I have uploaded a simple counting sketch through the ISP connection, it now shows me the expected result in serial monitor when viewed through the FTDI header. So the connection for the serial communication is there and working as it should be.

samuel235: I have uploaded a simple counting sketch through the ISP connection, it now shows me the expected result in serial monitor when viewed through the FTDI header. So the connection for the serial communication is there and working as it should be.

Now if you close the serial monitor window (after letting the count proceed a bit) and re-open it does the count start again or continue? This will let you know if the DTR reset circuit is working.

It restarts back at the beginning, I'm assuming this shows that the DTR circuit is working as should be? o.O

westfw: pro328.upload.speed=57600

AFAIK, the default ATmegaBOOT_168_atmega328_pro8MHz.hex bootloader runs at 19200bps, not 57600. Sparkfun may use a different bootloader that operates at the higher rate...

i dont know what ATmegaBOOT_168_atmega328_pro8MHz is but ATmegaBOOT_168_atmega328_pro_8MHz is on all low cost 8mhz promini boards i have purchased and its 57k not 19k. 57k is standard for pro-mini and life would be easier if all arduino used that.

john1993: i dont know what ATmegaBOOT_168_atmega328_pro8MHz is but ATmegaBOOT_168_atmega328_pro_8MHz is on all low cost 8mhz promini boards i have purchased and its 57k not 19k. 57k is standard for pro-mini and life would be easier if all arduino used that.

Life would be easier if all the '328p based Arduinii used Optiboot at 115k @ 16mhz, 57k @ 8mhz, seeing as Optiboot is better than ATmegaBOOT on just about every metric.

Oh - and when you do "upload using programmer", it erases the bootloader - so you need to do burn bootloader after that if you want to be able to upload over serial.

john1993: i dont know what ATmegaBOOT_168_atmega328_pro8MHz is but ATmegaBOOT_168_atmega328_pro_8MHz is on all low cost 8mhz promini boards i have purchased and its 57k not 19k. 57k is standard for pro-mini and life would be easier if all arduino used that.

Well, considering i have the default .hex file of that (atmega328_pro_8MHz.hex), I have been using the correct upload rate in the boards.txt then.

DrAzzy: Life would be easier if all the '328p based Arduinii used Optiboot at 115k @ 16mhz, 57k @ 8mhz, seeing as Optiboot is better than ATmegaBOOT on just about every metric.

Oh - and when you do "upload using programmer", it erases the bootloader - so you need to do burn bootloader after that if you want to be able to upload over serial.

if you have the time, could you explain to me why I would want to use Optiboot over the ATmegaBOOT please. A lot of people I have spoken to choose to use Optiboot and I'm not 100% sure where to find the features of Optiboot and therefor I can't make my own decision on which one to go with. If you would like to just point me towards some information regarding Optiboot rather than explain in your own words, I don't mind, what ever is easier for you ;)

I'm aware of the "Upload using programmer" feature erasing the bootloader, i found that out the hard way a while ago. Thank you for pointing it out in case though, much appreciated!

Optiboot is 512 bytes, ATmegaBOOT is 2048 bytes, leaving another 1536 bytes for your sketch. Additionally, it uploads faster (once you bootload a 16mhz board with Optiboot, you can just tell the IDE it's an Uno)

Okay, thank you. So could i use the optiboot_atmega328.hex for my atmega328p-au and run it at 8MHz or would i need to recompile the .hex file to suit my needs here?

samuel235: Okay, thank you. So could i use the optiboot_atmega328.hex for my atmega328p-au and run it at 8MHz or would i need to recompile the .hex file to suit my needs here?

Yep, you can use the same .hex file. That's what most people do, I think. You create a new boards.txt entry for it, copying every parameter for the uno (note - you need to change the name of the board on every goddamned line, and the failure modes when you miss a line are non-obvious), except changing the F_CPU to 8000000L instead of 16000000L, and setting the upload speed to 57600, and, if using internal RC oscillator, the low fuse.

Alrighty, i will give that a try in the morning. Thank you for yor suggestion and guidance. I will report back soon as i've attempted it.

DrAzzy: Life would be easier if all the '328p based Arduinii used Optiboot at 115k @ 16mhz, 57k @ 8mhz, seeing as Optiboot is better than ATmegaBOOT on just about every metric.

i agree it would be better than the current leaning tower of babel. and noticeably faster than that prehistoric 19k standard. the main advantage however being the same hex file can be flashed into both 8mhz and 16mhz chips.

one problem is that technically those baud rates are not 100% reliable considering divisor math and resonator accuracy. also 115k is significantly more susceptible to cable capacitance and noise issues yet not that much faster than 57k in practice.

regarding optiboot it has the drawback of not working for chips with >128k flash like m2560. there are versions floating around that do (ive developed one myself) but they are not officially recognized.

use the optiboot_atmega328.hex for my atmega328p-au and run it at 8MHz

I'm pushing this as the preferred technique. Running 115200bps at 8MHz is pretty questionable, and perhaps subject to complications like "works with USB/Serial adapter X, but not Y."

So, my boards.txt entry looks like this:

Optiatmega328p.name=Optiboot Breadboard w/ ATmega328 Internal Oscillator
Optiatmega328p.upload.tool=avrdude
Optiatmega328p.upload.protocol=arduino
Optiatmega328p.upload.maximum_size=32256
Optiatmega328p.upload.maximum_data_size=2048
Optiatmega328p.upload.speed=57600
Optiatmega328p.bootloader.tool=avrdude
Optiatmega328p.bootloader.low_fuses=0xE2
Optiatmega328p.bootloader.high_fuses=0xDA
Optiatmega328p.bootloader.extended_fuses=0x06
Optiatmega328p.bootloader.unlock_bits=0x3F
Optiatmega328p.bootloader.lock_bits=0x0F
Optiatmega328p.bootloader.file=optiboot/optiboot_atmega328.hex
Optiatmega328p.build.mcu=atmega328p
Optiatmega328p.build.f_cpu=8000000L
Optiatmega328p.build.board=AVR_UNO
Optiatmega328p.build.core=arduino
Optiatmega328p.build.variant=standard

However, I'm still getting a "programmer is not responding" error code. This is the verbose error log:

Sketch uses 450 bytes (1%) of program storage space. Maximum is 32,256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum is 2,048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM10 -b57600 -D -Uflash:w:C:\Users\DESKTO~1\AppData\Local\Temp\build05315c8eb0e75f4b3732e21cc2391b4e.tmp/sketch_mar03a.ino.hex:i 

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM10
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
         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 : Arduino
         Description     : Arduino
         Hardware Version: 3
         Firmware Version: 4.4
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e950f
avrdude: reading input file "C:\Users\DESKTO~1\AppData\Local\Temp\build05315c8eb0e75f4b3732e21cc2391b4e.tmp/sketch_mar03a.ino.hex"
avrdude: writing flash (450 bytes):

Writing | ################################################## | 100% 0.12s

avrdude: 450 bytes of flash written
avrdude: verifying flash memory against C:\Users\DESKTO~1\AppData\Local\Temp\build05315c8eb0e75f4b3732e21cc2391b4e.tmp/sketch_mar03a.ino.hex:
avrdude: load data flash data from input file C:\Users\DESKTO~1\AppData\Local\Temp\build05315c8eb0e75f4b3732e21cc2391b4e.tmp/sketch_mar03a.ino.hex:
avrdude: input file C:\Users\DESKTO~1\AppData\Local\Temp\build05315c8eb0e75f4b3732e21cc2391b4e.tmp/sketch_mar03a.ino.hex contains 450 bytes
avrdude: reading on-chip flash data:

Reading | avrdude: stk500_recv(): programmer is not responding
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.