Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Introduction

In this tutorial, we will learn how to flash an image from one HMI device to multiple devices. We can see an overview of copying the image from one device to another using a USB flash drive. We can investigate an example code of how to increment the IP and change the MAC address in all the devices automatically using the script.

Overview

  • Use any disk imaging tool to extract the image from the master HMI device.

  • Create an installation script using the extracted image from the master HMI device and store it in a bootable USB flash drive.

  • Insert the USB flash drive into the destination HMI device and run the script along with the IP increment and MAC address change script.

Requirements

  • The master device (HMI) with the changes

  • Host machine PC

  • A bootable USB flash drive.

  • Destination device

Step 1: Creating an Image of the Source HMI Device

The first step is to create an image of the source HMI device. This image will be used to flash the destination HMI device. To create the image, follow these steps:

...

In this command, if stands for "input file", and of stands for "output file". The bs option specifies the block size.

Step 2: Add a script to change the default IP address of the Destination HMI Device.

The IP address should not be the same in all the cloned devices so we are about to write a script to change the IP address for all the devices. We have a counter variable called $count and an IP address stored in the variable $CURRENT_IP, you can increment the IP address according to the counter value in a shell script like this:

...

To use this script, save it to a file (e.g. increment_ip_address.sh), make it executable using chmod +x increment_ip_address.sh, and then run it as root or with sudo privileges.

Step 3: Add script to replace hardware mac Address with the cloned IP address of the Destination HMI Device

The MAC address should be unique for all the cloned devices so we need to replace the hardware MAC address with the cloned MAC address of the previous device as the MAC address should be unique. We can make an example script to change the cloned MAC address

...

To use this script, save it as a file (e.g. change_mac.sh), make it executable (chmod +x change_mac.sh), and run it with root privileges (sudo ./change_mac.sh).

Step 4: Add script to replace the Image and run the script on the Destination HMI Device

Create the installation script which mounts the USB flash drive, changes the directory, flashes the cloned image, changes the IP address and MAC address.

...

  1. Transfer all the scripts and files to the root directory in the USB flash drive.

  2. Remove the USB flash drive from the master HMI device.

  3. Insert the USB flash drive into the destination HMI device

  4. Connect to the destination device using the serial console.

  5. Open the terminal of the destination device in the PC using any terminal program with a speed 115200 eg:-MobaXterm

  6. Run the installation script in the destination HMI device(install_image.sh).

Step 5: Verifying the Image on the Destination HMI Device

The final step is to verify that the image was successfully transferred to the destination HMI device. To do this, follow these steps:

...

The default IP address should be changed by using the above script.

Conclusion

In this tutorial, we discussed how to flash an image from one HMI device to another in general and looked into the example using the dd command. This method can be useful for deploying the same image across multiple HMI devices and changing the IP address and MAC address. We can install the customer setup on multiple devices by repeating the steps on multiple devices one by one.

We can get more information about the dd command in the following link 

We can use other imaging tools such as Clonezilla or Mondo Rescue tool to create images of the HMI devices.