SPI with BeagleBoard (for a newbie in Linux)

Hi all,

I have been working with BeagleBoard Rev C since last 2 months. At the
same time, I started using Linux firsttime. So far, I am able to place
the angstrom image on my SD partition and run on BeagleBoard with DLP
beamer. Now my actual task starts, in which i have to use expansion
header to connect ADS1258 (in short ADC) with SPI interface.

Before I start messing with the ADC hardware, I want to setup my SPI
at expansion header. I have googled and read many of the emaillist
answers concerning this issue. So far, i have accumulated following
information (in brief):

1. Pin Mux Configuration

In order to get SPI on the expansion header, I have to configure PIN
MUX. there are two ways to do that

                 a) Bootloader (U-boot)
                 b) Linux kernel

Can anybody guide how to configure PIN MUX for spi interface? Step by
step guide would really be appreciated, since that will ultimately be
documented into BeagleBoard development blog or wiki to reduce the
googling around time in this issue. http://elinux.org/BeagleBoardPinMux
is a nice endeavor, however lacks examples.

2. SPIDEV

We have nice spidev_test code to start with. So far, i have following
information to get it run:

           - compile it with gcc-arm and take it into Beagleboard
somehow.
           - run it on BeagleBoard.

Currently, I have no question in this section, as i have yet not
reached there.

I really appreciate the help of your previous and future posts. Thanks
a lot!

Kunal

Hi all,

I have been working with BeagleBoard Rev C since last 2 months. At the
same time, I started using Linux firsttime. So far, I am able to place
the angstrom image on my SD partition and run on BeagleBoard with DLP
beamer. Now my actual task starts, in which i have to use expansion
header to connect ADS1258 (in short ADC) with SPI interface.

Before I start messing with the ADC hardware, I want to setup my SPI
at expansion header. I have googled and read many of the emaillist
answers concerning this issue. So far, i have accumulated following
information (in brief):

1. Pin Mux Configuration

In order to get SPI on the expansion header, I have to configure PIN
MUX. there are two ways to do that

            a\) Bootloader \(U\-boot\)
            b\) Linux kernel

Can anybody guide how to configure PIN MUX for spi interface? Step by
step guide would really be appreciated, since that will ultimately be
documented into BeagleBoard development blog or wiki to reduce the
googling around time in this issue. BeagleBoardPinMux - eLinux.org
is a nice endeavor, however lacks examples.

I think the recent u-boot built with OE enables MCSPI4 in the pinmux.
That is the easiest way to start.

2. SPIDEV

We have nice spidev_test code to start with. So far, i have following
information to get it run:

      \- compile it with gcc\-arm and take it into Beagleboard

somehow.
- run it on BeagleBoard.

Currently, I have no question in this section, as i have yet not
reached there.

Have you patched the code to configure spi for use by spidev into the
board file?

I compile the spidev_test.c program on the beagle by instaling
task-native-sdk on teh beagle.

Philip

Thanks Philip,

Could you please tell me the location to download the recent u-boot
(built with OE) ? and i can start.

Kunal

Hi all,

I try to make my own Image for BB using openembedded and I have a
question:

When I using the command "bitbake x11-image" how can I know which
version of the kernel will be participate in the construction of the
image? I try to run the SPI and I don't know which files should I
taken into account using a patch.

I use a Philip Balister's patch "0001-Changes-to-make-MCSPI3-work-on-
the-Beagle-Board-expa" which was written for kernel version 2.6.28
(the current version which appears to me after the construction of the
image is "Omap1 2.6.30"). In the repository are some version like:
omap-linux-2.6.28 (original) and omap-linux-2.6.29 but oamp-
linux-2.6.30 version does not exist. Any ideas?

One of the solutions would be to force bitbake to do an image for
version 1.6.28. Probably there is a special order in local.conf file
to do this. I found in the FAQ:
(http://www.uv-ac.de/openembedded/openembedded-11.html#ss11.3):

Q: "How can I build older version"
that"

but I don't know where should I look for the correct date for the
2.6.28 :slight_smile:

Perhaps someone try this solution?

> Hi all,

> I have been working with BeagleBoard Rev C since last 2 months. At the
> same time, I started using Linux firsttime. So far, I am able to place
> the angstrom image on my SD partition and run on BeagleBoard with DLP
> beamer. Now my actual task starts, in which i have to use expansion
> header to connect ADS1258 (in short ADC) with SPI interface.

> Before I start messing with the ADC hardware, I want to setup my SPI
> at expansion header. I have googled and read many of the emaillist
> answers concerning this issue. So far, i have accumulated following
> information (in brief):

> 1. Pin Mux Configuration

> In order to get SPI on the expansion header, I have to configure PIN
> MUX. there are two ways to do that

> a) Bootloader (U-boot)
> b) Linux kernel

> Can anybody guide how to configure PIN MUX for spi interface? Step by
> step guide would really be appreciated, since that will ultimately be
> documented into BeagleBoard development blog or wiki to reduce the
> googling around time in this issue.BeagleBoardPinMux - eLinux.org
> is a nice endeavor, however lacks examples.

I think the recent u-boot built with OE enables MCSPI4 in the pinmux.
That is the easiest way to start.

How can I check this? I just built a fresh image yesterday so I
should have the latest u-boot.

> 2. SPIDEV

> We have nice spidev_test code to start with. So far, i have following
> information to get it run:

