Upgrading OpenEVSE / EmonEVSE Controller Firmware using ISP programmer

@JJC @glyn.hudson

I’ve been trying to update my openevse firmware today without any joy.

Initially I bought the programmer recommended by Glynn, but as noted here, the connector doesn;t match that on the openevse. It seemed it was going to cost almost as much to get a set of individual leads to make the connection as to buy the one that JJC recommended, so I got that. However, that isn’t recognised when I plug it into my windows 10 PC (USB C - USB adapter). And I wasn;t able to figure out how to install a driver for it as the ‘Zagig’ programme doesn’t see it. I’m also not clear on how much of the instructions posted by Glynn (How to Load OpenEVSE Firmware (WinAVR) - OpenEVSE) I’m supposed to follow as they don’t seem to match what other people are doing.

As there was a flashing light on the programmer I did try running the AVRdude line, but just get the following error:

Command:
C:\Users\Rachel\Dropbox\Home\House\EnergyStuff\OpenEvSEFirmware>avrdude -c stk500v2 -P COM14 -p atmega328p -U eeprom:r:oldevse.hex:i
Response:
avrdude: ser_open(): can’t open device “\.\COM14”: The system cannot find the file specified.

I’m guessing that’s because there isn’t a driver installed, but I’m not much of a nerd in this area!

So having failed with that programmer, I then remembered my son had some leads from an old electronics kit and managed to patch up the programmer Glyn recommended using JCCs diagram. I also downloaded the driver from the instructions in the guide Glynn listed and seemed to be able to install that OK. HOwever, when I try to run Glyn’s command line I get this:

Command:
C:\Users\Rachel\Dropbox\Home\House\EnergyStuff\OpenEvSEFirmware>avrdude -p atmega328p -c usbasp -P usb -e -U flash:w:openevse.hex

Response:
avrdude: error: programm enable: target doesn’t answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude done. Thank you.

So I’m not clear whether that’s just a connection issue or something more as I’m pretty sure my wiring is right and making contact.

Can anyone help?

Regards
Rachel

Hi Rachel,

have you get the EVSE powered on? This is the easiest way but you need to be careful :slight_smile:
If not then you need to alter the software config so the programmer board provides the power but found it was easier to just power the EVSE up.

Also the line I used was
avrdude -c stk500v2 -P COM14 -p atmega328p -U eeprom:r:oldevse.hex:i

but the COM14 may change depending what port your PC allocates to the programming board

Then

avrdude -c stk500v2 -P COM14 -p atmega328p -U flash:r:oldevse1.hex:i

This makes a copy of the flash to file oldevse1.hex

Then I flashed the new one in with
avrdude -c stk500v2 -P COM14 -p atmega328p -U flash:w:openevse.hex

John

Thanks John,

My PC doesn’t seem to recognise the programmer board being plugged in - I have no idea what if any COM port it is being assigned to. Is there a way to find this out (assuming it’s being recognised at all?)

I have tried it both ways - powered and unpowered!

Rachel

Rachel,

What OS are you using on your PC?
What cable are you using to connect the PC to the programmer board?

John

You might find some helpful information here: Learn→Electricity Monitoring→Programmers

Rachael, if you are using Windows 10, then right click on the start button and select device manager. Then have a look at the COM ports entry. I found it added two on mine, COM3 and COM4, I found that COM3 didn’t work but COM4 did for John’s command lines.

Pete

I have “Successfully” done the upgrade to 7.1.3 following John’s instructions and also updated the WiFi to version 4.1.1.

I put “Successfully” in quotes, because I think I may have messed up a bit. I am now restricted to 24 Amps, and I think I may have mistakenly downloaded the US version from GitHub. There was a file called EEPROM_24.bin which I also programmed - it seemed the right thing to do because that operation was also listed in flash.bat - but now I think it was a mistake.

