Leveraging the (free) power of Windows 10 for the IoT on the Raspberry Pi 2 and other development kit platforms

September 08, 2015

Leveraging the (free) power of Windows 10 for the IoT on the Raspberry Pi 2 and other development kit platforms

Inexpensive development kits and free/open source software and tools are making project development cheaper and easier than ever. The low-cost dev kit...

Inexpensive development kits and free/open source software and tools are making project development cheaper and easier than ever. The low-cost dev kits and open source tools have been around for a while now, but one thing I never expected to hear this year is that the new version of Windows would be free! Microsoft seems to be getting into the maker community spirit (and embedded IoT development space) by releasing its Windows 10 IoT Core operating system (OS) for maker platforms – free.

The IoT Core is an edition of the Windows 10 OS for low-cost, small-footprint embedded devices and is compatible with the Raspberry Pi 2, Minnowboard Max, and Galileo boards. This seems like a good fit as a lot of maker/dev kit projects are IoT applications at least in part, and Microsoft’s established suite of development tools can be a real help to developers.

In particular with the Raspberry Pi 2, this is the first time Windows will be available to use with the platform, and it took a bit of work to get there. Windows hasn’t historically been compatible with Raspberry Pi’s Broadcom chip and Synopsys’s DesignWare USB IP block – and let’s face it, USB is essential for connectivity and it’d be hard to get very far without USB functionality.

Terry Moore, CEO of MCCI (www.mcci.com), shed some light on developing the USB stack to allow Windows 10 to work with the Raspberry Pi 2 hardware in a recent conversation.

“Synopsys’s DesignWare USB 2.0 IP core is great for embedded systems, but it’s not software-compatible with any of the USB controllers that are used on desktop and notebook PCs.”

PCs traditionally use EHCI and XHCI register models for USB host functions. MCCI has worked with both EHCI and XHCI and the Synopsys core before, and combined its knowledge of the two to create a TrueTask USB stack to work with Windows 10 IoT Core OS and the Broadcom chip on the Pi 2 (Figure 1).

 

Figure 1: The MCCI TrueTask USB stack and device block diagram.
(Click graphic to zoom)


21

 

 

“We could just swap out the XHCI code that was already running on Windows and plug in the code for the Synopsys core, and we were 90 percent of the way there,” Moore says.

Even so, there were still some development challenges to get a traditionally desktop-focused operating system to work with a more embedded-focused core on the Raspberry Pi 2.

Windows class drivers assume Intel x86 cache coherence semantics, where cache coherency is managed by the hardware, and software doesn’t play a big role. However, with ARM, cache coherency is managed by software. See a problem with that?

“We found some issues with class drivers that were perfectly correct from an x86 point of view, and perfectly correct if you just looked at their code, but not correct when you combine that with the actual way that the cache happens to work on this system,” Moore says.

MCCI developers also had to work with modes of the Synopsys core they haven’t used before in order to meet requirements, which impacted performance.

“Scatter gather can’t be used, and in a virtual memory system scatter gather is pretty important,” Moore says. “The Synopsys core is really intended for a situation where you have a dedicated processor, so you can make real firm statements about what the response time on interrupts is going to be. Although the Windows kernel is really pretty good, because of the architecture of the Broadcom device we’re sharing our interrupt with a couple of other drivers. It turns out that the interrupt responsive time is not ideal.”

This problem can be demonstrated in the case of running a USB webcam, and how what Windows expects and what you get with the Raspberry Pi 2′s core don’t quite match up.

“With this hardware running a webcam, we have to take an interrupt every 125 microseconds; we have a hard real-time deadline to do our work and get out – if we slip up, we lose,” Moore says. “The drivers above us are the standard Microsoft drivers designed for a desktop environment where things are, relatively speaking, infinitely fast. The application using the webcam might need only 9 Mbps because they’re going to run in low res, but the class driver programs the webcam to give us those 9 Mb in 24 MBps bursts. During the 24 MBps bursts, we have a fair amount of work to do on every interrupt in order to keep up. This resulted in us having to do some reorganization of the code in order to make sure it would go that fast without having to give up portability.”

Developers have been working out the bugs of the Windows 10 IoT Core operating system as a whole through the Windows IoT Core Insider Preview, and as it’s being developed Microsoft has posted a lot of projects to show what these dev kits are capable of when paired with Windows 10.

One project uses speech recognition for a home automation proof of concept. A USB feature supported by Windows 10 IoT Core for the Raspberry Pi 2 was USB audio support, which allows for speech recognition so the user can turn different devices attached to the Pi 2 on and off. Other projects help with getting basics set up with the Pi 2 and Windows 10 IoT Core like adding buttons, LEDs, basic speech recognition and synthesis, displays, and more to get developers familiar with using Windows 10 on their dev kits.

It’ll be interesting to see how much Windows as a maker platform takes off as well as how popular it’ll become for IoT applications as it gets more established. If you’ve worked with Windows IoT Core we’d love to hear about your experience and your projects!

For makers and professional developers looking to use Windows 10 IoT Core for their projects, visit WindowsOnDevices.com for setup instructions, projects, downloads, and more.

Monique DeVoe, Managing Editor