Take advantage of APIs to take a typical USB stick to the next level
June 27, 2018
Blog
A smart controller can unlock the potential of the market-leading removable-storage standard in embedded applications.
From the outside, few things could be simpler than a USB stick or thumb drive, or an SD-format storage card. Each one contains a Flash memory array, a USB interface, and a storage controller that provides generic support for file-based non-volatile storage. But most generic devices don’t offer features to readily support the many use-cases made possible by this physically compact form factor with such a broad reach: a huge variety of systems now include USB or SD peripheral support as standard, which can be exploited for more than just data storage.
These factors make the USB or SD-format storage device an excellent platform on which to build added-value applications, such as enhanced functionality, reliability, and security. To ensure high uptime and safe operation, reliability in storage is vital. Conventional USB and SD controllers perform operations such as wear leveling to preserve the lifetime and limited write endurance of the Flash memory. However, these devices are designed for mass-market applications that have different requirements to embedded applications. They’re generally optimized for the storage of bulk data, such as multimedia files and documents, while embedded systems have drastically diverse functionality with different requirements from permanent storage.
Embedded systems need a reliable non-volatile storage solution that’s optimized for smaller transactions, such as sensor updates and data from other real-time monitors. The profile of writes to the filesystem can be very different to those used for large file updates. A single variable that represents sensor status could be rewritten millions of times during normal operation. Often, the storage locations will be quite fragmented, leading to highly unbalanced accesses. This will challenge the reliability of any Flash-storage cell and lead to failures if not managed, despite much of the rest of the array being comparatively lightly used.
Designers of embedded systems also must be sure that updates are completed properly and that the contents of non-volatile memory aren’t stale because a write was unsuccessful due to a power outage or a task crashing before completing its work. This is where a storage controller optimized for embedded environments is key. It includes the functions needed to deliver reliable non-volatile storage to a wide variety of embedded applications.
Further, by incorporating the ability to support custom algorithms, it’s possible to maximize the utility of the storage device. With an intelligent controller coupled with a rich set of functions accessed through an application programming interface (API), the storage controller can become the key component of the embedded system or act as a smart coprocessor that fully leverages removable Flash storage (see Figure 1).
The ability to embed encryption and other secure technologies into a memory device independent of the host CPU can greatly improve a system’s resistance to tampering and opens up new markets for smarter removable storage. With security functions built into an approved USB stick or SD card, the system manager can ensure that unprotected peripherals are rejected. An off-the-shelf solution based on mass-market USB storage controllers can’t provide the same level of functionality, reliability, and security.
Using custom functions, the system developer can implement a variety of value-added functions. For example, they can ensure that the system can only read or write information to a device if it provides a valid security certificate. This can be used to prevent the theft of IP or the introduction of malware through interfaces that are otherwise difficult to secure, but still support removable storage in the end equipment. In this way, for example, a manufacturer can preserve the ability for maintenance engineers to install software updates or access runtime data, but with the added benefit of authentication.
For secure access to the Flash-memory array, the storage controller needs to support effective encryption primitives that can be assembled by a user application into a solution. Access to custom hardware is a further requirement.
For added protection, the device itself may include biometrics, or sensors to ensure that can only be used in a particular location. A GPS-based sensor on the USB or SD card itself, for example, can check whether it’s being used in an approved location, and trigger an alert if it’s used outside that area. Such additional sensors and functions can provide manufacturers with the ability to provide time-limited and location-locked keys that only function if the storage element is present. This supports a wide variety of service-oriented business models and is functionality that is not available in desktop-oriented Flash-storage controllers.
For the design of its smart Flash-storage controllers, Hyperstone has taken these requirements into account. The controller itself performs a number of functions that are important to embedded systems as standard. For example, the wear-leveling algorithms consider small write and fragmented data, automatically consolidating these elements to ensure more efficient and reliable operation. By incorporating an API, it’s also possible to extend the full capability of the smart storage controller, with user-defined functions.
The API provides the many services needed to support value-added USB and SD storage applications. Developers can build more extensive applications on top of the core services that are able to access custom hardware on the USB drive or SD module (see Figure 2). To support this, the controller offers 16 general-purpose I/O lines that can be configured for use as SDIO, SPI. or I2C interfaces. Through these interfaces, it’s possible to attach a digital sensor, RF transceivers, and additional elements. For example, users can configure the I/O lines to support the ISO7816 protocol, which enables the integration of specialized peripherals. This includes a SIM card to perform authentication on behalf of the storage controller. Every read or write can be checked for its security status and the data encrypted and decrypted on the fly as it passes to and from the card’s Flash-memory array. This ensures that data is not at risk if the removable storage is lost or stolen.
The USB module can act as a secure connector that allows debug and test access to the system only when an authenticated module is plugged into the I/O ports. An external connector on the module’s outer surface provides the necessary ports. Some applications, however, won’t need such a high level of security. A vendor may choose to employ the USB port as a way of providing upgrade and enhancement offerings. For example, a MEMS microphone built into the module and managed by the storage controller makes it possible to add audio-recording capabilities.
In the Hyperstone architecture, the customer’s own firmware extension doesn’t depend on the underlying Flash technology. The differences between different forms of Flash memory are handled by the built-in functions of the controller itself. The user binary can be updated using conventional writes, and locks on the address ranges used for storage-controller firmware can prevent inadvertent or malicious writes. Once firmware has been loaded onto the device, the ability to update it can be removed. Support for redundant firmware as well as error-detection and correction ensures that corruption or failed updates to one copy of the firmware doesn’t compromise the device.
Development for the Hyperstone storage controller uses standard software tools that will be familiar to many engineers. The support includes a GNU-based compiler toolchain. For debugging, the Eclipse IDE and GNU debugger are used.
By implementing both hardware and software hooks for value-added applications, Hyperstone’s Flash-memory controllers enable new classes of storage devices that not only improve reliability and security for the storage elements themselves, they can also act as the resilient backbone against attacks on IoT and IIoT systems. With access to hardware peripherals through programmable I/O, the storage modules can become smart devices, using GPS receivers, encoders, and MEMS sensors to go far beyond being simple data repositories. The result is a technology that opens the door to new classes of removable-storage device.