getting started with t-kernel 2/x86getting started with t-kernel 2/x86 c 2008–2012 personal media...

60
Getting Started with T-Kernel 2/x86 Version 2.0.1 Personal Media Corporation Copyright c 2008–2012 by Personal Media Corporation

Upload: others

Post on 27-Jun-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

Getting Started with T-Kernel 2/x86

Version 2.0.1

Personal Media Corporation

Copyright c© 2008–2012 by Personal Media Corporation

Page 2: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

CONTENTS 2

Contents

History of Changes 3

Introduction 4

1 Installing Target 51.1 Real and Virtual Environments . . . . . . . . . . . . . . . . . . . . . . . . . 51.2 Installing VMware Player . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.3 Installing VMwareGateway . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.4 Installing T-Kernel 2/x86 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2 Installing Development Environment 212.1 Installing Cygwin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.2 Installing Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242.3 Installing T-Kernel Development Environment . . . . . . . . . . . . . . . . . 25

3 Development 323.1 Starting Target and Development Environment . . . . . . . . . . . . . . . . 323.2 Console Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333.3 Process-Based and T-Kernel-Based Programs . . . . . . . . . . . . . . . . . 353.4 ”Hello, world” as a Process-Based Program . . . . . . . . . . . . . . . . . . . 373.5 ”Hello, world” as a T-Kernel-Based Program . . . . . . . . . . . . . . . . . . 41

4 Running the Sample Programs 444.1 Juggling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444.2 Tiny Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494.3 Time-in-microseconds Sample . . . . . . . . . . . . . . . . . . . . . . . . . . 534.4 Physical Timer Sample Implementation . . . . . . . . . . . . . . . . . . . . . 55

Index 58

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 3: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

HISTORY 3

History of Changes

Version 2.0.1

• Modify “1. Installing Target” by updating target-side environment.

• Modify “2. Installing Development Environment” by updating development en-vironment.

Version 2.0.0

• First edition for T-Kernel 2/x86 Evaluation Kit.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 4: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

INTRODUCTION 4

Introduction

This document provides a tutorial on starting out with T-Kernel 2/x86 Evaluation Kit, forthose using this product for the first time.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 5: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 5

1 Installing Target

1.1 Real and Virtual Environments

In this section we’ll install the target-side environment (OS, drivers and middleware).

In general on developing embedded systems, the development environment is apart fromthe execution target. This style is called “cross development”. A typical “real developmentenvironment” is shown in Figure 1.1, which supports T-Kernel 2/x86 Evaluation Kit. Inaddition, T-Kernel 2/x86 also supports another type of development environment, namely“virtual environment” as shown in Figure 1.2, where the target-side runs on VMware.

PC (for development)

Eclipse -

Compiler

Debugger

Terminal

� -serial

Target (for execution)

Applications

Drivers, middleware

T-Kernel 2/x86

Figure 1.1 Real Environment

PC (both for development and execution)

Eclipse -

Compiler

Debugger

Terminal

� -redirect

VMware

Applications

Drivers, middleware

T-Kernel 2/x86

Figure 1.2 Virtual Environment

The end product of embedded systems should be on the real target machine in almostcases. Virtual environment is, however, also useful in software development phases, because:

• Only one PC is required in software development phases.

• One can start software development even when the target machine hardware is not yetdeveloped.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 6: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 6

If you prefer virtual environment, follow sections “1.2 Installing VMware Player”, “1.3Installing VMwareGateway” and “1.4 Installing T-Kernel/x86”.

On the other hand, if you prefer real environment, VMware Player and VMwareGatewayare not required. Skip these sections and go to “1.4 Installing T-Kernel/x86”.

Before installation please also refer to “T-Kernel 2/x86 Evaluation Kit Manual” con-tained in the T-Kernel 2/x86 Evaluation Kit CD-ROM, and look at “1.2 Hardware Require-ments” to see that your machine conforms to the hardware requirements.

1.2 Installing VMware Player

VMware Player is required to run T-Kernel 2/x86 on virtual environment.

(1) Start Installer

Start “VMware-player-3.1.6-744570.exe” on the common software folder “common\soft”in the T-Kernel 2/x86 Evaluation Kit CD-ROM.

† The version number in the file name may be different.

† If you want to install other version of VMware Player instead of that in the T-Kernel2/x86 Evaluation Kit CD-ROM, please download suitable version for your host PC fromthe following website:

http://www.vmware.com/

After a moment the Next button becomes enabled. Then click on this button. (Figure1.3)

Figure 1.3 Start dialog of VMware Player Installer

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 7: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 7

(2) Select Install Folder

Select install folder. No needs to change the default folder. Click on Next .

(3) Make Shortcut

No needs to change the default.Just click on Next .

(4) Start Installation

Click on Continue to start installation, and wait for completion.

(5) Installation Completed

After completion, click on Restart Now or Restart Later and restart Windows.

1.3 Installing VMwareGateway

In case of real environment, RS-232C (serial connection) is used to connect console betweenthe host PC and the target machine. In case of virtual environment, instead, socket connec-tion is used. To use this socket connection, VMwareGateway is required. It is installed as a“service” on Windows.

For details please also refer to “VMware Support Tool Install Manual” contained in theT-Kernel 2/x86 Evaluation Kit CD-ROM.

(1) Make Install Folder

Create “utilities” folder under “C:\Program Files\VMware”.

(2) Copy Executable File

Copy “vmwaregateway.exe” from the common software folder“common\soft” to “C:\Program Files\VMware\utilities”.

(3) Register VMwareGateway Service

Run “Command Prompt” of Windows.

† In cases of Windows 8, 7 and Vista, run Command Prompt as an administrator byright-click menu.

And execute“C:\Program Files\VMware\utilities\vmwaregateway.exe” with “/r” option. Notethat the path name must be quoted by "· · ·", because the path includes spaces. (Figure1.4)

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 8: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 8

C:\Documents and Settings\admin> "C:\Program Files\VMware\

utilities\vmwaregateway.exe" /r ←↩Create VMWare Gateway Service for executable C:\Program Fi

les\VMware\utilities\vmwaregateway.exe

CreateService SUCCESS

C:\Documents and Settings\admin> exit ←↩

Figure 1.4 Register VMwareGataway Service

(4) Start VMwareGateway Service

Open “Services”.

† Windows 8 and 7 : “Control Panel” → “System and Security” → “AdministrativeTools” → “Services”Windows Vista : “Control Panel” → “System and Maintenance” → “AdministrativeTools” → “Services”Windows XP : “Control Panel”→ “Performance and Maintenance”→ “AdministrativeTools” → “Services”

Select “VMwareGateway” in the list of services, and select “Start” of right-click menu.(Figure 1.5)

Figure 1.5 Start VMwareGateway Service

(5) Automatic Start VMwareGateway

Select “VMwareGateway”, and open its property by right-click menu. Set “Startuptype” to “Automatic”. (Figure 1.6)

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 9: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 9

Figure 1.6 Automatic Start VMwareGateway

This completes the installation of VMwareGateway.

1.4 Installing T-Kernel 2/x86

Install T-Kernel 2/x86 on virtual environment (VMware) or a real target machine. Fordetails please also refer to “T-Kernel 2/x86 Evaluation Kit Manual” at “2. Target-sideSoftware Installation”.

For this installation a terminal software is required, such as “HyperTerminal” and “TeraTerm Pro”.

† In cases of Windows 8, 7 and Vista, where HyperTerminal is not included, please download“Tera Term Pro (version 2.3)” from the following website:

http://hp.vector.co.jp/authors/VA002416/teraterm.html

(1) Copy Virtual Machine (required only in case of virtual environment)

• In case of virtual environment (VMware) :

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 10: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 10

Copy the virtual machine folder “tkx86_vm” from the “jp” folder of T-Kernel2/x86 Evaluation Kit CD-ROM to the “My Virtual Machines” folder in “MyDocuments”.

† If there is no “My Virtual Machines” folder in “My Documents”, please create it.

• In case of real environment :

No needs to copy.

(2) Start Terminal Software

• In case of Tera Term Pro :

Start Tera Term Pro.

• In case of HyperTerminal :

Start “HyperTerminal” (by clicking on “Start button” → “All Programs” →“Accessories” → “Communications” → “HyperTerminal”).

† You may be asked about “Default Telnet Program”, but it is not significant. Phonenumber is also not significant, because no telephone call is used actually.

Enter any name and select any icon, and click on OK . (Figure 1.7)

Figure 1.7 Start HyperTerminal

(3) Select Connection Type

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 11: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 11

• In case of virtual environment (VMware) :

Use telnet connection by VMwareGateway. Connect to the host “localhost”and port number 567.

• In case of Tera Term Pro :Select “File” → “New connection”. On the new connection dialog, check“TCP/IP”, enter “localhost” as host, check “Telnet”, and enter “567” asTCP port#. (Figure 1.8)

