You are on page 1of 29

Windows CE 6.

0 lab with SH7763RDP

Windows Embedded CE 6.0


Writing C# Managed Applications

Prepared
by
MPU Applications Group

To be presented at

DevCon 08
Renesas Developers Conference
San Diego, CA, USA
October 13-15, 2008
Version 1.0
Windows CE 6.0 lab with SH7763RDP

Table of Contents
Exercise 1 Creating a Platform Image .......................................... 3

1.1 Scenario................................................................................................................................ 3
1.2 Create a new OS Design ...................................................................................................... 3

Exercise 2 Customize and build the OS Design ........................... 9

2.1 Using the Catalog................................................................................................................. 9


2.2 Configure SH7763RDP Platform specifics ........................................................................ 10
2.3 Configure the OS Build Options ........................................................................................ 11
2.4 Build the OS Design........................................................................................................... 12
2.5 Open existing Project/Solution – Using pre-built OS image ............................................. 13

Exercise 3 Networking to EBoot & Downloading the OS Image . 14

3.1 Establish network connection ............................................................................................ 14


3.2 Set operating system deployment options.......................................................................... 17
3.3 Download and Boot the OS image ..................................................................................... 20

Exercise 4 Writing a Managed Application.................................. 22

4.1 Creating a C# Managed Application in VS 2005............................................................... 22

Exercise 5 Running the C# Application....................................... 27

5.1 Configuring the Target Device........................................................................................... 27

Summary..................................................................................... 29

2
Windows CE 6.0 lab with SH7763RDP

Exercise 1
Creating a Platform Image

1.1 Scenario
This lab uses Visual Studio 2005 Professional, Visual Studio 2005 SP1 and Windows Embedded CE 6.0.
You will be using Visual Studio 2005 (including Windows Embedded CE 6.0 Platform Builder) to create a
custom CE 6.0 operating system image.
During the first part of this lab you will use the New OS Design Wizard within Platform Builder to create an
initial OS Design which you will then modify by adding operating system features needed to support a C#
(or Visual Basic) managed application. Note that CE 6.0 ships with support for .NET Compact Framework
2.0 SP1 user interface based and headless applications.

1.2 Create a new OS Design

a. Start Visual Studio 2005 with Platform Builder either using the desktop shortcut , or
b. Start | All Programs | Microsoft Visual Studio 2005 | Microsoft Visual Studio 2005 (there may also
be a shortcut on the desktop)
c. Launch the Visual Studio 2005 New Project dialog.

• Select File | New… | Project…

d. Select the Platform Builder project type.


e. Choose the OS Design template
3
Windows CE 6.0 lab with SH7763RDP

f. Enter a name for your project, or go with the default name (highly recommended for this lab)
g. Click OK

The initial Dialog that is displayed below outlines the process of creating an OS Design. There are a
number of steps involved and you will step through the wizard and make selections as appropriate.

h. In the Welcome to the Windows Embedded CE 6.0 OS Design Wizard click Next.

You would next select a BSP (Board Support Package) associating to the SH7763RDP hardware
reference platform.

i. Select SH7763_RDP: SH4 as your target BSP


4
Windows CE 6.0 lab with SH7763RDP

j. Click Next

You are now given a number of Design Templates to choose from as the starting point for this project.
If none of the options match your needs you can simply select ‘Custom Device’ and build the image
based on the components you select from the catalog.
For the purposes of this tutorial you will be using the Industrial Device template.

k. Select Industrial Device from the list of Design Templates


l. Click Next

The Wizard now gives you the option of choosing a variant of the Design Template. For this tutorial
you will be using the Internet Appliance variant.

5
Windows CE 6.0 lab with SH7763RDP

m. Select Internet Appliance from the list of Design Template Variants


n. Click Next

You can use the Internet Appliance design template as a starting point for an Internet appliance. An
Internet appliance usually is a non-mobile, browser-based device.

As a fixed device, an Internet appliance supports a mouse and keyboard design that uses a CRT or LCD
display. This design template also supports the Windows Embedded CE Standard Shell and applications
that you can customize or substitute for a browser-based user interface (UI). On the other hand, it would
not make sense to include Internet Explorer or WordPad in a headless device such as a Residential
Gateway.

Use the Windows Embedded CE OS Design Wizard in Platform Builder to create a starting point for an
Internet appliance, and then customize the operating system (OS) design to fit your needs. The Catalog
items that you use to configure your OS design can vary.

