Tibbo LTPS Native C Development How To

441

Tibbo Technology Inc. has recently announced a Linux version of its popular Tibbo Project System (TPS).

LTPP is a Linux-based Tibbo Project PCB (TPS mainboard) based on the powerful 1GHz Cortex-A8 Sitara CPU from Texas Instruments. Carrying 512MB of RAM and 512MB of flash memory, the new LTPP3 board runs Tibbo’s own, highly polished distribution of Linux that is updated with the latest and greatest kernel and drivers.

LTPP may be programmed and managed in several different ways: the Tibbo-supplied Embedded AggreGate (purchased separately), NodeJS (comes pre-installed), TiOS (not yet fully ported). Tibbo also says that LTPP may be used and programmed as any other generic Linux board. For developers who have at least some Linux coding experience, the company supplies the LTPS SDK.

Is it hard to develop native C applications for LTPS? We don’t think so! If you have ever written a Linux program, it will be easy for you to figure out how to do this for the LTPP board.

Doubtful? OK, let’s see how to write a simple C application for the LTPP. Here is the list of steps: get the cross-compiler, install the SDK, build a program, and load it into the board.

Please note that root (supervisor) credentials are NOT required for installing the SDK and building programs.

We will assume that you are using a Linux PC or that you have previously created a Linux virtual machine on your computer. If you don’t have a Linux PC yet, please install any popular Linux distribution under Oracle VM VirtualBox, QUEMU or Vmware.

1. Getting the Cross-compiler for LTPS from Tibbo Website

*Note: the download location may change in the future. Please, search our website (tibbo.com) for updates.

Open the terminal emulator on your Linux host, make sure you are connected to the Internet, and download the LTPS SDK from http://tibbo.com/downloads/TPSL_tmp/SDK/


[dv@dvh hello_world]$ wget http://tibbo.com/downloads/TPSL_tmp/SDK/tps-systemd-glibc-i686-TPS-agent-cortexa8hf-neon-toolchain-1.8+snapshot.sh
--2016-05-16 22:02:01--  http://tibbo.com/downloads/TPSL_tmp/SDK/tps-systemd-glibc-i686-TPS-agent-cortexa8hf-neon-toolchain-1.8+snapshot.sh
Resolving tibbo.com (tibbo.com)... 93.174.104.89
Connecting to tibbo.com (tibbo.com)|93.174.104.89|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 443644550 (423M) [text/plain]
Saving to: 'tps-systemd-glibc-i686-TPS-agent-cortexa8hf-neon-toolchain-1.8+snapshot.sh'

100%[======================================>] 443,644,550 4.61MB/s   in 99s    

2016-05-16 22:03:40 (4.28 MB/s) - 'tps-systemd-glibc-i686-TPS-agent-cortexa8hf-neon-toolchain-1.8+snapshot.sh' saved [443644550/443644550]

[dv@dvh hello_world]$ ls -l
total 433256
drwxrwxr-x 2 dv dv      4096 May 16 22:00 html/
-rw-r--r-- 1 dv dv 443644550 Apr  4 14:07 tps-systemd-glibc-i686-TPS-agent-cortexa8hf-neon-toolchain-1.8+snapshot.sh

 

2. LTPS SDK Installation

Full SDK image weighs around 0.5 Gb. It is not just a binary file; it is an installation script with an archive inside. Make it executable and run it to install the SDK.

[dv@dvh hello_world]$ chmod 0755 ./tps-systemd-glibc-i686-TPS-agent-cortexa8hf-neon-toolchain-1.8+snapshot.sh 
[dv@dvh hello_world]$ ./tps-systemd-glibc-i686-TPS-agent-cortexa8hf-neon-toolchain-1.8+snapshot.sh 
TPS (Tibbo Project System) SDK installer version 1.8+snapshot
=============================================================
Enter target directory for SDK (default: /opt/tps-systemd/1.8+snapshot): ~/tpsC/
You are about to install the SDK to "/home/dv/tpsC". Proceed[Y/n]? Y
Extracting SDK................................................................................done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /home/dv/tpsC/environment-setup-cortexa8hf-neon-tps-linux-gnueabi

 

3. Setting up the Environment

