Getting Started with
Reference Kit

Version 1.03.00
Personal Media Corporation

c 2011–2014 by Personal Media Corporation
Copyright ⃝CONTENTS

2

Contents
History of Changes

3

Introduction

4

1 Install Target
1.1 Console Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Make Boot Disk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 Font Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5
5
10
13

2 Install Development Environment
2.1 Install Cygwin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Install Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 Install T-Kernel Development Environment . . . . . . . . . . . . . . . . . . . .

15
15
18
19

3 Development
3.1 Starting Target and Development Environment . . . . . . . . . . . . . . . . . .
3.2 Console Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3 Process-Based and T-Kernel-Based Programs . . . . . . . . . . . . . . . . . . .
3.4 ”Hello, world” as a Process-Based Program . . . . . . . . . . . . . . . . . . . .
3.5 ”Hello, world” as a T-Kernel-Based Program . . . . . . . . . . . . . . . . . . .

25
25
25
27
29
32

4 Running Learning Sample Programs
4.1 Juggling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Tiny Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.3 LED and Interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4 Physical Timer Sample Implementation . . . . . . . . . . . . . . . . . . . . . .

35
35
38
41
42

Index

Getting Started with Reference Kit

45

c 2011–2014 Personal Media Corporation⃝

HISTORY

3

History of Changes
VersionRemarks

1.03.00

Change title of this document.

1.02.00

Update Cygwin, Eclipse and USB-UART driver.

1.01.00

USB-UART driver is included in the “T-Kernel 2.0 Reference Kit” CD.
Add physical timer implementation sample.

1.00.00

First edition for T-Kernel 2.0 Reference Kit.

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

INTRODUCTION

4Introduction
This document provides a tutorial on starting out with Reference Kit, for those using thisproduct for the first time.
For development environment, both Windows and Linux are supported. In this document,
however, we introduce a tutorial only on Windows with Eclipse.

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

1

INSTALL TARGET

51

Install Target

In general on developing embedded systems, the development environment is apart from theexecution target. This style is called “cross-development”, shown in Figure 1.1. In case ofReference Kit, we also use this style for software development.
Host PC (development)

CPU board (target)

Compiler
Eclipse-Applications

Debuggergterm

USB orserialFigure 1.1-

Drivers, middleware
T-Kernel (OS)Cross-development

In this section we’ll install the target-side environment (OS, drivers and middleware) on a
microSD for Reference Board, while the section 2 describes the host-side installation. For
details please also refer to “T-Kernel 2.0 Reference Kit Manual” at “1. Introduction”.
Parts on the Reference Board are shown in Figure 1.2.

Reset
SW
s
DIP
SW
DSUB
9P

Power
SW

LED5
LED6
LED7
LED8

microSDc
DSUB 9P
bbbb
bb bbbc
MIC f

Figure 1.2

1.1

SW1,2,3,4
DC

s
s
s
s

SW4
SW3
SW2
SW1

USB-UART

USB-miniAB
LAN

Reference Kit CPU board

Console Connection

Both USB and serial (RS–232C) connections are supported for console of Reference Board.
(1) Connection
Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

1

INSTALL TARGET

6⃝ In case of USB connection
For the first time it is necessary to install device driver to Windows.
1. Log on Windows as an administrator. “common\soft” folder of the “T-Kernel 2.0
Reference Kit” CD contains the USB-UART (CP210x) driver archive,“CP210x_VCP_Windows.zip”.
Expand this archive file, and start your suitable installer.
CP210xVCPInstaller_x86.exe

for Windows 32 bit

CP210xVCPInstaller_x64.exe

for Windows 64 bit▷ If you prefer the newest one, it will be get from the URL below at Silicon Laboratories
Inc.:
http://www.silabs.com/Support%20Documents/Software/CP210x_VCP_Windows.zip

2. Run the downloaded executable file and install it.
3. Supply power to DC jack of Reference Board, and slide POWER SW to the upper
position. Connect USB port of your host PC and USB-UART connector of Reference
Board(Figure 1.3).
USB cable
USB port

Host PC
Figure 1.3-

USB-UART
Reference Board

USB connection

4. Windows detects Reference Board as a USB device, and installs device driver.
5. Open “Device Manager”.
• Iin cases of Windows 8, 7 and Vista: “Control Panel” → “System and Security”→ “System” → “Device Manager”• In case of Windows XP: “Control Panel” → “System and Security” → “System”→ “Hardware” → “Device Manager”
See “Port (COM and LPT)” and check that “Silicon Labs CP210x USB to UART
Bridge (COMn)” is installed. Here COMn is the COM port number.
Remarks on USB Connection• It is recommended to connect PC and Reference Board directly by USB cable (without USB hub). USB hub may cause some problems.
• Boot, reboot and reset must be done while pushing SW2 to connect by USB. Without
pushing SW2 serial connection is selected by default setting. But if you write ROM
information for USB connection to flash ROM, you can connect by USB without
pushing SW2. See page 9.
• If you boot, reboot or reset Reference Board, USB connection may be disconnected.
Then quit and restart your terminal software.
Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

1

INSTALL TARGET

7⃝ In case of serial connection (RS–232C)
Connect COM port of your host PC and DSUB 9P connector of Reference Board by
serial (RS–232C) cross cable (Figure 1.4).
RS–232C
cross cable
COM port

Host PC
Figure 1.4-

DSUB 9P
Reference Board

Serial connection(2) Boot Reference Board
Supply power to DC jack of Reference Board, and slide POWER SW to the upper
position.
In case of USB connection, start supplying power while pushing SW2.
(3) Start Terminal Software
For this installation a terminal software is required, such as “Tera Term” and “HyperTerminal”.
▷ In cases of Windows 8, 7 and Windows Vista, where HyperTerminal is not included, please
download and install “Tera Term” from the following website:
http://ttssh2.sourceforge.jp/index.html.en▷ If you install Eclipse Environment, you can use a terminal software “gterm” on Eclipse. But
for the first setup, we recommend to use a simple terminal software (such as Tera Term) foreasy trouble shooting.

• In case of Tera Term:
Start Tera Term.
• In case of HyperTerminal:
Start “HyperTerminal” (by clicking “Start button” → “All Programs” → “Accessories” → “Communications” → “HyperTerminal”).
▷ You may be asked about “Default Telnet Program”, but it is not significant. Phone
number is also not significant, because no telephone call is used actually.

Enter any name and select any icon, and click OK .
(4) Communication Setting
Select serial port of the host PC (COM1 etc.), and set the communication parameters as
follows:

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

1

INSTALL TARGET

8

Speed

115200 bps

Data bits

8 bitsParitynone

Stop bits

1 bit

Flow control