In this case we do need the .NET Compact Framework (Until we’re ready, we could have deselected
it and enabled Visual Studio 2005 to download the Compact Framework files to the running CE 6.0 OS
image to debug managed or native applications) – for a production device you would of course include
the .NET Compact Framework 2.0 component and your managed application in the operating system
image). Select this item accordingly.

o. Make sure your Applications and Media select items match the picture above
p. Click Next

Next comes networking and communications, you can see that Windows CE provides support for
Personal, local, and wide area networking through technologies such as Bluetooth, IrDA, Wired and
Wireless networking, and VPN.
For components we did not select, we could choose to add these components back into the operating
system later using the catalog.

6
Windows CE 6.0 lab with SH7763RDP

q. Use default Networking and Communications select items as shown above


r. Click Next

We’re done! – The wizard is complete. You’ve configured the OS Design and can now further
customize it by adding and/or removing components from the Catalog.

s. Click Finish

The Wizard will now prompt you with any security warnings or other notifications related to the
components you selected. Acknowledge these notifications (note that you could search the catalog for the
NDIS User-mode I/O Protocol Driver component and remove this from your operating system design, or

7
Windows CE 6.0 lab with SH7763RDP

read the documentation links provided on the NDISUIO Warning dialog to ensure that you understand the
security implications of including this component).

t. Click Acknowledge

At this point you have an OS Design containing all of the OS components which have been selected
from the Wizard. In the next section we will further customize the OS Design using the Catalog.

8
Windows CE 6.0 lab with SH7763RDP

Exercise 2
Customize and build the OS Design
2.1 Using the Catalog
You will now make changes to the items included in your OS Design using the Catalog View. As
example, we will add necessary components for the target board USB host connector to recognize device
of USB storage class. i.e. the USB flash drive.
First, ensure that the Catalog View is visible.
a. Select the View menu
b. Choose Other Windows | Catalog Items View

There are a couple of ways you can locate features in the catalog, you can either browse the catalog
and locate the feature you’re interested in manually (for example you may know that the .NET Compact
Framework 2.0 component lives in the Core OS | CEBASE | Core OS Services | USB Host Support | USB
Storage Class Driver node of the catalog), alternatively you can use the catalog search feature to locate
the component you are interested in. You want to ensure that USB Storage Class Driver is included in the
run-time image that you build you can search for “Storage Class” in the catalog to locate the appropriate
catalog item.
c. Type storage class in the catalog items search box
d. Hit Enter to search
e. Check the box next to the USB Storage Class Driver item to include it in your OS Design

9
Windows CE 6.0 lab with SH7763RDP

f. Type fat in the catalog items search box


g. Hit Enter to search
h. Check the box next to the FAT File System item to include it in your OS Design

2.2 Configure SH7763RDP Platform specifics


Under the Catalog Items View window, there is a BSP device driver specific group of items under
Third Party | BSP | SH7763_RDP: SH4 | Device Drivers need further customization depending on
user’s choice of OS Design Template. For this lab, we want to check the display driver component as
follows. Other device drivers like Audio and USB Host are being selected automatically as dependencies
of the choice of OS Design Template.
a. Type SH7763 LCD in the catalog items search box
b. Hit Enter to search
c. Expand Device Drivers | Display and check the box next to the SH7763 LCDC Display - GPE item to
include it in your OS Design

10
Windows CE 6.0 lab with SH7763RDP

Since the SH7763RDP platform supports two types of display – LCD panel in WVGA mode and
CRT/LCD monitor in VGA mode. As part of OS design customization, users must make sure the right
display registry file is included in the build. For convenience in this lab we will choose the CRT monitor.
Due to the fact that by default the display driver registry file is set to support the LCD Panel, users must
modify an existing SH7397LCDC.reg file to change its setting to support the CRT monitor. The file can be
found under C:\WINCE600\PLATFORM\SH7763_RDP\Src\Drivers\Display\Sh7763lcdc.

Specifically for this lab, instead of modifying the SH7397LCDC.reg file from its default LCD to CRT
configuration, we’ve done the modification before hand. The user just needs to copy the modified registry
file over existing one.
d. Open a Windows File Explorer and navigate to the
C:\WINCE600\PLATFORM\SH7763_RDP\Src\Drivers\Display\Sh7763lcdc folder to find
1. The file to be replaced - SH7397LCDC.reg (by default, this supports 800 x 600 LCD panel)
2. File that supports CRT/LCD monitor – SH7397LCDC_CRT.reg
e. Rename the file SH7397LCDC.reg to SH7397LCDC_original.reg
f. Rename the file SH7397LCDC_CRT.reg to SH7397LCDC.reg