Run the environment setup script as advised by the installer.

[dv@dvh hello_world]$ . /home/dv/tpsC/environment-setup-cortexa8hf-neon-tps-linux-gnueabi

 

4. Testing the Installation

In the same terminal emulator window, try to run the GCC compiler.

dv@dvh hello_world]$ gcc --version
gcc (GCC) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Oops, this looks like the default compiler, not the compiler we want. This compiler is the GCC from your Linux distribution, and it can only build for the x86 CPU.
Our cross-compiler is in the environment variables $CC, $CXX, $CPP.

[dv@dvh hello_world]$ echo $CC 
arm-tps-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 --sysroot=/home/dv/tpsC/sysroots/cortexa8hf-neon-tps-linux-gnueabi
[dv@dvh hello_world]$ $CC --version
arm-tps-linux-gnueabi-gcc (GCC) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

That is what we needed! Ok, let’s write our first LTPS “Hello World!” program and build it.

 

5. Write a Simple Program

[dv@dvh hello_world]$ mkdir test_0
[dv@dvh hello_world]$ cd test_0/

Create the “Hello World” program using any editor you like. We prefer MC (Midnight Commander) editor, but here I will use VI, just as an example.

[dv@dvh test_0]$ touch ./test_0.c

test_0.c contents:

#include 

int main( int argc, char *argv[]) {
 printf( "Hello world from LTPS!n");
 return( 0);  }

Now create Makefile for our program. This is an old, traditional way of building anything in UNIX.

[dv@dvh test_0]$ touch ./Makefile
[dv@dvh test_0]$ vi ./Makefile

Makefile contents:

all:
        $(CC) -o test_0 test_0.c

clean:
        rm -f test_0
        rm -f *.o

* Lead whitespaces are not the whitespaces, they are 2 (two) tabs.
Here is the Makefile syntax.

 

6. Building your Program with Cross-compiler

Run ‘make’ command in the same terminal emulator window where you previously ran LTPS SDK environment setup script.

[dv@dvh test_0]$ make
arm-tps-linux-gnueabi-gcc  -march=armv7-a -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a8 --sysroot=/home/dv/tpsC/sysroots/cortexa8hf-neon-tps-linux-gnueabi -o test_0 test_0.c
[dv@dvh test_0]$ ls -l
total 20
-rw-r--r-- 1 dv dv   64 May 16 22:28 Makefile
-rwxr-xr-x 1 dv dv 9144 May 16 22:28 test_0*
-rw-r--r-- 1 dv dv  110 May 16 22:27 test_0.c
[dv@dvh test_0]$ ./test_0 
bash: ./test_0: cannot execute binary file

Program build starts from “test_0.c” to “test_0”. It is an executable binary. I tried to run it but it failed with the “cannot execute binary file” message. Why? Because it was built for a non-Intel CPU. 

[dv@dvh test_0]$ objdump -f ./test_0

./test_0:     file format elf32-little
architecture: UNKNOWN!, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x000102f4

[dv@dvh test_0]$ $OBJDUMP -f ./test_0

./test_0:     file format elf32-littlearm
architecture: arm, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x000102f4

Yes, you understand this correctly: we have TWO ‘objdump’ executables: our traditional x86 ‘objdump’ program that can be found in the default $PATH and ‘cross-objdump’ from LTPS SDK that can be found in the $OBJDUMP environment variable.

First (intel) objdump says it can’t detect the architecture.
The second one (cross-objdump) says it
is an ARM 32bit little-endian executable.
Everything looks correct. Let’s copy the program into LTPS and try to run it…

[dv@dvh test_0]$ scp ./test_0 root@192.168.75.217:~/
root@192.168.75.217's password: 
test_0                                        100% 9144     8.9KB/s   00:00    
[dv@dvh test_0]$ ssh root@192.168.75.217
root@192.168.75.217's password: 
X11 forwarding request failed on channel 0
root@tpp:~# ./test_0 
Hello world from LTPS!
root@tpp:~# uname -a
Linux tpp 4.4.3-tpp #1 Sat May 14 14:28:50 MSK 2016 armv7l GNU/Linux
root@tpp:~# 

Success!