Practical Guide to Getting Started with the TS-4100

 

This practical guide gives us an opportunity to take a relaxed approach to getting started with the TS-4100 computer. We’re going to take a look at how to make our first connections, and setup the network. These are usually the first things we do before starting development. In the grand scheme of things, this is just a friendlier extrapolation from the official TS-4100 manual, so be sure to keep it handy for more advanced topics and specific details. The only assumption being made is that you’ve purchased the TS-4100 with a development kit, including the pre-programmed microSD card and TS-8551 reference board. Right then, let’s get started!  Home

Connections and Jumpers

Let’s get our TS-4100 hooked up with our TS-8551! This includes our very basic connections we’ll need for most any development or project: power, serial console, Ethernet, and WiFi.

Let’s take a look at the most basic of connections: serial console, power, and Ethernet. Follow along in order and we’ll be ready for the next section when we actually apply power and start using the TS-4100.

Jumpers

Out of the box, the TS-4100-8551 has its jumpers set to 1.) boot from the onboard eMMC flash, 2.) drop you to a U-Boot shell, and 3.) charge the TS-SILO supercaps. Certainly, it depends on your preferences when it comes to setup for development, but we’re going to go with the jumper configuration you see in the image above. That is, we will 1.) boot to the SD card, 2.) skip U-Boot shell and boot straight into the Debian environment, and 3.) not charge the TS-SILO supercaps so we can disconnect power without needing to wait for them to discharge (20 – 60 seconds). Later in this guide, we’ll re-enable TS-SILO supercaps charging so we can test their capabilities.  Home

Serial Console

A good ‘ol serial console provides a reliable and consistent connection to the single board computer. Other methods like SSH or Telnet are nice too, but a serial console isn’t prone to failure because of botched startup scripts or network snafus.

The TS-4100-8551 offers two port choices when it comes to serial console connections: USB serial on the TS-4100 and DB-9 on the TS-8551. It’s up to you which to choose, just don’t attempt to use both at once (undefined behavior). If you go the DB-9 route, you’ll need a null modem cable and possibly a Serial to USB adapter since computers don’t usually come with serial ports anymore. This author’s preference is to use the USB port to get a console, so that’s what we’ll cover in detail.  Home

It’s recommended that you work from a Linux development machine. Not only are the serial port drivers already installed, but you’ll also need it if you plan on using our cross compile toolchains for a larger project later on. For now, if you’re on a Windows or Mac OSX machine, you can obtain the serial port drivers from the Silabs USB-to-UART drivers page.

The image above shows the TS-4100 serial port connection without the TS-8551 reference board. While this is entirely okay to do, just note that for now, we should be connected to the reference board.

Next step is to connect the micro USB cable to your computer and follow the instructions given in the “Get a Console” section of the TS-4100 manual. This author’s preference is minicom, a no-frills, cross-platform serial communications program. Basically, we’re setting the baud rate to be 115200, 8N1, no hardware or software flow control. Typically, your serial device name may be:

  • Linux, /dev/ttyUSB0
  • Mac OSX, /dev/tty.SLAB_USBtoUART
  • Windows, use device manager to discover COM port

After setting some jumpers and applying power, which we’ll talk about both next, you’ll see something similar to the screenshot below (Mac OSX Terminal running minicom):

Then, you’ll simply login using the username ‘root’ without any password.

Pro-tip: Running minicom alone will constrain the terminal row and column count to something pretty small that will never take up the whole terminal window. To take advantage of all the real estate your terminal window has to offer, run TERM=linux minicom
instead. Remember to setup an alias as a shortcut for yourself!  Home

Pro Tip: If you’d like to use SSH after setting up your network connection, you’ll need to set a password. Run passwd  to create a password followed by dpkg-reconfigure openssh-server . Also, refer to the “Setting up SSH” section of the TS-4100 manual.

Power