2.3 Configure the OS Build Options


The default build option is to build a Debug operating system image, for the purposes of this lab we’re
not interested in debugging the operating system, but are more interested in writing, deploying, and
debugging C# applications from Visual Studio 2005 – you can change the build option from debug to
release – the operating system image will boot faster as a release build since the amount of debugging
information will be reduced.
a. Locate the build option combo box on the Visual Studio Toolbar (see image below)
b. Drop down the combo box and change the build option to SH7763_RDP SH4 Release

11
Windows CE 6.0 lab with SH7763RDP

You can also configure other operating system options through the Project | Properties menu.
c. Select Project | OSDesign1 Properties toward the bottom of pull down menu, or alt+F7

This will display the project properties dialog – for CE 6.0 this allows you to change general settings
(location of the build release folder, release type, and output filename), Locale, Build Options,
Environment Variables and more.
d. Expand Configuration Properties and make sure SH7763_RDP SH4 Release is configured as active
in the Configuration selection menu at upper left corner
e. Select the Build Options node

f. Click OK to close the Property Pages dialog

2.4 Build the OS Design


At this point, you would be all ready to build your OS Design. You now have two options, either build
the operating system (this could take more than 20+ minutes to complete depending on computer speed)
or move onto the next step in the lab using a pre-built operating system image.
a. To build the operating system (Not recommended for this lab) Select Build | Build Solution – note
that this could take more than 20 - 30 minutes to complete.

12
Windows CE 6.0 lab with SH7763RDP

No need to save your work up to this point because we’ll be using pre-built image instead

2.5 Open existing Project/Solution – Using pre-built OS image


a. To open an existing Platform Builder Workspace: Select File | Open | Project/Solution…
b. Browse for and open the Solution: C:\Wince600\OSDesigns\OSDesign-DevCon
c. Select Yes to save changes if you wish.

No need to save your work up to this point because we’ll be using pre-built image instead.
The prebuilt Solution you have opened contains everything you have done so far:

13
Windows CE 6.0 lab with SH7763RDP

Exercise 3
Networking to EBoot & Downloading the OS Image
You are now ready to download the CE 6.0 operating system image to the target. Before anything,
user must first establish network connection from host PC where Visual Studio 2005 is installed to the
target device (SH7763RDP platform) running Eboot loader which is pre-loaded to the flash memory of the
target device. At power up or reset, Eboot message will appear on Terminal Emulator awaiting the user to
enter boot up options such as burning target OS image to flash then boot, download target OS image to
SDRAM then boot or boot directly from existing OS image in flash memory.

3.1 Establish network connection


The following exercise attempts to establish standalone network connection from host PC to target
device. First of all, here is how the lab system configuration looks like. You would have to do anything
extra because all the cables are pre-installed for the purpose of this lab.

Mouse
Keyboard
USB Flash Drive

USB Hub

Audio
RESET
Host PC loaded Speakers
with VS 2005 USB2.0
and PB 6.0
Ethernet Cable
192.168.1.100 192.168.1.101
LCD
Monitor
RS232 Null Modem Serial Cable

Make sure you find the location of the RESET push button

First of all, we’ll configure the host PC with a fix IP address 192.168.1.100
a. Right click on the My Network Places icon on the desktop of the host PC then select Properties
b. Right click on the Local Area Connection icon of the host PC Ethernet port that connects to target
device. Once the Local Area Connection Properties window appears, scroll all the way to the bottom to
highlight Internet Protocol (TCP/IP)

14
Windows CE 6.0 lab with SH7763RDP

c. Change the properties of highlighted Internet Protocol (TCP/IP) by clicking on Properties. The
subsequent window should pop up for IP address settings.
d. Configure the host for a fixed IP address 192.168.1.100 with subnet mask 255.255.255.0 as follows

e. Select OK to save changes and exit.

15
Windows CE 6.0 lab with SH7763RDP

We are now ready to power up the target device to establish Ethernet connection to the Host PC.
After powering up the target board, Eboot loader message will appear on the Terminal Emulator via serial
debug port. We use Tera Term for this lab as Terminal Emulator pre-configured to 115200/8/N/1/N

f. Launch Tera Term application. Find the corresponding shortcut icon on desktop
g. Power up SH7763RDP target device. If already powered up, hit the reset bottom instead.

