CSE 466 Lab 6:
FriendlyArm Linux Kernel Review, plus Communicating between the FriendlyArm and MSP430

Introduction

In this lab, you will configure and build the linux kernel for your FriendlyArm, adding specific features to allow you to perform specific functions later in the lab. You will investigate the partition table on the FriendlyArm, then install the new kernel and verify it's function.
After getting your new kernel up and running on the FriendlyArm, you will compile and load a kernel module to allow further functionality. Once that is completed, you will work to link your FriendlyArm with one of your MSP430 systems (2013DIP, Amber Radio Module, or Chronos).

The last part of this lab is left as a choice for you, to implement whichever you feel is the most comfortable (or, depending on your desire, the most challenging).

Objectives

In this lab, you will learn to:

Suggested Reading and Resources

Part 1: Creating a linux kernel

Configuring the build environment

First, log into your attu account. In Lab 5, you configured the PATH variable on your attu account to include the path to the Arm version of the gcc compiler. Verify that you still have that destination in your path by typing the following:

echo $PATH
If you do not see "/cse/courses/cse466/Instr/arm_gcc/4.3.2/bin/" in the output, you will need to add it using the following statement:
export PATH=/cse/courses/cse466/Instr/arm_gcc/4.3.2/bin/:$PATH
Alternatively, you could add that command to your .bashrc profile, assuming you are using the bash shell. If using another shell, you will need to determine if it has a similar profile file.

Now that the path is configured, we need to add a pair of environment variables to help the Makefile determine which compiler to use. Run the following commands (in order)

  1. CROSS_COMPILE=arm-none-linux-gnueabi-
  2. CC="${CROSS_COMPILE}gcc -march=armv4t -mtune=arm920t"
  3. export CROSS_COMPILE
  4. export CC
NOTES:
-march=armv4t sets the base architecture to arm v4 thumb
-mtune=arm920t enables arm 9 extensions

Updating the Kernel

A few kernel configurations need to be changed from the one that was distributed on the FriendlyArm. Before you will be able to complete the later parts of this lab, you will need to update the Linux kernel on your FriendlyArm.

Extracting the Kernel

  1. Download the kernel source and extract it using the command
    tar -xvzpf linux-2.6.32.2-mini2440_20100609.tgz
  2. Make a directory alongside the unzipped kernel source to place your compiled kernel objects, for the sake of organization
    mkdir linux-bin
  3. Change to the newly extracted directory containing the kernel using the following command:
    cd linux-2.6.32.2
  4. Replace the mach-mini2440.c file in linux-2.6.32.2\arch\arm\mach-s3c2440 with the one provided. This contains the board specific details needed to use SPI

  5. Return to the root of the linux-2.6.32.2 directory.

Configuring the Kernel

Thank you GUI makers!

We will use a graphical interface to configure the kernel options, which greatly simplifies the process. Without that option, we would need to create the .configure file by hand
/shudder
  1. Make mrproper to prepare a build:
    make ARCH=arm O=../linux-bin/ mrproper
  2. Make the initial config run
    make ARCH=arm O=../linux-bin/ mini2440_defconfig
  3. Make menuconfig to build and run host program to configure build
    make ARCH=arm O=../linux-bin/ menuconfig
    The GUI will open automatically after the above command completes. Once in the GUI, complete the following (note the difference between enabling a feature in the kernel, and enabling a feature as a kernel module):

  4. Exit and save your kernel configuration. Copy the resulting
    ../linux-2.6.32.2/config_mini2440_n35
    file to
    ../linux-bin/.config
    (.config is reserved always for the CURRENT build configuration)
If you mak a mistake and need to start the process again, run:
make ARCH=arm O=../linux-bin/ distclean
(to clean out intermediate objects while preserving settings)

Building the Kernel

