Linux Arm

How to create an app and deploy to linux arm (RPI and Toradex)

To create your project, just follow the same step as Getting started, except that instead of pointing to the SDK version that is in Maven, you point to your machine.

See the example below:

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.totalcross.sample</groupId>
<artifactId>HelloTC</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.totalcross</groupId>
<artifactId>totalcross-sdk</artifactId>
<version>5.0.1</version>
<scope>system</scope>
<systemPath>/PATH/TotalCross-RaspberryPi/dist/totalcross-sdk.jar</systemPath>
</dependency>
</dependencies>
<repositories>
<repository>
<id>totalcross-repo</id>
<name>ip-172-31-40-140-releases</name>
<url>http://maven.totalcross.com/artifactory/repo1</url>
</repository>
</repositories>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>tc.Deploy</mainClass>
<arguments>
<argument>${project.build.directory}/${project.build.finalName}.${project.packaging}</argument>
<argument>/p</argument>
<argument>-linux_arm</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

In line 55 the parameter set is -linux_arm, because this is the command needed to generate the file that will go to RPI and Toradex. You can see the other commands in the Deploy session.

To better understand, we recorded a video tutorial showing how it works:

Sample code used in video:

Hello World Application:

HelloWorldApplication
HelloTCApplication
package com.totalcross.sample;
import totalcross.TotalCrossApplication;
public class HelloTCApplication {
public static void main(String[] args) {
TotalCrossApplication.run(HelloTC.class);
}
}

Hello World (Main class that extends from MainWindow):

HelloWorld
public class HelloTC extends MainWindow {
@Override
public void initUI() {
Label label = new Label("Hello World");
add(label,CENTER,TOP + 50);
Button button = new Button("Click Here");
button.addPressListener(new PressListener() {
@Override
public void controlPressed(ControlEvent controlEvent) {
label.setText("Hello Totalcross");
label.reposition();
}
});
add(button, SAME, CENTER);
}
}