Tuesday, 26 January 2016

arm-linuc-gcc installation

A compiler is a program that turns source code into executable code. Like all programs, a compiler runs on a specific type of computer, and the new programs it generates also run on a specific type of computer.
The computer on which the  compiler runs on is called the host, and the computer the new programs run on is called the target. When the host and target are the same type of machine, the compiler is a native compiler. When the host and target are different, the compiler is a cross compiler.
In our case Friendly ARM is the Target device & PC/Laptop is the Host.We’ve to install the Cross Compiler on the Host to enable deploying programs on to the target FriendlyARM device.In this post I shall explain the process of cross compiler installation on a Linux (Ubuntu 12.04) running Host Computer.
To start with copy the Linux directory from the DVD supplied along with the Friendly ARM device.Paste it to the /tmp  directory of File system.
              copyto_tmp
Open up the Terminal type cd /  & go to root.Change directory to /tmp/linux by typing
cd /tmp/linux
              cd_tmp
Type  ls command to list out the contents.
arm-linux-gcc-4.4.3.tar.gz  is the file we’ve to unTar.
            TAR
Enter the following command to untar the linux-gcc file.
                sudo_tar
Use sudo to be a super user .Also note the capital letter C , a space after it & a forward slash /
Type in your super user password.
The command line arguments we use with tar command are  x , v  , z , & f.
        x   is to extract/restore contents of tar file.
        v  is Verbose output i.e, to display the files being restored from tar file
        z  is to use zip/gzip to read or restore from tar file.
        f  is to specify the filename used to tar out from
This command will extract arm-linux-gcc to the directory    /opt/FriendlyArm/toolschain/4.4.3
     extaract
To run the compiler you’ve to add the PATH to the compiler environment variable of the system.
Change directory to Root  cd /    & then go to bin directory by typing
cd /opt/FriendlyArm/4.4.3/bin
       bash_edit1
We’ve to edit the hidden system file .bashrc ( a  ‘ . ‘  indicates that it is a hidden file) & add the PATH at the end of file.
To do that type    sudo gedit /root/.bashrc
Type your super user password.
.bashrc file will open up.Scroll down to the end of file & add the path as
   export PATH=$PATH:/opt/FriendlyArm/toolschain/4.4.3/bin
& save it.
     bash_edit2
To Restart shell ,type      source ~/.bashrc   or you’ve to logout & login back.
(Note the usage of  ~ for root )
    restart_shell
The Cross Compile environment has been successfully installed.
Type  echo $PATH   to verify the installation path.
         ECHO_PATH
Now type   arm-none-linux-gnueabi-cc –v
Note that the gnu compiler make use of EABI , the new Embedded Application Binary Interface.
The compilation process is perfect you will see the following screen.
       arm_linux
Now you are ready to cross compile your C code.

mini 2440 porting os

Friendly ARM Mini 2440 is a Single-Board Computer(SBC) built on 400 MHz Samsung S3C2440 ARM9 processor  & 3.5” Touch screen LCD is provided with mini 2440.
It has up to 256MB RAM & up to 1GB NAND Flash and 2 MB NOR Flash with BIOS.

farm2 

Image 2
Friendly Arm Mini2440 is factory preloaded with Linux Qtopia operating system.This post is intended to revive the operating system in case of non booting of device.
Mini2440 has a Flash NAND ROM of 1 GB &  2MB NOR alternate Bootloader.Top left is switch S2 for NOR/NAND boot selection.To the bottom left is the power ON/OFF switch S1.Slide this switch to left for power ON..
NAND flash is used in all removable memory cards because of fast write & erase operations (but slow random access).Because of NAND’s multiplexed command address & data bus it requires lesser number of pins for interface.
NOR flash memory has an advantage of fast Random access ability.It allows for Execute in place (XIP) capability which is often a requirement in Embedded applications.
Friendly Arm uses both types of flash memory.
Friendly ARM is capable of running 3 types of Operating system, Linux,Windows CE(Compact Edition 5.0 or 6.0) & Android.
Friendly Arm boards are available with 1GB Flash memory.Next to SD socket on mini2440 board you see Samsung NAND Flash chip.
                          Image 8
As seen in above picture,S92ALU16J7OTF102 IC is the NAND flash chip (1GB) which is the maximum available Flash memory for MINI2440.
K9K8G08U08 is NOR Flash IC.
In this post I shall demonstrate installation of Linux Qtopia on to NAND flash of Mini2440.
Mini 2440 comes preloaded with a SuperVivi bootloader in NOR flash.It is used to install Operating system on to NAND flash.SuperVivi is the BIOS for mini2440 & is used as a tool to download & burn OS image  to the Flash onboard.
Your Host Computer operating system may be Windows 7 /XP or Linux Ubuntu 12.04.It is easier to install Qtopia on FriendlyArm device from a Windows 7 running PC.Later we shall see how to develop programs in Linux Environment & load it to Mini2440.
From the DVD supplied along with the Friendly Arm collect the required software.
Go to    /images/linux  folder of DVD .
Or you can download it from my Skydrive here.
Copy the following software to a separate folder ,say mini2440 on Desktop :
1.  rootfs_qtopia_qt4   2. supervivi-128M   3. vboot  4. zImage_X35