It's time to build the kernel you just specified in ".config" (this part will take SEVERAL minutes, after the first minute or two, if there are no errors, go grab something to drink)

  1. Build the kernel:
    make ARCH=arm O=../linux-bin/ -j4
    (remember, if something doesn't work correctly, to use 'make distclean' as described above)
  2. After you build the kernel, build the modules
    make ARCH=arm O=../linux-bin/ -j4 modules

Next we'll partition and set up the FriendlyArm, using your new kernel!

Part 2: Load the new kernel and kernel module on the FriendlyArm

Connecting to the FrienlyArm Bootloader

In this section you will connect the FriendlyArm to your PC via USB and Serial cables (both are needed), then connect to the FriendlyArm Bootloader to help you load your new kernel and kernel module. Complete the following steps:
  1. Set the FriendlyARM's boot switch to 'NOR'
  2. Connect the USB and Serial cables to your PC and to the FriendlyArm and open the DNW application on your PC
  3. NOTE:You should connect the serial cable to COM0 on the FriendlyArm
  4. Go to the configuration -> options menu
  5. Change the USB download address to "0x3000000" -- This is the memory address the FA's bootloader is configured to look for new data at. (we need this because the USB port is configured as a samsung arm debug interface that can actually place things anywhere in memory, so we must specify)
  6. Ensure baud is 115200, and the com port is correct (Likely com1)
  7. Press OK and turn on your FA, then choose connect from the "Serial Port" menu in the DNW application
    You should be greeted with a menu (you may need to presss the ENTER key first). You're now running a bootloader utility stored in the NOR flash memory (as opposed to the NAND flash memory, which is where the root filesystem resides)
  8. Enter option q to enter the vivi shell
  9. Type part show to view the available partitions (along with offsets and sizes) on the primary (NAND) flash. If your table differs drasticallyfrom the below, consult your T.A.

  10. NOTE: The reasoning behind checking the size of the partition table is to see if anyone has a board that is wildly misconfigured. If your 'root' sector size is anything 'close' to the value stated below, you don't need to alert the T.A.

Loading the new Kernel

  1. type load flash kernel u (load to partition "kernel" on device "flash" from source "uSB")
  2. Once you see waiting a download [sic], send your kernel zImage by selecting the Transmit/Restore option in the USB Port menu, then selecting your new kernel zImage
    Hint: linux-bin\arch\arm\boot
    The zImage contains your kernel, in compressed form, along with a native arm routine to uncompress the kernel to ram, and boot it. It is both a binary and data file that the arm executes on "bare metal."
  3. when it finishes, turn the board off, position the bootloader switch to "NAND," and reboot. Your machine should come up with a new kernel

Loading the new USB Kernel Module

  1. Locate the CDC USB module (Hint: It's got a .ko extension)
  2. Copy the file to your device
  3. Issue the command:
    insmod {filename}

Verifying the FriendlyArm SPI Capabilities

Copy the archive spidev_test.zip locally and unzip it. Copy the enclosed program (spidev_test) to your FriendlyArm, then from a terminal prompt in the directory containing spidev_test run the following command (from the directory where you copied the program):
./spidev_test -D /dev/spidev0.0
You should see something similar to the following:
		
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF
If you don't get the above result, consult with your T.A.

Connect the FriendlyArm to an MSP430 system using SPI or Radio

This is the "make your own adventure" part of the lab. You can decide which path to follow, depending on how challenging you want this section to be.
NOTE: don't wimp-out here and just implement something you've done in a previous lab. You can use previous projects, as long as you update/alter them in some way. A portion of your grade on this part will be determined by the scope of your implementation

If you're concerned about the grading aspect of this section, discuss it with your T.A.
  1. Configure the USB dongle with the FriendlyArm to talk to the Chronos wirelessly, and grab data from one of the watch sensors. Do something interesting on the FriendlyArm with all that data!
  2. NOTE:
    Look at the Serial Settings file for info on configuring the Linux USB serial port on the FriendlyArm
  3. Configure SPI between the FriendlyArm and Amber module, and have the Amber connect to the Chronos wirelessly. Pass info from the Chronos to the Amber, and have the Amber control some function on the FriendlyArm
  4. \
  5. Configure the FriendlyArm to communicate with the MSP430 2013DIP via SPI to control some peripheral (can be as easy as controlling the RGB LED, or you can get creative)
  6. Step 1 is no longer recommended,
    as the SPI does not appear to be pinned-out on the FriendlyArm

Deliverables