<<

Faculty of Health, Science and Technology Department of Mathematics and Computer Science

Kristoffer Haglund Jia Qiu

Documentation and implementation of interfaces for an embedded platform

Degree Project of 15 credit points Computer Science

Date/Term: 130605 Supervisor: Martin Blom Examiner: Donald F. Ross Serial Number: C2013:13

Karlstads universitet 651 88 Karlstad Tfn 054-700 10 00 Fax 054-700 14 60 [email protected] www.kau.se

Documentation and implementation of interfaces for an embedded platform

Kristoffer Haglund, Jia Qiu

c 2013 Kristoffer Haglund, Jia Qiu and Karlstad University

This thesis is submitted in partial fulfillment of the requirements for the Bachelor’s degree in Computer Science. All material in this thesis which is not my own work has been identified and no material is included for which a degree has previously been conferred.

Kristoffer Haglund, Jia Qiu

Approved, 130605

Opponents: Ida Lundin, Jenny Agren˚

Advisor: Martin Blom

Examiner: Donald F. Ross

iii

Abstract

Using a new platform[54] can be challenging, especially with relatively newly released plat- form and developer equipment. Difficulties and problems can arise during development from both hardware and software, some problems can be solved but sometimes help must be requested from the developers of the products. The consulting firm Altran in Karlstad has been dealing with this and has developed em- bedded software used in industrial welders for cars. There have been some uncertainty during their work, which has given birth to this project. The purpose of this project was to reconstruct and document Altran’s initial development process, to make the process faster and easier for new developers. Besides the reconstruction, a discovery of unused features and components also became an important part of this project. The project has resulted in a documentation of various interfaces, an clock in system appli- cation called ”Personnel Interactive Display and Educator”, and a safe update application for the system.

v

Kristoffer and Jia would like to thank everyone involved in this project. Specially Martin Blom (advisor) and Donald F. Ross (examiner) at Karlstad University, Johan Lundin, Mattias Lindahl, Frank Grundin and all the employees at Altran Karlstad for your support.

vii

Contents

1 Introduction 1

2 Background 3 2.1 Author background ...... 3 2.2 Company background ...... 4 2.3 The existing system ...... 5 2.4 Requirements ...... 6

3 Tools 7 3.1 Hardware ...... 7 3.1.1 Motherboard and processor ...... 7 3.1.2 Carrier board ...... 8 3.1.3 Touchscreen ...... 10 3.1.4 RFID Reader ...... 12 3.2 Software ...... 13 3.2.1 Visual Studio 2008 ...... 13 3.2.2 Windows Embedded Compact 7 ...... 14 3.2.3 Expression Blend 3 ...... 14 3.2.4 Windows Embedded Silverlight Tools ...... 15 3.2.5 Virtual PC ...... 15

ix 3.2.6 Freescale CFImager (partitioning software) ...... 15 3.2.7 Server ...... 16 3.3 Summary ...... 18

4 Documentation of interfaces 19 4.1 Approach techniques to test interfaces ...... 20 4.2 Interfaces ...... 21 4.2.1 USB ...... 21 4.2.2 Audio ...... 23 4.2.3 Bluetooth ...... 24 4.2.4 GPIO ...... 24 4.3 The ...... 24 4.4 Summary ...... 25

5 Clock in system 27 5.1 Design ...... 27 5.1.1 ...... 27 5.1.2 Introducing the clock in system PIDE ...... 28 5.1.3 Fusion of programming languages (Native / Managed) ...... 30 5.2 Implementation of clock in system ...... 33 5.2.1 Model ...... 33 5.2.2 GUI ...... 36 5.2.3 RFID ...... 37 5.2.4 Temperature and stock exchange ...... 38 5.3 Problems ...... 39 5.3.1 OS - Installation ...... 39 5.3.2 OS - Update and installation service ...... 39 5.3.3 OS - Graphic acceleration ...... 40

x 5.3.4 OS - Changing platform for existing project ...... 40 5.3.5 OS - RFID ...... 41 5.4 Results ...... 41 5.4.1 The generic OS design ...... 42 5.4.2 Clock in system ...... 42 5.5 Summary ...... 46

6 Safe update 49 6.1 Design ...... 49 6.2 Implementation ...... 51 6.2.1 Partition modification ...... 51 6.2.2 Boot loader modification ...... 53 6.2.3 Automation ...... 54 6.3 Problems ...... 55 6.3.1 Sectors and offsets ...... 55 6.4 Results ...... 55 6.5 Summary ...... 56

7 Evaluation and conclusions 57 7.1 Reflections on requirements ...... 57 7.2 Alternative solutions ...... 58 7.3 Future of the platform ...... 58 7.4 Lessons learned ...... 59 7.5 Authors opinion ...... 59

References 61

Appendices 67

xi A Definitions, acronyms and abbreviations 69

xii List of Figures

3.1 A picture of the Quadmo747-X/i.MX51 ...... 8

3.2 Carrier board...... 9

3.3 Carrier board and its connectors...... 10

3.4 Datavision display...... 11

3.5 Datavision display connectors...... 11

3.6 Phidgets RFID circuit board...... 12

3.7 Illustration of how the partition structure of the SD after adding nk and eboot with CFImager...... 16

4.1 A list of USB driver showed in Catalog Items View ...... 22

4.2 USB ports on the carrier board ...... 23

5.1 Illustration of the first prototype of PIDE (Personnel Interactive Display and Educator) ...... 28

5.2 Illustration of how the C++ source code compiles straight to native machine code for a specific architecture...... 31

5.3 Illustration of how the managed C# and C++ source code compiles to native machine code on top of the .NET framework...... 32

xiii 5.4 Illustration of how the managed code compiles to native machine code on top of the .NET framework. Native code is accessible from the DLL, this link is illustrated with an arrow between the machine codes. The Marshalling[62] step between the managed code and native code is needed to transform and exchange data objects from one side to another...... 33 5.5 Class diagram of the logic part of PIDE...... 35 5.6 Model of steps from Blend GUI to Native DLL...... 36 5.7 Model of native and managed applications ...... 36 5.8 Stripped UML diagram...... 37 5.9 Profile image scroller in PIDE with arrows to navigate between profiles. . . 43 5.10 Navigate to profile with profile scroller, the profile contains information relevant to the specific user such as meetings ...... 44 5.11 Navigate to profile with RFID tag, the profile contains options to update the checked in profile’s information ...... 45 5.12 Time, temperature and stock exchange GUI objects updated with informa- tion from the Internet...... 46

6.1 Partition allocation with the new OS added after the old OS...... 50 6.2 Illustration of the design for safe updating...... 50 6.3 Highlighting of the first 5 unique bytes of the operating system file of 96 MB. 52 6.4 After opening the SD-card in the hex editor in raw-format, it was possible to search for the unique bytes and locate the first OS at sector 1280 (0x500) and offset 655360 (0xA0000). This was the default position in the CFImager. 52 6.5 Another search lead to the position of the second OS at sector 197886 (0x304FE) and offset 101317632 (0x609FC00) which was the position spec- ified in the modified version of CFImager...... 53 6.6 The constants for the boot loader...... 54 6.7 Constants’ values after calculation...... 54

xiv Chapter 1

Introduction

Forbes[48] released an analysis in 2012 about the ”10 Critical Tech Trends For The Next Five Years”, two of these trends involved embedded systems. Forbes described embedded systems as a concept of intelligent, cheap, small, always powered on, network connected devices with location awareness. In addition to personal computer (PC) hardware, input from sensors, image recognition, augmented reality and near field communication added new potentials and benefits.

Embedded systems were the target market when Microsoft in March 2011 released the new platform Windows Embedded Compact 7 (WEC7)[69] with support for the [70] and ARM[2] architectures.

Altran was asked by a customer to adapt this new platform and to create a Graphical (GUI) software for an industrial welder. The project was successful but with the drawback that the project took more time than expected and lacked certain func- tionality.

1 2 CHAPTER 1. INTRODUCTION

In order to make the process easier and to decrease the development time for similar projects, this thesis project was conceived with the purpose of describing the interfaces with guides and code samples. For this purpose a demonstration application of an clock in system was created called ”Personnel Interactive Display and Educator” (PIDE), to discover and use multiple interfaces for the documentation. An additional application for safe update was also designed and implemented in the system.

Please note that all acronyms can be found in section Definitions, acronyms and abbrevi- ations in the Appendix. Chapter 2

Background

This chapter presents the background to the project. The first part of this chapter briefly describes information about the authors. Then a short summary of the company that assigned the project follows. After that, some information are provided about the existing system made by Altran. The last part explains the requirements of the project and the division.

