create new tag
, view all tags

This is Al's step by step guide to getting working SPI pins on your BeagleBoard-xM (BB-xM)

Step 1 - Formatting the SD Card

Now this step is more fiddly that one would expect. It's fine to just use the SD card which comes with the BB-xM as that's already set up the way we want it. However, if you're using an unformatted card, well need to set it up for our own usage.

So we need one to be fat 32, this needs to be about 70Mb big, although we won't all of this space. (We need about 13Mb in total) We also need a Linux fs, seperately partitioned. This should contain the remainder of the SD cards space, so for an 8 Gb card it will contain 7930 Mb of space, more or less.

This can be achieved two ways; either via fdisk "expert mode" or by using a premade script. fdisk is hard and we're lazy, so lets go go with the easy, premade script. If anyone's a glutton for punishment, there is a handy tutorial here

but we'll ignore that.

  1. Download mkcard.txt from this location (http://downloads.angstrom-distribution.org/demo/beagleboard/)
  2. In the command terminal, in the directory you downloaded the mkcard.txt file too, run the following command
    chmod +x mkcard.txt
    This should make it an executable, so now we need to establish what device were going to be writing too...
  3. run the following command
    df -h
    Which should return something that looks like this
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/loop0       19G   14G  4.7G  74% /
    udev            1.9G  4.0K  1.9G   1% /dev
    tmpfs           749M  896K  749M   1% /run
    none            5.0M     0  5.0M   0% /run/lock
    none            1.9G  156K  1.9G   1% /run/shm
    none            100M   48K  100M   1% /run/user
    /dev/sda5       330G  153G  178G  47% /host
    /dev/sdc1       7.6G   40M  7.6G   1% /media/al/Linux Booty
    /dev/sdb1        64M   14M   51M  21% /media/al/boot
    /dev/sdb2       3.6G  1.1G  2.3G  32% /media/al/rootfs

    So we can see in my computer, the sd card is called /dev/sdb... SD cards should always show up as "sdX", where X is a letter depending upon which port the card has been attached too.
  4. Run the following command
    sudo ./mkcard.txt /dev/sdX
    where X is your card's letter
  5. Done!!!
  6. Run the following command
    just to make the sd card pop up again If it isn't, (don't yank it out, that'll just mean you'll have to start over)

Step 2 - Setting up Linux on your card

Mercifully, other people have already done the hard work for us for this step, and there are some nice linux builds out there which should fit nicely with our BB-xM boards. Checking the BB-xM wiki will lead us to the most up to date images:

but for now the following link works so well just use that
  1. Run the following code in command terminal
    wget http://rcn-ee.net/deb/rootfs/quantal/ubuntu-12.10-r2-minimal-armhf-2012-11-29.tar.xz
  2. Verify that image using the following command
    md5sum ubuntu-12.10-r2-minimal-armhf-2012-11-29.tar.xz
    Should you be using the current build, (ubuntu-12.10-r2-minimal-armhf-2012-11-29.tar.xz ), you should see:
    b0ee1964a3f8196f4f1a501d1d2ac83a ubuntu-12.10-r2-minimal-armhf-2012-11-29.tar.xz
  3. Unpack image with the following command
    tar xJf ubuntu-12.10-r2-minimal-armhf-2012-11-29.tar.xz
  4. Go to the unpacked files directory
    cd ubuntu-12.10-r2-minimal-armhf-2012-11-29
  5. Now upload that image to the BB-xM with the following command
    sudo ./setup_sdcard.sh --mmc /dev/sdX --uboot beagle_xm
Nice and simple smile

Step 3 - Modification of Linux

In the root directory of the SD cards (this would be our FAT partition), theres a file called "uEnv.txt" in the top directory

  1. Open uEnv.txt
    gedit uEnv.txt
  2. Add the following line near the top of the code
    This should enable the spi pins in the uboot

Step 4 - Configuring the Kernel

