Bring your Raspberry Pi to work

Call: +44 (0)23 8098 8890
E-mail:

Posted 18th March 2020, By Simon H

Bring your Raspberry Pi to work

The Raspberry Pi is a single board computer designed for home and educational use. It has approximately the computing power of a low end laptop and typically runs Linux. Unlike a laptop or mini PC it has plenty of microcontroller-style digital I/O, enabling automation and embedded computing applications. This allows the Raspberry Pi to bridge the gap between a desktop computer and a microcontroller, yielding many of the advantages of each.

We recently used the Raspberry Pi as the basis of an Industrial IoT proof of concept. This was a monitoring system feeding data from many and varied sensors to a database server in the cloud. Some of the sensing techniques were experimental and previously untried for this particular use case. The customer needed a proof of concept for demonstration and testing. There was a list of requirements, but these were not detailed, nor prioritised up front. It was vital to produce a working system by the end of a twelve week deadline. At this point the system would be shipped to a pre-arranged field trial which would determine the future of the project.

The system design ultimately envisaged an integrated microcontroller/cellular data module as the CPU but the mainboard PCB could alternatively mount a Raspberry Pi in this role. The overriding objective was to take the fastest and lowest risk route to a functioning proof of concept. With this in mind, we opted to use the Raspberry Pi and were glad that we did. The ability to jump straight into application development was crucial, as was the visibility provided by the Pi’s excellent networking, logging and debugging capabilities.

Batteries Included

Compared to embedded development environments, a Linux system such as Raspberry Pi comes with a wealth of facilities installed or instantly available with just 'apt-get' or 'git clone' command. There is a huge difference in expectations for code reuse between the embedded and non-embedded world. Non-embedded programmers expect to work almost entirely on application-specific code and turn to frameworks, libraries, database engines, middleware, etc. to provide the rest. Embedded programmers often find themselves programming against the “bare metal”, using the hardware reference manual and peripheral datasheets as their guide. Why does this happen? A variety of factors contribute, including; low-specification devices; non-standardised hardware; and a closed engineering culture.

In a general-purpose computer, computing power is valued as the headline specification of the product. Conversely, embedded microcontrollers are seen as a cost to be minimised. This cost minimisation can be rational for mass market devices where the marginal cost of higher-spec components soon adds up to real money; this concern pervades the embedded computing culture. Often high price / low unit count products are designed with irrationally cheap hardware for savings that will not recover the increased development costs. Due to the pervasive sense of computational scarcity, embedded software engineers are wary of the overheads involved in programming against reusable abstractions1.

Relatedly, the lack of hardware standards is a particular problem. General purpose computing exists in a highly standardised hardware environment programming against well-defined Operating System interfaces. Embedded programmers usually work with custom hardware and idiosyncratic microcontrollers. Where libraries exist, they are often too ‘thin’ and wrapper-like to be useful; it is still necessary to know the underlying hardware interface.

The embedded software business is culturally more like that of electronics than application software. Confidentiality, patents and trade secrets are the default. Transparency and open source distribution are less common. Anecdotally, it seems like a disproportionate number of GPL licence violations are in firmware. There are excellent embedded open source projects (such as FreeRTOS) but overall the commons is much smaller.

Hopefully the standard set by other computing fields will encourage the embedded programming world to adopt code reuse practices to a greater degree. There are signs this is already happening with tools such as ST Microcontroller’s STM32Cube code generation framework2.

Another huge advantage of the Raspberry Pi development environment over a bare metal microcontroller is that of visibility, by which we mean the ability to inspect the operation of the system for monitoring, verification and debugging. On a Raspberry Pi there is a full command line terminal accessible over the network (or even a GUI if you want); plenty of RAM and storage for logging; debugging tools; a memory management unit3 etc. In every aspect there are spare resources to assist the programmer.

By comparison, the visibility features of an embedded environment are patchy and irregular. You might have JTAG for debugging. You might have a free I/O channel to create a debug console (that you will likely have to write yourself). You might have a little spare memory to create an event log. You might be able to pass error codes to a host system with better visibility. You might, in the worst case, be able to flash an LED Morse-code style to indicate the cause of a crash. It will not be easy.

For rapid (and thereby cheap) prototyping the Raspberry Pi is a clear winner.

Raspberry Pi in Production?

