Raspberry PI Revolution - Backup and Firmware UpgradeFollow article
How do you feel about this article? Help us to provide better content for you.
Thank you! Your feedback has been received.
There was a problem submitting your feedback, please try again later.
What do you think of this article?
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
- Register with Kunbus in order to access a pre-built firmware image
- Download latest stretch image Your new firmware.
- Download Pi Boot application to allow access to the boot image on the Rev PI device.
- Download Win32DiskImager application used to perform the actual restore / Update or backup
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.
On the PC, run the PIBoot_Setup.exe application we downloaded earlier
You will see a screen like this...
...followed by two additional drive letters showing up in explorer
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.
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.
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.
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.
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.
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.
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
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 :)