TStik
App Note: Hello TStik
TINI400 in the familiar
SIMM72 module
package

TStik is powered by Dallas Semiconductor TINI


Hello TStik App Note

This app note will introduce you to writing programs using the TStik platform. It will show you an example build file using two class files and a native library, and will introduce you to the TStik configuration register.

Before you get started you need to set up TINI Ant. TINI Ant is a build tool that will greatly simplify building and deploying applications for TStik. All the build scripts in the Systronix app notes will be written in TINIAnt. It will save you a great deal of time when deploying any programs larger than a single class file, or using the Dallas One Wire API. See Practical Embedded Java for more information.

This App note will show you how to:

All files used in this project are contained in HelloTStik.zip revised 2004 Aug 05, prebuilt for TINIOS 1.13, and with many revisions to the example code.

Note: you must have a TStik with CPLD revision 1.2 or later. See the TStik errata for more details.

Here is the Ant target which created this project ZIP file. Note: the reference "/**/*" means "all the files in a directory".

< !-- top level ant task. depends on all other build tasks being completed. -->
< target name="jar" depends="TINI_flash,TINI_ram">
  <jar destfile="TStik_App_Notes.zip"><!-- The app note zip file -->
    <fileset dir="classes" /><!-- This needs to be in the root so the jar can be used in a classpath. -->
    <fileset dir="." includes="src/**/*"/><!-- source files and app note for the Hello TStik app note -->
    <fileset dir="." includes="doc/**/*"/><!-- Javadocs -->
    <fileset dir="." includes="build.xml"/><!-- Ant build file -->
<!-- Sample dependancies file for the Hello TStik app note. Also see %TINI_HOME%\BIN\owapi_dep.txt for a more complex dependancies file for One Wire. -->
    <fileset dir="." includes="Hello_TStik_dependancies.txt"/>
    <fileset dir="." includes="TINIload/**/*"/><!-- pre-built TINI programs and the required native library are in this directory -->
    <fileset dir="." includes="TStik_API.jar"/><!-- required jar file includes the java spi driver. -->
</jar>
</target>


User Source Code Overview

This app note contains three user defined code segments. The only one neccesary for running java programs is user source code. The other files are meant to demonstrate how to include both native libraries and java libraries in your TINI application. Including multiple java classes in your application will also be discussed.

  1. Hello_TStik.java user java source file.
  2. TINIload/TStik_spi_native_method_config_v100.tlib
  3. TStik_API.jar java class library.

Hello_TStik is written to demonstrate a couple of important TINI and TStik specific API features. First, the line of code:

Debug.setDefaultStreams(); // enable output in flash mode.

Sets System.out and System.in to the input and output streams of Serial0. These streams are actually forwarded from javax.comm streams by the TINIOS. Serial0 can also be used as a general purpose javax.comm serial stream, but you must type the command

stopserver -s

into slush first to avoid a resource conflict. Second, the line of code:

/** null args are either no arguments passed, or program running from flash. */
if (args == null || args.length == 0)

demonstrates the way main arguments are passed into the program. If the program is running from flash, the command line arguments are null. If no arguments are passed, slush passes in a String[] of length 0. Testing for null first prevents the length check later. If arguments are present, each argument is a separate element of the arguments array and can be processed later as is shown in the remainder of the program.

TINIload/TStik_spi_native_method_config_v100.tlib is a minimal spi library meant to write to the configuration register. It is based on the Dallas SPI app note located under the SPI directory after the licence agreement. Systronix uses different SPI pins for TStik than Dallas uses for the M400, so TStik users should always use the Systronix SPI library.

This library is implemented in 8051 assembly code and is accessed through a java wrapper class located in TStik_API.jar. Currently, this jar only holds the wrapper class and is included in the build from the build.xml build script.


Building User Programs for TINI and TStik

I will explain how user programs are built by explaining each Ant target in the build.xml file used to build the Hello_TStik.zip file containing all the source, class and TINI files used in this app note.