Could you go a step further and use the Raspberry Pi in a shipping product? While we have not done this, others apparently have. Although publicised examples are rare, we can see evidence of professional use of the Raspberry Pi in the support and hardware available. For commercial or industrial applications there are compatible versions of the Raspberry Pi platform such as the Compute Module and the Hilscher netPI. These substitute the oft criticised micro SD storage with on-board flash, among other improvements. Entirely customised boards are available through an official partner of the Raspberry Pi Foundation. Even the regular consumer boards have obsolescence statements promising availability to a given date.

Obviously, the Raspberry Pi is not for safety-critical applications or those that require especially high reliability. However, in comparison to regular single board computers, there is no reason to suppose that the Raspberry Pi is of lesser quality. Just as the reputation of the Linux operating system has grown from “just a hobby” to a first class option for serious applications, so too can the perception of the Raspberry Pi.

Addendum on the Raspberry Pi 4

The Raspberry Pi 4 has been released with significant improvements to RAM and I/O. Obviously, this increases the space of potential applications. I have used this model as a basic Linux desktop machine and found it quite usable for tasks such as running web and office applications, Linux development and remote desktop access. Two disadvantages of the new design are the lack of an industrial Compute Module version and the increased need for active cooling to enable the full computing power of the device.


Footnotes

1 This is also a reason why embedded programming is still dominated by low overhead languages such as C, C++ and assembler.

2 While STM32Cube is a worthwhile timesaver, the nature of microcontroller programming is still such that the generated output needs manual fix-up. It can suffer from ugly clashes with third-party components, even those distributed through the tool itself.

3 E.g. with a memory management unit, an invalid memory access triggers an immediate segfault instead of mysterious errors later on. Such a bug is much easier to find this way.

Image credit: Raspberry Pi logo


Interested in other ITDev Linux blogs?

Here at ITDev, we often work on client projects that use the Linux operating system, see this search index to other Linux related blogs.

Embedded Linux Interest Group

ITDev runs an Embedded Linux Interest Group to inform and support industry. If you are interested in learning more about Linux as well as attending events and workshops, sign up to our Interest Group here:

How ITDev Can Help

As a provider of software and electronics design services, we have extensive experience in building, modifying and debugging embedded software. This includes developing applications as well as writing device drivers and bringing up operating systems on custom hardware. We are flexible and can work according to the priorities of your project, be that rapid prototyping or production stability.

We offer advice and assistance to companies considering to use or already using Linux or Android on their embedded system. If you have any questions or would like to find out more, we would be delighted to speak to you. Email us or call us on +44 (0)23 8098 8890.



Simon

Senior Software Engineer

MSci - Physics, Imperial College London

I joined ITDev at the start of 2019. Previously I worked on banknote detection systems and automotive engineering research.

My engineering specialities are embedded software, instrumentation and control systems.

Outside work, I run a book group, practice yoga and go on adventures with my family.

 

View all posts by Simon    |    View all ITDev team members

IET Enterprise Partners logo

Latest Blog Posts

Ladybug in sight
Posted 3rd August 2020, By James H
If debugging a Linux driver is bugging you, this 'how to' guide explains how to approach this using the function tracer within ftrace to find out what’s going ...more
Linux penguin sending an email
Posted 19th June 2020, By Quentin D
In this final part of his blog, Quentin explains the final part of the process: submitting your changes to the Linux Maintainers.
Linux penguin
Posted 5th June 2020, By Quentin D
In his second 'Contributing to the Linux kernel' blog, Quentin looks at finding something to fix, coding and committing changes.
Jenkins for FPGA
Posted 29th May 2020, By Hugh J
FPGA development should be enjoyable but when bugs slip through the net, it can be a headache to find them later on. Hugh looks at a few of the plugins ...more

Latest News

Autumn
Posted 11th September 2020
From adapting to our new working situation to recruiting new staff members and engaging new clients, it’s been a busy summer. Find out more in our latest ...more
Spring 2020
Posted 17th April 2020
Following the beautiful weather over the Easter weekend, we are proud to be able to provide an update on our current activities, showing business is continuing ...more
Business as usual
Posted 20th March 2020
With a strong commitment to keeping our staff and clients safe during this period, we would like to reassure all our business contacts that we remain fully ...more
South Coast Tech Awards Trophy
Posted 6th December 2019
ITDev was excited to attend the first South Coast Technology Awards on Thursday 5th December at the Ageas Bowl. A much needed celebratory awards for a sector ...more