The level of technical detail in this chapter will be kept low, to keep focus in this chapter on what the project is about, leaving details for later chapters. Some terms will be used though and the readers are advised to look up terms they are not familiar with in section Definitions, acronyms and abbreviations.

2.1 Author background

This thesis is written as a third year bachelor’s degree project in Computer science at Karlstad University by Kristoffer Haglund and Jia Qiu.

The subject chosen for this project was one of the suggestions Altran had to offer. Since

3 4 CHAPTER 2. BACKGROUND both authors had previously done projects involving embedded systems, they thought that it would be both a challenge and fun to explore a new platform. Especially a platform published by Microsoft while the previous projects have been involving platforms published by The Raspberry Pi Foundation[14], Netduino[21] and Atmel[4]. Kristoffer and Jia came in contact with Altran in a mentoring program in 2012 arranged by Karlstad University. This mentoring program was meant to pair IT-professionals with students to prepare the students for the IT-business. Johan Lundin and Mattias Lindahl from Altran were the mentors paired with Kristoffer and Jia. The mentors had a background in programming embedded systems and influenced the adepts, which later led to the decision to work with it as the bachelor’s examination project.

2.2 Company background

Altran is a global IT-consultant company that was started in 1982 in France, they have over 17 000 employees globally (2010) and approximately four hundred of them located in Sweden.[56] The office in Karlstad opened in 2011 and currently has (130517) ten employ- ees. One of Altran’s specialized fields is embedded and critical systems with approximately 3 000 experts located in 20 different countries around the world. Recently, this division changed their name in 2013 to ”Intelligent Systems”. Altran describes the name change as reflecting ”next generation of embedded and real-time systems that are capable of op- erating complex applications thanks to their high degree of connectivity and tremendous processing power.”[10] 2.3. THE EXISTING SYSTEM 5

2.3 The existing system

The Karlstad office has previous created a GUI to an industry welder for cars. This was made in the programming language C++ (Native) with support from Blend 3 to create an appropriate look-and-feel on a touchscreen. The project went really well and they have high hopes to get new orders for similar products. The whole process behind this project was new to Altran since they used a new operating system (OS), Embedded Compact 7. When using a new system you lack the support from the public bulletin board systems available on the Internet, like you would get with a product with more users and has been released a longer time. The knowledge gained from developing the new system is something Altran wishes to continue to use in its existing products and use for implementing new products for other industrial machines, not just welders.

To ease further development with the WEC7 operating system, Altran needed to re- duce their learning curve and be able to program with both native code[63] and managed code[41]. Native program code compiles to machine code for a specific platform. This is great for speed and stability but makes it a bit more complicated and takes more time to develop. Another problem is the lack of garbage collectors and automated tests to assure the program is running smoothly. In managed code you increase the level of abstraction which will hopefully lead to faster development with less effort.[71]

When the initial discussion about the degree project took place, several options were received from Altran. One of them was to build a personnel information display and an- other one was to make a reusable application solution for the WEC7 platform. The project became a combination of both and it resulted in a personnel display with documentation on how all the technical problems were solved so the next person doing a project in a WEC 7 can use this project as help for getting started quickly. 6 CHAPTER 2. BACKGROUND

2.4 Requirements

The requirements from Altran on this project were to try out as many useful and widely used interfaces as possible (such interfaces are USB, Ethernet and SD card reader) to learn how the interfaces worked and document the process. This to provide the employees with documentation and working code examples to use. Some examples of solutions were:

• An updated guide on how to install WEC7 and all prerequisite applications. The last guide suggested a full install which required over 50 gigabytes of hard drive space and took a few hours to complete.

• A guide on how to make a stripped down operating system design and what compo- nents are needed and why. The actual size of the built binary image file can vary but when used on the prototype board it needs to be exactly 96 megabytes.[47, p. 375].

• Update firmware data over a Bluetooth connection.

• A safety mechanism during the upgrading procedure of the operating system. At- tempt to make it impossible to corrupt the operating system in case of power failures, communication errors or corrupted update files.

To cover all the requirements from Altran this project was divided into three parts:

• A documentation of interfaces (see chapter Documentation of interfaces)

• A demonstration application using the interfaces (see chapter Clock in system)

• A safe update function for the system (see chapter Safe update) Chapter 3

Tools

This chapter will describe all the hardware and software used in the project.

3.1 Hardware

This section will describe the hardware that was used in the project and inherited from a previous project at Altran with the addition of the RFID reader[8] used in the prototype described in chapter Clock in system.

3.1.1 Motherboard and processor

Seco Quadmo747-X[49] is a motherboard for embedded devices following the form factor standard Qseven v1.2[9]. It differentiates itself from PC motherboards because it lacks controllers and connectors for interfaces for input and output, and therefore requires a carrier board.

The Qseven standard v1.2 came out in 2010 and currently supports x86[70] and ARM[2] architectures, the size of the board is specified to be 70x70mm and has a power consump- tion not exceeding 12 watt. The connection between the Qseven board and the carrier

7 8 CHAPTER 3. TOOLS board is through a 230 pin Mobile Express PCI Module (MXM) connector[64].

The processor on the Quadmo747-X[49] is a Freescale i.MX515 System-on-Chip (SoC)[67]. It is based on an ARM Cortex A8[3] core running at 800MHz and contains DDR2[19] mem- ory of 256/512MB and integrated accelerators for OpenGL ES 2.0[1] 3D- and OpenVG 1.1[11] 2D graphics.

Figure 3.1: A picture of the Quadmo747-X/i.MX51

3.1.2 Carrier board

A carrier board is a circuit board on which you attach the motherboard[49]. It contains controllers, interfaces and connectors and is fully customizable from manufacturer to only 3.1. HARDWARE 9 contain the necessarily parts for a given project. A previous project used a carrier board with the name Seco Q7XDK-BAA[50] which came with all available controllers and inter- faces. In this project, it served as a prototype board for software production. When the product is finished this board will be replaced with a new custom made carrier board to decrease the size and cost.

Figure 3.2: Carrier board. 10 CHAPTER 3. TOOLS

Figure 3.3: Carrier board and its connectors.

3.1.3 Touchscreen

Datavision dtfs070d0shlx-l00[12] is a 7” Light-Emitting Diode (LED) backlit Liquid Crystal Display (LCD) width 165 mm, height 106,4 mm, depth 9,5 mm and max resolution of 800x480 pixels, a brightness of 320 nit and 400:1 contrast ratio. 3.1. HARDWARE 11

Figure 3.4: Datavision display.

Figure 3.5: Datavision display connectors. 12 CHAPTER 3. TOOLS

3.1.4 RFID Reader

RFID[65] which stands for Radio Frequency Identification is a technology widely used to- day. The technology can be used in many different fields, for example bus cards to pay for the transportation fare, door lock to collective rooms with access control and computer login where a user with a RFID chip can use it as identification. It was not until a few years ago the RFID technology became popular on the consumer level though the ancestor of this technology has been known and patented since 1973[7]. Today, you can easily find different types of RFID tags priced from 5 SEK depending on the specification of data speed, protocol, band and physical appearance (cards, key tags, discs).

The RFID reader in PIDE is manufactured by Phidgets[45]. The reason why PIDE was equipped and developed with the Phidgets unit which is more expensive (currently priced at 525 SEK from an official Swedish supplier[8]) than other competing solutions(currently priced at 59 SEK[13]) can be answered by the support available online. The reader had a big community supporting development of the device and the company had source code available on their which encouraged developers to buy their product. Another reason was that the book[6] for the WEC7 platform encourages and demonstrates this particular RFID reader.

Figure 3.6: Phidgets RFID circuit board. 3.2. SOFTWARE 13

3.2 Software

The software used in the project came bundled with the hardware and have in some cases become obsolete or are close to the end of their life cycles. One piece of software is also no longer supported for use, but since there were no replacements it is still used in production. The specific software have been marked with the general support and extended support end dates.

3.2.1 Visual Studio 2008

Microsoft Visual Studio 2008[38] is a popular development environment containing a com- plete set of tools for building web applications, web services, desktop applications and mobile applications. When creating applications for WEC7 it is created with the following three languages:

• Visual C#

• Visual C++

The three programming languages use the same Integrated Development Environment (IDE) which makes it possible to easily create -language solutions under the .NET Framework 3.5.

List of the latest versions of Visual Studio and their support for WEC7:

• Visual Studio 2008[38] is currently (130517) the only development environment sup- porting the Platform Builder which is a requirement by WEC7.[31]

• Visual Studio 2010[39] has no support.[31] 14 CHAPTER 3. TOOLS

• Visual Studio 2012[40] is planned to be supporting the next version of Windows Embedded Compact[6].