Image 5
Keep S1 switch found at bottom left in OFF mode (slide to Right).
Connect the 5v/2A adapter pin to the power socket found above the S1 switch.
Connect the RS232 cable to the DB9 connector seen above the power socket.Generally an USB to UART board is used to connect this RS232 to USB of your PC.
Connect the USB-B (device USB) seen above the Ethernet connector to another USB port of your PC.Remember to use the USB cable supplied along with the device.I’ve wasted a whole day by using a cable bought  from market.USB download was not possible & finally using the USB cable  that came along with the device solved the problem.
Keep the S2 switch found above the left corner in NOR mode.(slide the switch to left).
Open up the Device Manager to confirm that USB-UART board used to connect DB9 of Friendly Arm to USB of PC is detected.If not detected,download the driver from here & install it.
Image 20

Now visit the download site of FriendlyArm      http://www.friendlyarm.net/downloads
Download the USB driver & DNW tool .

                              Image8
Take a look at the files & software we collected & stored at mini2440 folder on desktop
Image 21
Unzip the downloaded driver file usb-downloaddr-setup_20090421.zip (1.49 MB) & double click on setup file.
Image9
Screenshots of driver installation are as below.
Image 9    Image 10

Open the Device Manager under the Control Panel.
Now power ON the FriendlyArm by sliding S1 switch to Left.
If the drivers are installed,you see Friendly Arm detected under “Universal Serial Bus Controllers”.
Image 7
We shall make use of a Terminal software to work with Supervivi BIOS .
Download Terminal software PuTTy from here.
You can also use Hyperterminal.But I prefer to use PuTTy as it is fast & reliable.
Open up PuTTy & in the welcome window do the settings as below :
1. Select Connection type as “Serial”.
2.Under Serial line enter the port number (in our case it is COM2).To know the port no. allotted ,open up Device manager & under Ports(Com&Lpt) you see the COM port number allotted to the USB-UART board we have used to connect DB9 of mini2440 to PC.
                     Image 6
3. Enter baud rate as 115200 under Speed.
                                 Image13

4. Save the settings by providing a name mini2440, so that you can load it latter.
5.Now load the saved setting by selecting mini2440 & clicking “Load”.
     A blank black window opens up.Click Enter to see the FriendlyArm BIOS setup under Putty terminal.
                      Image14
Now Unzip the downloaded DNW tool .Double click DNW
At the title bar you see USB:x indicating that USB is NOT ready for transfer of data.
 Image11  
Click Configurations –> Options
Select COM port as COM2 (as seen in Device Manager) ,Baud Rate as 115200.
Download address should be 0x3000000.
Image12
Click Connect under Serial Port.If Drivers are installed properly
USB:OK along with COM2,115200 is displayed on the title bar.
Image15
If  USB:OK is not displayed ,check up the Device Manger for “FriendlyArm “ entry.Else you have to install the drivers again.
Caution : Remember to open the Putty terminal  first & then fire up DNW.If you keep open DNW & try to connect COM port through Putty,it will show error.
Here is the list of activities we’ve to do :
1. Press  x to Format NAND Flash.
2. Press v  to download Supervivi via USB. From DNW transmit supervivi_128m file.
3. Press k to  download the Linux Kernel. From DNW transmit zImage_x35.
4. Press  y to  download yaffs root image.From DNW transmit  rootfs_qtopia_qt4  image.

Type  x  to start Formatting the NAND flash.
Image22
Type  v  to download the Supervivi  file.Terminal will display “USB host connected.Waiting a download “.
Image23
From within DNW select USB Port –> Transmit –> Transmit & browse to the folder
mini2440 where we collected all files & software.Select supervivi_128M file & click OPEN
Image24

Image25
Now type  k to download the Linux Kernel.
Image26
From DNW click USB Port—> Transmit  –> Transmit & browse to select file zImage_X35.
Image27

Image 28
Type  y  to download the yaffs root image which is the file system for QTopia.
Image29
From DNW  select USB Port –> Transmit –> Transmit & browse to the image file rootfs_qtopia_qt4 in the mini2440 folder
Image31

Image 30

Now switch off the device by sliding S1 to right.
Slide switch S2 on top to NAND position (slide Right).
Power ON the device by sliding S1 to left position.
QTopia Linux will start booting on the device.