CSE585 Laboratory Assignment #4


Overview:

    The purpose of this lab is

Setup:

Setup the sonar and SA board the same as you did in Lab #3 but this time connect a the second serial port on the SA board to COM3 of the host using the null-modem cable.  This time, everyone should use pin 5 of the ribbon cable for INIT and pin 7 of the ribbon cable for ECHO. These correspond to GPIO<4> and GPIO<5> respectively. 

Step one: Boot Linux on the SA board and run “hello” app

  1. Make a working directory (Lets say C:\work) and download  angelboot.exe  (for NT) and  opts.txt  files into it. You will use these files to download the OS and RAMDISK to the target.
  2. Setup your cross-compilation environment on the Linux server

·        Telnet to the machine sprittle and login as group1 and passwd hello .

·        Type in zsh  followed by source ~labuser/.zall

·        cd ~

·        tar zxvf ~labuser/  (this creates  two directories, "code" and "linux" in your group’s home directory on Sprittle. 

  1. Build the application a load it into the Ramdisk

·        cd code

·        ./ags hello_app  (This compiles the source file and strips it of all symbols.note that it is not "hello_app.c")

·        ./putinarm hello_app (This actually puts the file into the ramdisk. It mounts the ramdisk on a local directory, copies the file given in the argument and then umounts and compresses it for download. Note: After the umount command there will be no output for some time as it is gzipping the ramdisk. Do not Control-C, just wait for the shell prompt to return)

  1. Build the Kernel with the HELLO device driver

·         cd ~/linux

·        make zImage  (This should compile the kernel  and image is formed as ~/linux/arch/arm/boot/zImage

  1. Download the OS and the Ramdisk to the Target from your NT host.

·        Open up WS_FTP (Start->Programs->DesktopApps) and ftp the  the files ~/code/ramdisk.gz and ~/linux/arch/arm/boot/zImage into your work directory (C:\work).

·        Open up Hyperterm (Start->Programs->Accessories0>Hyperterminal) start a new session on COM3 ( or the serial port on which output  is attached .P0 is COM3) with default settings . (note you must press "Restore Defaults" button).

·        Open up bash shell (Start->Programs->Cygnus Solutions->Cygwin)  

·        cd C:/Work (This should now contain four files : angelboot.exe, opts.txt, ramdisk.gz and zImage)

·        ./angelboot.exe -f opts.txt zImage (you should see the message “Downloading image” followed by a few lines of asterisks. The Ramdisk download is about eight lines and is the slowest part of the process. If there is an error reset the strong arm board and try again (you need not restart the hyperterm)

  1. Run your app. The linux should booting ending in a ‘>’ prompt. Type ./<appname> to run an application in the Ramdisk. ‘ls’ doesn’t work in this very limited shell.
  2. Create Sonar Device Drivers and Application

·        Modify the Hello driver so that it is a character based sonar driver. Open and Close should do nothing, and READ should set the INIT line and busy wait on ECHO. Read should return the character representation of the busy wait count. You will need to access the hardware registers via the hardware register macros defined in hardware.h. For this example, you will need to access GPDR and GPLR. Here are some examples of use:

1.      to set GPIO<4> to output:  GPDR |= 0x00000010;

2.      to read GPIO<5>                  in = GPLR & 0x00000020;

·        Write an app that calls open, read and close on /dev/sonar0. Your app should have a parameter as to the number of times it calls read. The app should print out the returned value of each call to read. For fun, put fork() in your app so that you have two processes contending for the Sonar resource, and print out the process id along with the read results. Do both processes get fair access to the sonar resource?

·        Create /dev/sonar0 on the target or in the ramdisk.

·        Rebuild the kernel, and app, and the ramdisk. Download to target and try it.

Good Luck.