Microsoft ended general support for Visual Studio 2008 Professional Edition 130409[28] and is therefore no longer providing automatic fixes, updates and technical support online. However there is still extended support for paying business customers.

3.2.2 Windows Embedded Compact 7

WEC7 was formerly known as Windows Embedded CE 7.0 and it is a 32-bit real-time operating system for ARM and x86 architectures, it is designed to target products ranging from consumer electronics to critical industrial automation and medical devices.

The operating system is distributed as a source code package in modules where you select each required module from a view called OS Design in Visual Studio. The selected mod- ules and their dependencies are then compiled (which normally takes an approximately 20 minutes on a modern computer) and added to the archive files nk and eboot, where nk is the operating system and eboot is the boot loader.

Windows Embedded Compact 7 is currently supported by Microsoft until: 160412 and has extended support for paying business customers until: 210413[29].

3.2.3 Microsoft Expression Blend 3

Blend 3[27] is a product in Microsoft Expression 3 suite used for designing Extensible Ap- plication (XAML)[44]. It can create XAML based user interfaces for web pages and desktop applications with a What You See Is What You Get (WYSIWYG) frontend. 3.2. SOFTWARE 15

Blend 3 is currently (130517) the only supported version to create an interactive user interface with high quality pictures and animations that works on WEC7.

Expression 3 / Blend 3 is currently supported by Microsoft until: 150113 and has ex- tended support for paying business customers until: 200113[30].

3.2.4 Windows Embedded Silverlight Tools

To make a GUI for WEC7 Microsoft created a template for Expression Blend 3 called Silverlight for Windows Embedded Application[34], this is an optional module to install after the normal installation.

When creating a GUI with this template it needs be imported it into a Visual Studio 2008 - Smart Device project and to convert it from XAML[44] to native code (C++) without the need to write a single line of code.

3.2.5 Virtual PC

To be able to work without a prototype board WEC7 supports Virtual PC, which makes it possible to run WEC7 and code samples in a virtual environment, and at the same time has the ability to use the debug interface of Visual Studio. The requirement for this to work is that x86 architecture was selected in the installation of WEC7 and the application Virtual PC needed to be installed.

3.2.6 Freescale CFImager (partitioning software)

After a successful compilation of an OS Design two files are generated in the project folder, the nk.nb0 which contained all files needed to boot and run Windows and eboot.nb0 which contained the boot loader. The CFImager partitioning software was required to create the 16 CHAPTER 3. TOOLS correct partition structure on the SD-card to be able to boot on the device. It is available for free on Freescales website[16] as both compiled binary (x86) and source code (C++).

Figure 3.7: Illustration of how the partition structure of the SD after adding nk and eboot with CFImager.

3.2.7 Server

The first versions of PIDE did not have any ways to receive and synchronize user informa- tion with a server. A list with users were created when the program started and the same list was destroyed when the program ended.

To solve this, a server was needed. The first version of the server’s communication was done by socket-programming where the client sent a command as a raw text string e.g. ”GetProfile=1” to the server. When the server received the command it executed it and returned the result. The result was formatted in JavaScript Object Notation (JSON)[20] format to represent the same data structure on both sides and sent as a raw text string. This solution was very simple to implement and it worked. However, when the workload became heavier and when multiple responses were requested, the server stopped working.

Instead of a server implementation built from a basic foundation, a more advanced tech- nology was found that could satisfy the need. The name of this technology is Windows Communication Foundation (WCF).[42] WCF in short is a tool used to create and handle 3.2. SOFTWARE 17 services1, which is also why it is called a Service-oriented architecture (SOA).[66] Every problem the previous server had for e.g. multiple calls, data storage and error handling WCF solved.

Services are programmed like functions in modern programing languages which led to a short learning time to adapt this technology. Another positive discovery about services is the ability to separate different tasks in different services which gives the ability to easily create tests and debug tasks separately. A final change from the previous server was dealing with how the information was saved. The old server acted merely as a prototype server and all information it contained was only resident in the memory during program execution. On the WCF platform a SQL database was introduced and since SQL is very easy to use and the most supported type of database it was considered an obvious choice. When both WCF and SQL were ready a third important and decision-making body component called (EF)[24] was introduced.

The EF in this project had one job and it was to connect WCF with SQL. The con- nection between WCF and SQL meant that the WCF part could use and manipulate SQL tables as if they were objects. This connection would otherwise had to be written by the programmer every time a connection was needed. To automate the process even more, the models and mapping were made with a tool called Entity Framework Power Tools Beta 3[25]. This tool used a functionality called Reverse Engineer Code to inspect a database and later create required models and mappings automatically.

1“A Web service is a software system designed to support interoperable machine-to-machine interaction over a network.” - W3C[53] 18 CHAPTER 3. TOOLS

3.3 Summary

This chapter described all the different hardware inherited from a previous project on Altran. How the RFID reader was an addition to the project plan and was bought by Altran in the belief of that it would become useful for future projects. It has also described all the software that came bundled with the hardware. All the described tools were the same tools also used in this project. Chapter 4

Documentation of interfaces

The carrier board in Cross Platform Development Kit has more than 50 interfaces, every- thing from common interfaces like USB ports found in PC’s to more advanced interfaces like CAN bus[58] often used in cars to access and debug the car’s computer. Altran speci- fied the particular interfaces that were of most importance in future projects. By adding the necessary drivers and components for the interfaces in the design in an early stage, it became a simple task at the end to extract working code samples from the prototype and to create a guide for each interface.

The first section in this chapter will describe how interfaces are tested and some infor- mation on how interfaces works compared to PC interfaces. Following sections will deal with area of usage, results and problems of each tested interface. The section The assembly will briefly explain how the documentation on each interface was packed and delivered to Altran.

19 20 CHAPTER 4. DOCUMENTATION OF INTERFACES

4.1 Approach techniques to test interfaces

To learn if an interface worked on the carrier board, some tests were necessary. The tests could be as easy as plug in a cable and see if the plugged in hardware works, e.g. plugging in a mouse and see if the cursor moves on the screen while moving the mouse. While modern PC OS such as , Ubuntu and OSX often includes the legacy drivers1 as default, it needed to be included manually in the OS design for WEC7. To add an interface driver, the component2 must be found in a module page called ”Catalog Items View”[23]. Including one module would sometimes result in multiple modules getting selected automatically. The modules selected automatically were a part of the dependencies to the first selected module, which were required in order to make it work. Most interfaces located on the carrier board will only be used in special occasions, e.g. the CAN bus described earlier. Also some interfaces required extra equipment to test which led to the decision to only pick interfaces that could be in use for the demo product described in the chapter Clock in system. Each modification in the Catalog Items View required an average of 30 minutes to see if the modification had any impact. The process from choosing a interface’s driver in Catalog Items View to actually testing the interface was split up in these steps:

• Select the component in the Catalog Items View (1 min)

• Build the new OS (20 min)

• Format a SD-card, only need to do it once as long as no files corrupts the space OS will be stored in (3 min)

• Copy the new OS to a SD-card (2 min)

1Legacy drivers - often used to describe a driver included in the OS by default and works without any help from extra drivers that needs to be installed.[46][61] A good reference for this term could not be found but a good explanation for the meaning can be found in this reference[61] below Legacy Support chapter. 2Component is the collection name for each module in the Catalog Items View. A component does not have to be a driver, it could be everything from jukebox software or programming libraries that are designated to work on the platform. 4.2. INTERFACES 21

• Insert SD-card into the carrier board (1 min)

• Boot the OS located on the inserted SD-card (2 min)

The most time-consuming step in the process was the ”Build the new OS” step. Also if any errors were raised during the process it would not show it until end of the build. Because of the ineffective way to add new interfaces, only a few interfaces were tested and documented.

4.2 Interfaces

This section will explain how the USB, Audio, Bluetooth and General Purpose Input/output (GPIO) interfaces were tested.

4.2.1 USB

When the project started, Altran reported that they had some problems to get all USB ports to work. There are a total of 6 USB ports on the motherboard and Altran reported that 3 USB ports did work from time to time. As USB was an important interface for Altran, it was decided to prioritize the investigation of this interface.

As described in subsection: Approach techniques to test interfaces, legacy drivers were not expected to be included by default, the OS designer must include it to the OS build. Some basic USB function drivers for WEC7 were found in the Catalog Items View as the figure 4.1 shows. 22 CHAPTER 4. DOCUMENTATION OF INTERFACES

Figure 4.1: A list of USB driver showed in Catalog Items View

Adding the drivers seen in the figure 4.1 made the corresponding hardware work. The tested hardware items were mouse, keyboard and a USB-memory.