> - compile it with gcc-arm and take it into Beagleboard
> somehow.
> - run it on BeagleBoard.

> Currently, I have no question in this section, as i have yet not
> reached there.

Have you patched the code to configure spi for use by spidev into the
board file?

I compile the spidev_test.c program on the beagle by instaling
task-native-sdk on teh beagle.

Philip

What code needs to be patched with what?
Where can I find spidev_test.c? And how can I compile it?

> Hi all,

> I have been working with BeagleBoard Rev C since last 2 months. At the
> same time, I started using Linux firsttime. So far, I am able to place
> the angstrom image on my SD partition and run on BeagleBoard with DLP
> beamer. Now my actual task starts, in which i have to use expansion
> header to connect ADS1258 (in short ADC) with SPI interface.

> Before I start messing with the ADC hardware, I want to setup my SPI
> at expansion header. I have googled and read many of the emaillist
> answers concerning this issue. So far, i have accumulated following
> information (in brief):

> 1. Pin Mux Configuration

> In order to get SPI on the expansion header, I have to configure PIN
> MUX. there are two ways to do that

> a) Bootloader (U-boot)
> b) Linux kernel

> Can anybody guide how to configure PIN MUX for spi interface? Step by
> step guide would really be appreciated, since that will ultimately be
> documented into BeagleBoard development blog or wiki to reduce the
> googling around time in this issue.BeagleBoardPinMux - eLinux.org
> is a nice endeavor, however lacks examples.

I think the recent u-boot built with OE enables MCSPI4 in the pinmux.
That is the easiest way to start.

How can I check this? I just built a fresh image yesterday so I
should have the latest u-boot.

On second thought, I think the pinmux is setup, but I am not sure if
the board let the spidev driver claim it.

I really need to update the OE patch to use spi .....

> 2. SPIDEV

> We have nice spidev_test code to start with. So far, i have following
> information to get it run:

> - compile it with gcc-arm and take it into Beagleboard
> somehow.
> - run it on BeagleBoard.

> Currently, I have no question in this section, as i have yet not
> reached there.

Have you patched the code to configure spi for use by spidev into the
board file?

I compile the spidev_test.c program on the beagle by instaling
task-native-sdk on teh beagle.

Philip

What code needs to be patched with what?
Where can I find spidev_test.c? And how can I compile it?

The spidev_test.c prgram is in the kernel source Documentation/spi directory.

Philip

Hi,

Finally I chose to go U-boot edit option, since it seems less hectic
right now.

For those who is newbie in Linux:

Pin Mux configuration (U-Boot approach)

Step 1: U-Boot.bin is executable file which can't be edited. So to
get source code of u-boot, just follow the link http://elinux.org/BeagleBoard#U-Boot

Step 2: Make changes in relevant file to make SPI work. Now this is my
question to Linux experts.

What short of changes do we need to make in u-boot? is there any patch
available for u-boot regarding spi on expansion board? I found the
article http://wh1t3s.com/2009/05/06/enabling-uart1-on-rev-c2-beagleboard/
Is there similar link which can guide us step by step?

Thanks a lot,
Kunal

Info related with pin mux configuration it easy to find, and thus
setup
you expansion header pins so that everything could run well.

Regards on SPI:

1) If you have very clear idea about what it should be your operation
program,
I reccomend you to make your own driver using the Linux kernel of the
board.
In /beagle/2.6_kernel/drivers/spi you'll find two appropiate files:

spi.c and spidev.c

spi.c should be modified by you,
spidev.c should be modified by you but let remain some functions such
as everything related with spi_init,spi_exit,spi_release and of course
ioctl.

2) spi.c will be the trully driver you're going to use. Thus, there
should be written all functions related with spi inizialization
following your needs and
accordingly with TEXAS reference manual http://focus.ti.com/lit/ug/sprufc9b/sprufc9b.pdf

3) In the IOCTLS of spidev.c must be the functions you'll use in
spi.c, such us: stop_data_transmission(),start_data_transmission(),
setup_spi_registers(),...
4) Interrupts must be in spi.c and if I'm not wrong the associated IRQ
is 48.
It's up to you the fact of selecting which interrupts you're going to
use and enabling them at inizializaton, don't forget that you have to
set the appropiate bit in the IRQSTATUS register to clear the
interrupt state register.

5) Finally it will be your application which will use this driver, so
you must build a procedure not only via ioctl to communicate withj
your driver, but also when your driver want to communicate with your
application. I do that using polling methods, which are callback
functions to tell the application that by example I have received
enough data to be processed.

Try to explain me the operation (if you want) of your program so that
I can be more explicit.

Ignacio

[snip]

One of the solutions would be to force bitbake to do an image for
version 1.6.28. Probably there is a special order in local.conf file
to do this.
I found in the FAQ (http://www.uv-ac.de/openembedded/
openembedded-11.html#ss11.3):
Q: "How can I build older version"
A: "An entry CVSDATE =" YYYYMMDD " local.conf in your file should do
that"
but I don't know where should I look for the correct date for the
2.6.28 :slight_smile:
Perhaps someone try this solution?

The way I've done it is the following:

Add this line to your local.conf file:

PREFERRED_VERSION_linux-omap = "2.6.31"

This should force it to build to whatever version you want. Note that
the kernel version should correspond to an appropriate .bb file under
recipes/linux/

Good luck.
Amit