Having trouble uploading bootloader and sketch! Please HELP!

Hi everybody, I am having some trouble uploading a bootloader and the corresponding sketch on a standalone PCB. I had success in the past with this Arduino ISP tutorial, but this time I decided to use Nick Gammons bootloader tutorial and I get some strange results.

When I upload the bootloader using the Atmega_Board_Programmer I get the following result:

Atmega chip programmer.
Written by Nick Gammon.
Version 1.28
Compiled on Dec 19 2014 at 16:28:12
Attempting to enter programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x95 0x0F 
Processor = ATmega328P
Flash memory size = 32768 bytes.
LFuse = 0xFF 
HFuse = 0xDE 
EFuse = 0xFD 
Lock byte = 0xCF 
Clock calibration = 0xA2 
Bootloader address = 0x7E00
Bootloader length = 512 bytes.
Type 'L' to use Lilypad (8 MHz) loader, or 'U' for Uno (16 MHz) loader ...
Using Uno Optiboot 16 MHz loader.
Type 'Q' to quit, 'V' to verify, or 'G' to program the chip with the bootloader ...
Erasing chip ...
Writing bootloader ...
Committing page starting at 0x7E00
Committing page starting at 0x7E80
Committing page starting at 0x7F00
Committing page starting at 0x7F80
Written.
Verifying ...
No errors found.
Writing fuses ...
LFuse = 0xFF 
HFuse = 0xDE 
EFuse = 0xFD 
Lock byte = 0xEF 
Clock calibration = 0xA2 
Done.
Programming mode off.
Type 'C' when ready to continue with another chip ...

Then I use the Atmega_Board_Detector to check the chip and get the following:

Atmega chip detector.
Written by Nick Gammon.
Version 1.11
Compiled on Dec 19 2014 at 16:29:43
Entered programming mode OK.
Signature = 1E 95 0F 
Processor = ATmega328P
Flash memory size = 32768 bytes.
LFuse = FF 
HFuse = DE 
EFuse = FD 
Lock byte = EF 
Clock calibration = A2 
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 512 bytes starting at 7E00

Bootloader:

7E00: 11 24 84 B7 14 BE 81 FF F0 D0 85 E0 80 93 81 00 
7E10: 82 E0 80 93 C0 00 88 E1 80 93 C1 00 86 E0 80 93 
7E20: C2 00 80 E1 80 93 C4 00 8E E0 C9 D0 25 9A 86 E0 
7E30: 20 E3 3C EF 91 E0 30 93 85 00 20 93 84 00 96 BB 
7E40: B0 9B FE CF 1D 9A A8 95 81 50 A9 F7 CC 24 DD 24 
7E50: 88 24 83 94 B5 E0 AB 2E A1 E1 9A 2E F3 E0 BF 2E 
7E60: A2 D0 81 34 61 F4 9F D0 08 2F AF D0 02 38 11 F0 
7E70: 01 38 11 F4 84 E0 01 C0 83 E0 8D D0 89 C0 82 34 
7E80: 11 F4 84 E1 03 C0 85 34 19 F4 85 E0 A6 D0 80 C0 
7E90: 85 35 79 F4 88 D0 E8 2E FF 24 85 D0 08 2F 10 E0 
7EA0: 10 2F 00 27 0E 29 1F 29 00 0F 11 1F 8E D0 68 01 
7EB0: 6F C0 86 35 21 F4 84 E0 90 D0 80 E0 DE CF 84 36 
7EC0: 09 F0 40 C0 70 D0 6F D0 08 2F 6D D0 80 E0 C8 16 
7ED0: 80 E7 D8 06 18 F4 F6 01 B7 BE E8 95 C0 E0 D1 E0 
7EE0: 62 D0 89 93 0C 17 E1 F7 F0 E0 CF 16 F0 E7 DF 06 
7EF0: 18 F0 F6 01 B7 BE E8 95 68 D0 07 B6 00 FC FD CF 
7F00: A6 01 A0 E0 B1 E0 2C 91 30 E0 11 96 8C 91 11 97 
7F10: 90 E0 98 2F 88 27 82 2B 93 2B 12 96 FA 01 0C 01 
7F20: 87 BE E8 95 11 24 4E 5F 5F 4F F1 E0 A0 38 BF 07 
7F30: 51 F7 F6 01 A7 BE E8 95 07 B6 00 FC FD CF 97 BE 
7F40: E8 95 26 C0 84 37 B1 F4 2E D0 2D D0 F8 2E 2B D0 
7F50: 3C D0 F6 01 EF 2C 8F 01 0F 5F 1F 4F 84 91 1B D0 
7F60: EA 94 F8 01 C1 F7 08 94 C1 1C D1 1C FA 94 CF 0C 
7F70: D1 1C 0E C0 85 37 39 F4 28 D0 8E E1 0C D0 85 E9 
7F80: 0A D0 8F E0 7A CF 81 35 11 F4 88 E0 18 D0 1D D0 
7F90: 80 E1 01 D0 65 CF 98 2F 80 91 C0 00 85 FF FC CF 
7FA0: 90 93 C6 00 08 95 80 91 C0 00 87 FF FC CF 80 91 
7FB0: C0 00 84 FD 01 C0 A8 95 80 91 C6 00 08 95 E0 E6 
7FC0: F0 E0 98 E1 90 83 80 83 08 95 ED DF 80 32 19 F0 
7FD0: 88 E0 F5 DF FF CF 84 E1 DE CF 1F 93 18 2F E3 DF 
7FE0: 11 50 E9 F7 F2 DF 1F 91 08 95 80 E0 E8 DF EE 27 
7FF0: FF 27 09 94 FF FF FF FF FF FF FF FF FF FF 04 04 

