Avrdude not in sync errors attempting to update emonTx firmware

Hi all,
Having another crack at direct avrdude firmware programming of the emonTx via wired UART serial connection with a RPi. I’ve googled and searched but can’t find any clear ideas what’s going wrong - be grateful if someone can point me in the right direction?

I’ve tried 9600, 38400 and 115200 baud rates and the only difference in the errors is that at 115200 there’s an additional “programmer not responding” line.

I’ve also stopped the emonhub service first and checked via cat/dev/ttyAMA0 and the emonTx is still outputting data on the serial port but nothing else appears.

I’ve changed the reset GPIO pin to GPIO12 (BCM 18) in the autoreset file in /usr/bin/ and connected up the appropriate wires.

Here’s the shell output:

pi@emonpi:~ $ avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 9600 -U flash:w:/home/pi/emonTx_3Phase_PLL.ino.hex

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

                  System wide configuration file is "/etc/avrdude.conf"
                  User configuration file is "/root/.avrduderc"
                  User configuration file does not exist or is not a regular file, skipping

                  Using Port                    : /dev/ttyAMA0
                  Using Programmer              : arduino
                  Overriding Baud Rate          : 9600
avrdude-original: Using autoreset DTR on GPIO Pin 12
avrdude-original: stk500_getsync() attempt 1 of 10: not in sync: resp=0x4f
avrdude-original: stk500_getsync() attempt 2 of 10: not in sync: resp=0x70
avrdude-original: stk500_getsync() attempt 3 of 10: not in sync: resp=0x65
avrdude-original: stk500_getsync() attempt 4 of 10: not in sync: resp=0x6e
avrdude-original: stk500_getsync() attempt 5 of 10: not in sync: resp=0x45
avrdude-original: stk500_getsync() attempt 6 of 10: not in sync: resp=0x6e
avrdude-original: stk500_getsync() attempt 7 of 10: not in sync: resp=0x65
avrdude-original: stk500_getsync() attempt 8 of 10: not in sync: resp=0x72
avrdude-original: stk500_getsync() attempt 9 of 10: not in sync: resp=0xe7
avrdude-original: stk500_getsync() attempt 10 of 10: not in sync: resp=0x4f

avrdude-original done.  Thank you.

strace: |autoreset: Broken pipe

Anyone spot anything I’m doing wrong?

Have you tried swapping the data Rx and TX lines?

Obvious question, but you have connected the rst pin to that pin on the Pi?

I edited a different file when I did it.

Did you stop emonhub first?

I haven’t, because emonhub receives the data from the emonTx just fine with the wires as they are…

Yes! :wink: I also tried it with GPIO7(BCM 4) before modifying the script and results were the same…

So the setup on my SD card is slightly different to that described in the docs, despite following the exact same instructions (and it was already installed as-is anyway when I received the prewritten SD card from the shop - running the script, or doing it manually changed nothing).

I might be misunderstanding how symlinks work so bear with me…

The instructions in the README.md file (in the /opt/openenergymonitor/avrdude-rpi/ folder and on github and elsewhere) imply to me that you should end up with a file named “avrdude-autoreset” in /usr/bin/ and that there should be a symlink to this file in the same folder named “avrdude”, with the actual original avrdude renamed “avrdude-original”.

Running the script doesn’t leave me with a “avrdude-autoreset” file, only an “autoreset” file…?

Why are there two copies of these files, one in /usr/bin/ and another in /opt/openenergymonitor/??? The version in /opt/openenergymonitor/ still has GPIO7 as the reset pin so clearly this is not the version being run when I try it…

Yes it is rather torturous as I remember but it was a while ago so I don’t remember the details.

I do remember seeing this sync message but I was successful writing the Hex.

pi@emon-serial:~ $ ls -la /usr/bin/avrdud*
lrwxrwxrwx 1 root root     52 May  1  2020 /usr/bin/avrdude -> /opt/openenergymonitor/avrdude-rpi/avrdude-autoreset
-rwxr-xr-x 1 root root 383576 Apr 12  2019 /usr/bin/avrdude-original

I just had a look to remind myself :slight_smile:

One thing that strikes me is that this script is Python rather than Python3. I noticed on a Debian update yesterday that python2.7 was removed as part of the update.

Other than that it all looks fine.

Interesting… and annoying!! How are you supposed to reliably confirm it’s worked if these errors pop up?

Your symlink points to the other copy of avrdude-autoreset compared to mine, but otherwise that looks identical.

Interesting point… I knew python2 had been deprecated, but hadn’t considered how that might affect this… could this be the source of the error messages? I saw a forum thread where the time.sleep(0.32) line in the reset function had been increased from (0.12) to prevent this error… if this python script isn’t working properly anymore due to moving to python3 could this make a difference?

I’m pondering out loud now, I haven’t thought this through yet…

1 Like

Not just deprecated, but EOL. e.g. Python pip removed support for Python 2 starting with version 21.