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 Palette SDKs. It covers developing a simple ā€œHello Worldā€ program, configuring it for cross-compilation, and using the SDK’s tools for building.

Note

While cross-compilation is the standard approach for both platforms, Modalix (eLxr) also supports On-Device compilation directly on the hardware. For more details on building directly on Modalix, see the On-Device Compilation section.

Before you run the following commands, ensure you have followed the cross compilation setup for your target platform (Yocto or eLxr).

Step 1. Create the Application Source Code

First, write a simple C program as your custom application.

  1. Create a project directory and navigate to it:

user@palette-container-id:/home/docker/$mkdir ~/myproject
user@palette-container-id:/home/docker/$cd ~/myproject
  1. 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 SDK

To compile the program for the target architecture, you must be inside the correct SDK container and have the environment activated.

  1. Compile the program:

user@palette-container-id:/home/docker/myproject$ $CC hello.c -o hello
  1. 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.

  1. 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.

  2. 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!