Comment on page
Advance Host setup
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:
Symbol of terminal
Open view of Terminal
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
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
workdirectory inside your
homedirectory 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
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 :
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......
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 (
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
Step 5: Connect an Ethernet cable to the board and type
ifconfigon your PC and note down your server address. Highlighted white text shows server address in my case.
To check the server address
Step 6: Create a test file(Ex: test.txt) to work directory. Create a file named 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-A5D2x:~# tftp -r test.txt -g 192.168.1.12
Step 9: Now you should be able to see the file on your board.
test.txt file transferred to the board
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
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.
Step 4: Open your terminal (ctrl + alt + T), navigate to the Toolchain directory and untar the
gcc-linaro-7.3.1-2018.05-i686_arm-linux-gnueabihf.tar.xzfile using the command
tar -xvf gcc-linaro-7.3.1-2018.05-i686_arm-linux-gnueabihf.tar.xz.
After untarring Toolchain
Step 5: Navigate to the mentioned folder
/Toolchain/gcc-linaro-7.3.1-2018.05-i686_arm-linux-gnueabihf/binand then type in
pwdand copy the path that appears.
Step 6: Open the
env.shfile by typing
vi env.shand paste the copied path to the corresponding line.
Step 7: Run the
env.shfile by using the command
. env.sh. Make sure the the toolchain is running on your PC by typing "arm" and hitting the <TAB> key twice.
if the toolchain isn't running you'll only see a very few of them.
NOTE: Do not close or switch your terminal as it will disable the toolchain that is running. We need to compile the C file with the enabled toolchain to get an executable that can be executed on the Board, as our PC is an X86 architecture and the board is an ARM architecture.
Step 8: Navigate back to your C folder and compile the C code using the toolchain enabled terminal.
arm-linux-gnueabihf-gcc hello.c -o hello_board
Step 9: Copy the file to
/var/lib/tftpboot. Type in
cp hello_board /var/lib/tftpbootto copy the binary.
Step 10: Open a Terminal on the board, Transfer the compiled binary
"hello_board"to the board either by TFTP or by SD Card. (Click here to follow the process to transfer files from Host to Board) Now you can see your binary on the rootfs of the board.
Step 11: Give the necessary permissions
chmod +x hello_board
Step 12: Run the binary using
You just said hello to your board! :)
------------------Congratulations on running your first C program on the Board!!--------------------