Figure 1.8 Telnet Connection by Tera Term Pro

• In case of HyperTerminal :Select “TCP/IP (Winsock)TCP/IP”, enter “localhost” as host address, and

enter “567” as port number. Click on OK . (Figure 1.9)

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 12: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 12

Figure 1.9 Telnet Connection by HyperTerminal

• In case of real environment :

Connect your host PC and the target machine by serial connection (RS-232C).Select serial port of the host PC (COM1 etc.), and set the communication pa-rameters as follows:

Speed 115200 bpsData bits 8 bitsParity noneStop bits 1 bitFlow control hardware

(4) Boot target from CD-ROM

• In case of virtual environment (VMware) :

Insert T-Kernel 2/x86 Evaluation Kit CD-ROM to the CD-ROM drive of yourPC.

Run the virtual machine “T-Kernel_x86.vmx” in”My Documents\My Virtual Machines\tkx86_vm”.

VMware Player’s window is opened, but then appears a message “Operating Sys-tem not found”. It is because the CD-ROM drive is not yet connected to thevirtual machine. Then click on “CD/DVD(IDE)” icon on the bottom side of the

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 13: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 13

VMware Player’s window (or VMWare Player’s toolbar → “Virtual Machine” →“Removable Devices” → “CD/DVD(IDE)”) and select “connect”. (Figure 1.10)

Figure 1.10 Connect CD-ROM drive to VMware Player

† Even if you use USB-connected CD/DVD drive, you have to select “CD/DVD(IDE)”instead of USB device.

Click on VMware Player’s window to erase the mouse cursor arrow.

Push Ctrl + Alt + Insert to reboot the virtual machine from the CD-ROM.

• In case of real environment :

Insert T-Kernel 2/x86 Evaluation Kit CD-ROM to the CD-ROM drive of thetarget machine, and boot from the CD-ROM.

† Check BIOS settings to enable CD-ROM booting.

(5) Confirming Prompt

The target machine’s display (VMware Player’s window in case of virtual environment,or video display in case of real target machine) shows a T-Kernel logo graphic and thena console screen.

On the other hand, the terminal software of the host PC shows the CLI prompt“[/SYS]%” by entering ←↩(Enter) key. (Figure 1.11)

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 14: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 14

Figure 1.11 Prompt showed on Terminal Software

† The console screen on the target machine’s display also shows the CLI prompt, and youcan use it. But it is recommended to do the installation process below on the terminalsoftware of the host PC, instead of the target machine’s display.

(6) Making a Partition

Run hdpart command from the terminal software, create partition and set boot par-tition on the disk. The device name is “hda”, which means the whole disk.

[/SYS]% hdpart -m1 hda ←↩ — Run hdpart commandhda [C:1017 H:255 S:63 B:16357785 (7987 MB)]No System Boot StartCHS EndCHS SecNo SecCnt Size1 00 ------ 00 0: 0: 0 0: 0: 0 0 0 0 KB2 00 ------ 00 0: 0: 0 0: 0: 0 0 0 0 KB3 00 ------ 00 0: 0: 0 0: 0: 0 0 0 0 KB4 00 ------ 00 0: 0: 0 0: 0: 0 0 0 0 KB** Create/Delete/Boot/Edit/Quit ? c ←↩ — Create partitionCreate PartNo (1-4) ? 1 ←↩ — 1st partitionSize [GB/MB/KB,All] (<7987MB) ? a ←↩ — AllNo System Boot StartCHS EndCHS SecNo SecCnt Size1 13 BTRON 00 0: 1: 1 1018: 57:24 63 16357722 7987 MB2 00 ------ 00 0: 0: 0 0: 0: 0 0 0 0 KB3 00 ------ 00 0: 0: 0 0: 0: 0 0 0 0 KB4 00 ------ 00 0: 0: 0 0: 0: 0 0 0 0 KB** Create/Delete/Boot/Edit/Update/Quit ? b ←↩ — BootBoot PartNo (1-4,Clear) ? 1 ←↩ — 1st partitionNo System Boot StartCHS EndCHS SecNo SecCnt Size

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 15: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 15

1 13 BTRON 80 0: 1: 1 1018: 57:24 63 16357722 7987 MB2 00 ------ 00 0: 0: 0 0: 0: 0 0 0 0 KB3 00 ------ 00 0: 0: 0 0: 0: 0 0 0 0 KB4 00 ------ 00 0: 0: 0 0: 0: 0 0 0 0 KB** Create/Delete/Boot/Edit/Update/Quit ? u ←↩ — Update** hda: Updated Master Boot Block

[/SYS]%

† If you want to install T-Kernel 2/x86 Evaluation Kit to an existing partition, delete itby “d” (=delete) and create it again by “c” (=create).

† If you want to version-up from the previous product (T-Kernel/x86 Evaluation Kit),please also delete the partition of the previous product, create a new partition, andthen install the new product.

(7) Format

Format the created partition by formatsys command from the terminal software.Device name is “hda0” for 1st partition, “hda1” for 2nd partition, and so on. And“-b” option (write boot record) is required. Also “-x” option is usually required.

[/SYS]% formatsys -b -x hda0 SYSTEM ←↩ — Run formatsys commandFormat pcb0 [STD] SYSTEMLogical Formatting...Writing BootCode...Disk Format Success..ATYPE ATR NREC NREF SIZE BLK MTIME NAME0003 ----- 1 0 1 35812 10 121103 16:23:39 SBOOT0003 ----- 1 0 1 242847 61 121103 16:23:40 KERNEL.SYS0003 ----- 1 0 1 109984 28 121103 16:23:40 KDRIVER0003 ----- 1 0 1 4799 3 121103 16:23:40 SYSCONF0003 ----- 1 0 1 1479 2 121103 16:23:40 DEVCONF[/SYS]%

† You must use formatsys command here (NOT format command).

† Date and time of each files are current time at installation.

(8) Attach Target Disk

Attach the target disk, which is formatted in the last step.

[/SYS]% att hda0 HD ←↩ — Attach diskhda0 -> HD

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 16: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 16

[/SYS]% cd /HD ←↩ — Change current directory[/HD]% ls -l ←↩ — List of filesATYPE ATR NREC NREF SIZE BLK MTIME NAME0003 ----- 1 0 1 35812 10 121103 16:23:39 SBOOT0003 ----- 1 0 1 242847 61 121103 16:23:40 KERNEL.SYS0003 ----- 1 0 1 109984 28 121103 16:23:40 KDRIVER0003 ----- 1 0 1 4799 3 121103 16:23:40 SYSCONF0003 ----- 1 0 1 1479 2 121103 16:23:40 DEVCONF

[Trouble Shooting] If there are no files on /HD, it means that your installationprocess was not correct. Please change directory by “cd /SYS”, detach the diskby “det hda0”, and do the installation process again.

(9) Attach CD-ROM

Use df command to check the device name of CD-ROM, which contains the installdata. For example, if /SYS is hdc2, the install data is contained in its #0 partition,namely hdc0. Then attach it.

[/HD]% df ←↩ — Disk statusPATH DEV TOTAL FREE USED UNIT MAXFILE NAME

/SYS hdc2 3100 22 99% 1024 256 PM:TK2-x86

/HD hda0 8178860 8176304 0% 4096 65535 SYSTEM

[/HD]% att -c hdc0 CD ←↩ — Attach CD-ROMhdc0 -> CD (ReadOnly)

(10) Installing the Basic System

Expand and run the basic system installer.

[/HD]% expf -U /CD/EN/SOFT/INSTALL.BZ ←↩ — Expand archive[/HD]% install /HD ←↩ — Run installerBasic system installation completed.

[/HD]% rm -r install ←↩ — Remove installer

(11) Installing PMC T-Shell

Expand and run the T-Shell installer.

[/HD]% expf -U /CD/EN/SOFT/TSHELL.BZ ←↩ — Expand archive[/HD]% install_tshell /HD ←↩ — Run installerInstall completed, please reboot the system.

[/HD]% rm -r install_tshell ←↩ — Remove installer

Do not reboot the system now before installing the English patch in the next step.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 17: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 17

(12) Installing the English Patch

Expand and run the English patch. This patch translates T-Shell GUI applications toEnglish.

[/HD]% expf -U /CD/EN/SOFT/ENGLISH.BZ ←↩ — Expand archive[/HD]% english /HD ←↩ — Run installer.. Installing English Patch on /HD

.. Install completed

[/HD]% rm -r english ←↩ — Remove installer

(13) Reboot T-Kernel 2/x86

Use exit command to shutdown the target.

[/HD]% exit ←↩ — Exit CLI<< EXIT cli >>

[IMS]% exit