With the above message appear on Tera Term, Eboot loader is up and running with 3 options given to
users. User makes choice by entering the first letter of each option from the host PC. More detail about
each option is explained as below.
• (D) Burning OS image to flash then boot
• (E) Download OS image to SDRAM then boot
• (F) Boot directly from existing OS image in flash memory

16
Windows CE 6.0 lab with SH7763RDP

For this lab, we would choose “E” to download the OS image and boot from SDRAM.
h. on host PC respond the Eboot with choice (E) by entering e
i. As instructed hit ENTER within 5 seconds to enter static IP
j. Enter the target device static IP address to 192.168.1.101 then hit Enter
k. Enter the target device subnet mask to 255.255.255.0 then hit Enter

Resulting from above steps, Eboot loader should start outputting Sent BOOTME to 255.255.255.255
periodically like every 4 seconds for the next 2.5 minutes. This is the window of time when target device is
waiting for the TFTP on host PC to initiate OS image download command.

Make a note of your device name as shown on the message. The device name is a unique name of
the target device to be recognized later on by host PC target connectivity configuration. As highlighted
above, SEQ260 illustrates the unique device name where 260 is decimal representation of the least
significant two words of target device MAC address.

In the event that you miss the 2.5 minutes window of opportunity (indicated by stop outputting Sent
BOOTME to 255.255.255.255 message on serial port), initiating OS image download will not work as
expected. You should reset the target device then re-enter the static IP address to start over.

Now, let’s move back to Visual Studio to initiate OS image download and boot.

3.2 Set operating system deployment options


For this lab you will be deploying your CE 6.0 operating system to the target device - SH7763RDP
platform via Ethernet transport. This required user to setup Target Device Connectivity Options for
Download and Transport settings.

17
Windows CE 6.0 lab with SH7763RDP

a. Select Target | Connectivity Options

There are a number of options that can be set on the Target Device Connectivity Dialog – this
includes the download/debug transport which could be Ethernet, Serial, Device Emulator (DMA), Image
Update, USB or None – To connect to the SH7763RDP platform we will be using Ethernet option.

In case you don’t see the Target Device Connectivity Option window pops up, look for it under the tool
bar where it may hide.
• Confirm you have Ethernet selected for Download
• Confirm you have Ethernet selected for Transport
b. Click the Download Settings button (highlighted below).

While the target device is outputting Sent BOOTME to 255.255.255.255 message on terminal emulator,
c. click Settings displays the following dialog.

What appears on the Active Target devices window, in this case SEQ 260, is your unique target
device name. It should match the note you took earlier when entering the static IP address under Eboot.
Under the Target device boot name block, the system keeps a list of target device names which
displaying the most recent device connected.

18
Windows CE 6.0 lab with SH7763RDP

d. Click on the device name within the Active target devices window to move it under the Target device
boot name block.
e. Click OK to close the Ethernet Download Setting window

19
Windows CE 6.0 lab with SH7763RDP

You should see your target device name ready to be activated. Once activated, Ethernet connection
between the host PC (192.168.1.100) and target device (192.168.1.101) will be established.
f. click Apply then close the Target Device Connectivity Option window above

You are now ready to download the CE 6.0 operating system image.

First timer users may very well take more than 2.5 minutes from “Sent BOOTME to 255.255.255.255
message” starts outputting on debug serial port. Check to see if your serial port continues to send
BOOTME message. If not, next step (OS image download) would not work as expected. You must reset
the target device then re-enter the static IP address to start over.

3.3 Download and Boot the OS image


a. On Visual Studio select Target | Attach Device.

You should see download kicks off. In most cases the window below may not show up automatically,
it is likely hidden in your tool bar grouped with Visual Studio instead.

20
Windows CE 6.0 lab with SH7763RDP

About 30 -40 seconds after download completes, the following window should appear on your CRT
monitor to indicated a success boot of OS image.

b. Close the download window as it finishes.

21
Windows CE 6.0 lab with SH7763RDP

Exercise 4
Writing a Managed Application

4.1 Creating a C# Managed Application in VS 2005


You are now ready to write and deploy a C# managed application.
a. Minimize (don’t close) the current instance of Visual Studio/Platform Builder
b. Start a new instance of Visual Studio 2005 – you will use the new instance of Visual Studio 2005 to
write and deploy your managed application.
c. Within Visual Studio 2005 select File | New | Project

d. Select Project type: Other Languages | Visual C# | Smart Device | Windows CE 5.0

