Skip to main content

Raspberry PI Revolution - Backup and Firmware Upgrade

RevolutionPi_060736a152b2a76a7ca8b3edb728f4f87b1af21c.png

Open Source IPC based on Raspberry Pi

 

NOTE: All the modules used in this presentation will be available from RS-Components and I will add the links as soon as I have them.

One of the most important things to remember when working with industrial controllers in a production environment especially (Actually this applies to oh so many other scenarios too) is to make a BACKUP of your current state along with passwords etc. BEFORE MAKING CHANGES. This way if things go wrong you have a place to return to that is a known good state

In fact, any environment that is correctly managed will insist on it and this would be built into operating procedures

So with that in mind, in this post I will show you how to backup your Kunbus RevPi Core3 or Connect, I will point you to a few special files you may want to additionally keep a copy of (Every environment is different so just take my version as an example) and also show you how to upgrade the firmware to the latest (Raspbian Stretch 07 2018 at time of publishing) please note that this may not be the latest Raspbian for the Raspberry PI but the version available with all the Real Time patches installed and the core functionality to monitor and drive the IO modules.

It is worth restating that the IO of the Kunbus modules with the exception of perhaps a couple of the IO in the RevPI Connect itself are NOT accessible directly by the program in the way you would drive or read a GPIO pin on a standard Raspberry PI. The IO of all the modules is captured on a polled basis and presented to the users' program as a file on the flash drive, you can access it as a file and or use IOCTRL methods on it. In the next post, I will demonstrate how to use the IO from within Node-Red.

Prepare for BACKUP, Update or Restore

Ok, this is a fairly straight forward and is the same process you would use with a Raspberry PI Compute module (This is based on that after all )

The current Kunbus Tutorial refers to installing Jessie, my process is based on this but updated to use Stretch. Here is the original Jessie install tutorial

Download the required software

Plug the PC into the Rev PI Core 3 or Connect (Black USB Cable) and reboot/power cycle the revPi Connect or Core 3, the module will not boot into the firmware when the micro USB is connected to a PC, it will assume you're about to backup or restore/update the firmware.

Core_3_programming_firmware1_cc78d24d00c92b5c43950bf98c71c21e1e68bb9d.jpg

On the PC, run the PIBoot_Setup.exe application we downloaded earlier

You will see a screen like this...

2019-02-11_19-54-591_2ee841f6b085222666dfaf96c1b47615df6de142.jpg

...followed by two additional drive letters showing up in explorer

2019-02-11_19-55-461_0655ebbd14ab185a2884b03b9272a7aff0f58884.jpg

We're interested in the readable one (Also writeable). NOTE: your drive letters may be different. If you don’t see this then your connection is in error or you have not power cycled the RevPi or rebooted it. Try again if needed.

Backup

Now we can perform the backup using Win32 Disk imager. Set the image file name to the path and name you want for your backup and be sure to pick the correct drive letter to read from (The readable one from above) then simply press Read and wait for completion.

2019-02-11_20-01-231_147d22d0fe32cffdc71fd7468efbc88af0f19858.jpg

You have now completed a backup and can relax with the assurance that should something go wrong, you have a chance to restore to a working good state.

Restore / Update

Now we have a good backup, were safe to proceed with either restoring a previous image or a new one. in this example I will be updating to a new version of Stretch, the process is the same to restore a backup, just select a different file as needed.

Start with the “Prepare for Backup….” if you have not done so already. 

Using Win32Diskimager select your new firmware as shown here in my case. If you do this in the future there may be a newer file available so select it.

2019-02-17_21-05-33_ad4da59f8a1ea923492596d39a15f6a6ed874722.jpg

Verify you’re still selecting the correct drive letter and once confirmed, press write and accept any additional prompts to start the write process. This may take some time depending on your USB speed etc. on mine as the device was in the other room and connected via 2 USB hubs to get there, it took over 10 minutes. Just be patient, it will get there.

Once this is completed you should simply unplug the USB cable from your PC and power cycle the RevPi to boot into your new firmware or restored image,

If you have a screen attached to the HDMI output then you will see the RevPi booting and it will eventually show the IP address of the Ethernet adapter connected to your network. Use this IP address to connect via a terminal program like Putty or TerraTerm (Or whatever you’re liking) 

NOTE: this IP address may well change once you have run the initial script as you will be setting a MAC address etc. so don’t assume this will remain your devices IP in the field.

2019-02-17_21-17-05_e9dfd261913b172913da30e1e04084e0b2219d62.jpg

As soon as you log in (Default user and password at this point is "pi" and "raspberry") a script will run asking for Serial Number and MAC address of the device were configuring. You can find this on the front of the unit, this image shows the MAC address, the first image above shows the serial number to the right of the QR code on the RevPi Core 3 or Connect.

IMG_07791_015d914bb3702afd154807958cbcb0ea0c8cdf18.jpg

Using terraterm and done entering the details, you should be presented with the new password for your unit and a quick reboot is all that is now needed.

2019-02-17_21-46-39_02f80e19125bc41b1356578c9ac5003f3f79b14a.jpg

If you made a mistake with the MAC address etc., then you can change it by editing /boot/config.txt, you will see it at the end of the file. In my case, the new firmware also changed the hostname to something different to its original so I also edited /etc/hostname to fix that.

 There are a couple of files I mention in the video that are also of interest and that you may want to archive separately, one is config.txt and that is available in the boot folder or in the root as seen by the PC when connected in programming mode. The other is the module configuration files, these are stored in /var/www/pictory/projects folder. Here you will see the current file and also any save as project configurations. Use WinSCP or another program to back these up prior to restore or updating the file system as they will not be thereafter.

The final things you should do after restore or updating your firmware is to run the usual:

  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo apt-get dist-upgrade

This will bring things really up to the latest but won’t install things not already there like npm.

In order to get npm installed, the only reliable way I found to do it was listed on the Raspberry Pi forums

bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

2019-02-17_22-06-50_b11f1c29ed74db9644f5c0515f784ae885226042.jpg

This got Node-Red up to the absolute latest and also installed npm so we will be able to add node-red modules with ease.

One issue now is that we are using over 86% of the file system (A 4GB EMMC Flash chip) and as I found out the hard way, it is very easy to fill it and cause the system to become unstable so we should remove a few things. As I am not planning to use the local desktop I removed the following

  • sudo apt remove raspberrypi-ui-mods
  • sudo apt-get autoremove -y hicolor-icon-theme
  • sudo apt-get clean

In my case, I now only had 69% used. Nice.

NOTE: At the time of posting, the Raspberry Pi foundation has just announced the availability of new compute modules, slightly faster than the ones in the RevPi Core3 and Connect. The biggest thing we would be interested in is that they're also using bigger EMMC Flash chips.

8GB, 16GB and 32GB. I have not found any reason so far as to why you could not just upgrade the compute module in your RevPi with one of these if space is a real concern. I will have one soon and will test this out.

The other space-saving option I am aware of is to build a firmware version based on Raspbian Stretch Lite. This would make a significant difference and if you don’t need the desktop etc., then no loss of relevant functionality. I have brought this to the attention of Kunbus who are considering it as a downloadable image. I can’t wait to try it.

Now we are ready to try our first programming scenario... next post :)

With a background in Industrial Electronics, Solutions Architecture and programming, I now spend my time working on my YouTube channel ( https://www.youtube.com/thebreadboardca ) where I create educational videos showing how to use various devices including Test and measurement, Home and industrial Automation, Components and other fun things I am sent to review or include in projects. I will also create many projects to showcase the use of these items
DesignSpark Electrical Logolinkedin