Advance Host setup
Hardware required:
PC(Personal computer)/System
Rugged Board i.MX6UL
Installing Ubuntu
Host requires 64-bit, Ubuntu-16.x.x (LTS versions Recommended).
To install Ubuntu, follow the link below.
After successful installation Let us start Work with Linux – Ubuntu OS
Open up an application on your computer called “Terminal” by either pressing Control + Alt + T or by clicking the symbol at the top of the Ubuntu launcher and searching for “Terminal”.
It looks like this:
You can use the terminal to write commands to your computer (this is the “command line Interface of Linux Operating System”). Let’s try it out!
In your terminal, type
$ ls
and hit enter.
The ls command, short for “list”, tells your computer to list all of the file names for the Directory you’re inside.
For further development work we will be using ubuntu as a host system and will be referred as host, also create a work
directory inside your home
directory by typing the below command on your host terminal and use this directory to store all development related files.
$ mkdir /home/work
$ cd /home/work
Installing Additional Packages
Ubuntu doesn’t come with all the prerequisite archives for development, to prepare the host for development, download the bash shell scripts from the link below and store in the work directory :
(you can get the above files from https://developer.ruggedboard.com/g5-system-development-guide/host-setup)
Execution steps of the script are as follows.
Step 1: copy the downloaded file to work directory
Step 2: Open host terminal and execute the command below
$ sudo chmod +x elinux_pkg.sh
Step 3: type the below command to execute on the host pc.
$ sh elinux_pkg.sh
Upon entering you host password script will start running and stop once all the executions are completed.
Step 4: repeat the steps 1 & 2 for the file "if_machine_is_64-bit.sh" if your machine is 64bit.
Note : if you want to see the script type the below command
$ gedit elinux_pkg.sh
Congratulations!! Your PC is now ready with Ubuntu-Linux basic prerequisite......
Note: If you are facing any difficulties in these steps, please visit our YouTube channel "RuggedBoard" for video demonstrations.
Installing and Configuring TFTP and NFS Server.
Similar to the installation of additional packages, download the file named "tftp-script.sh"
given below and execute using the steps mentioned in the additional packages with the help of sh command (sh tftp-script.sh
).
Transferring Files from Host to Board
In this section we will show how to transfer files from host to the target board using NFS server. Follow the exact steps mentioned below from your work directory.
Step 1: Open a Terminal window on your PC and navigate to the work directory. This directory contains 3 files:
elinux_pkg.sh
if_machine_is_64-bit.sh
tftp-script.sh
Step 2: If you are running 64 bit machine, run if_machine_is_64-bit.sh . NOTE: You can ignore this step or else.
Step 3: Run the elinux_pkg.sh, tftp-script.sh using the following command
$ sh elinux_pkg.sh
$ sh tftp-script.sh
Step 4: Check if tftpboot folder has been created in /var/lib/ directory, The box highlighted in green shows that tftpboot folder has been created in /var/lib/ directory.
$ cd /var/lib
$ ls
Step 5: Connect an Ethernet cable to the board and type ifconfig
on your PC and note down your server address. Highlighted white text shows server address in my case.
Step 6: Create a test file(Ex: test.txt) to work directory. Create a file named test.txt
$touch test.txt
Step 7: Copy it to /var/lib/tftpboot
$ cp test.txt /var/lib/tftpboot
Step 8: Switch to your board's terminal and type in
root@ruggedboard-imx6ul:~# tftp -r test.txt -g 192.168.1.12
Step 9: Now you should be able to see the file on your board.
Installing and Configuring Toolchain
Write your first C program
Step 1: Find a suitable text editor that suits you eg: Atom, Sublime text, vim, notepad ++, etc..
Step2: Write a small C code on your HOST PC and save it with a .c
extension(eg: hello.c
). You can try our example code given below:
Step 3: Create a directory with the name Toolchain, Download toolchain from the link given below and save it in Toolchain directory.
$ wget https://download.phytec.de/Software/Linux/BSP-Yocto-i.MX6UL/BSP-Yocto-i.MX6UL-PD19.1.0/sdk/phytec-yogurt-glibc-x86_64-phytec-qt5demo-image-cortexa7hf-neon-vfpv4-toolchain-BSP-Yocto-i.MX6UL-PD19.1.0.sh
Step 4: Give the permissions to the toolchain script file as below and install it.
$ chmod 777 phytec-yogurt-glibc-x86_64-phytec-qt5demo-image-cortexa7hf-neon-vfpv4- toolchain-BSP-Yocto-i.MX6UL-PD19.1.0.sh
$ ./phytec-yogurt-glibc-x86_64-phytec-qt5demo-image-cortexa7hf-neon-vfpv4-toolchain- BSP-Yocto-i.MX6UL-PD19.1.0.sh
Step 5: To cross compile any sample application(hello.c) or compile any source, please run the below command.
$ . /opt/phytec-yogurt/BSP-Yocto-i.MX6UL-PD19.1.0/environment-setup-cortexa7hf-neon- vfpv4-phytec-linux-gnueabi
Step 6: Cross compiling the c application as below
$ $CC hello.c -o hello_board
NOTE: Do not close or switch your terminal as it will disable the toolchain that is running.
Step 7: Copy the file to /var/lib/tftpboot. Type in cp hello_board /var/lib/tftpboot
to copy the binary.
Step 8: Open a Terminal on the board, Transfer the compiled binary "hello_board" to the board either by TFTP or by SD Card. Now you can see your binary on the rootfs of the board.
Step 9: Give the necessary permissions
chmod +x hello_board
Step 10: Run the binary using
./hello_board
You just said hello to your board! :)
------------------Congratulations on running your first C program on the Board !!!--------------------
Last updated