XON/XOFF▷ Hardware flow control (RTS/CTS) is not supported. Please use XON/XOFF control instead.
• In case of Tera Term:
On the initial new connection dialog of Tera Term (or select Menubar → “File” →“New connection”), check “Serial”, and select the serial port (ex. COM1), and click
OK .
Then select Menubar → “Setup” → “Serial port”, and set parameters as above(Figure 1.5).

Figure 1.5

Communication Setting• In case of HyperTerminal:
Select the serial port (ex. COM1) and click OK . Then set the communication
parameters as above.
(5) Confirm Connection
Try pressing ←- (Enter) Key a number of times on the terminal software. The CLI
prompt ([/SYS]%) will appear on the terminal software (Figure 1.6).

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

1

INSTALL TARGET

Figure 1.6

9

CLI prompt on a terminal software(6) Write ROM Information (only for USB connection)
The “en\soft” folder of the “T-Kernel 2.0 Reference Kit” CD contains the following
files to write ROM information on flash ROM for switching USB connection and serial
connection.
rominfo.mot

serial(USB: boot with SW2)

rominfo-usb.mot

USB(serial: boot with SW2)

default

Without pushing SW2 serial connection is selected by default setting. But if you write
ROM information for USB connection to flash ROM, you can connect by USB without
pushing SW2.
Push reset switch while pushing both SW1 and SW2 to start T-Monitor. Try pressing ←(Enter) Key a number of times on the terminal software. The T-Monitor prompt (TM>)
will appear.
Input FlashLoad command on T-Monitor.
TM> FlashLoad←Copy Flash ROM Image to RAM Area
> Load S-Format Data of Flash ROM
After a moment a message “> Load S-Format Data of Flash ROM” will appear. Then
send the file rominfo-usb.mot in the “T-Kernel 2.0 Reference Kit” CD.
• In case of Tera Term:
Select Menubar → “File” → “Send file”, and specify the file to be sent(rominfo-usb.mot).
• In case of HyperTerminal:
Select Menubar → “Transfer” → “Send Text File”, and specify the file to be sent(rominfo-usb.mot). Select *.* for file name suﬃx, because it is not .txt.
Loaded: 70020000 -> 7002007F
Writing Flash ROM at 70020000 [1 blks] ...
TM>
Getting Started with Reference Kit

wait

c 2011–2014 Personal Media Corporation⃝

1

INSTALL TARGET

10

After writing flash ROM appears T-Monitor prompt (TM>). From now on you can connect
by USB without pushing SW2.

1.2

Make Boot Disk

(1) Insert microSD Card
Insert a blank (to be erased) microSD card to Reference Board.
▷ eMMC and USB storage devices are also available instead of microSD. For more details refer
to “T-Kernel 2.0 Reference Kit Manual” at “Making Boot Disk”.

(2) Make Partition
Run hdpart command from the terminal software, where the device name is “pcb”, whichmeans the whole disk.
[/SYS]% hdpart pcb←-— run hdpart commandpcb[C:485 H:64 S:63 B:1961984 (958 MB)]
No System
Boot StartCHSEndCHS
SecNo SecCnt
1 0b DOS00
0: 1: 1 486: 38:38
63 1961921
2 00 ------ 00
0: 0: 00: 0: 00
0
3 00 ------ 00
0: 0: 00: 0: 00
0
4 00 ------ 00
0: 0: 00: 0: 000Size
957 MB
0 KB
0 KB
0 KB

— delete partition— 1st partition** Create/Delete/Boot/Edit/Quit ? d←Delete PartNo (1-4) ? 1←No SystemBoot
1 00 ------ 00
2 00 ------ 00
3 00 ------ 00
4 00 ------ 00

StartCHS
0: 0: 00: 0: 00: 0: 00: 0: 0EndCHS0: 0: 00: 0: 00: 0: 00: 0: 0

SecNo
0
0
0
0

SecCnt0000— Create partition— 1st partition— partition size** Create/Delete/Boot/Edit/Quit ? c←Create PartNo (1-4) ? 1←Size [GB/MB/KB,All] (<957MB) ? a←No SystemBoot
1 13 BTRON00
2 00 ------ 00
3 00 ------ 00
4 00 ------ 00

StartCHS
0: 1: 10: 0: 00: 0: 00: 0: 0EndCHS486: 38:38
0: 0: 00: 0: 00: 0: 0

Size
0 KB
0 KB
0 KB
0 KB

SecNo SecCnt
63 1961921
0
0
0
0
0
0

Size
957 MB
0 KB
0 KB
0 KB

— Boot partition— 1st partition** Create/Delete/Boot/Edit/Update/Quit ? b←Boot PartNo (1-4,Clear) ? 1←No SystemBoot
1 13 BTRON
80
2 00 ------ 00
3 00 ------ 00
4 00 ------ 00

StartCHS
0: 1: 10: 0: 00: 0: 00: 0: 0EndCHS486: 38:38
0: 0: 00: 0: 00: 0: 0

SecNo SecCnt
63 1961921
0
0
0
0
0
0

** Create/Delete/Boot/Edit/Update/Quit ? u←** pcb: Updated Master Boot Block[/SYS]%

Size
957 MB
0 KB
0 KB
0 KB

— update(3) Format

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

1

INSTALL TARGET

11

Format the 1st partition by format command from the terminal software. Device nameis “pcb0”. And “-b” option (write boot record) is required. Also “-x” option is required
if the partition size is 2GB or more.
— format 1st partition[/SYS]% format -b pcb0 SYSTEM←Format pcb0 [STD] SYSTEM
Logical Formatting...
Writing BootCode...
Disk Format Success.
[/SYS]%(4) Copy the ROM Disk Files
Copy the all ROM disk files to the 1st partition.

— attach 1st partition[/SYS]% att pcb0 A←pcb0 -> A[/SYS]% rcp -r /SYS /A/=←[/SYS]% det pcb0←[/SYS]%— copy ROM disk files— detach 1st partition(5) Reboot Reference Board
Use “exit” and “exit -1” commands to reboot Reference Board.
[/SYS]% exit←<< EXIT cli >>[IMS]% exit
1[IMS]% exit -1←<< SYSTEM RESET >>..
.
[/SYS]%The terminal software of the host PC shows booting messages of T-Kernel, and the CLI
prompt ([/SYS]%).
(6) Confirm Booting from microSD
Use the CLI command “df” to confirm that the system (/SYS) was booted from the 1st
partition on the microSD card (logical device name is pcb0).
If the device name is rda, it means ROM disk. The system failed to boot from microSD
card. Please check the whole procedure above again.
[/SYS]% df←PATH DEVTOTAL/SYS pcb0
980960[/SYS]%

FREE USED
9771080%

UNIT MAXFILE NAME
4096
65535 SYSTEM(7) Copy PMC T-Shell Install Package Files

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

