Page 1 of 2

Firmware upgrade

Posted: Fri Jan 22, 2021 10:51 pm
by mcasamento
I've tried to update the firmware on my OTGW (nodoshop ver) through WiFi.
I've downloaded the latest OTMonitor and connected it through TCP port.
It started and went to like 6% (not sure) then stop. Probably my WiFi connection had an hiccup exactly then! :)
I've tried again but OTMonitor briefly said "Switching to self-programming mode" followed by "Please manually reset the OpenTherm Gateway"
I've then plugged out and replugged power supply and repeated the process, with no luck.

So I've detached the OTGW, removed the NodeMCU and attached it directly to my USB to TTL, (GND,RX-TX) after selecting the right COM port in OTMonitor, but no luck. :roll:
I've also followed and replicated what's already happened at this blog post that seem absolutely identical to what's happened to me, and I've also tried to swap RX/TX cable but nothing ever seems to change.

What's worst is that I can't see any response from the OTGW on the log (attached).
Is there something I can do ? Buy a compatible PIC Programmer maybe ? :cry:

Thanks,
Marco

Re: Firmware upgrade

Posted: Sat Jan 23, 2021 11:03 am
by hvxl
As already explained in several other topics, when OTMonitor asks to "Please manually reset the OpenTherm Gateway", you need to briefly short the pins on the RST jumper next to the PIC. If you power cycle the whole gateway, the WiFi connection needs to be reestablished, which simply takes too long. Your logs suggest that you should be able to recover that way.

Using a USB serial cable should also have worked. You describe the steps you took in quite detail. The part I'm missing is that you put the TxP/RxP jumpers to the FTDI position.

Apparently many people have unstable WiFi. Upgrading via WiFi is not a good idea in such cases.

Re: Firmware upgrade

Posted: Sat Jan 23, 2021 11:52 am
by mcasamento
Sorry I forgot to mention this, when I tried to program through FTDI I've short-circuited the two RST pin in the middle of the board, but it had no effect.
Yes, I've moved the two jumper toward the right, near the PIC.

I'm now pretty sure there was some WiFi hiccup, it WAS a stable connection but I've just noticed that the exact same WiFi channel that I use is now in use by a neighbour and ping lose about a packet in 20.
Lesson Learned: be 101% sure that WiFi is perfect before update, and yes, is stated on the site.

Worth to note that PIC firmware is so well written that even in this unbootable state it allows communication between boiler and thermostat, really love it.

I've found a PIC programmer on amazon that claims to be compatible with MPLAB / MPLAB X, is that enough to try to bring back to life my beloved PIC ? (not sure if forum rules allows me to put amazon link here, so I'm just attaching the picture link)

Re: Firmware upgrade

Posted: Sat Jan 23, 2021 1:37 pm
by hvxl
If the thermostat and boiler can still communicate through the OTGW after the failed upgrade and a power cycle, that is a clear sign that the firmware upgrade code is not compromised. That means that you should be able to recover the device. Just stay calm and follow the instructions.

Note: When OTMonitor indicates to manually reset the OpenTherm Gateway, you have to do that within 1 minute. Otherwise restart the firmware upgrade and try again.

Re: Firmware upgrade

Posted: Sat Jan 23, 2021 5:57 pm
by mcasamento
You're the saviour of my PIC and I'm an (happy) idiot.
Needless to say, you were right, I was just missing... THE POWER to the Board !!! :shock: :shock:

Thank you very much now I'm in a hurry to try the new feature and see if it fixes the instabilities on Home Assistant!

THHHHANK YOU.

Re: Firmware upgrade

Posted: Sat Jan 23, 2021 9:59 pm
by tjfs
Schelte has done an awesome job making the upgrade process bullet proof and helping out idiots like me on this board.

Thank you!

Tim

Re: Firmware upgrade

Posted: Sun Jan 24, 2021 7:04 pm
by mcasamento
Well, It is impossible to make anything foolproof because fools are so ingenious.

I had to downgrade the firmware, actually I was using "debug firmware" directly written by Schelte that managed a Msg differently and obviously the new one wasn't working but I thought I could give it a try.
Despite this time I've been really careful during the downgrade process and bring the board inside in line of sight of the access point it interrupted again at around 6%.
Then i restarted and tried again clearing the flag to copy eeprom settings, it started for some seconds and gave an error.
So I tried with the FTDI programmer, but... nothing.
OTMonitor asks me to Manual Reset but it seems that the manual reset have no effect.