After some investigation it became clear that two of the USB ports (group 1 in figure 4.1) were so called USB clients and not USB hosts. Two of the remaining four USB ports serve as common USB hosts (group 3 in figure 4.1) and the rest are adjustable USB ports (group 2 in figure 4.1) with jumpers3 to decide if they should serve as host or client. USB ports as host are the most common type and are always equipped on modern consumer motherboard.

3Jumper is often used to connect a pair of electrical contact points to configure hardware settings for a circuit board.[60] 4.2. INTERFACES 23

Figure 4.2: USB ports on the carrier board

The main difference between those two types is that the USB host serves devices with USB connection while USB client is meant to be a way to connect the device to a host device. Typically devices like USB memories, smartphones and cameras have USB ports as clients while a computer or laptop has USB ports as hosts.

4.2.2 Audio

Another idea which came from Altran was that a customer asked for the possibility to add movies to an application. This looked like a trivial problem since all you need is video and audio drivers, compressor-decompressor () and a player to play a movie. The Cross Platform Development Kit came with a driver package, the codec and player came as optional modules. At the beginning movies did not start at all, the reason was that the audio driver was not correctly initialized. All available drivers were tested without success and the manufacturer was asked for the correct driver. The manufacturer replied that the AC97[18] was the correct driver, this driver was tested multiple times without any success. As an alternative solution, the driver package contained a virtual audio driver. This driver did not give any audio in the speakers but it made it possible to play movies in WEC7. 24 CHAPTER 4. DOCUMENTATION OF INTERFACES

4.2.3 Bluetooth

Bluetooth was a bonus task Altran asked us to investigate. It would be used together with their firmware upgrade feature as a data source from where the new firmware would be downloaded. As it required an extra module to be purchased and drivers to be written, made the Bluetooth feature was considered not worth the time to investigate further.

4.2.4 GPIO

One of the design ideas for the prototype built in chapter 5 was to attach sensors for temperature and humidity readings to the GPIO connector. This would have made the application feel more dynamic to its users. Unfortunately the total lack of instructions and code examples made this too time consuming as a viable option in this project. As an alternative solution the readings were instead parsed from a local website.

4.3 The assembly

When Altran handed over the Cross Platform Development Kit it came along with an assembly guide made by Altran. This guide did not include any guiding pictures and it was outdated. As a solution a new guide was created with pictures which describes every step to a full assembly.

The documentation in the end was divided into six different packages. These are:

1. Installation

2. Setup the Virtual Environment

3. Silverlight DLL

4. The assembly 4.4. SUMMARY 25

5. Interfaces

6. OSDesign

Item 4 and 5 are results of the documentations of the interfaces while the others are guides on how to get started with the software part. In addition to the documentation on interfaces, there are a class and libraries for a third party hardware used in prototype described in Clock in system.

4.4 Summary

This chapter has described the process of testing different interfaces and how the pro- cess differentiates from the equivalent process on personal computers. How it handles dependencies of unselected modules and how four specific interfaces were tested. It has also described the six different guides created to assist similar projects with assembly and setup.

Chapter 5

Clock in system

This chapter will describe the creation of an operating system design to run the demon- stration application on. It will also describe the design, implementation, problems and result of the clock in system.

5.1 Design

This section will describe the design of the operating system. It will also introduce the clock in system application PIDE. Since PIDE require some additional programing techniques to accomplish the requirements, it will also be described in a subsection.

5.1.1 Operating system

A new WEC7 operating system design was created from scratch. The first step was to add the default drivers that were specified by a sample design bundled with the Cross Platform Development Kit. Then all required software libraries were added to get an application running. Since there were so many alternative modules it was difficult and time consuming to get it running the first time.

27 28 CHAPTER 5. CLOCK IN SYSTEM

When the design was finished it only needed to be built into a usable OS image, this step required an additional 20 min to finish.

5.1.2 Introducing the clock in system PIDE

During the first week of development the name PIDE (”Personnel Interactive Display and Educator”) was coined. The goal for the product was to be a useful tool in ’s work and at the same time provide developers with self-explanatory source code - therefore the last character E as in educator.

Figure 5.1: Illustration of the first prototype of PIDE (Personnel Interactive Display and Educator)

The illustration showed how the clock in system displayed on touch screen worked to- gether with multiple interfaces. To accomplish this both native- and managed code were required. 5.1. DESIGN 29

The prototype was created with:

• 20 inch touch screen.

• An ARMv7 processor.

• Analog and digital sensors for temperature and humidity readings attached to the General Purpose Input/output connector.

• Radio Frequency Identification (RFID) for identification of external key cards and badges.

• Ethernet connection with wire and a Wi-Fi module for a wireless connection to a database server to send and receive data.

• Bluetooth adapter for sending and receiving data. This was planned to be used as a way to receive firmware updates without having a physical storage to be inserted into the prototype.

Multiple devices and services with a similar goal as the prototype product were found in a comparison [59] available on the Internet. One of most common solutions found was a module-based software as a web service, with a monthly subscription fee. This option provided a fixed low rate each month and the ability to dynamically add or remove modules at an instant. Modules for managing common tasks such as: calendars, projects, reports, customers and administration were often unique for each product which might lead to problems.

The second option was a one-time investment computer system, this might be a better investment in a longer term but lacks the flexibility of modularity and problems can arise 30 CHAPTER 5. CLOCK IN SYSTEM if the system does not integrate well with the company. Then it might end up with a higher total price tag than estimated.

The whole idea with a digital clock in system was wanted by many industry companies to eliminate the old fashioned mechanical and electric punch clocks. This could also provide more and customized information when workers check in and out, for example if the com- pany has any important notice or if there are any personal appointments for the day.

Compared to the mechanical and electric punch clocks, the clock in system was a two way communication where the information of the person checking in could be stored and used for other purposes. For example it provides a nice way to keep track of people and at the same time generate useful data on employees’ work patterns, which easily could be plotted on a graph and analyzed further. The possibilities were many and a developer could easily find new modules to attach and implement more functionality.

One device using the similar technology can be found in many laundry rooms in Swe- den. Modern laundry rooms are often equipped with digital booking table and digital door locking mechanism using a RFID as identification. The digital booking table had many similar properties as the prototype device like the RFID identification, touch possibility and database with all users.

5.1.3 Fusion of programming languages (Native / Managed)

This section will explain the advantages and disadvantages of the different concepts of native and managed code and the attempt to mix them together. The techniques became the solution for the requirements on the project set by Altran at the project start. 5.1. DESIGN 31

Native

Native program code[63] compiles as machine code to a specific platform. This gives the highest performance which is required for real-time critical systems but at a cost of increased development time and lower level of abstraction.[47]

Figure 5.2: Illustration of how the C++ source code compiles straight to native machine code for a specific architecture.

Managed

Managed program code[41] is program code written in the program language C# (or in some cases VB or C++). It executes in a managed execution environment opposed to native code which is executed directly on the platform. It is used for lowering the development time for projects, with the drawback that the application runs slower.[71] 32 CHAPTER 5. CLOCK IN SYSTEM

Figure 5.3: Illustration of how the managed C# and C++ source code compiles to native machine code on top of the .NET framework.

Mixing managed and native code

The idea of mixing managed and native code came from a video tutorial created by Andy Wigley and published by [55]. In this video Wigley creates the program logics in managed code, and the GUI and real-time critical code in native code and then links them together. This gives the benefit of a separation of concerns between GUI and the logics and they can be developed individually.

The tutorial in the video warns at 01:01:15 that the price of separating the application in native and managed code could lead to an increase in latency. This latency is multiplied by five for all events involving the GUI. To avoid problems with increasing latency the interaction between components in the GUI should be kept at a minimum. 5.2. IMPLEMENTATION OF CLOCK IN SYSTEM 33

Figure 5.4: Illustration of how the managed code compiles to native machine code on top of the .NET framework. Native code is accessible from the DLL, this link is illustrated with an arrow between the machine codes. The Marshalling[62] step between the managed code and native code is needed to transform and exchange data objects from one side to another.

5.2 Implementation of clock in system

This section will show the system model and how the GUI, RFID, temperature and stock exchange were implemented.

5.2.1 Model

The clock in system PIDE was built as a class that required little work to implement new functionalities and interface controller. By using multiple threads1 in the application, handlers could work asynchronously to each other. This method had to be used in PIDE as the main thread was used to initiate and maintain GUI until the application instance

1Using threads in an application instance allows the software to multitask by assigning operations to do to multiple threads that can work concurrent without having to be depended to each other[35]. 34 CHAPTER 5. CLOCK IN SYSTEM would end. The reason to this was because GUI did resident in another execution library, this is explained with more details in GUI section. A class diagram generated by the PIDE project is shown in figure 5.5, the core functionalities were these:

