Unsupervised firmware + application update

Hi!
This may be well outside of normal scope, but hopefully someone may be of assistance.

Goal: To have a CC100 on a remote network be able to safely do an automatic firmware and app update without user interaction outside of pressing “update”.

I have gotten close to this before, but I have always needed to have another machine orchestrate everything by ssh’ing into the controller and passing commands to the fwupdate script in config-tools, and then loading the new runtime app.

The problem I’m facing is that any script I call will inadvertently be stopped during the switching of rootfs, and when the controller comes back up, nothing can run to mark the update as complete/trigger the download of a new codesys application.

Cron jobs are deleted on update, so that’s off the table. Codesys applications don’t start until fwupdate finish, so that’s out of the question too.

Do I have to build a custom image to be able to do this, or are there ways I haven’t thought of?
Very simplified - Is there a way to automatically run some piece of code on an unconfirmed firmware update?

Hi Sommerz.

If you are already thinking about a scripting way, cant you use the command /fwupdate status to control if the firmware is in the last state ? im guessing you could loop that over time, and after some time it should return “unconfirmed” and you could then push the /fwupdate finish command.
I am i no way a scripting guy, so im just thinking about it in the simplest of terms.

Alternativly our WAGO Solution builder software could handle all of it via its interface.

Best Regards Jan

Hej Jan,

Thank you for your suggestion.
If the script was running on a different computer, it would work fine, but in this case it sadly doesn’t.

What I’m trying to do is have the controller itself run the script without any interaction from a different computer. That fails because during the firmware update process, any script I have started on the controller will end when the controller boots to the new firmware in the unconfirmed state, leaving nothing to confirm it.

After a long evening yesterday I found a solution; Docker.
During the fwupdate process, when the controller comes back up with unconfirmed firmware, it will still start any docker containers that have the --restart flag set to always. That means that I can have it automatically run whatever checks I need and then send fwupdate finish. This was the last piece I was missing! :slight_smile:

Hi Sommerz.

Cool you found a solution via docker :slight_smile: ill keep that in mind for the future.

Best Regards Jan

The /settings folder is persistent across A/B rootfs switches. /settings/fwupdate_listener_scripts/on_unconfirmed is a “listener file”, where each line is executed as a command when the firmware update reaches “unconfirmed” state.

Your update script can add the path to a custom script or just simply the finish command:

/etc/config-tools/fwupdate finish

to on_unconfirmed before calling fwupdate start.

If you use a separate script, it must be executable with chmod +x. I havent tested this, but my earlier deep dive in the update mechanism found this. The related fwupdater functions are placed in /etc/init.d/fwupdate_service, /usr/sbin/fwupdate_common and /usr/sbin/fwupdate_basic_defines.

Edit: Looking at this again, theres a better solution using /etc/config-tools/online_update. This is a “one-shot” update tool that can carry the firmware update through the required reboots and complete the update automatically.

Firmware and application updates can be distributed using an appload archive containing a wupload.cfg together with the required firmware, application, and other files. See the WAGOupload manual for the package structure:

The PLC can retrieve the update package from a remote server using HTTP/HTTPS/TFTP, or from local storage using a file:// URL.

A minimal wupload.cfg for a firmware update can look like:

[Common]
Workflow=InstallApplication
FirmwareUpdateFile=PFC-G2-Linux_update_V040901_31_r9d0900aaed.wup

The update can then be started with for example

/etc/config-tools/online_update set-url file:///home/admin/
/etc/config-tools/online_update --text check update.appload
/etc/config-tools/online_update --text start update.appload

online_update registers itself with the firmware update mechanism so that it resumes after the A/B rootfs switch, handles the unconfirmed state, and finishes the firmware update automatically.

You can basically automate the entire update including deploying application and installing ipks, distribution of files, defining what should be backed up and restored etc. See one of the Wago Solution packages such as Lighting manager for an example of appload distribution at https://downloadcenter.wago.com/

This is extremely helpful!

I don’t remember seeing online_update on the CC100, but I will check it out. Gonna update this thread with my findings when I do :blush:

Just checked on a fw28 cc100 I have running and it has the online_update tool