Standalone barebones ATMEGA328p bootloader/sketch problem?

(While searching through my previous research, I found this:
"Editing the Arduino preferences file
"To use an external programmer for all boards you need to make some small changes to the Arduino preferences.txt. Make sure to edit this file "when the Arduino IDE is not running.
"This preferences file is found in this folder:
" * /Users//Library/Arduino/preferences.txt (Mac)
" * c:\Documents and Settings<USERNAME>\Application Data\Arduino\preferences.txt (Windows)
" * ~/.arduino/preferences.txt (Linux)
(If this is the solution, then disregard but I don’t have the time to test it at the moment).

I couldn’t figure out exactly what to put in the subject line so I put what I think I’m having trouble with.

I’ll start with the problem then go into what I did to solve it. I have done tons of research and tried various fixes, I promise.

Long story short, I get this:
stk500_getsync(): not in sync: resp=0x00
after I (think) I burned a bootloader to the chip using a leonardo as ISP. Uploading a sketch will not work as I get that error. Currently the module just blinks the activity light about once every 0.8 seconds, and it’s on for about 0.25 seconds (not like the stock “blink” example).

Now here’s what got me there.

To start, I followed this instructable:
It is a ATMEGA328p on a stripboard with a power indicator LED, activity LED, 7805 regulator, external crystal w/proper caps, and a few resistors in what seems like all the right places for things like resetting etc based on my research.

Let’s assume all the wiring, soldering, and building is sufficient. After I got it all together and got my FTDI Basic breakout board, I tried to program it.

FIRST thing I did was wire up and configure my leonardo to do the ISP work.

I used these instructions to set up the leo for ISP:
This provided the wiring, but the instructions regarding the ISP stuff software-wise weren’t 100% clear to me. We’re talking like 95%, but I can’t be certain I interpreted them correctly. Either way, I wired the 6-pin ICSP just like the picture, to all the right pins on my 328 (as the picture is for the Tiny85) and I uploaded the one-line-modified Arduino as ISP sketch to the leo.

On to the bootloader process…

I used these instructions to burn the bootloader: (primary) (rough outline)

Basically both times I tried to “burn bootloader” using arduino as ISP for the programmer, the activity LED on the standalone flashed like a machine gun pattern for a while, then it got done about 30-45 seconds later. After this was complete, the activity LED does the 0.25 second ON every 0.8 seconds ever since. Whenever I try to upload a sketch to it, the activity light patter changes a bit, but there’s no discernable pattern, then it goes back to the intermittent blink.

I tried updating/installing proper(?) drivers for USB Serial and Serial in Device Manager as per
which basically has me delete/uninstall all previous drivers, avoid online updating and installing the drivers that they had.

I tried swapping TX/RX pins (makes no sense, they should be one thing and not a 50/50 choice), using leo, power supply, and the regulator voltage, and like I said burning the bootloader again.

Question I have is… what’s going on? I’ve tried lots. The tutorial that showed me how to use the leo as an ISP also has a section on how to use it as a USB->Serial adapter as well, that’s my next step after I get back tonight but ANY (please!) any input would be super appreciated.

Thanks so much in advance!


That is a fantastic post! In theory. I'm working on it right now, and I'm stuck at one point. "When you run it you should see something like this in the Serial Monitor..."

How do I "run it?" I've uploaded the sketch to the duino and it said compiling ok, is there a command I type into the serial monitor in order to "execute" the board detector?

I feel like I'm so close!!

Thanks for the link!

You load the board detector sketch into an Arduino (not the board being detected, of course). Then in the IDE you open the serial monitor at 115200 baud, and you should see stuff.

That is true! Yea I opened the monitor and don't see nada but I think I have an idea about why. I'm sure you took this into consideration but it looks like (to my incomplete interpretative skills) the pin defined for SCK in the sketch is 13, which is not ok for a leonardo. The leo has the SCK on the ICSP header. Again, I'm sure you took this into consideration, especially seeing that you have a provision in there with that while !Serial command to allow for run on leos etc.

This is a very interesting and useful sketch, and I'd really like to have it handy to use for these other setups I'm about to build, I was wondering if you had any other suggestions?

cheers! alexandru

alexandrubenza: I'm sure you took this into consideration but it looks like (to my incomplete interpretative skills) the pin defined for SCK in the sketch is 13, which is not ok for a leonardo. The leo has the SCK on the ICSP header. Again, I'm sure you took this into consideration,...

Not necessarily. :)

I'll see if I can get the Leonardo to work.

Sorry it took so long to respond, while I was testing my Mac crashed, and then it takes about 20 minutes to reboot because it insists on opening all the apps I had running before. Once past that hurdle, the forum crashed. :(

In the end, the board detector sketch worked on the Leonardo without change. However as you said, you have to use the ICSP header.

Connect five of those (all except /RESET) from the Leonardo to the board being tested/programmed. You still connect pin D10 on the Leonardo to /RESET on the chip being tested.

I also found that the serial monitor was blank, but once I selected the correct serial port from the Serial Port menu it worked fine.

After this was complete, the activity LED does the 0.25 second ON every 0.8 seconds ever since.

This sounds like you have not managed to program the fuses correctly. When an 328 bootloader is correctly loaded on an otherwise blank 328p AVR, you should see the "activity" light blink three times "rapidly" (0.1s on, 0.1s off), and then repeat that pattern each time the bootloader "gives up" trying to load new code (about 1s using Optiboot, about 10s for older bootloaders (IIRC)) Approximately the pattern you describe is what you'd get if the AVR were running with the default 1MHz clock (internal 8MHz RC, divided by 8), instead of the crystal...

Which bootloader did you try to load, and using what method? The tutorial you linked to originally was about loading a m168 bootloader.

(Use Nick's tutorial instead!)

Guys thanks a lot for your help, I learned a whole lot, but the problem was maddeningly simple. The picture I was following that showed how to hook up everything to upload a sketch was unclear enough to throw a massive monkey wrench into the whole thing. Everywhere I looked it basically said to plug DTR into the uC’s RESET! On the drawing, the dude put /RESET (after closer inspection and more critical thinking I now realize that just means active low or generally NOT) which was next to the DTR connection. so it looked like DTR/RESET…

I got it working and will now try OptiBoot!

Thanks for the help!