The TS-8551 has both variable input voltage of between 8 to 28 VDC and fixed input voltage of 5 VDC. We’ll be using the 12 VDC power supply that comes with the development kit (Part# PS-12VDC-REG-2_5AMP-3PB). The boot process will begin immediately once you plugin the power supply and flip the large “Power” switch on the TS-8551 (switch toggled up). If you have a serial console program up and running, you’ll see the boot messages displayed on the console.

As shown in the image above, you’ll need to remove the pre-populated power connector, then flip the switch, as shown below.

There will be a green and red status LEDs lit on the TS-8551. If you’ve been following along and completed the serial console steps, you should also see bootup messages.

One of the appealing things about the TS-4100 is the fact that it can run by itself without the need for a baseboard. This essentially gives you a very small System on Module. There are limitations, like the lack of connectors, but it’s a powerful concept for some applications. Anyways, if you’re looking at running the TS-4100 without the TS-8551 board, you’ll be powering the system using a micro USB cable (5 VDC) plugged into the USB port marked P1, as shown in the image below.  Home

Ethernet

Undoubtedly, you’ll want to connect the TS-4100 to a network for SSH access, or NFS booting, or communicating with other systems, or downloading new programs, or countless other number of reasons. The first thing to note is the TS-4100 comes with two 10/100 Ethernet connections. The primary, designated as eth0, is located next to the vertical USB connector. The secondary, designated as eth1, will be populated to the next to the primary. Plug in a standard Ethernet cable connected to your router or switch, and continue reading for further instructions on setup. Of course, you could go wireless as well, but for development, a good ‘ol solid Ethernet connection eliminates a lot of guesswork and headache.

About the Embedded Linux Environments

The TS-4100 has the ability to boot to several different OSs and environments via U-Boot, a general purpose bootloader residing in the boot partitions of the on-board eMMC. You can find out more about the U-Boot environment by taking a look at the “U-Boot Environment” section of the TS-4100 manual. Currently, the supported OS image is Debian Linux, running the 3.14 kernel, which is preloaded onto the onboard eMMC flash and microSD card (sold as a separate option, included in development kit).

Pro Tip: For development, best practice is to boot to microSD card for ease of recovery should something go wrong. Just plug the microSD card into a development machine and modify files directly.

The onboard eMMC flash can be configured in two ways: 4 GB MLC for maximum capacity, and 2 GB pSLC (pseudo-SLC) for maximum data reliability. The images all weigh in at about 1.2 GB (or less), so while you could use either option, you may be uncomfortable with space restrictions with 2 GB pSLC.

Pro Tip: We’ve taken a hint from the eMMC flash manufacturer and called it pseudo SLC, or pSLC because it ships as MLC and SLC-like operation can be performed by running a command, which blows a fuse on the chip, making it behave like SLC flash.

Otherwise, the flash and microSD card contain two partitions, a small one where U-Boot is located and the larger one where the filesystem and kernel are located. U-Boot understands how to load the kernel, device tree, and boot arguments and run the OS from the one partition. More information about U-Boot startup sequence can be found in the “U-Boot” section of the TS-4100 manual.    Home

Pro Tip: If you’d like to run your application automatically upon boot, which is a very common request, take a look at the “Starting Automatically” section of the TS-4100 manual.

Setup Networking

If you recall, we’re going to be setting up our eth1 network interface. For this, we’re going to follow the “Configuring the Network” section of the manual. First, we’ll enable the network interface, and then we’ll go about obtaining an IP address. The easiest way to get an IP address is dynamically using DHCP. For some applications, like a web server, a static IP address is better to use. We’ll take a look at both.

Dynamic IP

Out of the box, the TS-4100 will automatically attempt to obtain an IP address via DHCP on eth0. There isn’t anything you should have to do, but it’s good practice to know how it works. You can skip this if you’d like, but we’re going to manually go through the steps.

First, we need to enable the eth0 network interface by issuing the following command:

root@ts-imx6ul:~# ifconfig eth0 up
root@ts-imx6ul:~#

Then, in order to get an IP address, we issue the command:

root@ts-imx6ul:~# dhclient eth0
root@ts-imx6ul:~#

Issuing the ifconfig command should show us our connection information, which in this case the board was assigned the IP address of 192.168.1.107:

root@ts-imx6ul:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.107  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::604b:30ff:fe78:603b  prefixlen 64  scopeid 0x20<link>
        ether 00:d0:69:4e:f2:e9  txqueuelen 532  (Ethernet)
        RX packets 21  bytes 4765 (4.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14  bytes 1626 (1.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 36  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 1  bytes 112 (112.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1  bytes 112 (112.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@ts-imx6ul:~#

Nothing to it! You should now be able to ping an external URL to test your connection:

root@ts-imx6ul:~# ping debian.org
PING debian.org (5.153.231.4) 56(84) bytes of data.
64 bytes from senfter.debian.org (5.153.231.4): icmp_seq=1 ttl=44 time=137 ms
64 bytes from senfter.debian.org (5.153.231.4): icmp_seq=2 ttl=44 time=137 ms
64 bytes from senfter.debian.org (5.153.231.4): icmp_seq=3 ttl=44 time=135 ms
64 bytes from senfter.debian.org (5.153.231.4): icmp_seq=4 ttl=44 time=134 ms
^C
--- debian.org ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 134.756/136.319/137.636/1.293 ms
root@ts-imx6ul:~#

Next time we boot the system with the Ethernet cable plugged in, we should automatically be connected to our network via DHCP. For this, we rely on systemd . Let’s take a look really quick at how that works. First, let’s take a look at the file responsible for setting up our Ethernet device at /etc/systemd/network/eth.network.    Home

root@ts-imx6ul:~# cat /etc/systemd/network/eth.network
[Match]
Name=eth*
 
[Network]
DHCP=yes

Pro Tip: If the file doesn’t exist, go ahead and create it with the content you see above. This will automatically setup your network interface next time the board is powered on.

What we’re saying here is any Ethernet device (eth*) will obtain an IP address via DHCP. We’ll want to change the [Network] section to enable static IP address, which we’ll talk about in the next section. For now, let’s take a look at the status of systemd-resolved.service.

root@ts-imx6ul:~# systemctl status systemd-resolved.service 
⚫ systemd-resolved.service - Network Name Resolution
   Loaded: loaded (/lib/systemd/system/systemd-resolved.service; enabled)
   Active: active (running) since Thu 2017-06-15 17:20:49 UTC; 3min 5s ago
     Docs: man:systemd-resolved.service(8)
 Main PID: 354 (systemd-resolve)
   Status: "Processing requests..."
   CGroup: /system.slice/systemd-resolved.service
           └─ /lib/systemd/systemd-resolved

Jun 15 17:20:49 ts-imx6ul systemd[1]: Started Network Name Resolution.

If it doesn’t say loaded and active, then we’ll need to issue the commands below. Otherwise, skip this part.

systemctl start systemd-resolved.service
systemctl enable systemd-resolved.service
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

Perfect. We should be good to go now. Give your system a reboot and make sure it comes back up with an DHCP assigned IP address.

Static IP

For this, we’ll create the /etc/systemd/network/eth0.network file and add the following text to it. Make sure to modify it to fit your specific network settings. Here, I want to assign the IP address of 192.168.1.122.

root@ts-imx6ul:~# cat /etc/systemd/network/eth0.network 
[Match]
Name=eth0
 
[Network]
Address=192.168.1.122/24
Gateway=192.168.1.1
DNS=192.168.1.1

And so that we don’t confuse dynamic and static IP address settings, let’s remove or move the eth.network file.

root@ts-imx6ul:~# mv /etc/systemd/network/eth.network /etc/systemd/network/eth.network.bak

Now, restart the system. Once we’ve logged back in, we’ll do a quick test by issuing the ifconfig eth0 command and double check that our IP address has now changed.

root@ts-imx6ul:~# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:d0:69:4d:8c:3a  
          inet addr:192.168.1.122  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::2d0:69ff:fe4d:8c3a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:94 errors:0 dropped:0 overruns:0 frame:0
          TX packets:19 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:15590 (15.2 KiB)  TX bytes:1466 (1.4 KiB)

That’s it! You should now be good to go. Next, we’ll talk about wireless connections.

Wireless Networking

The wireless module of the TS-4100, the Microchip ATWILC3000, is not only capable of connecting to a wireless access point, but it can also behave as an access point itself (aka master mode). We’ll concentrate on connecting to an access point in this guide. If you’d like to use it as an access point, you’ll want to review the “Host a WIFI Access Point” section of the TS-4100 manual.

We’ll need to repeat the step of creating the interface configuration file like we did in the wired section before this. So, create the file /etc/systemd/network/wlan0.network and populate it with the following:

root@ts-imx6ul:~# cat /etc/systemd/network/wlan0.network
[Match]
Name=wlan0
 
[Network]
DHCP=yes

Next, we’ll enable the interface, scan for an access point, and then associate with it. Enabling the wireless interface is a simple command:

ifconfig wlan0 up

Then, we’ll want to scan for access points using iwlist like so:  Home

iwlist wlan0 scan

The output can be overwhelming, so you may want to filter out just the ESSID names using the command:

iwlist wlan0 scan | grep ESSID | cut -d':' -f2

Okay, so once you’ve identified an access point you want to connect to, you’ll need to associate with it. Now, there are open access points that don’t require any credentials to associate and there are protected ones using WEP or WPA security types.

Open Access Point

This is the easiest. You’ll be able to simply issue the following command to associate:

iwconfig wlan0 essid "default"

Now, make sure you’ve associated with the access point:

root@ts-imx6ul:~# iwconfig wlan0
wlan0     IEEE 802.11bgn  ESSID:"default"  
          Mode:Managed  Frequency:2.417 GHz  Access Point: c0:ff:ee:c0:ff:ee   
          Bit Rate=1 Mb/s   Tx-Power=20 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=70/70  Signal level=-34 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

Finally, run dhclient eth0  to get an IP address.

WEP Protected Access Point

Very similar to ‘Open Access Point’ section above except you’ll need to specify a password:

iwconfig wlan0 essid “default” key “yourpassword”

Same as above, follow up with iwconfig wlan0 and dhclient wlan0.

WPA Protected Access Point

For this, we’re going to use the wpa_passphrase and wpa_supplicant utilities which make life easier. First, create the /etc/wpa_supplicant/ directory and generate a passphrase configuration file. Replace ‘the_essid’ and ‘the_password’ with the ESSID and password to connect to the access point.

mkdir /etc/wpa_supplicant/
wpa_passphrase the_essid the_password >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

You can take a look at this file, but essentially it contains information and a hashed password for the association. Next step is to start the wpa_supplicant daemon which will run in the background.

wpa_supplicant -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant-wlan0.conf -B

You should see output similar to this:

root@ts-imx6ul:~# wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B
 Successfully initialized wpa_supplicant
 root@ts-imx6ul:~# [  306.924691] wlan0: authenticate with 28:cf:da:b0:f5:bb
 [  306.959415] wlan0: send auth to 28:cf:da:b0:f5:bb (try 1/3)
 [  306.968137] wlan0: authenticated
 [  306.978477] wlan0: associate with 28:cf:da:b0:f5:bb (try 1/3)
 [  306.988577] wlan0: RX AssocResp from 28:cf:da:b0:f5:bb (capab=0x1431 status=0 aid=9)
 [  307.009751] wlan0: associated
 [  307.012768] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
 [  307.047989] wlcore: Association completed.

Then, same as the other sections above, follow up with iwconfig wlan0 and dhclient wlan0.

Finally, if you want your connection to be there when you reboot, you’ll need to configure systemctl to automatically set everything for you.

systemctl enable wpa_supplicant@wlan0
systemctl start wpa_supplicant@wlan0

As always, feel free to review the “Debian Wireless Client” section of the TS-4100 manual for more information.

Setup Bluetooth

For this, you’ll be using Bluez, the official Linux bluetooth protocol stack. There’s not much you need to do for setup, but there are some commands you’ll want to become familiar with such as hcitool and hciconfig. There is plenty of documentation and guides available online for this, so we won’t go into any detail on it here. We also have a small “Bluetooth” section of the TS-4100 manual you can refer to in order to get a taste of how it works.

TS-SILO Example Script

Quite possibly the neatest feature of the TS-4100-8551 is the TS-SILO on-board backup power solution. TS-SILO provides up to a minute of backup power (depending), allowing a custom script to run in the case of a power failure. Out of the box, the TS-4100-8551 will issue the shutdown -r now command to gracefully reboot the system. It will only startup again if the capacitor charge is greater than a certain number as defined in the U-Boot environment, 60% by default. For more information about TS-SILO, see the “SuperCaps” section of the TS-7680 manual (yes, the TS-7680 for now, while the TS-8551 manual is being developed). For now, let’s take a look at the script located at /usr/local/bin/tssilomon:    Home

#!/bin/bash

# Conservative value to wait for until shutting down
RESET_PCT=90

POWER_FAIL=128

# Set up the power_fail input pin to use sysfs gpio interrupt
echo "$POWER_FAIL" > /sys/class/gpio/export 2>/dev/null

while true; do
    let power_fail=$(cat /sys/class/gpio/gpio"$POWER_FAIL"/value)
    if [ "$power_fail" -eq "1" ] ; then
        eval "$(tsmicroctl -i)"
        echo "Supercaps at $SUPERCAP_PCT"

        if [ "$SUPERCAP_PCT" -le "$RESET_PCT" ]; then
            # Code can be added below in order to turn off power-hungry
            # devices, or start other shutdown procedures required.


            # The wall command can be removed if wanted.

            wall The script /usr/local/bin/tssilomon has detected main power has been lost!  Shutting down safely to prevent filesystem damage

            shutdown -r now
            exit
        else
            sleep .5
        fi
    fi
    sleep .5
done

Of course, you can insert your own code here if you’d like. It runs in the background as “TS-SILO SuperCap Monitor Daemon” as part of systemd services startup. You can see this by looking at /etc/systemd/system/tssilomon.service:

[Unit]
Description=TS-SILO SuperCap Monitor Daemon

[Service]
Type=simple
ExecStart=/bin/bash /usr/local/bin/tssilomon

[Install]
WantedBy=multi-user.target

Conclusion

In this getting started guide, we took a quick look at how to get everything connected, how to communicate with the board, and how to setup networking. You should be well on your way in developing your application, so go build something amazing!      

Is there anything else you’d like to see added to this practical getting started guide for the TS-4100? Be sure to comment below, and we’ll get it added!  Home

Leave a Reply

Your email address will not be published. Required fields are marked *