So how do I get back to 32 Amps now? I found the correct UK version, but there is no EEPROM file in that one. Will it revert to the correct limit if I re-flash openevse.hex ? Or is there some way I can change that limit from the UI?

Thanks,

Pete

Pete,

if you followed my instructions fully you will have created backup files that you could re-load taking you back to before you started. At this point you could start again and I hope all should be good.

John

That sounds like a plan, I did indeed create the backup files as per your instructions. As it’s now getting dark out there, I’ll leave taking the cover off again today, and have a go next time I have a gap in my work schedule, I can live with the 24A limit for a week or so if necessary.

Thanks,

Pete

Oh dear, I think I do need some help now, I seem to have gone backwards instead of forwards :frowning:

I had some time today, so decided to see if I could re-flash it and get my full 32Amps back again. I followed your instructions, John, and re-flashed it back to the old version before I messed up last time by putting the US version in. This worked fine, I got my 32A back and it was reporting 5.1 EU (or something similar).

So next I flashed it with 7.1.3EU which I got from the right (I hope) GitHub repository this time. I flashed the file openevse.hex - was this the right one?

Programming seemed to go ok, except that it reported some fuses had been changed, did I want to put them back? I answered no, on the basis that they should be set however that hex file specified them. Is this where I went wrong?

Now the display on my charger is completely blank, and no response to ping or web access from the wi-fi (which I didn’t modify this time).

I tried to flash it again, either with the old version or the new new one, but now I get:


avrdude: stk500v2_command(): command failed
avrdude: stk500v2_command(): unknown status 0xc9
avrdude: stk500v2_program_enable(): cannot get connection status
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

I tried the -F override suggested, and then I get the additional messages:


avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA328P is 1E 95 0F

Have I somehow managed to destroy my processor chip?
I now have a dead charger I cannot use. I have 80% in the car, which is good for 200 miles or so this time of year, and fortunately I don’t have any long trips planned in the next week or so, but it would be good to get it working again.

Can anyone suggest how I should proceed from here?

Thanks,

Pete

@PeteBee

I hope that there are no major issues, the responses that you are getting make me think the board has no power. can you “carefully” with the unit powered up check if you have 12V on the 12v connections. Also check that you have not disturbed the 240v connections on the left side of the board and that they have power.

John

Thanks John, I’l have a look tomorrow when the daylight is back. As you say, I shall do so very carefully!

I will double check the screws on the 12V terminal block are fully home and I can check the 12V on the top of those screws.

This photo was taken during the original build, looks like I should just about be able to get the meter probes onto the AC input connections.

Regards,

Pete

I’ve now checked those voltages. There is indeed mains (measured at 239V) on the mains input pins, and 12V DC on the 2 pin terminal block on the right. I also checked the voltage being supplied to both the ESP32 module and the display module via their input connector, 5V DC in both cases. But still nothing on the display at all when it is turned on with everything connected.

The last update I did was to flash the 7.1.3EU firmware into the openevse module, so that shouldn’t have affected the ESP32 at all, which wasn’t even connected at the time. It was working fine before I did that.

I see that the data connection to the display comes from the openevse module, so I guess even if the ESP32 is alive, it presumably can’t display anything if the openevse module is dead?

I’m wondering if I messed up in my answers to the “fuse changed do you want to put it back?” questions?

If so, is there any way to get the firmware and processor fuse settings back to virgin state on the openevse module, so I can start again?

@PeteBee
This has now gone past my knowledge on this subject. Only other thing I could suggest is as you said that the esp32 was disconnected is that you check that you have put the connectors back in the correct place as it is easy to misplace by a pin and I believe that in some of the instructions the orientation is incorrect. So check all the connectors are correct both sep32 and the LCD

John

Hi John, yes I have carefully checked all the connectors are in the correct position, oriented correctly and not inserted one pin out of alignment. I compared with the photos I took during the original build and everything matches.

I am pretty much convinced the problem is with the openevse module, not the display or ESP32, as they both depend on the openevse module for their comms.