build.xml Ant targets:

  1. Init: displays environment variables needed to build TINI projects to the screen. When these variables print out they should contain the paths appropriate to your system. See Practical Embedded Java for more information on what each variable should be.
  2. TINI_compile: This task compiles Hello_TStik.java into Hello_TStik.class. Note the bootclasspath attribute that specifies the TINI runtime instead of the default JDK 1.4.1 runtime used for the PC.
  3. javadoc: This creates the documents found in the /doc folder from comments embedded in Hello_TStik.java.
  4. Hello_Ram: This task specifies TINI build options explained in Building for Slush. Use this option if you want to invoke Hello TStik from the slush command shell. The Hello executable will be saved in TStik's NVRAM. The slush command shell with its services such as ftp, telnet, etc, is still present and available. NVRAM programs are more flexible but less reliable. If circumstances lead to a corrupted heap, the TINIOS will flush all NVRAM contents including the file system (and any of you applications in it).
  5. Hello_Flash: This task specifies TINI build options explained in Building for Flash. This option makes Hello TStik the default user application in flash bank 47, *instead of* slush. This is a simple example of creating an application which is stored in flash and will always boot up after a TStik reset. Slush will not be present in this case, so the slush services such as telnet or ftp are not available. Storing your application in flash is the most reliable way to store a program. Heap corruption which causes NVRAM to be purged will not affect your flash application.
  6. TINI_ram and TINI_flash: Both of these tasks are simple dependancies on Hello_Ram and Hello_Flash. You can add your own programs to these tasks by adding your ant tasks to the dependancy list.
  7. jar: builds the Hello_TStik.zip file. The classes directory is moved to the root so that this can actually be used as a jar file in a classpath. A jar file is a zip file containing class files stored in folders named after each class's package and whatever other arbitrary files you would like to include.

Building for Slush

To build for slush, you must include the options in the Hello_Ram target:

  • mainclass: The class containing the main(String[] args) method you want to run
  • classpath: Must include TINI.jar. Also make sure your classpath environment variable includes the current directory and other things specified in Practical Embedded Java.
  • dependancyfile: dependancies are different from the convert files because only the files listed in a dependancy are included in the final TINI application. They are defined in the %TINI_HOME%\doc\BuildDependency_README.txt file under section "II. Dependency File Creation". The example dependancies file, Hello_TStik_dependancies.txt is a single dependancy with a single file in the dependancies list.
  • Outputfile: The completed TINI application to be FTPed to TStik.
  • verbose: yes, get more messages
  • convert: All the files specified in convert are added to the finished TINI application. If you have several TINI applications built under the same classes folder, all the class files for each program will be included in the Outputfile. Use dependancies to reduce the size of your Outputfile.
  • dependpath: Locations to find each class file in the dependancies listed below.
  • depend: Name of a class list in your dependancyfile file. Each class in the list will be included in the Outputfile.

Running Ant

To build a target in build.xml just type in ant <target name> for this example type 'ant Hello_Ram'


TStik Configuration Register

The configuration register is a simple hardware SPI register implemented in a CPLD. Configuration register details are documented here.


Loading files to TStik using FTP

Before files can be loaded onto your TStik, its IP information needs to be entered. First, log into Slush using username 'root', password 'TINI'. Next, type the word 'ipconfig' into the Slush prompt. This will display your TStik's current IP information. If your TStik has been assigned an address using DHCP, it will be displayed here. Type 'help ipconfig' to display a list of ip configuration options. A typical DHCP setup will be set by 'ipconfig -d'. Static ip coniguration will be set with 'ipconifg -a 10.0.0.100 -m 255.255.255.0 -g 10.0.0.1'. The first parameter is the ip address you want to assign your TStik. The second parameter is the subnet mask and the third parameter is the gateway address.

Once your TINI has been assigned an IP address, plug it into your network and ping it from your computer. Open a command prompt, or unix shell and type the command 'ping 10.0.0.100'. If you get a reply, you are ready to connect to TStik with FTP.

You can use any FTP client with TStik. One of my favorites is Internet Explorer. If you type 'FTP://root@10.0.0.100' into the address bar of internet explorer, where 10.0.0.100 is the ip address of your TStik, IE will open a "web folder" with a list of files loaded onto TStik. You can then drag and drop arbitrary files onto your TStik from Windows Explorer, so long as there is enough memory to store them.

