Attention: the Quickstart Guide for BSP 2.8, based on the Ångström distribution, is not being updated anymore. Depending on your SoM, you have different options:
Vybrid and Tegra: the information is provided as-is and still accurate, since newer Toradex BSPs are not ported to those SoMs. Just keep in mind that the Guides are not being maintained anymore, even if we find bugs or outdated instructions.
Apalis TK1 (all variants), Colibri iMX6ULL (all variants), Colibri iMX7S 256MB and Colibri iMX7D 512MB: these computer on modules are still regularly maintained in our BSPs and, to get started, you must check the software page Toradex BSP Layers and Reference Images for Yocto Project. Since Torizon is not supported, at the moment a Quickstart Guide is not available.
All other i.MX-based SoMs: you have two options to get started with embedded Linux: the first is to follow the Quickstart Guide for Torizon, which provides the greatest out-of-the-box experience, or if you choose to use Yocto, check the software page Toradex BSP Layers and Reference Images for Yocto Project.
In this section, you will build a simple hello-world using the previously configured Software Development Kit (SDK).
Information provided in this section was based on the Linux SDKs article. Alternatively, the Hello World application on Embedded Linux article from the Toradex' knowledge-base provides an example of how to build an application from the command-line using the Linaro toolchain.
In this module you will:
Change Ubuntu shell from dash to bash:
sudo update-alternatives --install /bin/sh sh /bin/bash 100
Skipping this step might break instructions ahead. Still, you can have both dash and bash installed if you wish. To do so, please run the following commands to install dash as an alternative and select bash as the current shell:
sudo update-alternatives --install /bin/sh sh /bin/dash 50sudo update-alternatives --config sh
Create a file named hello-world.c with the following contents:
hello-world.c
#include <stdio.h>
int main(int argc, char *argv[]){
printf("Hello world!\n");
return 0;
}
Cross-compile the code. Make sure that you exported the required variables in the previous lesson.
Note: The Toradex SDK must be installed in the system and the correct variables exported. If you have any doubts, please go back to the previous lesson Configure Toolchain.
Warning: If you open a new terminal window, you must export the variables again. To check if a variable is set, use the echo command, for instance: "echo ${CC}".
${CC} -Wall hello-world.c -o hello-world
Log in to the board using minicom.
Note: Minicom usage is described in the Module 1 - Linux Terminal and Basic Usage lesson of this getting-started guide.
Find the target IP address. Search for the inet addr from the eth0 interface:
root@computer-on-module:~# ifconfig eth0 Link encap:Ethernet HWaddr 00:14:2D:49:E8:8E inet addr:192.168.0.21 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::214:2dff:fe49:e88e/64 Scope:Link inet6 addr: 2804:14d:ac82:116c:214:2dff:fe49:e88e/64 Scope:Global UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:699 errors:0 dropped:0 overruns:0 frame:0 TX packets:562 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:86400 (84.3 KiB) TX bytes:56325 (55.0 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:330 errors:0 dropped:0 overruns:0 frame:0 TX packets:330 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:30218 (29.5 KiB) TX bytes:30218 (29.5 KiB) usb0 Link encap:Ethernet HWaddr 00:14:2D:FF:FF:FF inet addr:192.168.11.1 Bcast:192.168.11.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
In this example, the target IP address is 192.168.0.21.
Back to the host computer, copy the application to the target using SCP. You may be prompted to continue during the first connection. If this is the case, just type yes and press Enter:
user@host:~$ scp hello-world root@192.168.0.21:/home/root The authenticity of host '192.168.0.21 (192.168.0.21)' can't be established. ECDSA key fingerprint is SHA256:+N5WCsnEtQXEnYWyMXxswZLf4hEVgmHPOR2pZgJRdrg. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.0.21' (ECDSA) to the list of known hosts.
Warning: The board and the host machine must be connected to the same network. Please refer to the Module 1 - Unboxing and Setup Cables lesson for more information about the system setup.
In the target terminal, run the application:
root@computer-on-module:~# ./hello-world Hello world!
This lesson only covers the basics of cross compilation from the command line, therefore this FAQ section is meant as an information complement.