• Main thread would after initiating the modules used in logics become responsible for the GUI instance and nothing else.

• One thread was used by RFIDHandler, this is explained more detailed in section RFID.

• One thread was used by HttpRequestHandler to update values displayed on the GUI. More about this in section Temperature and stock exchange.

By splitting up the functionality in modules allowed new modules to be implemented easily. The drawback with this model was the way information was exchanged between the modules. First the model required each module to initiate the instance with the reference2 of the object that needed to be accessible in the different modules. By having the object saved in many asynchronous on-going threads, the object could easily become corrupted if two or more modules worked with the same information in the object at the same time. As the clock in system was not planned to become a real product and the code would maintain in a ”controllable” state, the model was kept in spite of the potential risks.

2In C#, an argument passed with the ”ref” keyword will cause the reference to the value to be sent and not the value it-self[33]. 5.2. IMPLEMENTATION OF CLOCK IN SYSTEM 35

Figure 5.5: Class diagram of the logic part of PIDE. 36 CHAPTER 5. CLOCK IN SYSTEM

5.2.2 GUI

The GUI was designed using the template Silverlight for Windows Embedded Application in Blend. Since Blend uses a What You See Is What You Get (WYSIWYG) approach it was easy to select the required items and drag them to the right location. When this was finished Blend saved the project as an XAML project. This project was then imported to the Visual Studio project template Silverlight for Windows Embedded Application. This template converts the XAML to a runnable native code application. When the native GUI application could run through a executable file, it was converted to a Dynamic-link library file.

Figure 5.6: Model of steps from Blend GUI to Native DLL.

The last conversion made it possible to let the managed application to handle the native GUI application. This solution forced the managed application to become a console application, which resulted in logics part being handled in the managed part while the GUI part was handled in the native part.

Figure 5.7: Model of native and managed applications 5.2. IMPLEMENTATION OF CLOCK IN SYSTEM 37

5.2.3 RFID

A general RFIDHandler-class was written before PIDE was implemented. The intent was to leave a code sample for Altran to start from and show an example of how that code sample can be used in a software implementation.

However, the general class needs some explanation and also further implementation to fit the software. An extract from a UML diagram shown below summarizes the most important parts (explanation below the diagram):

Figure 5.8: Stripped UML diagram.

Starting from the top, PIDE main-class is where all handlers are initiated including the RFIDHandler. When the RFIDHandler class has initiated, it needed further code instructions to make the reader start listening for incoming signals. First the RFIDHandler needs to know how to handle events, that is where BindRFID function comes in and sets up the event handlers. The BindRFID function in PIDE’s version of RFIDHandler is an overloaded function used to receive and use other events than the default events in RFIDHandler. The default event handlers in RFIDHandler are:

• rfid Tag() - invoked when a RFID tag is present 38 CHAPTER 5. CLOCK IN SYSTEM

• rfid TagLost() - invoked when a RFID tag is outside range

• rfid Error() - invoked when the RFID reader finds a tag but an error was raised (typical when the RFID tag is using protocols not intended for the reader)

• rfid Detach() - invoked when the RFID reader is detached from the device

• rfid Attach() - invoked when the RFID reader is attached to the device

The default operations for each event handler are to save the messages in publicly accessible variables. In PIDE’s case, the event handler rfid Tag is an extended implementation to make GUI operations and other logic operations possible to run when the event is invoked. As time did not suffice, the new implementation using ChangedEventHandler could not be tested and implemented. The solution based on ChangedEventHandler is more elegant where the RFIDHandler class does not need further implementation to accomplish what PIDE does now with the overridden function. In theory, using ChangedEventHandler is like grouping the RFIDHandler with a listener where the listener can invoke a function (not necessary in RFIDHandler) when some of RFIDHandler’s content have changed.

5.2.4 Temperature and stock exchange

When the application was finished it lacked input from the outside world which made it feel outdated. To make it more dynamic a temperature and stock exchange input were added to the GUI by a new thread. This new thread started when the GUI is finished loading and fetched a JSON object containing the temperature and a Comma-Separated Value (CSV)[15] containing the stock rate. Both the object and CSV were then parsed and displayed in the GUI. This action repeats in the background every thirty minutes as long as the application was running. 5.3. PROBLEMS 39

5.3 Problems

This section will describe the major problems with the WEC7 discovered in the project.

5.3.1 OS - Installation

At the first glance the installation of WEC7 was straightforward, but according to the guide given by Altran, it said especially to do a full installation. This installed all the bundled software which required an estimate of 60 gigabytes of data for all tools, embed- ded architectures (ARM, MIPS, x86), documentation and help files which took about five hours to complete.

A new guide was written with this in mind where a more or less ”trial and error” method was used. As the errors only showed up at the end of every OS build, there was no other choice than go with the ”trial and error” method.

5.3.2 OS - Update and installation service

On Sunday 130203 the downloading service for WEC7 stopped working after a new update was posted[52]. WEC7 installation and updates come as an executable-file which contains a file list of Uniform Resource Locators (URL)[5] with matching checksums. After some investigation, the founded information lead to the belief that the file structure on Microsoft website went wrong in some way, files were suddenly missing and some others had wrong versions and did not match the checksums.

Microsoft created a new update (update 15[52]) 130214 which added all the missing files, but the trouble to update still remained as multiple files did not match the checksums which led to that installation and updating were not possible. In 130219 Microsoft finally 40 CHAPTER 5. CLOCK IN SYSTEM added a new update (update 18[52]) which resolved most of the issues and a guide was created so that everyone could update to the latest version.

Because of these problems with updating the WEC7 the developers had different incom- patible versions of the application during 130203 to 130219.

5.3.3 OS - Graphic acceleration

To make use of the extra graphic processing power from the dedicated GPU (graphics pro- cessing unit), some options must be enabled in the Catalog Items View. Using graphical effects made in Blend for example are very dependent on this extra graphic processing to run smoothly, e.g. animations with moving objects.

When the first version of PIDE OS design was created, the handheld enterprise device template was chosen as the instructions from SECO advised to use it. At that time, graphics were slow and lagged between each frame despite the GPU settings filled in. The problem was solved later by accident when the wrong OS design template was used in the process of a new experimental OS construction. It was a fortunate error and until today, it is still unknown why GPU will not work in some OS design templates.

5.3.4 OS - Changing platform for existing project

One of the benefits with the carrier board is the possibility to run processors with either ARM or X86 architecture. This is very easy to switch on the hardware, you just simply replace the processor board and the system is ready for X86 instructions. However, the software needed a few adjustments to work. First a new OS must be built with the replaced architecture platform. When the OS works on the new platform, the application needs to be rebuilt with the new platform to work. 5.4. RESULTS 41

Since a board with X86 processor was not available at the moment during this project, the Virtual PC with an X86 OS design was used and tested instead. The platform change in the project did not generate any problem itself, but the problems started during runtime. First KITL3 requested libraries that could not be found, apparently the requested libraries were going to help the OS debugging. A solution to disable the debugger was tried without success, the OS could not even boot with the OS debugger disabled. After some testing, it was concluded that the problem did not appear with separate projects in C# and C++ after a platform change. In the end, the module responsible for the problem was found and it was the Phidgets RFID reader library. The library is defined to be include in the OS design so it is available on the platform before PIDE software is started. The library was however compiled for ARM4I and not X86 which caused this problem.

5.3.5 OS - RFID

One problem that complicated development for RFID-reader is that the virtual pc did not have support for USB ports, which forced the testing directly on the ”real” hardware. However, the PIDE software does not require an RFID-reader to launch which made it possible to develop other parts of the software without having an RFID-reader connected.

5.4 Results

This section will describe the results of the operating system design and design and imple- mentation of the clock in system.

3Kernel Independent Transport Layer - communication channel between the development machine and the target device. Used to debug WEC7 OS.[22] 42 CHAPTER 5. CLOCK IN SYSTEM

5.4.1 The generic OS design

At the project start a new OS Design was designed from scratch with an empty template, all modules were then added in an iterative way when needed. The result of this was a minimal design with full functionality that worked for projects of both managed- and native code.

If a new module is needed for some previously unused functionality, the design only re- quired a minimal change to add this to the previous design instead of creating a new design.

The generic OS design project files were below 50 kB in size when the compiled WEC7 files were removed so for further ease it could be added to source code management systems.

5.4.2 Clock in system

This subsection will describe the result of the GUI, RFID, temperature and stock exchange functionality in PIDE.

GUI

The GUI for PIDE was entirely made in Blend.[27] This resulted in a responsive, auto adjusting to the screen resolution, easy navigated and stylish interface. The profile image scroller had the main focus from beginning because it was the function- ality the application was created around. It was built from scratch using the storyboard feature in Blend to modify the images position and their 3D projection properties during a timeline. The result is shown below: 5.4. RESULTS 43

