Advance Host setup
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 :
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-A5D2x:~# 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.
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.xz
file using the command tar -xvf gcc-linaro-7.3.1-2018.05-i686_arm-linux-gnueabihf.tar.xz
.
Step 5: Navigate to the mentioned folder /Toolchain/gcc-linaro-7.3.1-2018.05-i686_arm-linux-gnueabihf/bin
and then type in pwd
and copy the path that appears.
Step 6: Open the env.sh
file by typing vi env.sh
and paste the copied path to the corresponding line.
Step 7: Run the env.sh
file 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/tftpboot
to 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
./hello_board
------------------Congratulations on running your first C program on the Board!!--------------------
Last updated