Going Nuts Trying To Upload Code - What Am I Missing?

Hi, I’m new to this so please be gentle.

I’m actually trying to complete a Mk2PVRouter, which after completion will get at least one, maybe two eMon set-ups alongside to provide the monitoring. It’s a version with five output boards, which will scoop up 10kWp of solar PV and share it among three immersion heaters, some towel rails and other stuff. Hence the reason for building the router first and putting the monitoring on afterwards.

The Arduino on the board is ATMega328p (which according to the tech sheet is supposed to come with boot loader already installed). All is set up, continuity checked, voltages in the correct places, chips the correct way around, etc. Every pin on the processor has a zero ohm track to where it’s supposed to go. I’ve not popped the processor - I practiced safe installation on an anti-static surface with my earth strap on my wrist. I’m confident I’ve done nothing wrong.

Problem is … I can’t upload any code to it, not even the simplest of demo software. The connection to the board is okay but I get variations of the following error message every time.

I thought maybe the connection was too fast but no - serial parameters are set at 9600 baud, 8/1 bits, no parity, no flow control. I’ve even tried it at slower speed. No joy.

Please tell me, what am I doing wrong?

Cheers, Ian


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 “C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf”

     Using Port                    : COM4
     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=0x1e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x1e
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x30
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x20
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x20
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x20
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x20
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x30

avrdude done. Thank you.


Unfortunately, that error means only that it can’t communicate, it doesn’t help much (Arduino’s fault, not yours).

That’s not surprising - code upload speed is independent of what you set in the IDE and the sketch.

Are you using a “proper” programmer? Has it worked with our emonTx? The one supplied by Robin and the Shop here uses the RTS line to reset the '328P at the appropriate instant to put it into programming mode. If you have a programmer that doesn’t do that, I understand that you need to manually do a reset - and during a fairly narrow window.

The only other hardware-related one is to make sure you have Rx and Tx the right way round (on our emonTx, they are labelled wrongly - Rx is looking for something to receive the data, Tx is looking for something sending it data :exploding_head:). The Shop programmer is labelled conventionally - it transmits on Tx and receives on Rx.

I don’t use Windows any more, I presume those messages mean it’s got the drivers installed correctly and you’re using the correct port.

I don’t really have any more sensible suggestions.

Hmm - whose ‘tech sheet’? Having no boot loader burnt will show these symptoms.

Thanks for the feedback so far and apologies for the duplicate post you’ll see - I’m really not having a good day.

I’ll take on board the replies and have a play. The tech sheet, by the way, is for the chip not from Robin, I think I for it on the RS Components site. I’ve ordered a couple more of them just in case it’s a one-off hardware problem.

I’ll whip out the Arduino, stick it in a breadboard and do a reset. However, can anyone enlighten me - in the IDE if I go to “Tools, Run Bootloader” does it re-upload the bootloader so I can start again from scratch?

A bit more info - Rx and Tx are okay. I’ve tried it with an extension cable and also plugged directly into the board. Drivers are installed okay and on the Windows “Device Manager” diagnostic (for what it’s worth) everything is fine. Only one port to choose from, which it picks up from the USB port. I even went back to an old PC so I could use a native USB2 port instead of new fangled USB-C with an adapter. It’s talking to the UART quite happily and spots when it’s connected or removed.

I think I’m going to get the ATMEGA328P out, give it 5 volts and see if I can upload some really simple code to it. If that doesn’t work I’ll buy another programmer and try again.

Sorry, I’ve no idea. I’ve never had occasion to use it. But there’s this:

https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard

You can use an Arduino to burn the bootloader to another Arduino as briefly described on that page Robert linked to by uploading the ArduinoISP sketch, but you need to be able to upload to an Arduino using the standard method (which is failing for you) to be able to do that.
Full description of how all of that works is at https://www.arduino.cc/en/Tutorial/ArduinoISP
EDIT: I found it very useful to include the status LEDs (described near the bottom of that page) when I’ve had to burn bootloaders using the Arduino as an ISP.

When you say you:

A couple more of what? ATMega 328p chips? or Arduino boards?
If you’ve purchased the former, they definitely come without bootloaders so you’ll definitely need an ISP to load one on. If you’ve ordered the latter (Uno’s, Nano’s, etc) they should come with bootloaders and you should be able to program them using the shop programmer and the Arduino IDE.

Can you take a photo of it all connected up to the programmer and post that? Maybe someone here will spot something that isn’t right.

1 Like

Although the lion’s share of 328s purchased will be acquired sans bootloader, they can
be bought with the “Optiboot” (Arduino Uno) bootloader pre-loaded. :wink:



Yeah, but not from RS Components :slight_smile:

Is there any particular reason it has to be RS?

It absolutely doesn’t, I was just going from the original posters message:

I’ve made the assumption that while there looking at the datasheet, he bought some more.

Once @Ian_the_curmudgeon responds, we’ll find out if he actually bought ones with a bootloader pre-installed or not :slight_smile:

I see. I thought maybe it was because it needed to be a UK supplier. (shipping cost, delay, etc.)
Hence my inclusion of at least one in the UK, of the three that I linked to.