Note that you are selecting a Windows CE 5.0 project type and deploying the application to a CE 6.0
device.
e. Change the Project name to something appropriate or leave the default name
f. Click OK to create the Smart Device application.

By default the C# application form is created at 640x480 pixels, the emulator image you have
created/booted is running at 320x240, we need to adjust the form size.
g. Right click on the form within Visual Studio
22
Windows CE 6.0 lab with SH7763RDP

h. Select Properties – this will display the forms properties in the bottom right of the Visual Studio UI.

i. Scroll the Properties window to locate the Size item


j. Set the form size to 320x240 (see below)

The Visual Studio application wizard automatically adds a mainMenu to the application, this appears
to be invisible on the form, but if you add controls close to the top left of the form then your controls would
be overwritten by the mainMenu. See the image below that shows where the mainMenu would be
displayed.

23
Windows CE 6.0 lab with SH7763RDP

To stop the mainMenu overwriting any controls you put onto the form we can simply delete the
mainMenu control. Just below the form designer you have the Component Tray, an area set aside for
controls you’ve added to the form that typically don’t have UI – you will see mainMenu1 displayed.
k. Right Click on mainMenu1
l. On the popup menu select Delete – this will delete the forms mainMenu.

You are now ready to populate the form by adding controls from the Toolbox.

m. Click on the toolbox shortcut icon (upper right side of the screen) – this will display the Toolbox.

n. Click (and hold) a Button control and drag onto your form

24
Windows CE 6.0 lab with SH7763RDP

o. Repeat this process with a textBox control. Drag a TextBox control onto your form
p. [Optional] – feel free to set the button/textBox controls positions and size on the form.
q. [Optional] – you can also use the properties panel (bottom right of Visual Studio 2005) to set the name
and default text of the Button and textBox.

In the example below the Button and textBox text have been set to Tahoma 18pt, and we will change
the Button text to Click Me !
r. Right mouse click on the Botton on your application, select Properties. Then, go to the Property panel
on the lower right of your screen to change the botton text from button1 to Click Me !

Now you are ready to add code behind the button.


s. Double click on the Button you added to the form – this will take you into a Code View within Visual
Studio 2005 (see below).

25
Windows CE 6.0 lab with SH7763RDP

Visual Studio has created a button_click handler for your button and has opened the code editor at
the right place for you to add your code.
t. Add the following code to the button_click handler textBox1.Text=”Cool Tools!”;

u. Press Function Key 7 (F7) to build the application

Upon successful build, you should find the executable output file DeviceApplication2.exe under
..\My Documents\Visual Studio 2005\Projects\DeviceApplication2\DeviceApplication2\bin\Debug

26
Windows CE 6.0 lab with SH7763RDP

Exercise 5
Running the C# Application
5.1 Configuring the Target Device
Before launching the application using Target Control, you must first copy the DeviceApplication2.exe
to the release directory.
a. Locate the file
..\My Documents\Visual Studio
2005\Projects\DeviceApplication2\DeviceApplication2\bin\Debug\DeviceApplication2
and copy it to
C:\WINCE600\OSDesigns\OSDesign-DevCon\OSDesign-DevCon\RelDir\SH7763_RDP_SH4_Release

Use the start command within Target Control to start the application
b. Back to Visual Studio of your OSDesign: Open Target | Target Control
c. Type: gi proc (this will list all processes currently running in the system)
d. Type: s DeviceApplication2 (this will start the DeviceApplication2 application)

You can verify that the application is running using a command within the Target Control Window.
e. Type: gi proc (you should see the DeviceApplication2 application being added to the list)

You can see that there are 9 processes running on the SH7763RDP platform, this includes five
instances of udevice.exe – the user mode device driver manager, and also included in the list are
NK.EXE and shell.exe.

Once the application is started you should find the image below appear on the target device.

27
Windows CE 6.0 lab with SH7763RDP

f. Click the applications “Click Me” button


g. Confirm that the textBox shows the appropriate content

Congratulations! You’ve completed the lab.

28
Windows CE 6.0 lab with SH7763RDP

Summary
You have now completed all the steps in this guide. Here’s what we have covered:
• Created an OS Design
• Customized the OS Design by components needed to support Visual Studio application
development
• Built an OS image
• Downloaded an operating system to the target device
• Used Target Control to launch applications on the device
• Deployed and run a C# .NET Compact Framework application

Acknowledgement:
This lab material is derived from Microsoft® Windows Embedded Virtual
Labs modified specifically for SH7763RDP platform

29

You might also like