Figure 5.9: Profile image scroller in PIDE with arrows to navigate between profiles.

A feature that is missing in PIDE, but exists in many scroller based menus nowadays is the flick gestures[36] allowing users to quickly scroll through choices. This could have been implemented because an OS design with WEC7 can be configured to include touch gestures and the touch gestures physics engine.[37]

RFID

As PIDE was intended to be a clock in system, RFID made the task to identify users easy. When using the RFID tag instead of the image scroller it did provide some extra personal options in the profile page linked to the scanned RFID tag. Choices available when a user clicked into someone’s profile: 44 CHAPTER 5. CLOCK IN SYSTEM

Figure 5.10: Navigate to profile with profile scroller, the profile contains information rele- vant to the specific user such as meetings

Choices available when a user scans an RFID tag: 5.4. RESULTS 45

Figure 5.11: Navigate to profile with RFID tag, the profile contains options to update the checked in profile’s information

Temperature and stock exchange

The GUI had time, temperature and stock exchange objects that receive and update with information made asynchronously. This solution from the beginning was to create a sepa- rate real-time part where PIDE could manipulate it without to be worried about the main 46 CHAPTER 5. CLOCK IN SYSTEM

PIDE app hanging. It turned out that the task was more complicated than expected from the beginning when Altran requested an additional native thread for real-time critical hardware. The solution was use both managed[41] and native code threads in the same project.

Figure 5.12: Time, temperature and stock exchange GUI objects updated with information from the Internet.

5.5 Summary

This chapter’s first part described the design of the operating system, the idea behind the prototype of PIDE and the required techniques of native- and managed code. The following part described the implementation of GUI, RFID reader, temperature and stock exchange indicators. Later in the chapter, it explained the problems of selecting software for the 5.5. SUMMARY 47 operating system, the malfunctioning update system, the missing graphics acceleration, the change of platform architecture during development and lack of interfaces in the virtual environment. In the final part it demonstrated the results of generic OS design and the PIBE application.

Chapter 6

Safe update

This chapter will describe how the safe update functionality was designed and implemented as well as the problems that arose and the results.

6.1 Design

A safe way to update the OS was part of what Altran wanted from the beginning. The previous system was vulnerable to many types of failures such as write errors and power failures in the updating process which might end up corrupting the system to a state where it was no longer able to boot after an update.

A design of a possible solution was created by adding an additional partition to con- tain the new OS and leave the old OS intact in the update process. This step would make the update more resilient to power failures as the old OS would boot as normal on failure. Another additional step was also introduced which involved using a checksum to verify that the newly written OS was identical to its source to handle bad reads and writes, and possibly detect bad memory. At the end an updated boot loader of 512KB would overwrite the existing one and get verified against a checksum. Since this last step would be the only

49 50 CHAPTER 6. SAFE UPDATE dangerous part of the entire process this design was accepted by Altran to satisfy their demand.

Figure 6.1: Partition allocation with the new OS added after the old OS.

Figure 6.2: Illustration of the design for safe updating. 6.2. IMPLEMENTATION 51

6.2 Implementation

This section will explain the changes that were made to the software to be able to make the safe update possible.

6.2.1 Partition modification

The Freescale CFImager[16] is a general partition solution for WEC7 which works for multiple different embedded systems. The source code is available free as a download and contains the binary executable and the code written in C++. Since it is not written for a specific platform it also contains a header file called CStCFBootImager.h[16] which describes layout of each system it supports. The CSTCFBootImager.h contained the defi- nition of the i.MX51 processor[49] used on the prototype board, all addresses are specified as sectors of 512 bytes in hexadecimal.

• kEBOOTStart = 0x100 (boot loader start address)

• kNKStart = 0x500 (operating system start address)

• kBootPartitionSize = 0x2FFFE (free space start address)

By modifying the following values it was possible to write the second OS to the free space after the first OS and at the same time move the allocation of free space to after the second OS. This made it possible to store two OS on the same SD-card without conflicts.

• kNKStart = 0x304FE // (kNKStart + kBootPartitionSize) (operating system start address)

• kBootPartitionSize = 0x5FFFC // (kBootPartitionSize * 2) (free space start address)

To verify that the operating system was placed at the right sector a hex editor called HxD[17] was used. 52 CHAPTER 6. SAFE UPDATE

The verification system consisted of the following steps:

Figure 6.3: Highlighting of the first 5 unique bytes of the operating system file of 96 MB.

Figure 6.4: After opening the SD-card in the hex editor in raw-format, it was possible to search for the unique bytes and locate the first OS at sector 1280 (0x500) and offset 655360 (0xA0000). This was the default position in the CFImager. 6.2. IMPLEMENTATION 53

Figure 6.5: Another search lead to the position of the second OS at sector 197886 (0x304FE) and offset 101317632 (0x609FC00) which was the position specified in the modified version of CFImager.

To recreate the structure later you must use the CFImager (cfimager) to add boot loader (eboot.nb0) and the first OS (NK.nb0), then use the modified CFImager (cfimager mod) to insert the second OS (NK.nb0) in the free space.

Program execution order:

1. cfimager -f eboot.nb0 -d g -imx51

2. cfimager -f NK.nb0 -d g -imx51 -a

3. cfimager mod -f NK.nb0 -d g -imx51 -a

Note also that the files must be named nk.nb0 and eboot.nb0 to work with CFImager or it will not start, it is specified in the source code[16].

6.2.2 Boot loader modification

In the previous subsection the starting location of the operating system was moved from 0x500 to 0x609FC00. To be able to boot the second OS on the SD-card, the boot loader 54 CHAPTER 6. SAFE UPDATE had to be modified to boot into the second OS’s address instead of the first OS’s address. WEC7 contains a set of unique platform files for each platform you develop for, the Seco Cross Platform Development Kit[50] came with a set called PRJMX51. [51] After parsing through all the source code the constants for the boot loader was found.

Figure 6.6: The constants for the boot loader.

But it was not until all the constants had their values calculated and converted to hexadecimal a familiar value came up, the offset 0xA0000 (see figure 6.4).

Figure 6.7: Constants’ values after calculation.

0xA0000 was the offset of the sector 0x500, WEC7 source code addresses with offsets not sectors as the CFImager.

To test if the boot loader would boot the second OS the IMAGE BOOT NKIMAGE SD OFFSET was set to 101317632 (0x609FC00) which was the offset of the second OS.

When used together with the modified CFImager the second operating system booted.

6.2.3 Automation

When the system could boot both the first and the second operating system, the process had to be automated. To verify that both the OS and the boot loader passed the checksum 6.3. PROBLEMS 55 and for simplicity of the fail-safe updater.

This was done by creating a native code application on WEC7 that was able to read and write raw data directly on the SD-card. The boot sequence is difficult to get com- pletely failsafe, however with this in mind this design (figure 6.2) and implementation should be safe.

6.3 Problems

This section will describe the problems discovered creating the safe update functionality.

6.3.1 Sectors and offsets

During the project two different types of addressing. First the CFImager used hexadecimal sectors(512 byte/sector) for addressing, but the WEC7 boot loader used decimal offsets(1 byte/offset) for addressing in the source code. This caused annoyance and confusion when modifying the software to work together.

6.4 Results

To automatically or semi-automatically maintain a system, the user needs a safe method to perform the update. Since the project lacked time to finish the product, a theoretical solution was made to show how the application could be created. While the automated solution was not implemented, the manual way was implemented to show that the automated solution could be made if it was given more time. The automatic safe update was planned to work in a five step procedure, the steps are explained below in chronological order:

1. Download the update from a data source to either RAM or SD-card 56 CHAPTER 6. SAFE UPDATE

2. Decide which OS on the SD-card is the older OS of the two.

3. Overwrite the old OS with the newly downloaded OS and then compare the checksum with the downloaded version from step 1

4. Overwrite the existing boot loader with the second boot loader with modified OS location variable and also compare checksums here. This step is critical because a failure here would destroy the boot sequence leading to inability to use the system

5. Reboot

If more time was given, it was planned to implement an option in PIDE where you could update the software by using an external data storage, e.g. USB flash drive or directly from an FTP server. The idea was to update both the application and the OS at once.

6.5 Summary

This chapter described the idea and design behind the safe update, how it was implemented and what software that were modified to make it work. It also described the problems of different ways of addressing the starting addresses in the software, and the plan for the resulting product. Chapter 7

Evaluation and conclusions

This chapter will explain the author’s reflections on the requirements, possible alternative solutions, future of the platform, lesson learned and the author’s final opinion.

7.1 Reflections on requirements

