Build Custom C/C++ App
This guide provides step-by-step instructions for creating a custom C application and building it for the SiMa DevKit using the Yocto Software Development Kit (SDK). It covers developing a simple “Hello World” program, configuring it for cross-compilation, and using the SDK’s tools for building. While similar to standard C/C++ development, this process requires setting up the Yocto cross-compilation environment to target the DevKit’s embedded architecture.
Before you run the following commands, ensure you have setup the cross compilation environment.
Step 1. Create the Application Source Code
First, write a simple C program as your custom application.
Create a project directory and navigate to it:
user@palette-container-id:/home/docker/$mkdir ~/myproject
user@palette-container-id:/home/docker/$cd ~/myproject
Create a file named
hello.c
with the following content:
#include <stdio.h>
int main() {
printf("Hello, SiMa DevKit!\n");
return 0;
}
This basic program prints a greeting when executed.
Step 2. Compile the Application Using the Yocto SDK
The Yocto SDK provides a cross-compilation toolchain (e.g., aarch64-poky-linux-gcc
). Use it to compile hello.c
for the DevKit’s architecture.
Compile the program:
user@palette-container-id:/home/docker/myproject$ $CC hello.c -o hello
Here, $CC
expands to aarch64-poky-linux-gcc
with flags like --sysroot=/opt/poky/4.0.23/sysroots/cortexa65-poky-linux
preconfigured by the SDK environment. This generates an executable named hello
.
Verify the build:
user@palette-container-id:/home/docker/myproject$ file hello
Output should resemble:
hello: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, ...
Step 3. Deploy the Application to the DevKit
To run the application, transfer it to the SiMa DevKit and execute it.
Copy the executable to the DevKit (e.g., via
scp
if networked):user@palette-container-id:/home/docker/myproject$ scp hello sima@devkit-ip:~/
Replace
user@devkit-ip
with your DevKit’s SSH credentials and IP address.Connect to the DevKit via SSH and run the application:
user@palette-container-id:/home/docker/myproject$ssh sima@devkit-ip "./hello"
Expected output:
Hello, SiMa DevKit!