Hi there.
I’m testing a PCB similar to EmonPi with some tweaks of my own and I’m having trouble programming the firmware to it with avrdude.
My board has the same connections from the 328P to the RPi GPIO header as the original emonPi and I’m using a recently downloaded SD image.
EmonHUB service is stopped.
The 328P used was pulled up from an Arduino Nano I had laying around (the JLCPCB price for it was unacceptable) and coincidently it has a random energy monitoring firmware (maybe one adapted by me for one of my projects).
I can do the command “screen /dev/ttyAMA0 38400” and if I press any key it will return “J i10 g210 @ 433 MHz”, so this means that the 328P is running and the RX/TX communication is good.
With some shell commands I was able to pull pin 7 (GPIO 4) down and up again and was able to detect that the 328P was reset by opening the screen command immediately after and watching the boot-up messages.
But avrdude won’t reset it with the command “avrdude-autoreset -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200” or program it with the command “avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:/root/FirmWares/MyEmonPi_NewBoard_2022.ino.eightanaloginputs.hex”
Here is the output for both commands:
avrdude-autoreset -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200
avrdude-original: Version 6.3-20171130
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg WunschSystem 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 : 115200
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: stk500_getsync() attempt 1 of 10: not in sync: resp=0x1c
avrdude-original: stk500_getsync() attempt 2 of 10: not in sync: resp=0xe0
avrdude-original: stk500_getsync() attempt 3 of 10: not in sync: resp=0x8e
avrdude-original: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0
avrdude-original: stk500_getsync() attempt 5 of 10: not in sync: resp=0x1c
avrdude-original: stk500_getsync() attempt 6 of 10: not in sync: resp=0xe0
avrdude-original: stk500_getsync() attempt 7 of 10: not in sync: resp=0xf0
avrdude-original: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude-original: stk500_getsync() attempt 9 of 10: not in sync: resp=0x1c
avrdude-original: stk500_getsync() attempt 10 of 10: not in sync: resp=0x0eavrdude-original done. Thank you.
strace: |autoreset: Broken pipe
avrdude -v -c arduino -p ATMEGA328P -P /dev/ttyAMA0 -b 115200 -U flash:w:/root/FirmWares/MyEmonPi_NewBoard_2022.ino.eightanaloginputs.hex
avrdude-original: Version 6.3-20171130
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg WunschSystem 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 : 115200
avrdude-original: Using autoreset DTR on GPIO Pin 7
avrdude-original: stk500_getsync() attempt 1 of 10: not in sync: resp=0x1c
avrdude-original: stk500_getsync() attempt 2 of 10: not in sync: resp=0xe0
avrdude-original: stk500_getsync() attempt 3 of 10: not in sync: resp=0x8e
avrdude-original: stk500_getsync() attempt 4 of 10: not in sync: resp=0xe0
avrdude-original: stk500_getsync() attempt 5 of 10: not in sync: resp=0x1c
avrdude-original: stk500_getsync() attempt 6 of 10: not in sync: resp=0xe0
avrdude-original: stk500_getsync() attempt 7 of 10: not in sync: resp=0xf0
avrdude-original: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude-original: stk500_getsync() attempt 9 of 10: not in sync: resp=0x1c
avrdude-original: stk500_getsync() attempt 10 of 10: not in sync: resp=0x0eavrdude-original done. Thank you.
strace: |autoreset: Broken pipe
Any idea how to overcome this programmer problem?
This should be a common problem with the original EmonPi on an Raspberry Pi 4.
Cheers.