I strongly suspect I messed up when updating the firmware to V3.1.7EU, and I have incorrect “fuses” set in the processor. Research online seems to indicate that it is possible to reset this situation, but I think I need a programmer capable of high voltage programming. I wonder if the firmware author(s) and/or hardware designer(s) can help with what I should do next?

I did consider replacing the ATMEGA328P-AU chip - I downloaded the schematics and gerbers from GitHub and had a look, it is a 32 pin TQFP package, which is probably just within my capabilities, with care, to desolder the old one and solder in a replacement… The chip only costs couple of quid, but that idea came to a halt when I disovered that none of my usual electronics suppliers have any in stock. Microchip would allow me to order samples, with “shipment in 364 days”! So back to the drawing board on that one. I found a forum where it was suggested that a programmer called an AVR dragon would be capable of resetting fuses (if only I knew exactly what to reset) - but that seems to be an obsolete tool so I am not quite sure where to go from here.

So any advice from the more knowledgeable would be gratefully received, as right now my charger is completely dead.

Hi John, you have been very helpful, but now I’m hoping that I might get some support from the developers who will be more familiar with the internals of the circuit.

I have managed to get some useful advice over on the MERG forum, where I am an active member, and there are quite a few experts on Atmel processors and Arduino stuff - however they are mostly less familiar with the specific internals of the OpenEVSE.

I’ve been advised that avrdude does have a habit of sometimes getting out of sync and corrupting the “fuses” on the chip, so it should be used additionally with the -u (lower case) switch which stops it going anywhere near the fuses when programming flash. I have tried to read the fuses but I get the same error message that it cannot connect. It seems the fuses may be corrupted so that I cannot use ISP any more. I’m told that to fix that needs HVP, which I believe cannot be done via the ISP connector, and is difficult to do in circuit.

I have removed the OpenEVSE module from the charger and brought it indoors to the workbench.

I wonder if any of the developers follow this forum, and if anyone who is more familiar with the circuit can advise me if I can safely connect +5V into the 5V line to power up the microcontroller separately, so I can try to see if I can find a method to program it? I’m wondering if this might cause any damage to the DC to DC converter, as this would effectively feed 5V into its output whilst it is not powered by mains on its input?

Is posting on here the best place to get support from the developers/hardware suppliers, or am I best sending an email?

Any further advice gratefully received.

Thanks,

Pete

@PeteBee

One last bit, I did some tests last night and the light on the esp32 module lights up as soon as it gets power even when not connected to the EVSE module, when you powered up the unit did this light up? If you feel that you can do it safely then you could power up the EVSE module from 240V and probe on the reverse of the AC/DC module and ensure you are getting both the 12v and 5v feeds. Hope you get it sorted :slight_smile:

John

Hi John,

I didn’t check the light on the ESP32, although I did measure 5V DC on its input connector, as well as 5V on the display connector and 12V on the connector on the side of the EVSE module. So all voltages looked ok.

I think I will try supplying the 328 circuit with 5V and try talking to it on the bench, it shouldn’t need other than the 5V supply for that.

Although all suppliers are out of those chips, a MERG member has kindly offered to send me a spare he has, so I might yet try swapping the chip. I’m ordering a Nano anyway, which is cheap enough, and I can use for various experiments as well as testing that my USB ISP programmer is good.

What is the official way to ellicit support from the OpenEVSE designers and authors?

@PeteBee

@glyn.hudson @jeremypoulter Guys, I have tried my best but this has now outstripped my diagnostic ability could you possibly help?

John

Hiya @PeteBee just trying to catch up, so just to summarise, you have tried to update the firmware on the OpenEVSE module and it is now showing no sign of life?

My domain is mostly the WiFi module, but can try to help. You should be able to power the OpenEVSE module from the programmer no problem (when set to 5v if it has a switch), so I would try reprogramming the 328 with nothing else connected and see if that is showing any signs of life.