In the previous post we saw the initial set up procedure & how to unTar the example files.
In this post we shall see the ways of loading these files on to mini2440 device & executing it.
I assume that you are ready with the connections as described in previous post & your mini2440 is switched ON.Keep open both the Linux Terminal & the PuTTY Terminal.
Here is the screen shot of both the Terminals open.
PuTTY Terminal Linux Terminal
In the Linux Terminal go to root by typing cd /.
Then change directory to mini2440 under /opt folder.
cd /opt/FriendlyARM/mini2440
Inside this is the examples folder which we extracted (details in previous post).
Type cd examples
& then ls to list out the contents.The “examples” folder contains many test programs.
First we shall test the hello example.
Change directory to hello by typing
cd hello
Inside this hello folder are the hello.c & Makefile.
Type make hello
Now a command is automatically issued by the compiler to generate an executable binary file called hello from the file hello.c which is a C code file.
You can see the command in action as :
arm-linux-gcc –o hello hello.c
Instead of giving a make command you can feed in the above command directly.Note the space after gcc & then hyphen ,letter o , space, hello is the name of resulting bin file & hello.c is the source file to be compiled.
Issue a ls command to list out the contents of hello folder.You can see a bin file hello created.
To read out the C code in hello.c file use gedit.
sudo gedit hello.c
The compiled hello bin file has to be loaded on to the mini2440 device for execution.
There are 3 ways of achieving this.
1.Using a Pen drive or SDCard.
2.Using File Transfer Protocol FTP method.
3. Using NFS – Network File System service.We shall see NFS in detail in next post.
The 1st & 2nd method are described here.
Using Pen drive / SDcard method.
Plug in a pen drive to the host PC.Copy the hello executable file we compiled inside the
/opt/FriendlyARM/mini2440/examples/hello folder.
From the Linux Terminal issue following commands to copy the file :
# mount /dev/sda1 /mnt ; to mount pen drive on host PC.
# cp hello /mnt ; copy hello bin file to pendrive
# umount /mnt ; uninstall pendrive
Remove the pen drive from host PC & plug in to the mini2440 USB host port found at the right side top (above the SDCARD Socket).
It is automatically mounted to /udisk directory.
From PuTTY terminal type
# cd /udisk
to change directory to Pendrive.To execute the file issue following command
# ./hello
Note a “.” followed by a forward slash / & then the bin file name.
2. FTP method
From the Linux Terminal type ftp 192.168.1.230
192.168.1.230 is the IP address of the mini2440.FTP always works with a password.
When prompted for name, type in plg & the password is also plg.Be sure to reside in the folder /opt/FriendlyARM/mini2440/examples/hello .
Now you get the ftp prompt.
Type ftp> bin
to set the configuration of document format.
Now type ftp> put hello
to transfer hello file to a folder called plg which resides inside /home folder of our Friendly ARM device..
Now the file is transferred to the target device mini2440.
Type ftp> by
to log out of FTP.
From within the PuTTY terminal type ls to list out the contents.
Change directory to /home/plg where we transferred the bin file.
Inside the plg folder you can see the hello bin file we transferred from the host PC.
Before executing this file we have to change the execute permission scope of the hello file, by typing
# chmod +x hello
Now issue the command ./hello to see the result “hello,FriendlyARM”
Instead of working from within the PuTTY terminal you can directly open the Terminal on the mini2440 device & issue above commands.It’s all one & the same.PuTTY terminal is nothing but the terminal of device itself.
Congratulation, it is more a great tutorial, thank you!