<< SYSTEM SHUTDOWN >>

Then eject T-Kernel 2/x86 Evaluation Kit CD-ROM, and reboot the target.

• In case of virtual environment (VMware) :

Run the virtual machine “T-Kernel_x86.vmx” in”My Documents\My Virtual Machines\tkx86_vm”. It is recommended to createits shortcut for later use.

• In case of real environment :

Supply power again to the target machine to reboot.

The display of the target machine (or VMware Player’s window in case of virtualenvironment) shows an initial window on PMC T-Shell. (Figure 1.12)

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 18: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 18

Figure 1.12 An initial window on PMC T-Shell

The terminal software of the host PC shows booting messages of T-Kernel 2/x86, anda prompt “[/SYS]%”.

Use df command to check the device name of the boot disk (/SYS).

[/SYS]% df ←↩ — Check device namePATH DEV TOTAL FREE USED UNIT MAXFILE NAME

/SYS hda0 265040 239752 9% 4096 22528 SYSTEM

(14) Screen Size and Colors

The default screen resolution is XGA (1024 × 768), 65536 colors. You can change itby VIDEOMODE entry of device configuration file.

[/SYS]% devconf VIDEOMODE 2 ←↩ — 640× 480, 65536 colors+ 0: VIDEOMODE 2

[/SYS]% exit ←↩ — Exit CLI<< EXIT cli >>

[IMS]% exit 1

[IMS]% exit -3 ←↩ — System reboot<< SYSTEM REBOOT >>

† Refer to “T-Kernel 2/x86 Implementation Specification” at “4.6 Screen (Display) Driver”for correspondence between screen modes and VIDEOMODE values.

† Instead of devconf command, System Setup Utility is also available. Select Right-click→ “Utility” → “System Setup” → “Screen size/Color” to change screen mode. Thechange becomes valid after system reboot.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 19: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 19

(15) Additional Font Installation

The “common\font” folder of the T-Kernel 2/x86 Evaluation Kit CD-ROM containsmany additional fonts, including several English fonts, as well as large sets of Chi-nese/Japanese/Korean ideographs.

The following install files are for English fonts:

File Name Font NameSSAVALON SSAvalonSSCOURIE SSCourierSSEUROMD SSEuromodeSSHELVET SSHelveticaSSHELVTN SSHelveticaNSSTIMES SSTimes

At least SSHelvetica is recommended to be installed, since T-Shell GUI applicationsassume it.

Insert T-Kernel 2/x86 Evaluation Kit CD-ROM to the CD-ROM drive of the targetmachine. In case of virtual environment (VMware), click on “CD/DVD(IDE)” icon onthe bottom side of the VMware Player’s window and select “connect”.

