How To: Create a self installing SD Card (aka Magic SD)

Steps to create an SD card that when booted, will perform an automatic Firmware Update.

  1. Create a bootable sd-card

    • Using a flashing utility (like Balena or WinDiskImager)
    • Using WBM via Administration>Create Image
  2. Boot the PFC from this sd-card

  3. Shell into the PFC as root user

ssh root@192.168.1.17

  1. Type the following command in the shell:

/etc/init.d/cpsd2intern makelink

Now the SD card will copy itself at every boot into the PFC’s flash!

  1. Power off/on to test the function (with inserted sd-card)
    The progress of firmware update displayed via LED’s U1 to U4
    YELLOW: Copy process is active(approx. 1 minute)
    GREEN: Successfully done!
    RED: Finished with ERROR!
    image

  2. The image is copied into flash. now remove the sd-card and test if the PFC is rebooting from internal flash.

9 Likes

Fantastic Kurt !
Much easier than I thought !

Thanks Kurt, it’s very clear !

Just be careful with this Magic SD if you create an Image with a program which contains Retain Persistent variables.
Sometimes, after PFC reboot (step 6), you will see that Firmware will be updated but program won’t be downloaded.

3 Likes

Indeed I had this problem myself more than once.
Anyone have a script/idea to solve this ?
I only found the best way in that case was to log in the PLC, disable the runtime and do the magic flash.

I used the same workaround as well.
For now, I am used to read/write data in file or database instead of using Retain Persistent variables, as much as possible.