MD5 sum of bootloader = FB F4 9B 7B 59 73 7F 65 E8 D0 F8 A5 08 12 E7 9F 
Bootloader name: optiboot_atmega328

First 256 bytes of program memory:

0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
10: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
20: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
30: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
40: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
50: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
60: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
70: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
80: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
90: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
A0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
B0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
C0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
D0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
E0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
F0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF

And I think everything is ok. Since I am still waiting for my USB to TTL to upload sketches so I put the chip on the Uno board to upload the sketch since it has a bootloader now. When I upload there are no errors but when I put the chip in my PCB it doesn't. :frowning:

I tried to upload the bootloader again using the official Arduino Tutorials I had no errors again but the chip still won't work. :frowning:

My current build is the following:
The breadboard setup with the 0.1uF capacitors, the crystal and everything.

The Uno.

The custom PCB.

On the custom PCB I have a row of pins out connected to pins 17 to 19 on the ATmega328P. The cable I made to upload everything has a separate cable for the reset pin for the custom board and +5V and GND.

So if anyone has any idea why I can't upload anything or why it doesn't work I'd appreciate it.

P.S. I made the breadboard wires, that is why they are so ugly, but they work, and the 22pF capacitors to the crystal are SMD with soldered pins since I didn't have any TH nearby.

Just so we are clear:

On the breadboard you can upload sketches and bootloaders.

On your custom board you can't do both or only can't upload sketches?

I can't see the 22pF caps for the crystal on the board.

I can upload the bootloader and sketches on both breadboard and custom board with no errors, but they don't work, and I have 22pF capacitors, they are just SMD ones and I soldered two legs so I can use them with the breadboard(those two things connected to GND right under the crystal are the capacitors).

I can't see the 22pF caps on the board, (I presume if they are SMD they are on the other side) but can on the breadboard.

Do the sketches you have work on an Uno?

Post the code between code tags.

Yes the custom PCB has SMD capacitors on the other side, and yes the code works on the uno, I made a simple little shield of this to try it but can't upload a picture right now. And the code is too big to fit here (the site wont let me)so I am gonna attach it.

eeprom_test.ino (12.3 KB)