- Yes the board is powered.
- Yes I've switched the two pins towards the PIC
- Yes I've repeatidly tried to briefly short the reset pin
- Yes TX and RX are right (and I've also inverted them just in case)
- Yes my FTDI board works (just flashed a ESP01 just to try) and Yes I've switched it to 5V before
- No, this time Boiler and Thermostat are not talking, Thermostat asks to be connected to an OT Boiler


I'm a bit puzzled because this time I don't understand what could have gone wrong.
If useful to add, both the access point and the OTGW board are powered by an UPS

Re: Firmware upgrade

Posted: Mon Jan 25, 2021 12:38 am
by hvxl
That does sound like you managed to mess up the PIC to the point that a PIC programmer would be needed to recover.

You could try the new NodeMCU firmware I have just published on the web site. If the PIC is recoverable, that should be able to do it. But as I said, I don't have high hopes for yours.

Re: Firmware upgrade

Posted: Mon Jan 25, 2021 9:47 am
by rvdbreemen
Hi Schelte,

Would you be willing to release the source to this, so I can integrate it in the Nodoshop version? Otherwise I will try to replicate something you already built, and are clearly more experienced, as you have been programming PIC for many years already.

In the mean time I have added a reset detection in the DEV branch, and I reset the PIC "manually" using a GPIO signal. This should enable more reliable recover, but recovering over serial over wifi is with unstable wifi is just not the best way.

Let me know,
Robert

Re: Firmware upgrade

Posted: Mon Jan 25, 2021 11:36 am
by mcasamento
Hi Schelte thanks for directions.
I've just tried what you suggested.
After having uploaded the new NodeMCU FW and reinstalled the NodeMCU on the otgw board I've pressed the FLASH button and the wifi led light up steady, then after a couple of sec it started to blink quickly. No other led on the whole board (both NodeMCU and otgw board) ever light up.

Can you confirm that I've somehow messed up the PIC ?

Marco

Re: Firmware upgrade

Posted: Mon Jan 25, 2021 1:48 pm
by hvxl
I was afraid that was going to happen. Then in your case a PIC programmer will unfortunately be needed to recover the PIC.

Re: Firmware upgrade

Posted: Wed Aug 25, 2021 12:01 pm
by jacobdvh
Just tried to upgrade the firmware as per the instruction of the (marvellous) manual. This failed halfway. I noticed a large number of retries and errors.
Trying to upgrade a second time failed also, at around same point, ie 45-46%.
Then I rebooted the OTGW, but it was dead. :cry:
I assume that I will now have to get a PIC programmer etc and upgrade the 5.1 firmware manually? Any ideas or suggestions?

As always, your help will be greatly appreciated.

Jacob.

Re: Firmware upgrade

Posted: Fri Aug 27, 2021 10:20 am
by hvxl
It is supposed to be quite hard to break the OTGW PIC while upgrading the firmware. The device may not appear to be working anymore after a failed upgrade, but a new upgrade is normally still possible. I'm not sure what model of OTGW you're using, but the general procedure is:
  • Open OTmonitor and connect to the OTGW
  • Start a firmware upgrade
  • OTmonitor asks to manually reset the OTGW
  • Within 1 minute, briefly short the reset pin of the PIC to ground
  • The firmware upgrade starts
Unless you have the original serial model, cycling the power of the OTGW will not work because OTmonitor loses its connection to the NodeMCU, LAN module, or USB interface. By the time it reconnects, it will have already missed the window to start a firmware upgrade.

There are different NodeMCU firmware images available that can recover the OTGW, if you have a NodeMCU version.

Re: Firmware upgrade

Posted: Fri Aug 27, 2021 1:45 pm
by jacobdvh
Many thanks Schelte for the quick and professional response. I have to say, it did not quite work as you describe: after starting the upgrade as per your step 1 & 2 I did NOT get the instruction to manually reset the OTGW. On the contrary, the process started immediately, but quite slowly, and after some 20 or 30 minutes or so it crashed; showing over 1,000 errors and retries.
Anyway, I have the OTGW from Nodo shop without wifi and I contacted Nodo (Remco) and they kindly offered to re-flash my PIC with 5.1 and return it. So, very good service.

Expect the repaired PIC back any moment now and hopefully it will then work OK. I do hope that the self programming mode works, as I will need that if I want to make some adaptations to the firmware.

Can you recommend any specific test bed to develop some additional code? Or do I need to test every version in the actual setup of Boiler, OTGW and Thermostat/controller?

Once again, many thanks so far. I think the OTGW is a marvellous product and if anything it will be a tremendous learning experience for me.

Jacob

Re: Firmware upgrade

Posted: Fri Aug 27, 2021 11:09 pm
by hvxl
You said your OTGW was dead. I described the process for recovering from such a situation. If the upgrade starts on its own, then the OTGW is not dead. You should just be able to reflash it. It does not need to be "repaired".

The upgrade process gives up when it has encountered 1000 errors. It does not "crash".

The slowness and errors indicate that you have a communication issue. You still left my question about which model you have partially unanswered. So you don't have the WiFi version. That leaves the USB and LAN version. In case of the LAN version, you may not have the USR-TCP232-T2 module configured correctly. For both versions it could be that you have multiple processes talking to the device. Each process would then get part of the data. That will severly interfere with the upgrade. Maybe Domoticz is still connecting to the device? Make sure OTmonitor has exclusive access to the OTGW when doing an upgrade.

The OTGW source code package comes with a readme.txt file, containing notes on how to build and test the firmware.