The requirements covered in the background chapter (see subsection Requirements) are ac- cording to the authors and Altran covered by the thesis, documentation and source code. Chapter 4 reflects on the work done to fulfil the requirements to test as many interfaces as possible. The following chapter 5 also became a part of the documentation, but the clock in system focused more on how the implementation was done rather than technical details of the interfaces. The last part of this project described in chapter 6 was a bonus from the beginning and resulted in a theoretical study without a fully working implementation.

The results of this project will have some separate future plans. The documentations and clock in system will be a part of education to the next person who wants to learn how WEC7 works. The safe update feature will be implemented to the previous project Altran did. Changes will be made to make the safe update software’s code more professional as

57 58 CHAPTER 7. EVALUATION AND CONCLUSIONS the safe update in this project just showed the concept and was not meant to be released in a real product.

7.2 Alternative solutions

Since the clock in system was a demonstration application to produce source code for the documentation of interfaces, no alternative solution is of relevance.

An alternative solution for the safe update process would be to remove the step that creates the partition structure of the SD-card on a PC. This would have required less preparation before handing over a system to the customer. But a disadvantage would be that it required more work to implement and is more difficult.

7.3 Future of the platform

WEC7 was released in March 2011[68] as a successor to the Windows Embedded CE 6.0 within five years after its release. At the end of this project Microsoft was preparing to release the next version of the Windows Embedded Compact as a successor to WEC7, this was entitled Windows Embedded Compact 2013. It was planned to be released[32] the second quarter of 2013 and will have support for Visual Studio 2012 which has the independent application Blend integrated in the Visual Studio 2012 suite.

This release will most likely solve all the issues of creating a native code GUI and logics in managed code. Also the unsupported software will be replaced with supported software. However, it is still uncertain if the Seco Cross Platform Development Kit will support this new software. Seco has replied in an email that it was up to the hardware producers to create a new Board Support Package (BSP)[57] and Windows Embedded Compact drivers. 7.4. LESSONS LEARNED 59

7.4 Lessons learned

This project gave new experiences on working with Seco Cross Platform Kit and Microsoft’s embedded platform WEC7, it was more demanding to learn than previously tested plat- forms see section Author background. The estimation of time for the project the authors did at start was therefore wrong since it was not finished in time. It requires more experi- ence of the subject to estimate time for similar projects.

It also gave the authors valuable insight of the daily work at a consulting firm for almost five months, which gave the authors many new contacts and knowledge of the business.

7.5 Authors opinion

WEC7 was really an interesting platform to explore. It did not feel as polished and fin- ished as other products Microsoft has made such as Visual Studio and Windows operating systems, e.g. lack of support from the latest versions of Visual Studio and Blend at release made the product feel outdated from start. The question why Microsoft decided to release a new embedded platform 2011 which was only supported by their IDE Visual Studio 2008 (released 2007) and not Visual Studio 2010 (released 2010) the authors find hard to answer. WEC7 had the potential to make embedded systems easy to learn, design, develop and run. However, an complete documentation of WEC7 was not available until one month into the project started[43]. Other information sources besides MSDN[26] were an Bulletin board system and a book, that seems to be the only book about this developing on WEC7 platform. In general, it was very hard to solve problems that arose because of this and it required much time to find relevant information. It were in the authors’ opinion that the project was a success even if the implementation was not finished in time. The implementation was planned to be finished after this thesis completion.

References

[1] Aaftab Munshi, J. L. Opengl es common profile specification version 2.0.25. http://www.khronos.org/registry/gles/specs/2.0/es full spec 2.0.25.pdf, 2010. [On- line; accessed 2013-06-10].

[2] ARM. Arm processor architecture. http://www.arm.com/products/processors/instruction-set-architectures/index.php, 2013. [Online; accessed 2013-06-10].

[3] ARM. Cortex-a8 processor. http://www.arm.com/products/processors/cortex- a/cortex-a8.php, 2013. [Online; accessed 2013-06-10].

[4] Atmel. Atmel corporation - microcontrollers, 32-bit, and touch solutions. http://www.atmel.com/, 2013. [Online; accessed 2013-06-12].

[5] Berners-Lee, T., Fieldingand, R., Masinter, L., AdobeSystems, W3C/MIT, and DaySoftware. Uniform resource identifier (uri): Generic syn- tax. http://tools.ietf.org/html/rfc3986#section-6.2.2.1, 2013. [Online; accessed 2013-06-11].

[6] Campbell, D. Visual studio 2012 to support windows embedded compact. http://blogs.msdn.com/b/windows-embedded/archive/2012/10/04/visual-studio- 2012-to-support-windows-embedded-compact.aspx, 2012. [Online; accessed 2013-05- 17].

[7] Cardullo, M., and Parks, W. Transponder apparatus and system. http:// worldwide.espacenet.com/publicationDetails/biblio?CC=US&NR=3713148&KC= &FT=E&locale=en EP, 1973. [Online; accessed 2013-05-17].

[8] Clcsystems. Phidgetrfid kit. http://clcsystems.nordicshops.com/product.html? product id=60&category id=20, 2013. [Online; accessed 2013-05-17].

[9] Consortium, Q. Qseven. http://www.qseven- standard.org/fileadmin/spec/Qseven-Spec 1.20.pdf, 2008. [Online; accessed 2013-05-17].

61 62 REFERENCES

[10] Cousin, L. Intelligent systems. http://www.altran.com/fileadmin/medias/1.altran. com/documents/Press Releases/2013/PR ALT 20130305 Intelligent Systems.pdf, 2013. [Online; accessed 2013-05-17].

[11] Daniel Rice, R. J. S. Openvg specification. http://www.khronos.org/registry/vg/specs/openvg-1.1.pdf, 2008. [Online; accessed 2013-06-10].

[12] Datavision. Tft module. http://www.datavision.com.tw/lcm 03.php, 2013. [On- line; accessed 2013-05-17].

[13] Dealextreme. Intelligent id card usb reader. http://dx.com/p/ intelligent-id-card-usb-reader-174455, 2013. [Online; accessed 2013-05-24].

[14] Eben Upton, L. U. Raspberry pi an arm gnu/ box for $25. http://www.raspberrypi.org, 2013. [Online; accessed 2013-06-12].

[15] Force, I. E. T. Rfc 4180 - internet engineering task force. http://www.ietf.org/rfc/rfc4180.txt, 2005. [Online; accessed 2013-06-11].

[16] Freescale. Windows tool for the creation of boot sd cards for the i.mx plat- forms. includes binaries and sources files. https://www.freescale.com/webapp/ sps/download/license.jsp?colCode=CF IMAGER&appType=file2&location= null&DOWNLOAD ID=null, 2013. [Online; accessed 2013-05-17].

[17] Horz,¨ M. Hxd - freeware hex editor and disk editor. http://mh-nexus.de/en/hxd/, 2013. [Online; accessed 2013-06-11].

[18] . Audio codec ’97. http://download.intel.com/support/motherboards/ desktop/sb/ac97 r23.pdf, 2002. [Online; accessed 2013-06-11].

[19] JEDEC. Ddr2 sdram standard. http://www.jedec.org/standards- documents/docs/jesd-79-2e, 2009. [Online; accessed 2013-06-10].

[20] JSON. Introducing json. http://www.json.org/, 2013. [Online; accessed 2013-06-11]. [21] Labs, S. Netduino. http://netduino.com/, 2013. [Online; accessed 2013-06-12]. [22] Microsoft. Kitl transport (windows ce 5.0). http://msdn.microsoft.com/en- us/library/ms894172.aspx, 2006. [Online; accessed 2013-05-14].

[23] Microsoft. Catalog items view window (compact 7). http://msdn.microsoft.com/ en-us/library/ee482549.aspx, 2013. [Online; accessed 2013-06-11].

[24] Microsoft. Entity framework. http://msdn.microsoft.com/en-us/data/ef.aspx, 2013. [Online; accessed 2013-06-11]. REFERENCES 63

[25] Microsoft. Entity framework power tools beta 3. http://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2- 846072eff19d/, 2013. [Online; accessed 2013-06-11].

[26] Microsoft. Microsoft developer network. http://msdn.microsoft.com/en-US/, 2013. [Online; accessed 2013-06-13].

[27] Microsoft. Microsoft expression. http://www.microsoft.com/expression/eng/#blend, 2013. [Online; accessed 2013-06-10].

[28] Microsoft. Microsoft product lifecycle search. http://support.microsoft.com/ lifecycle/search/?sort=PN&alpha=Visual+Studio, 2013. [Online; accessed 2013-05- 17].

[29] Microsoft. Microsoft product lifecycle search. http://support.microsoft.com/ lifecycle/search/default.aspx?sort=PN&alpha=Windows+Embedded+Compact+ 7&Filter=FilterNO, 2013. [Online; accessed 2013-05-17].