Almost there, now the final step we need to do is to set up the kernel for out Linux boot disk. The thing to remember about kernels is that they establish how the software interfaces with the hardware, so for a non-normal board like a BB-xM we're going to need a non-normal kernel to go along with it. The other thing to remember is that re-writing a kernel on your own is f**king hard, its a big complicated mess and debugging it is a lot of work that is best avoided if possible. So for this part we will use some code which creates a custom kernel, written by Robert C Nelson, (our friend responsible for our custom Linux build).

  1. Go to whatever directory you want to save stuff into and run the following command
    git clone https://github.com/RobertCNelson/stable-kernel.git
    This should download RCN's latest build onto your PC into a folder called "stable-kernel".
***************************************************************************************** A note from the handsome author ***************************************************************************************

Now the next few steps I will follow the procedure I took, however I STRONGLY STRONGLY recommend checking the readme file of the stable kernel folder. If the stable=kernel files have been modified since the completion of this wiki entry then these steps below may not work, while the correct ones can always be found in the readme. In fact, thats a fairly solid rule anyway. Always read the ReadMe, its got all sorts of tasty tidbits... Anyway... ******************************************************************************************************************************************************************************************************************************

  1. Before we can start anything, we'll need the necessary bits and pieces. So run the following lines of code and install them
    sudo apt-get install gcc-arm-linux-gnueabih
    git checkout origin/v3.1.x -b v3.7.x
    <--------------This should change our version of the build to the one specific to our BB-xM. Again, check the readme to make sure you are using the correct one for your board
    git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
    This last line will download a file thats about 500Mb to whatever directory you specify, (for simplicities sake place it in the top folder of your user directory, the same one that "stable-kernel" should be in. It may take a bit to download but unfortunately is necessary. This download is the basic kernel we will be building our custom one from)
  2. We need to modify a file called setup.sh file, but it doesn't exist!!! Open system.sh.sample with gedit and save it as system.sh
  3. Now fire the new system.sh up in gedit using the following code in the stable-kernel directory
    gedit system.sh
  4. First thing we need to change for now is the CC line, on line 18. Change this to
    Check exactly what we need to change this to in the readme, as it is dependent upon the version of Linux were building the kernel for. Our version is Ubuntu 12.10, we need gnueabihf
  5. Finally, we need to upload this to our SD card, change line 57 to the following
    where X=letter for SD drive. Save your changes.
  6. Now that everythings (finally) set up, build the kernel by running the following code
    *This will take about 15 minutes... Coffee break!
  7. Upload the image. Last step, RCN was nice enough to give us some code to upload the kernel, so run the following code from the "stable-kernel" directory

Step 5 - Confirming setup

Ok, so all our pieces should be in place. Place the SD card into the BB-xM and fire that puppy up (get it? Puppy... BeagleBoard... ahh Hilarious!)

  1. Your login should be
  2. run a search for spi using the following command
    dmesg|grep spi
    This should return the following
    [ 2040.715728] omap2_mcspi omap2_mcspi.1: registered master spi1
    [ 2040.715881] omap2_mcspi omap2_mcspi.2: registered master spi2
    [ 2040.716033] omap2_mcspi omap2_mcspi.3: registered master spi3
    [ 2040.716094] spi spi3.0: setup: speed 48000000, sample trailing edge, clk normal
    [ 2040.716094] spi spi3.0: setup mode 1, 8 bits/w, 48000000 Hz max --> 0
    [ 2040.716186] omap2_mcspi omap2_mcspi.3: registered child spi3.0
    [ 2040.716217] spi spi3.1: setup: speed 48000000, sample trailing edge, clk normal
    [ 2040.716247] spi spi3.1: setup mode 1, 8 bits/w, 48000000 Hz max --> 0
    [ 2040.716339] omap2_mcspi omap2_mcspi.3: registered child spi3.1
    [ 2040.716461] omap2_mcspi omap2_mcspi.4: registered master spi4
    [ 2040.716491] spi spi4.0: setup: speed 48000000, sample trailing edge, clk normal
    [ 2040.716522] spi spi4.0: setup mode 1, 8 bits/w, 48000000 Hz max --> 0
    [ 2040.716613] omap2_mcspi omap2_mcspi.4: registered child spi4.0
    see the spi3.0, 3.1 and 4.0? That means we can now write to our pins, so we have the BB-xM set up with the SPI pins enabled.
Topic revision: r4 - 2012-12-21 - AlYoung
This site is powered by the TWiki collaboration platformCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback