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:
- Creating a linux kernel
- Configure a linux kernel
- Compile a linux kernel
- Compile a linux kernel module
- Load the new kernel and kernel module on the FriendlyArm
- Connect the FriendlyArm to an MSP430 system using SPI or Radio
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)
- CROSS_COMPILE=arm-none-linux-gnueabi-
- CC="${CROSS_COMPILE}gcc -march=armv4t -mtune=arm920t"
- export CROSS_COMPILE
- 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
- Download the kernel source and extract it using the command
tar -xvzpf linux-2.6.32.2-mini2440_20100609.tgz
- Make a directory alongside the unzipped kernel source to place your compiled kernel objects, for the sake of organization
mkdir linux-bin
- Change to the newly extracted directory containing the kernel using the following command:
cd linux-2.6.32.2
- 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
- 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
- Make mrproper to prepare a build:
make ARCH=arm O=../linux-bin/ mrproper
- Make the initial config run
make ARCH=arm O=../linux-bin/ mini2440_defconfig
- 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):
- Load the alternative configuration for the 3.5 N panel & mini2440 config_mini2440_n35
- Find the option for USB Modem (CDC ACM) and set it as a Module
- Find the option for EXT3 and enable it (note that it could also be built as a module)
- Find the option for yaffs and enable it similarly to EXT3 (otherwise your kernel won't know how to read the rootfs!)
- Find the option for "SPI Support" and enable it with the following options:
- Samsung S3C24XX Series SPI
- User mode SPI device driver support
- Find the option for the GPIO sysfs interface (Under GPIO support) and enable it
- 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)
- Build the kernel:
make ARCH=arm O=../linux-bin/ -j4
(remember, if something doesn't work correctly, to use 'make distclean' as described above)
- 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:
- Set the FriendlyARM's boot switch to 'NOR'
- Connect the USB and Serial cables to your PC and to the FriendlyArm and open the DNW application on your PC
- If you can't find DNW in the C:\DNW folder, contact your T.A.
NOTE:You should connect the serial cable to COM0 on the FriendlyArm
- Go to the configuration -> options menu
- 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)
- Ensure baud is 115200, and the com port is correct (Likely com1)
- 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)
- Enter option q to enter the vivi shell
- 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.
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.
Number of partitions: | 4 |
name | : | offset | size | flag |
------------------------------------------------------------ |
vivi | : | 0x00000000 | 0x00040000 | 0 |
param | : | 0x00040000 | 0x00020000 | 0 |
kernel | : | 0x00060000 | 0x00500000 | 0 |
root | : | 0x00560000 | 0x40000000 | 0 |
Loading the new Kernel
- type load flash kernel u (load to partition "kernel" on device "flash" from source "uSB")
- 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."
- 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
- Locate the CDC USB module (Hint: It's got a .ko extension)
- Copy the file to your device
- 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.
- 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!
NOTE:Look at the Serial Settings file for info on configuring the Linux USB serial port on the FriendlyArm
- 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
\
- 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)
Step 1 is no longer recommended, as the SPI does not appear to be pinned-out on the FriendlyArm
Deliverables
- Turn in all required documents via an e-mail attachment to cse466-tas@cs. For all files turned in, the comments at the top of the file should contain:
- Your full name, login and student number
- The lab number and the part of the lab (e.g. "Lab6, Part2").
- Demonstrate your new kernel on the FriendlyArm for the T.A.
- Demonstrate your implementation from Part 3 for the T.A. You can either do this during the first 1/2 hour of the next lab
You should create a .zip or .tar archive of all of the files you are turning in.