[/SYS]% att -c hdc0 CD ←↩ — Attach CD-ROM (partition #0)hdc0 -> CD (ReadOnly)

[/SYS]% cd /CD/COMMON/FONT ←↩ — Change current directory[/CD/COMMON/FONT]% INSTFONT SSHELVET ←↩ — Install font

Font File Name : regist

0: **-**** : use

1: ****-SSHelvetica** : use

Use “exit” command twice to shutdown the target.

[/CD/COMMON/FONT]% exit ←↩ — Exit CLI<< EXIT cli >>

[IMS]% exit 1

[IMS]% exit ←↩ — System shutdown<< SYSTEM SHUTDOWN >>

Then eject the CD-ROM, and reboot the target.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 20: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

1 INSTALLING TARGET 20

(16) Shutdown the Target System

To shutdown the target system, on the initial window select Right-click → Exit, andclick on the Exit button of the confirm dialog.

But the system is still alive in case of debug mode. Then on the terminal software ofthe host PC, use “exit” command twice to shutdown the target.

[/SYS]% exit ←↩ — Exit CLI<< EXIT cli >>

[IMS]% $logon E

pid = 13 (pri = -1)

[IMS]% exit 1

[IMS]% exit ←↩ — System shutdown<< SYSTEM SHUTDOWN >>

(17) Exit Terminal Software

Exit Terminal Software (Tera Term Pro, HyperTerminal etc.)

† If you install Eclipse Environment in the next chapter, you can use a terminal software“gterm” on Eclipse instead of HyperTerminal.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 21: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

2 INSTALLING DEVELOPMENT ENVIRONMENT 21

2 Installing Development Environment

2.1 Installing Cygwin

Cygwin is required for the T-Kernel 2/x86 Development Environment on PC.For more details please also refer to the “Cygwin Install Manual” in the T-Kernel 2/x86

Evaluation Kit CD-ROM.

† Windows Login account must be administrator to install Cygwin. And the account namemust be in alphanumeric characters without spaces to avoid trouble on Cygwin.

† Even if you have already installed Cygwin, please check its version and installed modules.Refer to “Cygwin Install Manual” again and reinstall Cygwin if necessary.

(1) Expand Cygwin Package

Copy (save) the following file to the root of your install drive (such as C:\) fromthe common software directory (common\soft) of T-Kernel 2/x86 Evaluation Kit CD-ROM.

Cygwin System Package cygwin_d-1.7.17-1.zip

Expand this zip archive by Windows Explorer.

† Version numbers may be different.

(2) Start the Installer

The installer setup.exe is in the expanded folder. Double-click on setup.exe tolaunch the installer program. (Figure 2.1)

Figure 2.1 Start Cygwin Installer

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 22: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

2 INSTALLING DEVELOPMENT ENVIRONMENT 22

Click on Next .

(3) Select Install Type

Select “Install from Local Directory” and click on Next .

(4) Select Install Directory

Specify where the root directory in Cygwin is to be located in Windows. By defaultthis is C:\cygwin. Unless there is some reason for changing this, it can be left as is.(Figure 2.2)

Figure 2.2 Select Install Directory

Select “All Users” at “Install For”. It is also the default choice.

And click on Next .

(5) Select Local Package Directory

Specify the folder, where you expanded the Cygwin system package.

Click on Next to continue.

(6) Select Install Packages

After a file check is performed, a screen for selecting packages to install is displayed.

† A “Setup Alert” dialog appears for the first installation of Cygwin 1.7. Please read itcarefully before continuing installation. If you use old version of Cygwin, it will causesome trouble.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 23: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

2 INSTALLING DEVELOPMENT ENVIRONMENT 23

The initial selected state is “All© Default”. Click on “Default” to change to “Install”.(Figure 2.3)

Figure 2.3 Select Install Package

(7) Install

Then click on Next to proceed with the installation.

(8) Create Icon

Finally a dialog appears asking whether to add icons to the Start menu and desktop.Choose as appropriate, and click on Finish .

If appears “Program Compatibility Assistant”, click on “This program installed cor-rectly”.

(9) Initialize home directory

After modifying the batch file, double-click on the “Cygwin Terminal” icon on thedesktop to launch Cygwin. The first time it is started, the user’s home directory isinitialized.

(10) Create a symbolic link for gmake

On Cygwin, create a symbolic link from gmake to make.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 24: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

2 INSTALLING DEVELOPMENT ENVIRONMENT 24

$ cd /usr/bin ←↩$ ln -s make gmake ←↩

(11) Create a symbolic link for Perl

On Cygwin, create a symbolic link from /usr/local/bin/perl to /usr/bin/perl.

$ cd /usr/local/bin ←↩$ ln -s /usr/bin/perl ←↩

Use exit command to exit Cygwin.

(12) Set ja_JP.eucJP character set

After that log on Windows by the the actual user, double-click on the Cygwin icon onthe desktop to launch Cygwin. The first time it is started, the user’s home directoryis initialized.

Add a line “LANG=ja_JP.eucJP” to the .bashrc file on your home directory.For example,

$ cd ←↩$ echo LANG=ja_JP.eucJP >> .bashrc ←↩

On the Cygwin window, click on the mouse right button to show a menu, and select“Option”. Select “Text”, set “Locale” as “ja_JP”, and set “Character set” as eucJP.Click on OK .

Use exit command to exit Cygwin.

2.2 Installing Eclipse

Install Eclipse, an integrated development environment (IDE).For more details please also refer to the “Eclipse Install Manual” in the T-Kernel 2/x86

Evaluation Kit CD-ROM.

(1) Installing Java Runtime

Java Runtime is necessary for running Eclipse.

If you does not installed the Java Runtime, or your Java Runtime is old, please visitthe website http://www.java.com/ to download Java Runtime.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 25: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

2 INSTALLING DEVELOPMENT ENVIRONMENT 25

† In case of 64 bit Windows, 32 bit Java Runtime is required. Please install 32 bit JavaRuntime.

(2) Expand Eclipse System Package

Copy (save) the following file to a temporary directory of your install drive (such asC:\temp) from the common software directory (common\soft) of the T-Kernel 2/x86Evaluation Kit CD-ROM.

Eclipse+CDT eclipse-cpp-indigo-SR2-incubation-win32.zip

† Version numbers may be different.

Expand the archive files above to the root directory of your install drive (such as C:\).

† If you expand the packages to C:\, the new folder C:\eclipse is created, and thepackages are expanded under this folder.

(3) Making a shortcut

Make a shortcut on the desktop to the C:\eclipse\eclipse.exe.

2.3 Installing T-Kernel Development Environment

Add plug-ins for T-Kernel Development Environment to Eclipse.For more details please also refer to the “Eclipse-based T-Kernel Development Environ-

ment Install Manual” and the “GNU Development Environment (on Eclipse) Manual” inthe T-Kernel 2/x86 Evaluation Kit CD-ROM.

(1) Expand Eclipse plug-ins

Copy (save) the following files to a temporary directory of your install drive (suchas C:\temp) from the English software directory (en\soft) of the T-Kernel 2/x86Evaluation Kit CD-ROM.

Common part for Eclipse platform com.t_engine4u.te.1.2.0.zip

Machine-dependent part com.t_engine4u.tl.pcat.1.2.0.zip

And expand these archives to the Eclipse directory (such as C:\eclipse) by WindowsExplorer.

† Please use Windows Explorer to expand these ZIP files. Other software may not cor-rectly expand these archives.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 26: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

2 INSTALLING DEVELOPMENT ENVIRONMENT 26

† Version numbers may be different.

(2) Expand T-Shell Additional Package

Copy (save) the following file to a temporary directory of your install drive (suchas C:\temp) from the English software directory (en\soft) of the T-Kernel 2/x86Evaluation Kit CD-ROM.

T-Shell additional package com.t_engine4u.tsh.pcat.1.2.0.zip

And expand this archive toC:\eclipse\plugins\com.t_engine4u.tl.pcat.1.2.0_1.2.0\te by Windows Ex-plorer.

† Version numbers may be different.

† bappl\.templates is replaced.

(3) Start Eclipse

Double-click on the shortcut of Eclipse to launch Eclipse (Figure 2.4).

Figure 2.4 Starting Eclipse

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 27: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

2 INSTALLING DEVELOPMENT ENVIRONMENT 27

[Trouble Shooting] If appears an error message about Java Runtime Environ-ment, please confirm again about Java Runtime.

(4) Select (or create) a workspace

Appears a dialog of “Select a workspace”. Select (or newly create) the workspace

C:\te\bappl for process-based programs, and click on OK .

† Here a workspace means a directory to save projects. The default workspaces are asfollows.C:\te\bappl Process-based programs

C:\te\kappl T-Kernel-based programs

C:\te\driver Device drivers

(5) Go to the Workbench

Then appears the “Welcome” view. Click on the icon of “Go to the workbench”.(Figure 2.5)

Figure 2.5 “Welcome” view of Eclipse

(6) Open the “T-Engine Development” Perspective

Select Toolbar → “Window” → “Open Perspective” → “Other...’.Select “T-Engine Development”, and click on OK . (Figure 2.6)

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 28: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

2 INSTALLING DEVELOPMENT ENVIRONMENT 28

Figure 2.6 Select T-Engine development perspective

(7) Setting of T-Engine Development

Select Toolbar → “Window” → “Preferences” to open the Preferences Dialog. Selectthe page of “T-Engine Development”. (Figure 2.7)

Figure 2.7 T-Engine Development Settings

As the parameter of Cygwin directory, specify your Cygwin installed directory, likeC:\cygwin.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 29: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

2 INSTALLING DEVELOPMENT ENVIRONMENT 29

As the parameter of te vcom, specify as follows:

• In case of virtual environment (VMware) :

As the parameter of te vcom, specify “-l localhost”.

† -l is minus ell.

• In case of real environment :

As the parameter of te vcom, specify “-B -l /dev/ttyS0” in case of COM portnumber COM1, “-B -l /dev/ttyS1” in case of COM2, and so on.

† “-B” means 115200 bps, “-l” is minus ell, which stands for line device, and“/dev/ttySn” means COM(n+ 1).

(8) Setting of Workspace

Select the page of “General” → “Workspace”. (Figure 2.8)

• “Build automatically” is to be checked.

• “Text file encoding” is to be Other → EUC-JP.

• “New text file line delimiter” is to be Other → Unix.

Figure 2.8 Setting of Workspace

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 30: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

2 INSTALLING DEVELOPMENT ENVIRONMENT 30

And click on OK to close the Preference Dialog.

This configuration must be done for each workspace (C:\te\bappl, C:\te\kappl,C:\te\driver etc.).

(9) Opening console

Select Toolbar → “External Tools” → “External Tools Configurations...” to show the“External Tools Configurations” Dialog.

On the dialog, click on the “+” at the left of “Program”. Then appear te vcom andgterm under “Program”.

Select te vcom and click on the Run button. (Figure 2.9)

Figure 2.9 Running te vcom

Open the “External Tools Configurations” Dialog again, select gterm, and click on theRun button.

On the console view of gterm, hit ←↩ (Enter) key several times. Then appears aprompt (such as [/SYS]%) from the target side (T-Kernel 2/x86). This is a prompt ofCLI (Command Line Interpreter), which runs on T-Kernel 2/x86. (Figure 2.10)

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 31: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

2 INSTALLING DEVELOPMENT ENVIRONMENT 31

Figure 2.10 CLI prompt on gterm

Next time, the shortcuts to these external tools (te vcom and gterm) will appear onthe pull-down menu of External Tools.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 32: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

3 DEVELOPMENT 32

3 Development

3.1 Starting Target and Development Environment

Start T-Kernel 2/x86 and Eclipse as follows.

(1) Boot the target side (T-Kernel 2/x86)

• In case of virtual environment (VMware) :

Run the virtual machine “T-Kernel_x86.vmx” in”My Documents\My Virtual Machines\tkx86_vm”. It is recommended to createits shortcut for later use.

VMware Player’s window shows an initial window on PMC T-Shell. (Figure 1.12in page 18)

[Trouble Shooting] An initial window will not appear due to the previousexit situation. In this case try to reset the virtual machine by “Player” →“Troubleshoot” → “Reset” at the topside of the VMware Player’s window.

• In case of real environment :

Boot the target machine.

The display of the target machine shows an initial window on PMC T-Shell.

(2) Start Eclipse

Double-click on the shortcut of Eclipse to launch Eclipse.

Select a workspace, such as C:\te\bappl for process-based programs.

(3) Run te vcom and gterm

Select the external tools, and run te vcom and gterm.

† These external tools do not run just after starting Eclipse. Every time you startedEclipse (or switched workspace), you also have to run te vcom and gterm.

On the console view of gterm, hit ←↩ (Enter) key several times, and confirm a CLIprompt (such as [/SYS]%) from the target side (T-Kernel 2/x86).

† Do not use other terminal software including HyperTerminal while using te vcom andgterm. And do not start te vcom or gterm twice.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 33: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

3 DEVELOPMENT 33

[Trouble Shooting] If CLI prompt does not appear (including T-Monitor promptTM>), please reset the target.

In case of virtual environment (VMware), reset the virtual machine by “Player”→ “Troubleshoot” → “Reset” at the topside of the VMware Player’s window.

3.2 Console Tools

T-Kernel 2/x86 comes with a variety of console tools useful for development, as well asEclipse dialogs. By Eclipse dialogs one can transfer and execute programs without consoleoperation. But for other miscellany operations, you can use these console tools on gterm.

CLI (Command Line Interpreter)

A process-based command line interpreter, providing powerful features essential fordevelopment, especially file operation features. The standard prompt is [/SYS]%. Seethe “Development Tool Manual” at “3. Command Line Interpreter (CLI)” for details.

† The CLI prompt shows the working (current) directory name, which is set by cd com-mand.

Utilities on CLI

Various utilities, such as “hdpart” (partitioning disks) and “format” (format disks)are stored in the system disk, and available as external commands on CLI. See the“Development Tool Manual” at “4. Utilities”, “5. UNIX (File) Emulator CommandTools” and “6. Network Utilities” for details.

IMS (Initial Monitor System)

IMS is a T-Kernel based monitor. Its prompt is [IMS]% by default. See the “Develop-ment Tool Manual” at “2. IMS” for details.

T-Monitor

The most basic monitor program. Its forte is hardware-level operations and the like.The prompt is TM>.

T-Monitor commands are listed in the “T-Monitor Specification” at 3.3, “List of Com-mands.” T-Kernel 2/x86 adds additional commands to T-Monitor for Flash ROMwriting and other functions. These additional commands are given in the “Implemen-tation Specification” at 2, “T-Monitor Implementation Specification.”

A simple practice is given below to illustrate use of the CLI and T-Monitor.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 34: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

3 DEVELOPMENT 34

(1) Confirm CLI Prompt

On the console view of gterm, hit ←↩ (Enter) key several times, and confirm a CLIprompt (such as [/SYS]%).

[/SYS]%

(2) List of CLI Commands

Enter the CLI command “?” to display a list of CLI commands.

[/SYS]% ? ←↩CLI command list

att det eject cd ls fs · · · omitted · · ·

(3) CLI Command Help

Use the CLI command “?” to display a description of the “ls” command.

[/SYS]% ? ls ←↩ls [-f][-F][-l|-t] [<path name>..]

list files under the path name

· · · omitted · · ·

(4) List of Files

Use the CLI command “ls” to display a list of files.

[/SYS]% ls ←↩SBOOT KERNEL.SYS SYSCONF · · · omitted · · ·

(5) Switch to T-Monitor

Use the CLI command “#” to switch to T-Monitor.

[/SYS]% # ←↩TM>

(6) List of T-Monitor Commands

Use the T-Monitor command “?” to display a list of T-Monitor commands.

TM> ? ←↩--- Command List : "? command" for details ---

DumpByte/Half/Word(D/DB/DH/DW) · · · omitted · · ·

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 35: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

3 DEVELOPMENT 35

(7) Show Registers

Use the T-Monitor command “R” (Register) to show CPU registers.

TM> r ←↩EIP : 001117D7 EFLAGS: 00001246 IF:1 · · · omitted · · ·

(8) Return from T-Monitor

Use the T-Monitor command “g” (Go) to return to the CLI.

TM> g ←↩[/SYS]%

3.3 Process-Based and T-Kernel-Based Programs

Programs that run on T-Kernel 2/x86 are generally classified as either process-based pro-grams or T-Kernel-based programs. (Additionally there are monitor-based programs, butthese are not dealt with here.)

Process-based programs :

These are programs that run on T-Kernel Extension.

Ordinary application programs are generally of this type.

And process runs in memory protection mode for system safety such that process failurewill not cause system down.

As memory space, an independent local space is assigned to each process. A processhas one or more tasks, which shares the local space of the process.

A process is run by invoking the main() function, and when the main() functionterminates, the process terminates as well.

APIs available in process-based programs are described in the following documents inthe T-Kernel 2/x86 Evaluation Kit CD-ROM.

• “T-Kernel Extension Manual”

Process, tasks, files, events and so on.

• “PMC T-Shell Manual”

Screen drawing, fonts, GUI and network (TCP/IP) functions.

† Basically PMC T-Shell is available only on process.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 36: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

3 DEVELOPMENT 36

• “Library Manual”

Standard C library and other libraries, including fopen() and other <stdio.h>functions.

• “Device Driver Manual”

Process-based programs can call device drivers.

T-Kernel-based programs :

These are programs that make direct use of T-Kernel features.

This type of programming is geared to creating device drivers and the like, sincehardware control and interrupts can be handled. As memory space, multiple T-Kernel-based programs are loaded into the same system space and are made resident.

A T-Kernel-based program is loaded into system space by the lodspg command. Atthis time the main() function is called, and the first argument ac indicates the numberof arguments passed. Ordinarily, task and handler creation and other initializationtakes place in this processing.

The unlspg command can be used to unload a program. Here, the main() functionis called again; but this time a minus value is passed in ac. Post-processing such asdeleting the initial task and handlers normally takes place in this processing.

APIs available in T-Kernel-based programs are described in the following documentsin the T-Kernel 2/x86 Evaluation Kit CD-ROM.

• “T-Kernel Specification”

T-Kernel/OS provides the kernel functions of real time OS, such as tasks, semaphores,interrupt handlers. And T-Kernel/SM provides device driver management and soon.

• “Library Manual”

Standard C library and other libraries.

† Some library are process-based only, or T-Kernel-based only, but other library canbe commonly used.

• “Device Driver Manual”

T-Kernel-based programs can call device drivers, as well as making device drivers.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 37: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

3 DEVELOPMENT 37

3.4 “Hello, world” as a Process-Based Program

First of all, we’ll try the well-known program “Hello, world” as a process-based program.For more details refer to “GNU Development Environment (on Eclipse) Manual”.

(1) Select a Workspace

Launch Eclipse, and on the “Select a workspace” dialog, select (or newly create) the

workspace “C:\te\bappl” for process-based programs, and click on OK .

If you have already launched Eclipse and works on other workspace, switch workspaceto “C:\te\bappl”, by Toolbar → “File” → “Switch Workspace...”.

† If you switched workspace, also terminate external tools te vcom and gterm. Then youhave to run te vcom and gterm again. On the console view of gterm, hit ←↩ (Enter)key several times, and confirm a CLI prompt (such as [/SYS]%).

(2) Create a Project

On the “C/C++ Project” View, click on the mouse right button to show a menu,and select “New” → “T-Engine C/C++ Project”. (Or select Toolbar → “New” →“T-Engine C/C++ Project”.)

Specify the following items. (Figure 3.1)

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 38: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

3 DEVELOPMENT 38

Figure 3.1 New Project Dialog

• Project name :

Specify your project name, for example, hello.

• Target :

Specify your target machine, if you have already installed two or more develop-ment environments.

• Program Type:

Specify “Process Base”, or “Decide by workspace”, if your workspace is C:\te\bappl.

• Template:

Check it and select the template “gdbsample: a sample program for gdb opera-tion”.

• Output Directory:

Check it.

And click on the Finish button to create a new project.

(3) Create a source program

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 39: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

3 DEVELOPMENT 39

The sources of the template are copied under the src directory of the project helloin the “C/C++ Project” View. Double-click on hello to view the source files.

Here modify these source files as follows to make “Hello, world”.

• hello/src/main.c :

Modify the main function as follows:

/* Hello, world (process-based) */

#include <basic.h> /* basic common header */

#include <stdio.h> /* printf() etc. */

W main( W ac, TC *av[] )

{

printf( "Hello, world\n" );

return 0;

}

Save the modified file by Toolbar → “File” → “Save”.

† Here the types W and TC are defined by T-Kernel Specification. And return 0

returns the exit code of process.

• hello/src/Makefile :

Change the make target to “TARGET = hello”.

Change the list of source files to “SRC = main.c”. (Delete sub.c.)

Save the modified file by Toolbar → “File” → “Save”.

• hello/src/sub.c, hello/src/sub.h :

Delete these files by right-click menu.

(4) Make (compile and link)

Select the target Makefile, hello/pcat/Makefile, in the “C/C++ Project” View.

And then, select Toolbar→ “Project”→ “Make T-Engine Target all” to make (compileand link) your program.

If the make is succeeded, the executable file hello/pcat/hello is generated (with a©. icon).

[Trouble Shooting] If appears a message “Error launching builder”, confirm thatyou have selected the make target hello/pcat/Makefile.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 40: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

3 DEVELOPMENT 40

[Trouble Shooting] If appears a message “makedeps: Command not found”,confirm installation of Perl on /usr/local/bin/perl after Cygwin installation.

(5) Transfer and Execute the Executable File

Select the executable file hello/pcat/hello, click on the mouse right button to showa menu, and select “Run As” → “Run Configurations...”. Then appears the RunConfigurations Dialog.

On the dialog, select “T-Engine Application”, click on the mouse right button to showa menu, and select “New”. Then appears the default settings to transfer and executethe program. (Figure 3.2)

Figure 3.2 Run Dialog

Click on the Run button at the bottom of the dialog to transfer and execute theprogram. Then the process is executed, and appears “Hello, world” on the gterm

console. (Figure 3.3)

Figure 3.3 “Hello, world” appears on console

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 41: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

3 DEVELOPMENT 41

[Trouble Shooting] The serial communication is required to transfer files to thetarget.

Confirm that you have run te vcom and gterm again, and on the console viewof gterm, hit ←↩ (Enter) key several times, and confirm a CLI prompt (such as[/SYS]%).

[Trouble Shooting] If appears a message “Can’t Create (-1966080)”, it meansread only error. Please check that T-Kernel 2/x86 is booted from writable disk.

3.5 “Hello, world” as a T-Kernel-Based Program

Next we’ll try the “Hello, world” as a T-Kernel-based program. It puts “Hello, world” atloading, and “See you again” at unloading.

(1) Select a Workspace

Launch Eclipse, and on the “Select a workspace” dialog, select (or newly create) the

workspace “C:\te\kappl” for T-Kernel-based programs, and click on OK .

If you have already launched Eclipse and works on other workspace, switch workspaceto “C:\te\kappl”, by Toolbar → “File” → “Switch Workspace...”.

† If you switched workspace, also terminate external tools te vcom and gterm. Then youhave to run te vcom and gterm again. On the console view of gterm, hit ←↩ (Enter)key several times, and confirm a CLI prompt (such as [/SYS]%).

(2) Create a Project

On the “C/C++ Project” View, click on the mouse right button to show a menu,and select “New” → “T-Engine C/C++ Project”. (Or select Toolbar → “New” →“T-Engine C/C++ Project”.)

Specify the following items.

• Project name :

Specify your project name, for example, hello2.

• Target :

Specify your target machine, if you have already installed two or more develop-ment environments.

• Program Type:

Specify “T-Kernel Base”, or “Decide by workspace”, if your workspace is C:\te\kappl.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 42: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

3 DEVELOPMENT 42

• Template:

Check it and select the template “sample: print strings sample program”.

• Output Directory:

Check it.

And click on the Finish button to create a new project.

(3) Create a source program

The sources of the template are copied under the src directory of the project hello2in the “C/C++ Project” View. Double-click on hello2 to view the source files.

Here modify these source files as follows to make “Hello, world”.

• hello2/src/main.c :

Modify the main function as follows:

/* Hello, world (T-Kernel-based) */

#include <basic.h> /* basic common header */

#include <tk/tkernel.h> /* T-Kernel header */

#include <stdio.h> /* printf() etc. */

ER main( INT ac, UB *av[] )

{

if (ac >= 0) {

printf("Hello, world\n");

} else {

printf("See you again\n");

}

return E_OK;

}

Save the modified file by Toolbar → “File” → “Save”.

• hello2/src/Makefile :

Change the make target to “TARGET = hello2”.

Save the modified file by Toolbar → “File” → “Save”.

(4) Make (compile and link)

Select the target Makefile, hello2/pcat/Makefile, in the “C/C++ Project” View.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 43: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

3 DEVELOPMENT 43

And then, select Toolbar→ “Project”→ “Make T-Engine Target all” to make (compileand link) your program.

If the make is succeeded, the relocatable executable file hello2/pcat/hello2 is gen-erated (without a ©. icon, but it is correct). And hello2.abs is a absolute addressexecutable file, and hello2.trg is its stripped file.

(5) Transfer and Execute the Executable File

Select the executable file hello2/pcat/hello2, click on the mouse right button toshow a menu, and select “Run As” → “Run Conrigurations ...”. Then appears theRun Configurations Dialog.

On the dialog, select “T-Engine Application”, click on the mouse right button to showa menu, and select “New”. Then appears the default settings to transfer and executethe program.

Click on the Run button at the bottom of the dialog to transfer and execute theprogram. Then the program is loaded on the system common space, and appears“Hello, world” on the gterm console.

(6) Show the System Common Space

On the gterm console , use ref spg command to confirm that hello2 is loaded.

[/SYS]% ref spg ←↩[ 1] - 0xc0261000 - 5 vmwdrv

· · · omitted · · ·[14] - 0xc056b000 - 4 hello2

[/SYS]%

† System program ID and load address may be different.

(7) Unload the program

Now unload hello2 by executing the “unlspg” command, specifying the program byits system program ID as displayed in the previous step (14 in the above example).Then appears “Hello, world” on the gterm console.

[/SYS]% unlspg 14 ←↩See you again

[/SYS]%

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 44: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

4 RUNNING THE SAMPLE PROGRAMS 44

4 Running the Sample Programs

The Tutorial page on the T-Kernel 2/x86 Evaluation Kit CD-ROM contains a collection ofsample programs.

• Process application samples

(1) Juggling

This program shows juggling animation.

(2) Tiny Web Server

This program transfers files from T-Kernel 2/x86 to Web browsers on other PCsby TCP/IP network.

• T-Kernel-based samples on T-Kernel 2.0 new functions

T-Kernel 2.0 specification defines the following new functions as standards:· Time control in microseconds· Physical timer· Large capacity storage device support· Cache control, memory access right· Fast lock

The T-Kernel 2/x86 Evaluation Kit CD-ROM contains the following samples.

(3) Time-in-microseconds sample

This is a sample program using tk_get_otm_u (get operating time in microsec-onds) and tk_cre_cyc_u (create cyclic handler in microseconds).

(4) Physical timer sample implementation

This sample program uses physical timer to measure time to start task (tk_sta_tsk).

There are several methods and implementations for physical timer, de-pending on hardware and purpose. Hence T-Kernel 2/x86 does not im-plement physical timer as a standard, while one sample implementationis given in a source program. Refer to the header comment of the sourceprogram about specification and limitation of this sample physical timer.

4.1 Juggling

This process-based program shows juggling animation, using PMC T-Shell drawing functions.This sample is also useful to learn debug operations: set break points, change variables

and so on.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 45: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

4 RUNNING THE SAMPLE PROGRAMS 45

(1) Select a Workspace

Launch Eclipse, and on the “Select a workspace” dialog, select the workspace “C:\te\bappl”for process-based programs, and click on OK .

If you have already launched Eclipse and works on other workspace, switch workspaceto “C:\te\bappl”, by Toolbar → “File” → “Switch Workspace...”.

† If you switched workspace, also terminate external tools te vcom and gterm. Then youhave to run te vcom and gterm again. On the console view of gterm, hit ←↩ (Enter)key several times, and confirm a CLI prompt (such as [/SYS]%).

(2) Create a Project

On the “C/C++ Project” View, click on the mouse right button to show a menu,and select “New” → “T-Engine C/C++ Project”. (Or select Toolbar → “New” →“T-Engine C/C++ Project”.)

Specify the following items.

• Project name :

Enter the project name, juggling.

• Target :

Specify your target machine.

• Program Type:

Specify “Process Base”, or “Decide by workspace”, if your workspace is C:\te\bappl.

• Template:

Do not check it, because the source program will be expanded later.

• Output Directory:

Check it.

And click on the Finish button to create a new project.

(3) Expand Source Program

The source program is archived in “juggling.zip” on the “en\tutorial” folder inthe T-Kernel 2/x86 Evaluation Kit CD-ROM. Expand this archive “juggling.zip”to “C:\te\bappl” by Windows Explorer.

In the “C/C++ Project” View, select right-click menu → “Refresh”. Now the sourcefiles appear under the “src” directory of the project “juggling” in the “C/C++Project” View. Double-click on “juggling” to view the source files.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 46: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

4 RUNNING THE SAMPLE PROGRAMS 46

(4) Make (compile and link)

Select the target Makefile, “juggling/pcat/Makefile”, in the “C/C++ Project”View.

And then, select Toolbar→ “Project”→ “Make T-Engine Target all” to make (compileand link) your program.

If the make is succeeded, the executable file “juggling/pcat/juggling” is generated(with a ©. icon).

(5) Transfer and Execute the Executable File

Select the executable file “juggling/pcat/juggling”, click on the mouse right buttonto show a menu, and select “Run As” → “Run Configurations...”. Then appears theRun Configurations Dialog.

On the dialog, select “T-Engine Application”, click on the mouse right button to showa menu, and select “New”. Then appears the default settings to transfer and executethe program.

Click on the Run button at the bottom of the dialog to transfer and execute theprogram. Juggling animation is showed on the screen (Figure 4.1)

Figure 4.1 Run Juggling

(6) Make for Debugging

To debug your program, the executable file must include debug information. To makethat file, make your program on the folder with a debug option, such as “pcat.debug”.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 47: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

4 RUNNING THE SAMPLE PROGRAMS 47

Select the target Makefile, “juggling/pcat.debug/Makefile”, in the “C/C++ Project”View. And then, select Toolbar → “Project” → “Make T-Engine Target all” to make(compile and link) your program.

If the make is succeeded, the executable file “juggling/pcat.debug/juggling” isgenerated with debug information (with a bug icon).

(7) Start Debugging

Select the executable file “juggling/pcat.debug/juggling”, click on the mouse rightbutton to show a menu, and select “Debug As” → “Debug Configurations...”. Thenappears the Debug Configurations Dialog.

On the dialog, select “T-Engine Application”, click on the mouse right button to showa menu, and select “New”. Then appears the default settings to transfer and debugthe program.

† There remains a previous setting created in (5) for execution. But create a new one fordebugging.

Click on the Debug button at the bottom of the dialog to transfer and debug the

program. If appears a “Confirm Perspective Switch” dialog, click on Yes to switchperspective. Then appears the Debug perspective.

[Trouble Shooting] If terminates the debugger while its start, you have to extenddebugger timeout.

(1) Remove console of the terminated debugger:Click on the “Remove All Terminated Launches” (double cross) button at thetop of the console view.

(2) Extend debugger timeout:Select Toolbar → “Window” → “Preferences”, open the page of “C/C++”→ “Debug”→ “GDB MI”, and extend the values of “Debugger timeout” and“Launch timeout”.

(3) Start debug again by the Debug Configurations Dialog.

(4) Set a Breakpoint

The program is stopped at the beginning of the main() function.

Now set a breakpoint in the line “if (i > 0) sleep( i );” near the end of themain() function. At the leftmost side of this line, click on the mouse right button toshow a menu. Select “Toggle Breakpoint” to set a breakpoint. (Figure 4.2)

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 48: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

4 RUNNING THE SAMPLE PROGRAMS 48

Figure 4.2 Set a Breakpoint

(5) Continue Execution

Click on the “Resume” (green right triangle) button in the debug view to continueexecution. The program runs until a breakpoint. (Figure 4.3)

Figure 4.3 Continue Execution

By repeating this continuation, the balls move step by step on the target screen.

(6) Change Variables

When the program is stopped at a breakpoint, change the value of the variable N

(number of balls) in the variables view from 3 to 6. (Figure 4.4)

Figure 4.4 Change a Variable

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 49: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

4 RUNNING THE SAMPLE PROGRAMS 49

By continuing execution, the number of balls becomes 6 on the target screen.

In the same manner one can change the value of the variable R (radius of balls on thescreen).

(7) Terminate Debugging

Click on the “Terminate” (red square) button in the debug view to terminate debug-ging. And click on the “Remove All Terminated Launches” (double cross) button inthe same view.

Select “�” at the right-top of the Eclipse window to back to the “T-Engine Develop-ment” Perspective.

4.2 Tiny Web Server

This process-based tiny web server is provided as an example of a network application usingTCP/IP functions of PMC T-Shell. Files on T-Kernel 2/x86 are transferred to web browserson other PCs.

(1) Select a Workspace

Launch Eclipse, and on the “Select a workspace” dialog, select the workspace “C:\te\bappl”for process-based programs, and click on OK .

If you have already launched Eclipse and works on other workspace, switch workspaceto “C:\te\bappl”, by Toolbar → “File” → “Switch Workspace...”.

† If you switched workspace, also terminate external tools te vcom and gterm. Then youhave to run te vcom and gterm again. On the console view of gterm, hit ←↩ (Enter)key several times, and confirm a CLI prompt (such as [/SYS]%).

(2) Network Configuration

On the console view of gterm, hit ←↩ (Enter) key several times, and confirm a CLIprompt (such as [/SYS]%). Then use netconf command for network configuration.

If the network environment is one that assigns IP addresses automatically by DHCP,the default setting of 0.0.0.0 can be left as is. If not, first use the “netconf c” commandto assign an IP address to T-Kernel 2/x86.

[/SYS]% netconf c ←↩hostname = ? tkernel ←↩ — local host namehost ip = 0.0.0.0 ? 192.168.0.70 ←↩ — local IP address

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 50: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

4 RUNNING THE SAMPLE PROGRAMS 50

dns1name = ? ←↩ — DNS server #1dns1 ip = 0.0.0.0 ? ←↩dns2name = ? ←↩ — DNS server #2dns2 ip = 0.0.0.0 ? ←↩domain = ? ←↩ — domain namegateway ip = 0.0.0.0 ? ←↩ — gatewaysubnetmask = 255.255.255.0 ? ←↩ — subnet maskwlan = none (n/a/i)? ←↩ — no wireless LAN[/SYS]%

† Instead of netconf command, Network Setup Utility (right-click → “Utility” → “Net-work Setup”) is also available.

(3) Confirm Network Connection

On the console view of gterm, use the “ping” command to confirm the network con-nection.

[/SYS]% ping localhost ←↩ — ping selflocalhost is alive <192.168.0.70> : 0 ms

[/SYS]% ping 192.168.0.1 ←↩ — pint another machine192.168.0.1 is alive <192.168.0.1> : 0 ms

† In this example, the T-Kernel 2/x86 IP address is 192.168.0.70 and that of anothermachine is 192.168.0.1. Change these as appropriate for the particular network envi-ronment.

† In case of virtual environment (VMware), select “Network Adapter” icon at the bottomside of the VMware Player’s window, and select “connect”. And also select “Settings...”,and select “Bridged”, “NAT” or “Host-only”, depending on your network environment.For example “Bridged” is used to connect the virtual machine directly to network aswell as other physical machines.

† In case of real environment, select right-click → “Utility” → “System Setup” → “Net-work adapter” to set network device.

(4) Transfer Image Files

Transfer Image Files to the target side (T-Kernel 2/x86), for the contents of the tinyweb server.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 51: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

4 RUNNING THE SAMPLE PROGRAMS 51

On the console view of gterm, use the “recv” command to transfer image files fromthe host PC to the target side (T-Kernel 2/x86).

For example, if you want to transfer C:\tmp\abc.jpg,

[/SYS]% recv -c -d /cygdrive/c/tmp/abc.jpg ←↩

Transfer several image files in the same manner (those extension must be .jpg or.png).

(5) Create a Project

On the “C/C++ Project” View, click on the mouse right button to show a menu,and select “New” → “T-Engine C/C++ Project”. (Or select Toolbar → “New” →“T-Engine C/C++ Project”.)

Specify the following items.

• Project name :

Enter the project name, webserv.

• Target :

Specify your target machine.

• Program Type:

Specify “Process Base”, or “Decide by workspace”, if your workspace is C:\te\bappl.

• Template:

Do not check it, because the source program will be expanded later.

• Output Directory:

Check it.

And click on the Finish button to create a new project.

(6) Expand Source Program

The source program is archived in “webserv.zip” on the “en\tutorial” folder inthe T-Kernel 2/x86 Evaluation Kit CD-ROM. Expand this archive “webserv.zip” to“C:\te\bappl” by Windows Explorer.

In the “C/C++ Project” View, select right-click menu → “Refresh”. Now the sourcefiles appear under the “src” directory of the project “webserv” in the “C/C++Project” View. Double-click on “webserv” to view the source files.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 52: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

4 RUNNING THE SAMPLE PROGRAMS 52

(7) Make (compile and link)

Select the target Makefile, webserv/pcat/Makefile, in the “C/C++ Project” View.

And then, select Toolbar→ “Project”→ “Make T-Engine Target all” to make (compileand link) your program.

If the make is succeeded, the executable file “webserv/pcat/webserv” is generated(with a ©. icon).

(8) Transfer and Execute the Executable File

Select the executable file “webserv/pcat/webserv”, click on the mouse right buttonto show a menu, and select “Run As” → “Run Configurations ...”. Then appears theRun Configurations Dialog.

On the dialog, select “T-Engine Application”, click on the mouse right button to showa menu, and select “New”. Then appears the default settings to transfer and executethe program.

Click on the Run button at the bottom of the dialog to transfer and execute theprogram.

(9) View from Web Browser

From another PC on the network, enter the T-Kernel 2/x86 IP address in a Webbrowser, and confirm that the images loaded earlier are listed in the browser. If, forexample, the T-Kernel 2/x86 IP address is 192.168.0.70, enter the URL as follows:

http://192.168.0.70/index.html

† index.html is the image list page, which is generated automatically by the tiny webserver.

(10) Terminate Process

On the console, send ^C (Ctrl-C) to terminate the web server process.

Use the TE logo button upside the console view of Eclipse. (Figure 4.5)

Figure 4.5 Send ˆC on Eclipse

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 53: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

4 RUNNING THE SAMPLE PROGRAMS 53

4.3 Time-in-microseconds Sample

This is a T-Kernel-based sample program using tk_get_otm_u (get operating time in mi-croseconds) and tk_cre_cyc_u (create cyclic handler in microseconds).

(1) Select a Workspace

Launch Eclipse, and on the “Select a workspace” dialog, select the workspace “C:\te\kappl”for T-Kernel-based programs, and click on OK .

If you have already launched Eclipse and works on other workspace, switch workspaceto “C:\te\bappl”, by Menubar → “File” → “Switch Workspace...”.

† If you switched workspace, also terminate external tools te vcom and gterm. Then youhave to run te vcom and gterm again. On the console view of gterm, hit ←↩ (Enter)key several times, and confirm a CLI prompt (such as [/SYS]%).

(2) Change system timer interrupt period (TTimPeriod)

Although T-Kernel 2.0 has functions to control time in microseconds, its time resolutiondepends on the system timer interrupt period (TTimPeriod). The default value is 10milliseconds, namely 10000 microseconds. Here let’s change it to 100 microsecondsby “sysconf TTimPeriod milliseconds microseconds” command. The change becomesvalid after system reboot.

[/SYS]% sysconf TTimPeriod 0 100 ←↩+ 0: TTimPeriod 0 100

[/SYS]% exit ←↩<< EXIT cli >>

[IMS]% exit 1

[IMS]% exit -3 ←↩<< SYSTEM REBOOT >>

(3) Create a Project

On the “C/C++ Project” View, click on the mouse right button to show a menu,and select “New” → “T-Engine C/C++ Project”. (Or select Menubar → “New” →“T-Engine C/C++ Project”.)

Specify the following items.

• Project name :

Enter the project name, usec.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 54: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

4 RUNNING THE SAMPLE PROGRAMS 54

• Target :

Specify your target machine (pcat).

• Program Type:

Specify “T-Kernel Base”, or “Decide by workspace”, if your workspace is C:\te\kappl.

• Template:

Do not check it, because the source program will be expanded later.

• Output Directory:

Check it.

And click on the Finish button to create a new project.

(4) Expand Source Program

The source program is archived in “usec.zip” on the “en\tutorial” folder in the T-Kernel 2/x86 Evaluation Kit CD-ROM. Expand this archive “usec.zip” to “C:\te\kappl”by Windows Explorer.

In the “C/C++ Project” View, select right-click menu → “Refresh”. Now the sourcefiles appear under the “src” directory of the project “usec” in the “C/C++ Project”View. Double-click on “usec” to view the source files.

(5) Make (compile and link)

Select the target Makefile, usec/pcat/Makefile, in the “C/C++ Project” View.

And then, select Menubar→ “Project”→ “Make T-Engine Target all” to make (com-pile and link) your program.

If the make is succeeded, the relocatable executable file usec/pcat/usec is generated.

(6) Transfer and Execute the Executable File

Select the executable file usec/pcat/usec, click on the mouse right button to showa menu, and select “Run As” → “Run Configurations...”. Then appears the RunConfigurations Dialog.

On the dialog, select “T-Engine Application”, click on the mouse right button to showa menu, and select “New”. Then appears the default settings to transfer and executethe program.

Click on the Run button at the bottom of the dialog to transfer and execute theprogram. Then the program is loaded on the system common space.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 55: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

4 RUNNING THE SAMPLE PROGRAMS 55

[/SYS]% lodspg usec

SYSPRG usec [14] c0676000 - c067a000

TTimPeriod = 100[us]

#1: 8783629700[us]

#2: 8783629800[us]

#3: 8783629900[us]

#4: 8783630000[us]

#5: 8783630100[us]

[/SYS]%

(7) Unload the program

Now unload usec by executing the “unlspg” command, specifying the program by itssystem program ID as displayed in the previous step (14 in the above example).

[/SYS]% unlspg 14 ←↩[/SYS]%

(8) Resume TTimPeriod

Resume the system timer interrupt period (TTimPeriod) to the default value, namely10 milliseconds.

[/SYS]% sysconf TTimPeriod 10 ←↩+ 0: TTimPeriod 10

[/SYS]% exit ←↩<< EXIT cli >>

[IMS]% exit 1

[IMS]% exit -3 ←↩<< SYSTEM REBOOT >>

4.4 Physical Timer Sample Implementation

This T-Kernel-based sample program uses physical timer to measure time to start task(tk_sta_tsk). Note that the resolution of the physical timer does not depend on the systemtimer interrupt period (TTimPeriod).

(1) Select a Workspace

Launch Eclipse, and on the “Select a workspace” dialog, select the workspace “C:\te\kappl”for T-Kernel-based programs, and click on OK .

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 56: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

4 RUNNING THE SAMPLE PROGRAMS 56

If you have already launched Eclipse and works on other workspace, switch workspaceto “C:\te\bappl”, by Menubar → “File” → “Switch Workspace...”.

† If you switched workspace, also terminate external tools te vcom and gterm. Then youhave to run te vcom and gterm again. On the console view of gterm, hit ←↩ (Enter)key several times, and confirm a CLI prompt (such as [/SYS]%).

(2) Create a Project

On the “C/C++ Project” View, click on the mouse right button to show a menu,and select “New” → “T-Engine C/C++ Project”. (Or select Menubar → “New” →“T-Engine C/C++ Project”.)

Specify the following items.

• Project name :

Enter the project name, ptimer.

• Target :

Specify your target machine (pcat).

• Program Type:

Specify “T-Kernel Base”, or “Decide by workspace”, if your workspace is C:\te\kappl.

• Template:

Do not check it, because the source program will be expanded later.

• Output Directory:

Check it.

And click on the Finish button to create a new project.

(3) Expand Source Program

The source program is archived in “ptimer.zip” on the “en\tutorial” folder inthe T-Kernel 2/x86 Evaluation Kit CD-ROM. Expand this archive “ptimer.zip” to“C:\te\kappl” by Windows Explorer.

In the “C/C++ Project” View, select right-click menu → “Refresh”. Now the sourcefiles appear under the “src” directory of the project “ptimer” in the “C/C++ Project”View. Double-click on “ptimer” to view the source files.

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 57: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

4 RUNNING THE SAMPLE PROGRAMS 57

(4) Make (compile and link)

Select the target Makefile, ptimer/pcat/Makefile, in the “C/C++ Project” View.

And then, select Menubar→ “Project”→ “Make T-Engine Target all” to make (com-pile and link) your program.

If the make is succeeded, the relocatable executable file ptimer/pcat/ptimer is gen-erated.

(5) Transfer and Execute the Executable File

Select the executable file ptimer/pcat/ptimer, click on the mouse right button toshow a menu, and select “Run As”→ “Run Configurations...”. Then appears the RunConfigurations Dialog.

On the dialog, select “T-Engine Application”, click on the mouse right button to showa menu, and select “New”. Then appears the default settings to transfer and executethe program.

Click on the Run button at the bottom of the dialog to transfer and execute theprogram. Then the program is loaded on the system common space.

[/SYS]% lodspg ptimer

SYSPRG ptimer [14] c0676000 - c067a000

Physical timer resolution: 167.8[MHz] = 6.0[ns]

GetPhysicalTimerCount: 30.2[count] = 179.7[ns]

GetPhysicalTimerCount + tk_sta_tsk: 142.8[count] = 850.9[ns]

tk_sta_tsk: 112.6[count] = 671.2[ns]

[/SYS]%

The above result shows that starting task requires about 670 nanoseconds (0.67 mi-croseconds). Note that getting physical timer count(GetPhysicalTimerCount) also requires time, which must be subtracted.

† This result depends on hardware and software conditions, for example it may be slowon virtual environment (VMware).

(6) Unload the program

Now unload ptimer by executing the “unlspg” command, specifying the program byits system program ID as displayed in the previous step (14 in the above example).

[/SYS]% unlspg 14 ←↩[/SYS]%

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 58: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

Index

B

breakpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

C

console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33continue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48cross development . . . . . . . . . . . . . . . . . . . . . . . 5Cygwin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

D

debug information . . . . . . . . . . . . . . . . . . . . . . 46df command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

E

Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

F

formatsys command . . . . . . . . . . . . . . . . . . . . 15

G

gterm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

H

hdpart command . . . . . . . . . . . . . . . . . . . . . . . 14HyperTerminal . . . . . . . . . . . . . . . . . . . . . . . . . . 9

I

IMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

J

Java Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . 24juggling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

L

lodspg command . . . . . . . . . . . . . . . . . . . . . . . 36ls command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

M

memory protection . . . . . . . . . . . . . . . . . . . . . 35

microsecond . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

N

netconf command . . . . . . . . . . . . . . . . . . . . . . . 49

P

Perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24physical timer . . . . . . . . . . . . . . . . . . . . . . . . . . 44ping command . . . . . . . . . . . . . . . . . . . . . . . . . . 50process-based . . . . . . . . . . . . . . . . . . . . . . . . . . . 35project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

R

real environment . . . . . . . . . . . . . . . . . . . . . . . . . 5recv command . . . . . . . . . . . . . . . . . . . . . . . . . . 51reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

S

screen size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

T

TCP/IP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49Tera Term Pro . . . . . . . . . . . . . . . . . . . . . . . . . . . 9te vcom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32T-Kernel 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44T-Kernel-based . . . . . . . . . . . . . . . . . . . . . . . . . 36TTimPeriod . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

U

unlspg command . . . . . . . . . . . . . . . . . . . . . . . 36

V

virtual environment . . . . . . . . . . . . . . . . . . . . . . 5VMware Player . . . . . . . . . . . . . . . . . . . . . . . . . . 6VMwareGateway . . . . . . . . . . . . . . . . . . . . . . . . 7

58

Page 59: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

INDEX 59

W

web server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

Getting Started with T-Kernel 2/x86 c© 2008–2012 Personal Media Corporation

Page 60: Getting Started with T-Kernel 2/x86Getting Started with T-Kernel 2/x86 c 2008–2012 Personal Media Corporation HISTORY 3 History of Changes Version 2.0.1 Modify \1. Installing Target"

Getting Started with T-Kernel 2/x86Version 2.0.1

Web: http://www.t-engine4u.com/E-Mail: [email protected]

Copyright c© 2008–2012 by Personal Media Corporation