Load the files 'Hello_TStik.TINI' and 'TStik_spi_native_method_config_v100.tlib' to the TINI file system along with any other TINI programs you would like to run.


Executing your program using Telnet

The Slush command shell can be accessed by Telnet (TCP/IP) or JavaKit (serial). Type 'telnet 10.0.0.100' (user your actual IP address) to connect to your TStik. Log into Slush using username 'root', password 'TINI'.

Slush works much like a DOS prompt or Unix shell. Type the command 'help' for a list of Slush commnads. Type the commnad 'dir' into slush (look for the Hello_Tstik.TINI file) to verify that your FTP load was successful. Next type 'java Hello_TStik.TINI' to execute your TINI program. The Hello_TStik program will then run through all the configuration register options to show you what they do. Most of the effects are not detectable without hardware that utilizes these options, but the two configuration bits that you can see in action immediately are Serial0 shutdown and Ethernet shutdown. Both of these modes will save power if you know you will not be using these communications interfaces. From Telnet type the command 'java Hello_TStik !Serial0'. This will disable serial0 and will cause slush on Javakit to stop responding. Type 'java Hello_TStik Serial0 to re-enable Serial0 and slush from JavaKit.


Building your program for Flash

Building your program for flash makes it less susceptible to file system corruption, and memory erasure and increases the amount of nvram you can use to store objects on the heap. When running from flash, you do not get the features of slush, an interactive command shell, FTP server and telnet. The Flash target is almost the same as the Ram target. There are only a few options that need to be changed in order for it to work.

  • flash: 'yes' tells TINIAnt to build for flash instead of slush.
  • target address: The memory maps for the DSTINI1 module and TStik are different. Part of this difference is the user application (Slush or your own flash application) location. Both DSTINI1 and TStik divide memory into banks -- 1 Mbyte each for DSTINI1 and 2 MBytes for TStik. The TINI390 loader is in flash in memory bank zero. The TINIOS Java interpreter is stored in banks 0x01 through 0x06 and slush or other user code is stored in bank 0x07. TStik and other DS80C400 based modules have their loaders in silicon ROM. This means all DS80C400-based systems cannot have their loaders accidentally (or deliberately) erased. You have access to the loader even in complete absence of external memory. TStik stores the TINIOS in memory banks 0x40 through 0x46 and user code or slush is stored in bank 0x47. TStik has far more flash than DSTINI1, but at this time (TINI 1.11) JavaKit will not load user programs larger than a single block into flash. Using netboot, it should. in theory, be possible to load larger programs into flash. This will be discussed in an upcoming app note.
  • native: This tag specifies a TINI native library to be included in the tbin output file. Without the FTP feature of slush, all code the program needs to run must be included in the completed TINI application file. This tag will not work when building for slush, you still must FTP any native libraries to the TINI file system.

Loading Your Program Using JavaKit

TStik comes with TINIOS and Slush pre-loaded.

To load your user program in place of slush, first make sure that DTR reset is enabled using JP5 on your TILT400 board (or equivalent jumper on other socket boards). Next, click on the reset button in JavaKit. This should start the serial loader. Next, use the JavaKit menu file-> load file and browse to your completed .tbin file. Open the file and wait for the message "Load Complete" to appear in JavaKit. Your load is now complete.

To restore Slush, load the file '%TINI_HOME%\bin\Slush_400.tbin' into your TStik. To upgrade your firmware from the version 1.11 that currently comes with TStik, load the file TINI_400.tbin and Slush_400.tbin from the new version's .bin directory. Make sure to keep your TINI_HOME environment variable consistant with your new firmware and rebuild all applications you want to run on the new version.


Executing your flash application

If you are connected to the serial loader, use the 'E' command. You can also power cycle your TStik.

Each time your TStik is powered up, whatever flash application is stored in bank 0x47 will automatically execute.

 
Systronix® 939 Edison Street, Salt Lake City, Utah, USA 84111
contact us
 

Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
Systronix is independent of Sun Microsystems, Inc.
TStik, JStik, JCX, JStamp, JSimm, JDroid, and JRealTime are trademarks of Systronix, Inc.
1-Wire, iButton and TINI are trademarks of Dallas Semiconductor
Simmstick is a trademark of Dontronics