Enhancing TINI

9 May

Enhancing TINI
In Chapter 6 we discussed the hardware perspective of the TINI stick, but TINI and its associated socket board were designed with flexibility and expansion in mind. In this chapter we will discuss a number of additions for TINI; some are part of the Dallas Semiconductor E10/E20 socket board but most are additional circuitry and are intended to demonstrate how you can add new peripherals to your TINI. For each new device, we will give detailed schematics and a Java program to demonstrate the capabilities of that device.

Adding 512 kbytes on the SIMM
TINI is currently available from Dallas Semiconductor in two versions depending on the amount of SRAM included on the stick: one version with 512 kbytes of SRAM (DSTINI1-512) and the other version with 1 Mbyte (two 512 kbyte chips) of SRAM (DSTINI1-1MG). Early in TINI’s development, Dallas Semiconductor was only shipping the 512 kbyte version but is now shipping both. The amount of memory that the TINI stick knows is available for use was determined by a software memory probe at boot time in the TINI API previous to version 1.02. In API 1.02, the amount of memory available is determined by examining the contents of the DS2502 1-Wire chip (1024 bits of write-once memory) on the TINI stick. This was implemented to avoid some of the possible errors that occur with a software probe1. It is possible to add memory to your TINI stick if you purchased a 512-kbyte version, but you will need to reprogram the DS2502 for the API to recognize that additional memory. This is not a simple effort, as the DS2502 needs a 12-volt program voltage to perform the EPROM write and this is not available on the TINI stick. You must remove the DS2502 and connect it to a 1-Wire bus that can deliver a 12-volt program pulse. If you are purchasing a new TINI, it is much more cost-effective to purchase a TINI with the full 1 Mbyte of memory than to purchase a 512-kbyte version and add another 512 kbyte on your own.

In the event that you decide to add memory to the TINI stick, the possible memories that are pin-for-pin compatible with the layout of the TINI stick are shown in Table 8-1.
Table 8-1: SRAM part numbers

Note that each of these memory chips is available in several speeds and several package styles. TINI uses the 55-ns memory in the 32-lead TSOP (thin small outline package).

Use the df command to find out the amount of free memory after booting. A number less than 512,000 indicates one memory chip (or lots of stuff in the file system) and a number between 512,000 and 1,024,000 indicates two memory chips (1 megabyte). The exact amount of free RAM will vary depending on what you have stored on your file system. You can use the TINIOS class for your programs to determine the amount of free memory.

Listing 8-1: FreeMem.java

import com.dalsemi.system.*;
import com.dalsemi.tininet.*;
// Class FreeMem tells us how much FreeMemory TINI has available
class FreeMem {
public static void main(String[] args) {
String hn = TININet.getHostname();
int ram                              = TINIOS.getFreeRAM();
System.out.println( “Node “ + hn + “ has “ + ram + “ free RAM.” );
}
}
Compile this and convert it to a TINI file with the following commands:
C:\> javac -bootclasspath                                                      %TINI_HOME%\bin\tiniclasses.jar
-d bin src\FreeMem.java
C:\> java                                                                      -classpath %TINI_HOME%\bin\tini.jar;. BuildDependency
-p                                                                             %TINI_HOME%\bin\owapi_dependencies_TINI.jar
-f bin
-x                                                                             %TINI_HOME%\bin\owapi_dep.txt
-o bin\FreeMem.tini
-d %TINI_HOME%\bin\tini.db
Try this out on a 1-megabyte TINI (and with a relatively empty file system):
TINI /> java FreeMem.tini
Node TINI has 710528 free RAM.
TINI />

The amount of memory TINI has installed is stored on the DS2502. If the data in page 0 of the DS2502 is corrupted, TINI tries to figure out the amount of available memory using a software probe. If you add memory it will be wrong until you corrupt the DS2502. Be careful as this is where the TINI MAC address is stored. 2 3 The following program dumps the contents of the DS2505 in hex and ASCII so we can see what’s there:

Listing 8-2: UniDump.java
import java.util.*;
import com.dalsemi.onewire.*;
import  com.dalsemi.onewire.adapter.*;
import  com.dalsemi.onewire.container.*;
import  com.dalsemi.onewire.utils.*;
// Class UniDump – Tells us all about whats stored in the TINI
// UniquieWare 1-wire chip
class UniDump {
public static void dump( byte[] data, int width)
{
int i=0;
boolean done=false;

int w = width;
int pad=0;
do {
if ((i+width)>(data.length-1)) {
done=true;
w=data.length-i;
pad=(width-w)*3;
}
System.out.print( ByteUtils.toHexString(data,i,w) );
for (int j=0; j<pad; j++) System.out.print( “ “ );
System.out.print( “
System.out.println( ByteUtils.toAsciiString(data, i,w) );
i+=width;
} while (!done);
}
public static void main(String[] args)
{
try {
DSPortAdapter adapter = OneWireAccessProvider.getAdapter(
“TINIInternalAdapter”, “default” );
System.out.println( “Adapter: “ + adapter.getAdapterName() );
System.out.println( “Port: “ + adapter.getPortName() );
if (adapter.adapterDetected()) {
System.out.println( “Searching for all 2502 devices” );
System.out.println( “(0×89 family code devices)” );
adapter.setSearchAllDevices();
adapter.targetFamily( 0×89 );
Enumeration ibutton_enum = adapter.getAllDeviceContainers();
while( ibutton_enum.hasMoreElements() ) {
OneWireContainer node =
(OneWireContainer)  ibutton_enum.nextElement();
System.out.print( “Found Container “ + node.getName() );
System.out.println( “at address “
+ node.getAddressAsString() );
System.out.println( “” );
for (Enumeration banks=node.getMemoryBanks();
banks.hasMoreElements(); ) {
//
Object memobj = banks.nextElement();
MemoryBank mem = (MemoryBank)memobj;
PagedMemoryBank pmb = (PagedMemoryBank)memobj;
System.out.println( “Has “
+ pmb.getNumberPages() + “ pages of “
+ pmb.getPageLength() + “ bytes each” );
int pages = pmb.getNumberPages();
System.out.println( “Bank: “
+ mem.getBankDescription() );
System.out.print( “size is “
+ mem.getSize() );
System.out.print( “, start address is “
+ mem.getStartPhysicalAddress() );
System.out.println(“”);
if (mem.isWriteOnce()) {
System.out.print( “write protected” );
}
if (mem.isReadWrite()) {
System.out.print( “, read/write” );
}
if (mem.isNonVolatile()) {
System.out.print( “, non volatile” );
}
if (mem.isReadOnly()) {
System.out.print( “, read only” );
}
if (mem.needsPowerDelivery()) {
System.out.print( “, needs power delivery” );
}
if (mem.needsProgramPulse()) {
System.out.print( “, needs program pulse” );
}
System.out.println( “” );
byte[] buff2=new byte[pmb.getPageLength()];
for (int i=0; i<pages; i++) {
pmb.readPageCRC( i, false, buff2, 0 );
dump( buff2, 16 );
System.out.println( “” );
}
}
}
}
adapter.freePort();
}
catch (Exception e) {
System.out.println(e);
}
}
}

This program uses two methods from the ByteUtils class (found in Appendix B on the CD-ROM) to print out the byte array in hex and ASCII. To compile this, you need to add -add  OneWireCOntainer09 to the BuildDependency options:

C:\> cd src
C:\> javac -bootclasspath %TINI_HOME%\bin\tiniclasses.jar
-d ..\bin UniDump.java
C:\> cd ..
C:\> java -classpath %TINI_HOME%\bin\tini.jar;. BuildDependency
-p %TINI_HOME%\bin\owapi_dependencies_TINI.jar
-f bin
-x%TINI_HOME%\bin\owapi_dep.txt
-o bin\UniDump.tini
-d %TINI_HOME%\bin\tini.db
-add OneWireContainer09

Notice that we change the working directory to the directory where the Java source is located, so that javac can find the static methods in ByteUtils.java and compile that as well. We direct javac to place the class files in a separate directory (bin). We then run BuildDependency and tell it to convert the entire bin directory. We do this so we don’t need to tell BuildDependency which files in that directory we want to convert (we want them all). We will use this technique throughout the book.

The output of this program (on a 1-Mb TINI) looks like this:

TINI /> java UniDump.tini
Adapter: TINIInternalAdapter
Port: default
Searching for all 2502 devices
(0×89 family code devices)
Found Container DS1982at address 0A5E70005D54B589
Has 4 pages of 32 bytes each
Bank: Main Memory
size is 128, start address is 0
write protected, non volatile, needs program pulse

Has 1 pages of 8 bytes each Bank: Write protect pages and Page redirection size is 8, start address is 0 write protected, non volatile, needs program pulse

EE FF FF FF FF FF FF 00
TINI />

In case you are curious what’s here, in the first line of hex, the 6D 8B 00 35 60 00 (in bold in the UniDump output above) is the MAC address of this particular TINI. Compare this to the output of an earlier release of the TINI stick with 512 kbytes of memory. Not a lot of information was kept in the DS2502 (just the MAC address, also in bold, below).

Random Posts

Comments are closed.