1

INSTALL TARGET

12

Prepare a FAT-formatted USB storage (USB memory etc.). Copy the following 2 files
from the “en\soft” folder of the “T-Kernel 2.0 Reference Kit” CD to a USB storage on
PC.
File nameContent

install_tshell.bz

PMC T-Shell install package

english.bz

PMC T-Shell English patch▷ Instead of file copy on USB storage, serial/USB transfer in XMODEM protocol and LANtransfer in FTP are also available. For more details refer to “T-Kernel 2.0 Reference Kit
Manual” at “Installing PMC T-Shell”.

(8) Install PMC T-Shell
Connect this USB storage to the USB miniAB connector of Reference Board. (Use acable to connect between your USB storage and USB miniAB connectors.)[/SYS]% att -m uda0 uda0←uda0 -> uda0[/SYS]% expf -U /uda0/install_tshell.bz←[/SYS]% install_tshell /SYS←Install completed, please reboot the system.
[/SYS]% rm -r install_tshell←[/SYS]%— attach USB storage (FAT)— expand package— install— remove installer

Now use English patch before rebooting the system. This English patch translates GUI
applications to English.
— expand English patch— install English patch[/SYS]% expf -U /uda0/english.bz←[/SYS]% english /SYS←.. Installing English Patch on /SYS.. Install completed[/SYS]% rm -r english←[/SYS]% det -u uda0←[/SYS]%— remove English patch— detach USB storage

The USB storage can be disconnected after det command.
(9) Confirm PMC T-Shell
Use “exit” and “exit -1” commands to reboot Reference Board.
[/SYS]% exit←<< EXIT cli >>[IMS]% exit
1[IMS]% exit -1←<< SYSTEM RESET >>..
.
[/SYS]%
Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

1

INSTALL TARGET

13

The terminal software of the host PC shows booting messages of T-Kernel, and the CLI
prompt ([/SYS]%).
And the LCD screen of Reference Board shows an initial window of PMC T-Shell(Figure
1.7).

Figure 1.7

Initial Window of PMC T-Shell

Touch the system message panel at the bottom of the screen to show menu. Select menu
→ “Utility” → “Touch Panel Adj.” to adjust touch panel coordination. This adjustment
becomes valid after system reboot.

1.3

Font Installation

The “common\font” folder of the “T-Kernel 2.0 Reference Kit” CD contains many additional fonts, including several English fonts, as well as large sets of Chinese/Japanese/Korean
ideographs.
The following install files are for English fonts:
File Name

Font NameSSAVALON

SSAvalon

SSCOURIE

SSCourier

SSEUROMD

SSEuromode

SSHELVET

SSHelvetica

SSHELVTN

SSHelveticaN

SSTIMES

SSTimes

At least SSHelvetica is recommended to be installed, since GUI applications assume it.
(1) Copy Font File

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

1

INSTALL TARGET

14

Copy the following 2 files from the “en\soft” folder of the “T-Kernel 2.0 Reference Kit”
CD to a USB storage on PC.
File nameContent

instfont

font installer

SSHELVET

SSHelvetica font

(2) Install Font
Connect this USB storage to the USB miniAB connector of Reference Board. (Use acable to connect between your USB storage and USB miniAB connectors.)[/SYS]% att -m uda0 uda0←uda0 -> uda0[/SYS]% /uda0/instfont /uda0/SSHELVET←Font File Name
: regist
0: **-****: use
1: ****-SSHelvetica** : use[/SYS]% det -u uda0←[/SYS]%— attach USB storage (FAT)— install font— detach USB storage(3) Reboot Reference Board
Use “exit” and “exit -1” commands to reboot Reference Board.
[/SYS]% exit←<< EXIT cli >>[IMS]% exit
1[IMS]% exit -1←<< SYSTEM RESTART >>..
.
[/SYS]%

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

2

INSTALL DEVELOPMENT ENVIRONMENT

15

2

Install Development Environment

2.1

Install Cygwin

Cygwin is required for the Reference Board Development Environment on PC.
For more details please also refer to the “Cygwin Install Manual” in the T-Kernel 2.0 Reference
Kit CD-ROM.
▷ Windows Login account must be administrator to install Cygwin. And the account name must
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:\) from the common software directory (common\soft) of T-Kernel 2.0 Reference Kit CD-ROM. Expand
this zip archive by Windows Explorer.
Cygwin System Package

cygwin_d-X.X.X.zip▷ Here X.X.X stands for version number of the file.
(2) Start the Installer
The installer setup-x86.exe is in the expanded folder. Double-click setup-x86.exe tolaunch the installer program. (Figure 2.1)

Figure 2.1

Start Cygwin Installer

Click Next .
(3) Select Install Type
Select “Install from Local Directory” and click Next .
(4) Select Install DirectorySpecify where the root directory in Cygwin is to be located in Windows. By default thisis C:\cygwin. Unless there is some reason for changing this, it can be left as is. (Figure
2.2)

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

2

INSTALL DEVELOPMENT ENVIRONMENT

Figure 2.2

16

Select Install Directory

Select “All Users” at “Install For”. It is also the default choice.
And click Next .
(5) Select Local Package DirectorySpecify the folder, where you expanded the Cygwin system package.
Click 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 it
carefully before continuing installation. If you use old version of Cygwin, it will cause sometrouble.

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

Figure 2.3

Getting Started with Reference Kit

Select Install Package
c 2011–2014 Personal Media Corporation⃝

2

INSTALL DEVELOPMENT ENVIRONMENT

17(7) Install
Then click Next to proceed with the installation.
(8) Create Icon
Finally a dialog appears asking whether to create icons on desktop and Start menu.
Choose as appropriate, and click Finish .
If appears “Program Compatibility Assistant”, click “This program installed correctly”.
(9) Initialize home directory
After modifying the batch file, double-click the “Cygwin Terminal” icon on the desktop
to launch Cygwin. The first time it is started, the user’s home directory is initialized.
(10) Create a symbolic link for gmake
On Cygwin, create a symbolic link from gmake to make.
$ 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 the Cygwin icon on thedesktop to launch Cygwin. The first time it is started, the user’s home directory is
initialized.
Add a line “export LANG=ja_JP.eucJP” to the .bashrc file on your home directory.
For example,$ cd ←$ echo export LANG=ja_JP.eucJP >> .bashrc ←On the Cygwin window, click the mouse right button to show a menu, and select “Option”. Select “Text”, set “Locale” as “ja_JP”, and set “Character set” as eucJP. ClickOK .
Use exit command to exit Cygwin.

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

2

INSTALL DEVELOPMENT ENVIRONMENT

2.2

18

Install Eclipse

