- Copy SD Card Image to an SD Card
- Copy Software to the Board via SSH and SCP
- Getting and Running the PHYTEC VM
- Install FTDI Driver on Windows
- Set Static IP Address in Ubuntu 20.04 LTS
- Setup a Second Network Interface in the Virtual Machine
- Setup qbee Device Management on phyBOARD-Polis
- Using phyLinux to build a yocto BSP with a build-container
- Using thingsboard.io to connect phyBOARD-Polis to the Cloud
Compile a C program for the board using SDK
Goal
This tutorial will show you how to use the cross-compile chain provided by the preinstalled SDK on the virtual machine.
This tutorial will only use the command line and not any IDE.
Preconditions
The PHYTEC VM is on the host system and boots correctly:Get the Phytec VM and start it
Tutorial
The Hello World Program in C
The following small program is a standard Hello World program written in C:
#include <stdio.h> int main () { printf("Hello World.\n"); return 0; }
Feel free to copy the content into a file.
For this tutorial, we will use a file named hello.c located in a folder named "test". This folder is created on the desktop of the user phyvm in the virtual machine.
Create the Folder and the File
$ cd Desktop $ mkdir test $ cd test $ touch hello.c $ cat > hello.c << EOF #include <stdio.h> int main () { printf("Hello World.\n"); return 0; } EOF
If the code above is done correctly, you can see that you have navigated to the "test" folder and created a file with the contents of the hello-world program shown above.
Compile the File for the Host
This step is optional and is only used to see if there are any errors in the hello.c file.
$ gcc hello.c -o hello
If there are no errors displayed by this command, everything is correctly compiled into a runnable program for the virtual machine.
Warning
The output of the compiler is only for this processor architecture and cannot be started on the board.
$ ./hello # the output should be: Hello World and the prompt should be shown in a new line
If everything is correct, you can delete the compiled file from the virtual machine.
Use the Preinstalled SDK to Compile the File for the Board
- Open a new terminal
You will need to add the SDK to our environment
Add SDK to environment$ source /opt/environment-setup-* # this command will source the sdk to the actual environment # e.g.: source /opt/environment-setup-cortexa53-crypto-phytec-linux $ echo ${CC} # expected output: # aarch64-phytec-linux-gcc -mcpu=cortex-a53 -march=armv8-a+crc+crypto -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/sysroots/cortexa53-crypto-phytec-linux
Navigate to the desktop/test folder:
navigate and compile$ cd /home/phyvm/Desktop/test $ ${CC} hello.c -o hello-board
If the command does not create any errors, the program is compiled for the board.
- Now you can copy the "hello_board" file to the board via SCP and run it there (Copy Software to the Board via SSH and SCP)