Using a Dual SD Card Data Storage Strategy to Boost Reliability in Raspberry Pi Based Industrial Systems

By Giampiero Baggiani

Co-Founder, Head of Software Development

Sfera Labs

March 31, 2022

Blog

Using a Dual SD Card Data Storage Strategy to Boost Reliability in Raspberry Pi Based Industrial Systems
Image Provided by Sfera Labs

Raspberry Pi is acknowledged as a great platform, proving popular because of its usability and versatility. However, the platform is often frowned upon because of its reliance on SD card technology for system data storage. That said, we need to remember that SD cards are easily accessible, straightforward to flash, and simple to replace. SD cards have a lot of merits which should not be overlooked.

It is just a matter of making certain that the chosen SD card is correctly aligned with the seriousness of the application. For the simple Raspberry Pi projects of hobbyists, school pupils, and college students, where additional expense isn’t justified, there is an understandable tendency to opt for lower-priced SD cards. Though these are fine for getting started with your Pi, you cannot go cheap if the reliability of your end application is business-critical.

Good quality industrial-grade single-level cell (SLC) SD cards are a wise investment, purely because this will give you high-performance and long-term reliability. Because they only write one bit of data per cell, as opposed to multi-level cell (MLC) or triple-level cell (TLC) SD cards, they have an order of magnitude better read/write endurance.

Industrial-grade SD cards can withstand high temperatures and heavy vibrational forces, performing just as well as any other system storage alternatives (where standard SD cards would likely fail). There are still a couple of sticking points that need to be addressed. The first is an unstable power supply, which can lead to file system or data corruption - so steps must be taken to take care of this. Secondly, any storage media is eventually destined to fail.

Addressing Storage Failure Situations

Through the introduction of the industrial-oriented Raspberry Pi Compute Module series, new opportunities have opened for the Raspberry Pi platform. It is now supplied in a form factor that is much easier to embed into industrial applications. The standard version replaces the SD card with an embedded eMMC Flash device, while the ‘Lite’ version doesn’t have an SD card or an eMMC. Instead, it just has the interface lines which basically enable manufacturers to link to their preferred external storage media.

Alongside the primary SD interface (for system boot), the Raspberry Pi Compute Module specifications also incorporate provision for extra data storage. It therefore seems wasteful not to make proper use of this. This is exactly what Sfera Labs has done!

The innovative approach that has been taken here is to connect a high-speed switching matrix to the two 50Hz interface lines so that they can be managed by the on-board microcontroller. This brings intelligence to the memory storage resource, allowing its configuration to be adapted in several valuable ways. Consequently, major operational benefits can be derived - leading to greater system reliability. 

The Benefits of a Dual SD Card Architecture

A dual SD card architecture will enable a separation of the operating system (OS) from the data storage. The primary SD card’s file system can be configured as read-only, or the write operations can be limited to the bare minimum to preserve its integrity - avoiding the prospect of corruption and keeping it away from continuous writing activity that would otherwise shorten its lifespan.

All the heavy write work will then take place on the secondary SD card. If the secondary SD card fails, the system will continue to work and, depending on how it is set up, can trigger an alert for the faulty data storage element to be fixed.

This is very useful, extending the lifespan of the system, but it won’t give you the complete ongoing reliability that many industrial systems really need, since any downtime experienced could have huge implications.

To be assured of this, storage system redundancy is needed. By storing a copy of the full file system on both SD cards, it is possible for the Sfera Labs’ switch matrix to swap from one card over to the other, should the one that is already running start to fail. After being switched over, the failing SD card can be accessed via the secondary bus and an attempt being made to automatically repair it, which will clearly be advantageous when dealing with remotely situated unmanned equipment.

If it can, then it will return to using that SD card again. If it is not possible to save the faulty SD card, then an alert can be sent out that it should be replaced. In the meantime, the other SD card will keep on running the file system and equipment operation will continue.

Figure 1: The dual SD card capabilities that Sfera Labs can enable through its unique switching matrix

Eventually, after many years of continuous uptime, with minor run-time updates and patches, hardware in difficult to reach locations is going to reach a point where it needs a total system upgrade. That, of course, cannot be performed while the system is running. This is where having a dual SD card architecture can, once again, really show its worth.

A full-scale upgrade can be carried out while the system continues to function as usual, it is just a matter of downloading the latest system image and flashing it to the secondary SD card. Once it has loaded, a fast reboot from the newly flashed SD card will quickly get the system back up and running again.

Hardware Featuring a Dual SD Approach

Targeted at use in industrial control infrastructure and industrial servers, the new Strato Pi CM Duo and the Iono Pi Max from Sfera Labs both feature a Raspberry Pi Compute Module. It is important to note that, thanks to the high-speed switching matrix included in each of these, they are the only Raspberry Pi based devices currently on the market with built-in dual SD card capabilities. Via simple commands from the Raspberry Pi, it is possible to switch between the two microSD cards- giving them OS redundancy and scope for run-time updates.

Figure 2: Sfera Labs’ Strato Pi CM Duo and the Iono Pi Max

Both of these devices have an embedded microcontroller that supervises their Raspberry Pi Compute Module’s activity and a watchdog function which monitors one of the GPIOs in order to detect any interruption in operation (acting like a digital heartbeat for the system). If something gets stuck, a forced reset can be performed.

Should the primary SD card fail, the microcontroller will notice and forcefully shut down the Pi, switch to the other SD card, and then reboot. The Raspberry Pi Compute Module can tell the microcontroller from which of the SD cards the system should be booted up on future power ups.

This can all be done programmatically and can be fully configured to fit the needs of the application. For instance, by setting the shutdown and watchdog timings, the number of attempts to boot from one of the SD cards before switching to the other can be set.

In addition to having the functional advantages just explained, the Strato Pi CM Duo and Iono Pi are further differentiated from competing products by other attributes. These include a real time clock (RTC) with replaceable back-up battery, USB ports with individual power control and fault detection, plus a dedicated ATECC608 secure element IC from Microchip. A stabilized/protected power supply stage is also featured for continued power input stability.

For more information about Sfera Labs and its products featuring the Raspberry Pi Compute Module, like the Strato Pi CM Duo or the Iono Pi Max, please visit: https://www.sferalabs.cc/

Giampiero Baggiani is a computer engineer, a maker, and a tech geek. He graduated from the Politecnico di Milano University with a BSc in Computer Engineering. He then moved to Sweden, where he completed his MSc in Secure and Dependable Computer Systems at Chalmers University while participating in a research group for formal methods applied to computer security. After his studies, he worked as a software engineer, focusing on systems integration for home and building automation.

More from Giampiero