.. _build_custom_app: 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 :ref:`setup the cross compilation environment `. .. dropdown:: Step 1. Create the Application Source Code :animate: fade-in :color: secondary :open: First, write a simple C program as your custom application. 1. Create a project directory and navigate to it: .. code-block:: bash user@palette-container-id:/home/docker/$mkdir ~/myproject user@palette-container-id:/home/docker/$cd ~/myproject 2. Create a file named ``hello.c`` with the following content: .. code-block:: c #include int main() { printf("Hello, SiMa DevKit!\n"); return 0; } This basic program prints a greeting when executed. .. dropdown:: Step 2. Compile the Application Using the Yocto SDK :animate: fade-in :color: secondary 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. 1. Compile the program: .. code-block:: bash 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``. 2. Verify the build: .. code-block:: bash 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, ...`` .. dropdown:: Step 3. Deploy the Application to the DevKit :animate: fade-in :color: secondary 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): .. code-block:: bash 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: .. code-block:: bash user@palette-container-id:/home/docker/myproject$ssh sima@devkit-ip "./hello" Expected output: ``Hello, SiMa DevKit!``