I am unable to flash the firmware to the AVR

I am unable to flash the firmware onto my AVR module.

Steps.

  1. Firmware — OpenEnergyMonitor 0.0.1 documentation
  2. Using the terminal and PIO
  3. It compliles OK
  4. When attempting to flash the chip it keeps giving the following error - programmer is not responding.
  5. I can see the device using dmesg @ ttyAMA0

Welcome, Vaughn, to the OEM forum.

What’s an AVR Module? Is it an emonTH connected via a programmer, or a modern emonTx with a USB-C connector, and if so, which one?

Remember what it says in the FAQ - all we know about what you have is what you write down here.

Hi

Thanks, pretty new to this.
Its the AVR chip onboard the EmonPi2. IT connected via UART on the Raspberry Pi4

Did your emonPi2 “work” before you tried to do this - and why are you re-flashing it? Have you tried using one of the pre-compiled options via emonCMS and Setup → Admin → Update → Update Firmware Only? Or are you customising the front end software?

If none of those options will load, and you selected the correct port and hardware, and there’s nothing else connected to your emonPi2 so you had a choice of one for the port - then I think it must probably be a hardware problem. It might just be worth taking one of the end plates off to take a look inside, but I can’t see how the connector could have become dislodged.

Unfortunately, all those error messages mean only that it can’t communicate. This can be for any one of a multitude of faults.

It has never worked. I had it fabricated with JLCPCB as per the github.
Is there anyway to try and diagnose the faults.

@Vaughn_Fisher - could you post a picture of your setup, including the connection to the Pi? Might help. Which version did you have assembled by JLCPCB? Have you tried manually uploading with avrdude?

You don’t have an emonPi2, you have a clone, one not manufactured and tested by The Shop. It makes a big difference, and it would have saved time if you’d made this clear at the start. I did write “Remember what it says in the FAQ - all we know about what you have is what you write down here.” We can help only as much as the information you give us allows.
I have yet to see a report of a Megni-manufactured emonPi (either version) having a fault like you describe.

I’m not totally sure of your specific hardware, but in general terms, to flash an AVR chip using the serial UART requires that the AVR already has a bootloader installed.

1 Like

Thanks, I did think that.

Is there a tutorial on how to do this from the raspeberry pi?

You’ll need to install avrdude on the Pi (sudo apt install avrdude) and connect some kind of programmer (ISP) between the Pi and the target boards ICSP header. The exact bootloader file and the command to install it will vary depending on the hardware but you should be able to search the web for that.

You can use a Raspberry Pi, you don’t need a dedicated ISP for it. Decent Adafruit tutorial here.

Oh, even better!

I’ve had an AVR ISP since before the Pi existed, so never thought about using anything else.

Thanks for the help guys.
One small problem where is the ICSP header on the emonPi2 board

It seems that the emonPi2 uses the AVR-DB variant, which has replaced ICSP with UPDI, but I’ve no experience of that so unfortunately can’t really advise further.

1 Like

Oh, I forgot it was UPDI :man_facepalming:You need to populate the UPDI header on the Pi2 - it’s the 3x one next to the expander header, labelled as UPDI.

On the Pi side, you need to connect the UART Rx and Tx pins similar to that shown below:

The diode provides protection between the Rx and Tx pins. On that UPDI port, pin 1 would be the middle pin on the emonPi2 board.

Great thanks

Last help I promise how do I burn boatloader using raspberry pi and UPDI

Note, I have not done this - but it should all be relatively straightforward. The bootloader for the AVR-DB is here. You can upload with avrdude with something like:

avrdude -v -pavr128db48 -cserialupdi -D -P/dev/cu.usbserial-1320 -b115200 -Uflash:w:bootloader.hex:i

The -P option should be the path to your serial device.

Or get yourself a UPDI programmer.