Install Eclipse, an integrated development environment (IDE).
For more details please also refer to the “Eclipse Install Manual” in the T-Kernel 2.0 Reference
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 visit thefollowing website to download Java Runtime.
http://www.java.com/▷ 32 bit Java Runtime is required even for Windows 64 bit. Please install 32 bit Java Runtime.
(2) Expand Eclipse System Package
Copy (save) the following file to a temporary directory (such as desktop) from the common
software directory (common\soft) of the T-Kernel 2.0 Reference Kit CD-ROM.
Eclipse+CDT

eclipse-cpp-kepler-R-win32.zip

Expand the archive file 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 the packages
are expanded under this folder.

(3) Making a shortcut
Make a shortcut on the desktop to the C:\eclipse\eclipse.exe.
(4) Confirming for running Eclipse
Double-click on the shortcut of Eclipse to launch Eclipse (Figure 2.4). On the “Select aworkspace” dialog, click on Cancel to quit Eclipse.

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

2

INSTALL DEVELOPMENT ENVIRONMENT

Figure 2.4

19Starting Eclipse[Trouble Shooting] If appears an error message about Java Runtime Environment, please confirm again about Java Runtime.

2.3

Install 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 Environment
Install Manual” and the “GNU Development Environment (on Eclipse) Manual” in the “TKernel 2.0 Reference Kit” CD.
(1) Expand Eclipse plug-ins
Copy (save) the following files to a temporary directory (such as desktop) from the English
software directory (en\soft) of the “T-Kernel 2.0 Reference Kit” CD.
Common part for Eclipse platform

com.t_engine4u.te.X.X.X.zip

Machine-dependent partcom.t_engine4u.tl.em1d512_te.X.X.X.zip

And expand these archives to the Eclipse directory (such as C:\eclipse) by Windows
Explorer.
▷ Here X.X.X stands for version number of the file.
▷ Please use Windows Explorer to expand these ZIP files. Other software may not correctly
expand these archives.
Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

2

INSTALL DEVELOPMENT ENVIRONMENT

20(2) Expand PMC T-Shell Additional Package
Copy (save) the following file to a temporary directory of your install drive (such as
C:\temp) from the English software directory (en\soft) of the “T-Kernel 2.0 Reference
Kit” CD.
PMC T-Shell additional package