[30] Microsoft. Microsoft product lifecycle search. http://support.microsoft.com/ lifecycle/search/default.aspx?sort=PN&alpha=Expression+Blend+3&Filter= FilterNO, 2013. [Online; accessed 2013-05-17].

[31] Microsoft. Prerequisites (compact 7). http://msdn.microsoft.com/en- us/library/jj200345.aspx, 2013. [Online; accessed 2013-06-10].

[32] Microsoft. Product lifecycles. http://www.microsoft.com/windowsembedded/ en-us/product-lifecycles.aspx, 2013. [Online; accessed 2013-05-10].

[33] Microsoft. ref (c# reference). http://msdn.microsoft.com/en-us/library/ 14akc2c7.aspx, 2013. [Online; accessed 2013-06-12].

[34] Microsoft. Silverlight for windows embedded application development (compact 7). http://msdn.microsoft.com/en-us/library/jj592912.aspx, 2013. [Online; accessed 2013-06-10].

[35] Microsoft. Threading (c# and visual basic). http://msdn.microsoft.com/en-us/ library/ms173178.aspx, 2013. [Online; accessed 2013-06-12].

[36] Microsoft. Touch gestures (compact 7). http://msdn.microsoft.com/en- us/library/ee499124.aspx, 2013. [Online; accessed 2013-06-11].

[37] Microsoft. Touch gestures physics engine reference (compact 7). http://msdn.microsoft.com/en-us/library/ee501465.aspx, 2013. [Online; accessed 2013-06-11]. 64 REFERENCES

[38] Microsoft. Visual studio. http://msdn.microsoft.com/en- us/library/52f3sw5c(v=vs.90).aspx, 2013. [Online; accessed 2013-03-29].

[39] Microsoft. Visual studio 2010. http://msdn.microsoft.com/en- us/library/dd831853(v=vs.100).aspx, 2013. [Online; accessed 2013-06-10].

[40] Microsoft. Visual studio 2012. http://www.microsoft.com/visualstudio/eng/products/visual-studio-overview, 2013. [Online; accessed 2013-06-10].

[41] Microsoft. What is managed code? http://msdn.microsoft.com/en- us/library/windows/desktop/bb318664(v=vs.85).aspx, 2013. [Online; accessed 2013- 06-11].

[42] Microsoft. What is windows communication foundation. http://msdn.microsoft.com/en-us/library/ms731082.aspx, 2013. [Online; ac- cessed 2013-06-11].

[43] Microsoft. Windows embedded compact 7. http://msdn.microsoft.com/en-us/ library/gg154201.aspx, 2013. [Online; accessed 2013-06-13].

[44] Microsoft. Xaml overview. http://msdn.microsoft.com/en- us/library/ms752059.aspx#what is xaml, 2013. [Online; accessed 2013-06-10].

[45] Phidgets. Products for usb sensing and control. http://www.phidgets.com/, 2013. [Online; accessed 2013-06-10].

[46] Puneet. Legacy drivers. http://www.winvistatips.com/ legacy-device-drivers-t179341.html, 2013. [Online; accessed 2013-06-10].

[47] Samuel Phung, David Jones, T. J. Professional Winodws Embedded Compact 7, 1 ed. Wiley / Wrox, 9 2011.

[48] Savitz, E. Gartner: 10 critical tech trends for the next five years. http://www.forbes.com/sites/ericsavitz/2012/10/22/gartner-10-critical-tech-trends- for-the-next-five-years, 2013. [Online; accessed 2013-05-17].

[49] Seco. Quadmo747-x/i.mx51. http://www.seco.com/en/item/quadmo747-x i mx51, 2013. [Online; accessed 2013-05-17].

[50] Secoqseven. Cross platform development kit. http://www.secoqseven.com/en/item/cross-platform-development-kit-/, 2013. [Online; accessed 2013-05-17]. REFERENCES 65

[51] Secoqseven. Private area. http://www.secoqseven.com/en/download/downloads.html, 2013. [Online; accessed 2013-06-11].

[52] Unknown. Windows embedded compact 7 update fails to download payloads. http://social.msdn.microsoft.com/Forums/en-US/winembplatdev/thread/c4804e01- 37c2-44e2-844b-344f9b4c3156, 2013. [Online; accessed 2013-05-17].

[53] W3C. Web services architecture. http://www.w3.org/TR/ws-arch/, 2013. [Online; accessed 2013-06-12].

[54] Webopedia. Platform. http://www.webopedia.com/TERM/P/platform.html, 2013. [Online; accessed 2013-05-17].

[55] Wigley, A. Programming microsoft sil- verlight for windows embedded using microsoft .net. http://channel9.msdn.com/Events/TechEd/NorthAmerica/2010/WEM309, 2013. [Online; accessed 2013-05-17].

[56] Wikipedia. Altran. http://sv.wikipedia.org/wiki/Altran, 2013. [Online; accessed 2013-05-17].

[57] Wikipedia. Board support package. http://en.wikipedia.org/wiki/Board support package, 2013. [Online; accessed 2013-06-11].

[58] Wikipedia. Can bus. http://en.wikipedia.org/wiki/CAN bus, 2013. [Online; ac- cessed 2013-06-10].

[59] Wikipedia. Comparison of time tracking software. http://en.wikipedia.org/wiki/Comparison of time tracking software, 2013. [Online; accessed 2013-05-17].

[60] Wikipedia. Jumper (computing). http://en.wikipedia.org/wiki/Jumper (computing), 2013. [Online; accessed 2013-06-11].

[61] Wikipedia. Legacy system. https://en.wikipedia.org/wiki/Legacy system, 2013. [Online; accessed 2013-06-10].

[62] Wikipedia. Marshalling (computer science). http://en.wikipedia.org/wiki/Marshalling (computer science), 2013. [Online; accessed 2013-05-17].

[63] Wikipedia. Native (computing). http://en.wikipedia.org/wiki/Native (computing), 2013. [Online; accessed 2013-06-11]. 66 REFERENCES

[64] Wikipedia. Qseven. http://en.wikipedia.org/wiki/Qseven, 2013. [Online; accessed 2013-05-17].

[65] Wikipedia. Radio-frequency identification. http://en.wikipedia.org/wiki/Radio- frequency identification, 2013. [Online; accessed 2013-05-17].

[66] Wikipedia. Service-oriented architecture. http://en.wikipedia.org/wiki/Service- oriented architecture, 2013. [Online; accessed 2013-06-11].

[67] Wikipedia. System on a chip. http://en.wikipedia.org/wiki/System on a chip, 2013. [Online; accessed 2013-06-10].

[68] Wikipedia. Windows ce. http://en.wikipedia.org/wiki/Windows CE, 2013. [On- line; accessed 2013-05-17].

[69] Wikipedia. Windows embedded compact 7. http://en.wikipedia.org/wiki/Windows Embedded Compact 7, 2013. [Online; accessed 2013-05-17].

[70] Wikipedia. x86. http://en.wikipedia.org/wiki/X86, 2013. [Online; accessed 2013- 06-10].

[71] Wisegeek. What is managed code? http://www.wisegeek.com/what-is-a-managed- code.htm, 2013. [Online; accessed 2013-06-11]. Appendices

67

Appendix A

Definitions, acronyms and abbreviations

• aRFID - Active Radio Frequency Identification

• BSP - Board Support Package

• Codec - Compressor-decompressor

• CPU - Central Processing Unit

• CSV - Comma-Separated Value

• DLL - Dynamic Link-Library

• EF - Entity Framework

• GPIO - General Purpose Input/output

• GPU - Graphics Processing Unit

• GUI - Graphical User Interface

• IDE - Integrated Development Environment

69 70 APPENDIX A. DEFINITIONS, ACRONYMS AND ABBREVIATIONS

• JSON - JavaScript Object Notation

• KITL - Kernel Independent Transport Layer

• LCD - Liquid Crystal Display

• LED - Light-Emitting Diode

• LVDS - Low-Voltage Differential Signaling

• MXM - Mobile Express PCI Module

• OS - Operating System

• PC - Personal Computer

• PInvoke - Platform Invocation

• RAM - Random Access Memory

• RFID - Radio Frequency Identification

• SD - Secure Digital

• SOA - Service-oriented architecture

• SoC - System-on-Chip

• SQL - Structured Query Language

• URL - Uniform Resource Locator

• USB - Universal Serial Bus

• WYSIWYG - What You See Is What You Get

• WCF - Windows Communication Foundation 71

• WEC7 - Windows Embedded Compact 7

• X86 - Processor architecture (based on the Intel 8086 CPU)