How to simulate IoT Gateway using VMware Workstation

The IoT systems are one of the most interesting software solutions during the last last few years.  These systems collects information from different sensors and send this information to the back-end. Data is being processed ( aggregations, different kind of analysis ). Usually these solutions has separate storages for:

  • raw data
  • processed data
  • configuration data

The application created for this article series is a simple IoT solution implemented with C# and contains the following parts (see the picture below):

  • Managed objects (sensors), that measure specific values like temperature, speed, displacements, etc.
  • Gateways: devices that collects information from sensors and communicates via
  • Back office – set of services and applications that are used to ingress, process and store data, manage and monitor the whole solution.

The simple prototype used for this article includes:

  • Gateway (.NET application)
  • Gateway service: a web service, implemented on .NET and hosted in Microsoft Azure, that communicates with the gateway and stores data to a cloud storage ( Azure SQL Database ) 
  • Gateway service: IoT Hub – this is the recommended messaging service for IoT solutions in Azure
  • Azure Stream Analytics
  • Azure SQL Database 
  • PowerBI Reports, that represent some statistic, based on the generated messages

Cloudant-tut1-pic13[1]

Quite often during the development process usage of real gateway ( embedded devices like Raspberry Pi 2 and 3, MinnowBoard Max, DragonBoard 410c ) leads to more complexity and technical challenges. That is the reason to consider usage of “Simulated gateway”.

Simulated gateways could be just a client application, adapted to work on the development machine or virtualized client device.

The first approach can lead to some differences between development environment and the real production environment: development machines are usually much more powerful and often it is not possible to have the 100% identical codebase as this one on the embedded devices because of some differences in the SDKs.

Virtualization of the embedded devices gives from one side possibility to run the same code, that developers will use in the real devices, but from another hand gives a flexibility, because software engineers are less dependent on additional hardware during the development phase.

There are different virtualization platforms: Hyper-V, VMware, Virtual Box etc. Which one is better to choose ?
Embedded devices have some specific features, so probably it is better to consider on which platform can virtualize these devices relative easy and have quite good performance.

If you need different VMs on your workstation it is not possible to use Hyper V at the same time when you use other virtualization platforms. When you enable Hyper-V it changes the way windows on the host loads, it loads the hyper-v hypervisor and your host OS is actually running on top of that hypervisor

This is because the Hyper-V role is installed and this conflicts with VMware Workstation. To disable Hyper-V from starting the following command can be used:

  • bcdedit /set hypervisorlaunchtype off
  • A reboot of of the Windows OS is necessary.
  • To enable the Hyper-V role again use the following command:
  • bcdedit /set hypervisorlaunchtype auto
  • A reboot of of the Windows OS is necessary.

If you don’t want to change the settings any time you can create a multi-bootable configuration:

You could make a new boot entry. You can then choose on reboot whether to boot with Hyper V turned on or not.
This is useful as if Hyper V is installed then Virtual Box or VMware will not work. You get a message VT-x is not available (as Hyper-V is using it).
1. Install Hyper V
2. bcdedit /copy “{current}” /d “Hyper-V”
3. bcdedit /set “{current}” hypervisorlaunchtype off

More details you can find in this blog post:
Creating a “no hypervisor” boot entry – Ben Armstrong – Site Home – MSDN Blogs

How to setup Windows 10 IoT Core virtualized environment.

  • Downloads

You will also need a Windows 10 Core image. You can get one from Microsoft here. Choose Download Windows 10 IoT Core for MinnowBoard Max. This is important, because its easier to virtualize the x86 build. We now have to install it. Microsoft has bundled Windows 10 Core in an installer together with some tools for helping you provision it on a sd card and controlling it. So go ahead and run the downloaded installer. After the installation is complete you can find the image in C:\Program Files (x86)\Microsoft IoT\FFU\MinnowBoardMax

IoT-Gateway-VMWare-pic014[1]

  • Setting the virtual hard drive

You need to expand the ffu and create a virtual hard drive that VirtualBox can use. To do that we are going to use a 3rd party tool called ImgMount. it’s a community tool that can be found on xda developers here. What it does is it reads the ffu, converts it to a vhd virtual hard drive and mounts it. Download it and place it some place easy to call from the console. Now follow these steps:

  • Open a privileged powershell. Right click on powershell icon and click Run as administrator.
  • “cd” into the Windows 10 core image
  • Run the ImgMount tool providing the flash.ffu as an argument. You should see output similar to this:

IoT-Gateway-VMWare-pic015[1]

  • you have to unmount the image. Open Disk Management inside of Computer management. You will see a new disk that shows below your hard disks. To unmount it right click around the disk name and in the menu that opens select Detach VHD. A new dialog will open that will give you the location of the virtual hard disk that ImgMount has created. Now press OK in the dialog to unmount the virtual hard disk.
  • Navigate to the location of the virtual disk that we saved in notepad. After being unmounted it can be safely moved. Move it to the place you will going to store the virtual machine.

Using this approach it is possible to have a virtual disk in VHD format. There is additional work to run this VHD on Hyper-V. Hyper-V virtualization of Windows 10 Core devices is not a subject of this article.

  • Running Windows 10 IoT Core on VMware

Both VHD and VMDK contains hard disk image which used by virtual machines. Actually a VHD can be converted to VMDK format and used as the hard disk image for VMWare virtual machine. The virtual machines created in Microsoft virtualization products can be easily converted VMWare virtual machines with several pro0ducts like  VMware vCenter Converter and some free tools like StarWind V2V Converter .

StarWind V2V Converter is used in this example to convert the VHD file to VMware VMDK virtual disk.

  • In VMware Workstation you need need to create a new machine using a custom configuration.
  • The OS should be set to be installed later
  • The type of the OS is Windows 10
  • The firmware type should be EFI
  • The disk controller should be SATA
  • You need to use an existing disk adding the converted VMDX file.

That is all: you can run your device:

IoT-Gateway-VMWare-pic010[1]

New updates can be installed on the existing VM

IoT-Gateway-VMWare-pic011[1]

The graphical UI and command console are available in the same way like you connect an external monitor to the embedded device.

IoT-Gateway-VMWare-pic010a[1]

 IoT-Gateway-VMWare-pic011a[1]

All running devices are available in the IoT Dashboard.

IoT-Gateway-VMWare-pic012[1]

Next blogs on Windows IoT Core will demonstrate how you can develop and deploy a simple IoT solutions in Azure with much more details

If you want more information feel free to contact me at michael@mateev.net Follow my blog : https://mmateev.wordpress.com/  .

You can learn more also if you follow me on Twitter @mihailmateev  , and stay in touch on Facebook, Google+, LinkedIn and Bulgarian BI and .Net User Group !

Advertisements

About Mihail Mateev

am a Microsoft Regional Director currently living in Sofia, Bulgaria. My interests range from technology to entrepreneurship. I am also interested in programming, web development, and education. Technical Consultant, Community enthusiast, PASS Regional Mentor for Central Eastern Europe, chapter lead, Microsoft MVP – Microsoft Azure. Organizer of SQLSaturday, Azure Bootcamp, IoT and JavaScript conferences. My experience is in various areas related to Microsoft technologies, including Windows Platform, ASP.Net MVC, MS SQL Server and Microsoft Azure. I have a PhD in cloud computing and am a university lecturer on Smart Homes and Smart Energy IoT Solutions
This entry was posted in .Net, Azure, BI, BI & .Net Geeks, BI & .Net UG, BI & .NET User Group, C#, IoT, IoT Suite, Microsoft, Microsoft Azure, Uncategorized, Windows 10, Windows 10 IoT Core and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s