com.t_engine4u.tsh.em1d512_te.X.X.X.zip▷ Here X.X.X stands for version number of the file.
And expand this archive to
C:\eclipse\plugins\com.t_engine4u.tl.em1d512_te.X.X.X_X.X.X\teby Windows Explorer.
▷ Some files are replaced (overwritten) during expanding the archive file.
(3) Start Eclipse
Double-click the shortcut of Eclipse to launch Eclipse.
(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 OK .
▷ Here a workspace means a directory to save projects. The default workspaces are as follows.
C:\te\bappl

Process-based programs

C:\te\kappl

T-Kernel-based programs(5) Go to the Workbench
Then appears the “Welcome” view. Click the icon of “Go to the workbench”. (Figure
2.5)

Figure 2.5
Getting Started with Reference Kit“Welcome” view of Eclipse
c 2011–2014 Personal Media Corporation⃝

2

INSTALL DEVELOPMENT ENVIRONMENT

21(6) Open the “T-Engine Development” Perspective
Select Menubar → “Window” → “Open Perspective” → “Other”.
Select “T-Engine Development” and click OK . (Figure 2.6)

Figure 2.6

Open Perspective(7) Setting of T-Engine Development
Select Menubar → “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 te_vcom, specify “-b -x -l /dev/ttyS0” in case of COM port
number COM1, “-b -x -l /dev/ttyS1” in case of COM2, and so on.

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

2

INSTALL DEVELOPMENT ENVIRONMENT

22• “-b” means 115200 bps.
• “-x” means suppressing hardware flow control (RTS/CTS).
• “-l” is minus ell, which stands for line device,and “/dev/ttySn” means COM(n + 1).
▷ In case of USB connection:
Some problem will occur on debugging.
In such a case replace te_vcom location with the path below:(Before)(After)$pmc_plugin_loc:COMMON\te\tool\Cygwin-i686\etc\te_vcom.exe↓$pmc_plugin_loc:COMMON\te\tool\Cygwin-i686\etc\te_vcom.1_13.exe▷ In case of serial connection (RS–232C) via USB-serial adapter:
Communication speed will be slow down.
In such a case modify te_vcom parameter as below:(Before)(After)-b -x -l /dev/ttyS0↓-b -x -l /dev/ttyS0 -e c1024(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.
• Select “New text file line delimiter” to be Other → Unix.

Figure 2.8
Getting Started with Reference Kit

Setting of Workspacec 2011–2014 Personal Media Corporation⃝

2

INSTALL DEVELOPMENT ENVIRONMENT

23

This configuration must be done for each workspace (C:\te\bappl, C:\te\kappl etc.).
(9) Opening console
Select Menubar → “Run” → “External Tools” → “External Tools Configurations” toshow “External Tools Configurations” Dialog.
On the dialog, open “Program”. Then appear te_vcom and gterm under “Program”.
▷ Also may appear “te_vcom(telnet)”, but it is not used here.
Select te_vcom and click Run . (Figure 2.9)

Figure 2.9

Running te_vcom

Open the “External Tools Configurations” Dialog again, select gterm, and click Run .
On gterm in the console view, hit ←- (Enter) key several times. Then appears a prompt(such as [/SYS]%) from the target side (Reference Board). This is a prompt of CLI(Command Line Interpreter), which runs on Reference Board. (Figure 2.10)

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

2

INSTALL DEVELOPMENT ENVIRONMENT

Figure 2.10

24

CLI prompt on gterm

Next time, the shortcuts to these external tools (te_vcom and gterm) will appear on thepull-down menu of External Tools.

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

3

DEVELOPMENT

25

3Development

3.1

Starting Target and Development Environment

Start Reference Board and Eclipse as follows.
(1) Boot the target side (Reference Board)
Supply power to DC jack of Reference Board, and slide POWER SW to the upper
position.
The LCD screen of Reference Board shows an initial window of PMC T-Shell.
(2) Start Eclipse
Double-click 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 started Eclipse(or switched workspace), you also have to run te_vcom and gterm.

On gterm in the console view, hit ←- (Enter) key several times, and confirm a CLI prompt(such as [/SYS]%) from the target side (Reference Board).
▷ Do not use other terminal software (such as Tera Term and HyperTerminal) while using
te_vcom and gterm. And do not start te_vcom or gterm twice.
[Trouble Shooting] If CLI prompt does not appear (including T-Monitor prompt TM>), please
reset the target by the reset switch of Reference Board.

3.2

Console Tools

Reference Kit comes with a variety of console tools useful for development, as well as Eclipse
dialogs. By Eclipse dialogs one can transfer and execute programs without console operation.
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 for development, especially file operation features. The standard prompt is [/SYS]%. See the“Development Tool Manual” at section of “Command Line Interpreter (CLI)” for details.
▷ The CLI prompt shows the working (current) directory name, which is set by cd command.

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

3

DEVELOPMENT

26

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 sections of “Utilities”, “UNIX (File) Emulator Command
Tools” and “Network Utilities” for details.
IMS (Initial Monitor System)
IMS is a T-Kernel based monitor. Its prompt is [IMS]% by default. See the “Development
Tool Manual ” at section of “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 section of “List ofCommands.” Reference Kit adds additional commands to T-Monitor for Flash ROM
writing and other functions. These additional commands are given in the “Implementation Specification” at section of “T-Monitor Implementation Specification.”
A simple practice is given below to illustrate use of the CLI and T-Monitor.
(1) Confirm CLI Prompt
On gterm in the console view, hit ←- (Enter) key several times, and confirm a CLI prompt(such as [/SYS]%).
[/SYS]%(2) List of CLI Commands
Enter the CLI command “?” to display a list of CLI commands.
[/SYS]% ?←att

det

eject

CLI command list
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←SBOOTKERNEL.SYS

Getting Started with Reference Kit

SYSCONF· · · omitted · · ·c 2011–2014 Personal Media Corporation⃝

3

DEVELOPMENT

27(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 · · ·(7) T-Monitor Command Help
Use the T-Monitor command “?” to display details of the “iw” command.
TM> ? iw←InputWord(IW) port : Input Word from I/O port
(8) I/O readUse the T-Monitor command “iw” to read 32 bit value from address 0xc0050010 (GIO[31:0]
input data read register) to read status of push switchs SW1,2,3,4.
SW1
TM> iw c0050010←- — SW1 pushed
SW2
Port C0050010:W --> 00000101
TM> iw c0050010←- — SW2 pushed SW3
Port C0050010:W --> 00000081
SW4

bit8

0x00000100

bit70x00000080

bit60x00000040

bit40x00000010(9) 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 Reference Board are generally classified as either process-based programs
or T-Kernel-based programs.
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 failure
will not cause system down.
Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

3

DEVELOPMENT

28

As memory space, an independent local space is assigned to each process. A process has
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() function terminates, the process terminates as well.
APIs available in process-based programs are described in the following documents inthe “KIT” CD.
• “PMC 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 functions are available only on process.
• “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, since hardware 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. At thistime the main() function is called, and the first argument ac indicates the number ofarguments passed. Ordinarily, task and handler creation and other initialization takes
place in this processing.
The unlspg command can be used to unload a program. Here, the main() function iscalled again; but this time a minus value is passed in ac. Post-processing such as deleting
the initial task and handlers normally takes place in this processing.
APIs available in T-Kernel-based programs are described in the following documents inthe “KIT” CD.
• “T-Kernel 2.0 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.

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

3

DEVELOPMENT

29▷ Some library are process-based only, or T-Kernel-based only, but other library can becommonly used.

• “Device Driver Manual ”
T-Kernel-based programs can call device drivers, as well as making device drivers.

3.4“Hello, world” as a Process-Based ProgramFirst 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 Workspace
Launch Eclipse, and on “Select a workspace” dialog, select the workspace “C:\te\bappl”
for process-based program, and click OK .
If you have already launched Eclipse and works on other workspace, switch workspace to“C:\te\bappl”, by Menubar → “File” → “Switch Workspace”.
▷ If you switched workspace, also terminate external tools te_vcom and gterm. Then you
have to run te_vcom and gterm again. On gterm in the console view, hit ←- (Enter) key
several times, and confirm a CLI prompt (such as [/SYS]%).

(2) Create Project
On “C/C++ Project” view, click the mouse right button to show a menu (or selectMenubar → “File”) and select “New” → “T-Engine C/C++ Project”.
And specify the following items.
• Project name: enter the project name, “hello”.
• Target: specify your target machine (em1d512_te).
• Program Type: specify “Process Base”.
▷ “Decide by workspace” is also right, if your workspace is C:\te\bappl.
• Create Template Program: check it and select and select “gdbsample: a sample
program for gdb operation”.
• Create Output Directory: check it.
And click Finish to create a new project “hello”. (Figure 3.1)

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

3

DEVELOPMENT

30

Figure 3.1

New Project Dialog(3) Create Source Program
The sources of the template are copied under the src directory of the project hello in
the “C/C++ Project” View. Double-click 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 Menubar → “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 Menubar → “File” → “Save”.
• hello/src/sub.c, hello/src/sub.h :Delete these files by right-click menu.

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

3

DEVELOPMENT

31(4) Make (compile and link)
Select the target Makefile, hello/em1d512.te/Makefile, in “C/C++ Project” view.
And then, select Menubar → “Project” → “Make T-Engine Target all” to make yourprogram.
If the make is succeeded, the executable file hello/em1d512.te/hello is generated.
▷ Process executable file is shown with a run or bug icon. The “bug icon” means that someof linked libraries include debug information, but it is all right.
[Trouble Shooting] If appears a message “Error launching builder”, confirm that you haveselected the make target hello/em1d512.te/Makefile.
And if appears a message “makedeps: Command not found”, confirm installation of Perl on/usr/local/bin/perl after Cygwin installation.

(5) Transfer and Run
Select the executable file hello/em1d512.te/hello, click the mouse right button toshow a menu, and select “Run As” → “Run Configurations”. Then appears the Run
Configurations Dialog.
On the dialog, select “T-Engine Application (T-Monitor)”, click the mouse right button
to show a menu, and select “New”. Then appears the default settings to transfer andexecute the program. (Figure 3.2)

Figure 3.2

Run Configuration Dialog▷ Also may appear “T-Engine Application (dbgmgr)”, but it is not used here.
Click Run at the bottom of the dialog to transfer and execute the program. Thenthe process is transferred and runs. And appears “Hello, world” on the gterm console.
(Figure 3.3)

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

3

DEVELOPMENT

32

Figure 3.3“Hello, world” appears on console[Trouble Shooting] The serial communication is required to transfer files to the target.
Confirm that you have run te_vcom and gterm again, and on the console window of 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 means read only
error. Please check that Reference Board 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 Workspace
Launch Eclipse, and on “Select a workspace” dialog, select the workspace “C:\te\kappl”
for T-Kernel-based program, and click OK .
If you have already launched Eclipse and works on other workspace, switch workspace to“C:\te\kappl”, by Menubar → “File” → “Switch Workspace”.
▷ If you switched workspace, also terminate external tools te_vcom and gterm. Then you
have to run te_vcom and gterm again. On gterm in the console view, hit ←- (Enter) key
several times, and confirm a CLI prompt (such as [/SYS]%).

(2) Create Project
On “C/C++ Project” view, click the mouse right button to show a menu (or selectMenubar → “File”) and select “New” → “T-Engine C/C++ Project”.
And specify the following items.
• Project name: enter the project name, “hello2”.
• Target: specify your target machine (em1d512_te).
• Program Type: specify “T-Kernel Base”.
▷ “Decide by workspace” is also right, if your workspace is C:\te\kappl.
• Create Template Program: check it and select the template “sample: print strings
sample program”.
• Create Output Directory: check it.
And click Finish to create a new project “hello2”.
Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

3

DEVELOPMENT

33(3) Create Source Program
The sources of the template are copied under the src directory of the project hello2 inthe “C/C++ Project” View. Double-click 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 Menubar → “File” → “Save”.
• hello2/src/Makefile :Change the make target to “TARGET = hello2”.
Save the modified file by Menubar → “File” → “Save”.
(4) Make (compile and link)
Select the target Makefile, hello2/em1d512.te/Makefile, in “C/C++ Project” view.
And then, select Menubar → “Project” → “Make T-Engine Target all” to make yourprogram.
If the make is succeeded, the relocatable executable file hello2/em1d512.te/hello2 isgenerated.
▷ Eclipse shows relocatable executable files by a “binary file icon”.
(5) Transfer and Run
Select the executable file hello2/em1d512.te/hello2, click the mouse right button toshow a menu, and select “Run As” → “Run Configurations”. Then appears Run Configurations Dialog.
On the dialog, select “T-Engine Application (T-Monitor)”, click the mouse right button
to show a menu, and select “New”. Then appears the default settings to transfer andexecute the program.
Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

3

DEVELOPMENT

34

Click Run at the bottom of the dialog to transfer and execute the program. Then the
program is transferred by recv command and loaded on the system common space bylodspg command.
And appears “Hello, world” on the gterm console.
(6) Show System Common SpaceOn the gterm console , use “ref spg” command to confirm that hello2 is loaded.
[/SYS]% ref spg←[ 1] - 0xd018b000 · · · omitted · · ·[13] - 0xd049d000 [/SYS]%

6

screen5

hello2▷ System program ID and load address may be diﬀerent.
(7) Unload Program
Now unload hello2 by executing the “unlspg” command, specifying the program by its
system program ID as displayed in the previous step (13 in the above example). Thenappears “Hello, world” on the gterm console.
[/SYS]% unlspg 13←See you again[/SYS]%

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

4

RUNNING LEARNING SAMPLE PROGRAMS

435Running Learning Sample Programs

The tutorial page (en\tutorial) on the “KIT” CD contains a collection of learning sample
programs.
• Juggling
This program shows juggling animation.
• Tiny Web ServerThis program transfers files from Reference Board to Web browsers on other PCs by
TCP/IP network.
• LED and Interrupt
This T-Kernel-based program blinks LED and detects switch by interrupt.
• Physical timer sample implementation
This T-Kernel-based program uses 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 soon.
(1) Select Workspace
Launch Eclipse, and on “Select a workspace” dialog, select the workspace “C:\te\bappl”
for process-based program, and click OK .
If you have already launched Eclipse and works on other workspace, switch workspace to“C:\te\bappl”, by Menubar → “File” → “Switch Workspace”.
▷ If you switched workspace, also terminate external tools te_vcom and gterm. Then you
have to run te_vcom and gterm again. On gterm in the console view, hit ←- (Enter) key
several times, and confirm a CLI prompt (such as [/SYS]%).

(2) Create Project
On “C/C++ Project” view, click the mouse right button to show a menu (or selectMenubar → “File”) and select “New” → “T-Engine C/C++ Project”.
And specify the following items.
• Project name: enter the project name, “juggling”.
• Target: specify your target machine (em1d512_te).
• Program Type: specify “Process Base”.
▷ “Decide by workspace” is also right, if your workspace is C:\te\bappl.
• Create Template Program: do not check it.
Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

4

RUNNING LEARNING SAMPLE PROGRAMS

36• Create Output Directory: check it.
And click Finish to create a new project “juggling”.
(3) Import Source Program
Select the created project “juggling”. Select right-click menu → “Import” (or Menubar→ “File” → “Import”) to open Import Dialog.
Open “General” and select “Archive File”. Click Next .
Click Browse at “From archive file” to open “Import from Archive File” dialog. Select“juggling.zip” in the “T-Kernel 2.0 Reference Kit” CD and click Open . And click
Finish . Now the source program is imported in juggling/src.
(4) Make
Select the target Makefile, juggling/em1d512.te/Makefile, in “C/C++ Project” view.
And then, select Menubar → “Project” → “Make T-Engine Target all” to make yourprogram.
If the make is succeeded, the executable file juggling/em1d512.te/juggling is generated.
(5) Transfer and Run
Select the executable file juggling/em1d512.te/juggling, click the mouse right button
to show a menu, and select “Run As” → “Run Configurations”. Then appears Run
Configurations Dialog.
On the dialog, select “T-Engine Application (T-Monitor)”, click the mouse right button
to show a menu, and select “New”. Then appears the default settings to transfer andexecute the program.
Click Run at the bottom of the dialog to transfer and execute the program. Then the
program is transferred by recv command and runs. Juggling animation is showed on thescreen of Reference Board(Figure 4.1)

Figure 4.1

Getting Started with Reference Kit

Run Jugglingc 2011–2014 Personal Media Corporation⃝

4

RUNNING LEARNING SAMPLE PROGRAMS

37(6) Make for Debugging
To debug your program, the executable file must include debug information. To make that
file, make your program on the folder with a debug option, such as “em1d512.te.debug”.
Select the target Makefile, “juggling/em1d512.te.debug/Makefile”, in “C/C++ Project”
view. And then, select Menubar → “Project” → “Make T-Engine Target all” to makeyour program.
If the make is succeeded, the executable file “juggling/em1d512.te.debug/
juggling” is generated with debug information (showed by a insect icon).
(7) Start Debugging
Select the executable file “juggling/em1d512.te.debug/juggling”, click the mouseright button to show a menu, and select “Debug As” → “Debug...”. Then appears the
Debug Dialog.
On Debug Dialog, select “T-Engine Application”, click the mouse right button to showa menu, and select “New”. Then appears the default settings to transfer and debug the
program.
▷ There remains a previous setting created in (5) for execution. But create a new one fordebugging.

Click Debug at the bottom of Debug Dialog to transfer and debug the program. If
appears a “Confirm Perspective Switch” dialog, click Yes to switch perspective. Thenappears the Debug perspective.
(8) Set Breakpoint
The program is stopped at the beginning of the main() function. Now set a breakpointin the line “if (i > 0) sleep( i );” near the end of the main() function. At theleftmost side of this line, click the mouse right button to show a menu. Select “Toggle
Breakpoint” to set a breakpoint. (Figure 4.2)

Figure 4.2

Set a Breakpoint(9) Continue Execution
Click “Resume” button in Toolbar (or Menubar → “Run” → “Resume”) to continue
execution. The program runs until a breakpoint. (Figure 4.3)
Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

4

RUNNING LEARNING SAMPLE PROGRAMS

Figure 4.3

38

Continue Execution

By repeating this continuation, the balls move step by step on the target screen.
(10) Change Variables
When the program is stopped at a breakpoint, change the value of the variable N (numberof balls) in the variables view from 3 to 6. (Figure 4.4)

Figure 4.4

Change a Variable

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).
(11) Terminate Debugging
Click “Terminate” button ( ) in Toolbar (or Menubar → “Run” → “Terminate”) toterminate debugging. And click “Remove All Terminated Launches” button ( ) in the
debug view.
Select “T-Engine Development” near the right-top of the Eclipse window to back to
T-Engine Development Perspective.

4.2

Tiny Web ServerThis process-based tiny web server is provided as an example of a network application using
TCP/IP functions. Files on Reference Board are transferred to web browsers on other PCs.

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

4

RUNNING LEARNING SAMPLE PROGRAMS

39(1) Select a Workspace
Launch Eclipse, and on “Select a workspace” dialog, select the workspace “C:\te\bappl”
for process-based program, and click OK .
If you have already launched Eclipse and works on other workspace, switch workspace to“C:\te\bappl”, by Menubar → “File” → “Switch Workspace”.
▷ If you switched workspace, also terminate external tools te_vcom and gterm. Then you
have to run te_vcom and gterm again. On gterm in the console view, hit ←- (Enter) key
several times, and confirm a CLI prompt (such as [/SYS]%).

(2) Network Configuration
On gterm in the console view, hit ←- (Enter) key several times, and confirm a CLI prompt(such as [/SYS]%). Then use netconf command for network configuration.
If the network environment is one that assigns IP addresses automatically by DHCP, thedefault setting of 0.0.0.0 can be left as is. If not, first use the “netconf c” command toassign an IP address to Reference Board.
[/SYS]% netconf c ←hostname= ? tkernel←host ip= 0.0.0.0 ? 192.168.0.70←dns1name= ? ←dns1 ip= 0.0.0.0 ? ←dns2name= ? ←dns2 ip= 0.0.0.0 ? ←domain= ? ←gateway ip = 0.0.0.0 ? ←subnetmask = 255.255.255.0 ? ←wlan= none (n/a/i)? ←[/SYS]%— local host name— local IP address— DNS server #1— DNS server #2— domain name— gateway— subnet mask
— no wireless LAN▷ Instead of netconf command, Network Setup Utility (right-click → “Utility” → “Network
Setup”) is also available.

(3) Confirm Network Connection
On gterm in the console view, use the “ping” command to confirm the network connection.
[/SYS]% ping localhost ←localhost is alive <192.168.0.70> : 0 ms[/SYS]% ping 192.168.0.1 ←192.168.0.1 is alive <192.168.0.1> : 0 ms

— ping self
— pint another machine▷ In this example, the Reference Board IP address is 192.168.0.70 and that of another machineis 192.168.0.1. Change these as appropriate for the particular network environment.

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

4

RUNNING LEARNING SAMPLE PROGRAMS

40(4) Transfer Image Files
Transfer Image Files to the target side (Reference Board), for the contents of the tiny
web server.
On gterm in the console view, use the “recv” command to transfer image files from thehost PC to the target side (Reference Board).
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 Project
On “C/C++ Project” view, click the mouse right button to show a menu (or selectMenubar → “File”) and select “New” → “T-Engine C/C++ Project”.
And specify the following items.
• Project name: enter the project name, “webserv”.
• Target: specify your target machine (em1d512_te).
• Program Type: specify “Process Base”.
▷ “Decide by workspace” is also right, if your workspace is C:\te\bappl.
• Create Template Program: do not check it.
• Create Output Directory: check it.
And click Finish to create a new project “webserv”.
(6) Import Source Program
Select the created project “webserv”. Select right-click menu → “Import” (or Menubar→ “File” → “Import”) to open Import Dialog.
Open “General” and select “Archive File”. Click Next .
Click Browse at “From archive file” to open “Import from Archive File” dialog. Select“webserv.zip” in the “T-Kernel 2.0 Reference Kit” CD and click Open . And click
Finish . Now the source program is imported in webserv/src.
(7) Make
Select the target Makefile, webserv/em1d512.te/Makefile, in “C/C++ Project” view.
And then, select Menubar → “Project” → “Make T-Engine Target all” to make yourprogram.
If the make is succeeded, the executable file webserv/em1d512.te/webserv is generated.
(8) Transfer and Run
Select the executable file webserv/em1d512.te/webserv, click the mouse right button
to show a menu, and select “Run As” → “Run Configurations”. Then appears Run
Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

4

RUNNING LEARNING SAMPLE PROGRAMS

41

Configurations Dialog.
On the dialog, select “T-Engine Application (T-Monitor)”, click the mouse right button
to show a menu, and select “New”. Then appears the default settings to transfer andexecute the program.
Click Run at the bottom of the dialog to transfer and execute the program. Then the
program is transferred by recv command and runs.
(9) View from Web Browser
From PC on the network, enter the Reference Board IP address in a Web browser, andconfirm that the images are listed in the browser. If, for example, the Reference Board
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 web server.
(10) Terminate Process
On the console, send ^C (Ctrl-C) to terminate the web server process. Use “TE logo”
button upside the console view of Eclipse. (Figure 4.5)

Figure 4.5

4.3

Send ˆC on Eclipse

LED and Interrupt

This is a T-Kernel-based sample program to blink LED and detect switch by interrupt.
(1) Select Workspace
Launch Eclipse, and on “Select a workspace” dialog, select the workspace “C:\te\kappl”
for T-Kernel-based program, and click OK .
If you have already launched Eclipse and works on other workspace, switch workspace to“C:\te\kappl”, by Menubar → “File” → “Switch Workspace”.
▷ If you switched workspace, also terminate external tools te_vcom and gterm. Then you
have to run te_vcom and gterm again. On gterm in the console view, hit ←- (Enter) key
several times, and confirm a CLI prompt (such as [/SYS]%).

(2) Create Project
On “C/C++ Project” view, click the mouse right button to show a menu (or selectMenubar → “File”) and select “New” → “T-Engine C/C++ Project”.
And specify the following items.
Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

4

RUNNING LEARNING SAMPLE PROGRAMS

42• Project name: enter the project name, “ledint”.
• Target: specify your target machine (em1d512_te).
• Program Type: specify “T-Kernel Base”.
▷ “Decide by workspace” is also right, if your workspace is C:\te\kappl.
• Create Template Program: do not check it.
• Create Output Directory: check it.
And click Finish to create a new project “ledint”.
(3) Import Source Program
Select the created project “ledint”. Select right-click menu → “Import” (or Menubar→ “File” → “Import”) to open Import Dialog.
Open “General” and select “Archive File”. Click Next .
Click Browse at “From archive file” to open “Import from Archive File” dialog. Select“ledint.zip” in the “T-Kernel 2.0 Reference Kit” CD and click Open . And click
Finish . Now the source program is imported in ledint/src.
(4) Make
Select the target Makefile, ledint/em1d512.te/Makefile, in “C/C++ Project” view.
And then, select Menubar → “Project” → “Make T-Engine Target all” to make yourprogram.
If the make is succeeded, the relocatable executable file ledint/em1d512.te/ledint isgenerated.
(5) Transfer and Run
Select the executable file ledint/em1d512.te/ledint, click the mouse right button toshow a menu, and select “Run As” → “Run Configurations”. Then appears Run Configurations Dialog.
On the dialog, select “T-Engine Application (T-Monitor)”, click the mouse right button
to show a menu, and select “New”. Then appears the default settings to transfer andexecute the program.
Click Run at the bottom of the dialog to transfer and execute the program. Then the
program is transferred by recv command and loaded on the system common space bylodspg command.
By this program LED5, LED6, LED7 or LED8 starts blinking. By pushing SW4 changes
blinking pattern.

4.4

Physical Timer Sample Implementation

This is a T-Kernel-based sample program for physical timer.

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

4

RUNNING LEARNING SAMPLE PROGRAMS

43

There are several methods and implementations for physical timer, depending on
hardware and purpose. Hence T-Kernel 2.0 Reference Kit does not implement
physical timer as a standard, while one sample implementation is given in a source
program. Refer to the header comment of the source program about specificationand limitation of this sample physical timer.
(1) Select Workspace
Launch Eclipse, and on “Select a workspace” dialog, select the workspace “C:\te\kappl”
for T-Kernel-based program, and click OK .
If you have already launched Eclipse and works on other workspace, switch workspace to“C:\te\kappl”, by Menubar → “File” → “Switch Workspace”.
▷ If you switched workspace, also terminate external tools te_vcom and gterm. Then you
have to run te_vcom and gterm again. On gterm in the console view, hit ←- (Enter) key
several times, and confirm a CLI prompt (such as [/SYS]%).

(2) Create Project
On “C/C++ Project” view, click the mouse right button to show a menu (or selectMenubar → “File”) and select “New” → “T-Engine C/C++ Project”.
And specify the following items.
• Project name: enter the project name, “ptimer”.
• Target: specify your target machine (em1d512_te).
• Program Type: specify “T-Kernel Base”.
▷ “Decide by workspace” is also right, if your workspace is C:\te\kappl.
• Create Template Program: do not check it.
• Create Output Directory: check it.
And click Finish to create a new project “ptimer”.
(3) Import Source Program
Select the created project “ptimer”. Select right-click menu → “Import” (or Menubar→ “File” → “Import”) to open Import Dialog.
Open “General” and select “Archive File”. Click Next .
Click Browse at “From archive file” to open “Import from Archive File” dialog. Select“ptimer.zip” in the “T-Kernel 2.0 Reference Kit” CD and click Open . And click
Finish . Now the source program is imported in ptimer/src.
(4) Make
Select the target Makefile, ptimer/em1d512.te/Makefile, in “C/C++ Project” view.
And then, select Menubar → “Project” → “Make T-Engine Target all” to make yourprogram.
If the make is succeeded, the relocatable executable file ptimer/em1d512.te/ptimer isgenerated.
Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

4

RUNNING LEARNING SAMPLE PROGRAMS

44(5) Transfer and Run
Select the executable file ptimer/em1d512.te/ptimer, click the mouse right button toshow a menu, and select “Run As” → “Run Configurations”. Then appears Run Configurations Dialog.
On the dialog, select “T-Engine Application (T-Monitor)”, click the mouse right button
to show a menu, and select “New”. Then appears the default settings to transfer andexecute the program.
Click Run at the bottom of the dialog to transfer and execute the program. Then the
program is transferred by recv command and loaded on the system common space bylodspg command.
[/SYS]% lodspg ptimer
Physical timer number=1, clock=28672000[Hz], limit=2866
SYSPRG ptimer [14] d04a1000 - d04a7000[/SYS]% Hello 10000
Hello 20000
Hello 30000..
.
Physical timer handler is called in every 100 microseconds, and printf is called in every
10000th (1 second) time.

Getting Started with Reference Kit

c 2011–2014 Personal Media Corporation⃝

IndexB

N

breakpoint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 netconf command . . . . . . . . . . . . . . . . . . . . . . . . 39
CP

CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
continue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
cross-development . . . . . . . . . . . . . . . . . . . . . . . . 5
Cygwin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
physical timer . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
ping command . . . . . . . . . . . . . . . . . . . . . . . . . . 39
process-based . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

DR

debug information . . . . . . . . . . . . . . . . . . . . . . . 37 recv command . . . . . . . . . . . . . . . . . . . . . . . . . . 40
df command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 reset switch . . . . . . . . . . . . . . . . . . . . . . . . . . . 5, 25
ROM information . . . . . . . . . . . . . . . . . . . . . . . . . 9
EEclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

T

TCP/IP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Tera Term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
FlashLoad command . . . . . . . . . . . . . . . . . . . . . . 9 te_vcom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 T-Kernel-based . . . . . . . . . . . . . . . . . . . . . . . . . . 28
format command . . . . . . . . . . . . . . . . . . . . . . . . 11 T-Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
FG

U

gterm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 unlspg command . . . . . . . . . . . . . . . . . . . . . . . . 28
HW

hdpart command . . . . . . . . . . . . . . . . . . . . . . . . 10 web server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
HyperTerminal . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
I

IMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
J

Java Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
juggling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
L

LED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5, 41
lodspg command . . . . . . . . . . . . . . . . . . . . . . . . 28
ls command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Mmemory protection . . . . . . . . . . . . . . . . . . . . . . 27
microSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1045

Getting Started with Reference Kit
Version 1.03.00
Personal Media Corporation
Web: http://www.t-engine4u.com/
E-Mail: te-sales@personal-media.co.jp
c 2011–2014 by Personal Media Corporation
Copyright ⃝