DCC-EX / CommandStation-EX

EX-CommandStation firmware from DCC-EX. Includes support for WiFi and a standalone WiThrottle server. A complete re-write of the original DCC++.
https://dcc-ex.github.io/
GNU General Public License v3.0
158 stars 111 forks source link

Add ArduinoOTA Support for ESP32-Based Boards #395

Open SenMorgan opened 10 months ago

SenMorgan commented 10 months ago

This pull request introduces support for ArduinoOTA updates on ESP32-based boards. This feature allows for wireless updating of the firmware over the network, which significantly simplifies the update process for devices that are not easily accessible.

Changes include:

This enhancement provides a robust and user-friendly method for firmware updates, reducing the need for physical access to the device and streamlining the update process.

Please review and provide any feedback.

habazut commented 10 months ago

Thanks for the contribution. Have you tested also with arduino-cli? I ask because the ex-installer uses arduino-cli. What do you think about a command like <C OTA> to start it instead of having OTA available all the time? Regards, Harald.

SenMorgan commented 10 months ago

I haven't had the chance to test it with arduino-cli yet, and I'm not quite sure how to go about it. Could you possibly guide me through the process?

As for the suggestion to manually enable OTA with a command, I see the merit in it. However, during development and debugging of automation processes, it might become cumbersome to send this command before every update. It would be ideal if the ESP32 could remember to enable OTA even after a reboot, but as far as I can tell from the code, there doesn't seem to be EEPROM support for the ESP32 device yet. Could you confirm this, please?

habazut commented 10 months ago
  1. OTA: One could have the "enable OTA" in the mySetup.h if devel person

  2. EEPROM: There is emulated EEPROM which can be allocated in FLASH on the ESP32 but to use it you must add "commit" statements which copy the RAM cache to EEPROM. I think we talked about it on Discord and I looked at that and then got sidetracked.

Regards.

habazut commented 10 months ago

Could you possibly guide me through the process?

Install arduino-cli (or use the install you get with the ex-installer) Start the OTA on the ESP32 Check if you see it with arduino-cli board list Check if you can upload by using what it shows as "port" (IP addr or mDNS name)

Regards. Now I have timeout for today.

SenMorgan commented 10 months ago

Hello again,

I believe there might be a misunderstanding: I don't use Discord, so perhaps you've confused me with someone else.

I've tested the OTA upload using arduino-cli and can confirm that it works flawlessly.

Your suggestion to temporarily enable OTA via a command and permanently enable it through a config file seems very good. I'll attempt to implement this. Thank you for the advice.

SenMorgan commented 10 months ago

You suggested using the command , but I couldn't find any information about the opcode. I only found the one, which is used for requesting track current information. However, I did find that the opcode could potentially be used to control OTA. Am I mistaken, or did you intend for me to implement a new opcode?

SenMorgan commented 10 months ago

So, I've chosen to implement this feature using the opcode. Please review my changes.

habazut commented 10 months ago

As you have based your changes on master does not exist yet. But C is like D but I want to divide the commands into C for config and D for diag. So that we on system with little RAM can disable all D if we need to.

I will not have time to review this before start of next week but you are not forgotten.

Harald.

SenMorgan commented 10 months ago

Ah, okay, I found this in another branch. Ok, will wait for your verification.

SenMorgan commented 9 months ago

Hello. Any updates/reviews?