[beagleboard] Re: Beagleboard xM - SPI

On Sun Feb 5 2:39 , bhensley <bjhensley2010@gmail.com> sent:

Hey Thanks for the feedback. I actually have been working on getting Ubuntu

working for the BB XM with SPI, and today I got it all working. Had a little help
from Robert and i've documented my findings on my blog. If anyone is looking for
a full walk though for novice users using Ubuntu I hope this helps. My problem
was I hated searching too many sites for all the answers over the last couple
weeks. Sure feels good to have this all working now.

http://www.brianhensley.net/2012/02/spi-working-on-beagleboard-xm-rev-c.html

Cheers,
Brian

Very nice writeup, Brian.

Dumb question, maybe: how much of this
might apply to the standard Beagleboard?

/Rafe

Hello Rafe,

I don’t know exactly how much might apply to the Beagleboard, but I’m assuming most of the concepts can be applied as well as compiling the kernel and patch. I think the biggest thing to understand the process of what needs to happen. Let me know if you try it and it works.

Cheers,

Brian Hensley
www.brianhensley.net

Hi,

I'm currently working on getting my SPI running and found this thopic
very interesting. I tried building it like Vasilis and ran into the
same problem, so now i have followed Brians instructions on using the
http://www.angstrom-distribution.org/building-angstrom. What i have
done is to download the files and then i ran:

MACHINE=beagleboard ./oebb.sh config beagleboard
MACHINE=beagleboard ./oebb.sh update
MACHINE=beagleboard ./oebb.sh bitbake console-image

This took a couple of hours as expected, and i got everything
generated as intended(i think). I could locate uboot, uImage etc in
the deploy folder.But now i'm at the stage where i want to update the
arch/arm/mach-omap2/board-omap3beagle.c to expose McSPI3 & 4 to the
userspace( http://elinux.org/BeagleBoard/SPI ).
The problem i have is that i'm not certain how to do this. Shall i go
into the "build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/
arch/arm/mach-omap2/board-omap3beagle.c", then apply the changes and
then run the three ./oebb.sh commands again?

To add to my confusion i found this website:
http://www.slimlogic.co.uk/2011/05/openembeddedangstrom-kernel-workflow/
Having read it, i wonder, is this the suitable work order when using
the scripts and files downloaded from building-angstrom site? If thats
the case i'm abit confused about the bitbake, because i tried to run
the first commands listed and it said i had to install bitbake(but i
can clearly see bitbake in the sources/ directory i got when
downloading the angstrom build).

Best regards, a linux begginer
Tomas

OK good! You are almost there. Now it is time to get your hands dirty.

I'm going to use my last build as an example which should be similar
to what you should see but your mileage may vary :slight_smile:

The quick and dirty way to make your changes (this is "a way" not "the
way" - as there are many):

The kernel comes from git and gets patches applied to it for your
target (machine) during the bitbake process and the product of that
processes ended up in a work directory. My board-omap3beagle.c file
is in:

build/tmp-angstrom_2010_x-eglibc/work/beagleboard-angstrom-linux-gnueabi/linux-3.0.17-r115c/git/arch/arm/mach-omap2
directory.

Refer to the elinux spi page in earlier messages of this thread but
basically ....
Make your SPI changes to this file (board-omap3beagle.c ). To use my
project as an example I added the following changes/sections:

#include <linux/spi/spi.h>

// For McSPI3 on expansion connector
static struct spi_board_info beagle_mcspi_board_info[] = {
    {
        .modalias = "spidev",
        .max_speed_hz = 100000, //100 KHz
        .bus_num = 3,
        .chip_select = 0,
        .mode = SPI_CS_HIGH | SPI_MODE_1,
    }
};

In omap3_beagle_init I added:

//BTH - For McSPI3
spi_register_board_info(beagle_mcspi_board_info,
ARRAY_SIZE(beagle_mcspi_board_info));

Now for the fun part. After you make these changes, if you run the
bitbake virtual/whatever you will most likely wipe out your changes
(at least that was my experience when I was learning). Oh, you will
get a kernel image but it will take kernel from git and apply the
patches and the result will over write the files you just changed.

You want to just recompile the kernel (everything else has already
been done for you if you did say a console-image etc.) so you need to
do that with a command like:

bitbake -f -c compile linux-3.0.17

When this is done ... your uImage will be somewhere like:
build/tmp-angstrom_2010_x-eglibc/work/beagleboard-angstrom-linux-gnueabi/linux-3.0.17-r115c/git/arch/arm/boot

... but will not be in the image directory.

Run the deploy command on the kernel:
bitbake -f -c deploy linux-3.0.17

... and you should have ready-to-go images in a directory that looks
something like:
build/tmp-angstrom_2010_x-eglibc/deploy/images/beagleboard

Put these in the proper place on the SD Card and enjoy. Go get
yourself a cold beverage ... you earned it. Enjoy watching the board
boot the kernel you just modified. You'll have to rename the files on
the SD Card to be MLO, u-boot.bin, uImage etc. There is the small
detail of a boot.scr or uEnv.txt script that you'll need but you can
google for how to construct one of those too.

look in /dev/ to see if you have a /dev/spidev3.0 device (the result
of my example above). If it is there, then you should be good to go.
Write a user space program to use it. Checkout and google spidev_test
as an example.

Regards,

Brian

If you don't have normal kernel files in a directory similar to:

build/tmp-angstrom_2010_x-eglibc/work/beagleboard-angstrom-linux-gnueabi/linux-3.0.17-r115c/git

... then it could be that the bitbake command you ran to build the
system (console-image etc.) is cleaning up after itself and you may
have to run bitbake -f -c linux-3.0.17 (or whatever it is now ... this
was the last git pull I did) so that the kernel is built and the final
source is left in place.

You might have to run some find commands to make sure you aren't
getting lost in the directory jungle.

cd into build/ and run find . -name "board-omap3beagle.c" ... it
should be in a directory similar to what I described.

Regards,

Brian

Here is a page that might help you pick up what I'm laying down:

http://wh1t3s.com/2009/05/11/oe-bitake-kernel-mods/

From: beagleboard@googlegroups.com [mailto:beagleboard@googlegroups.com]
On Behalf Of Tomas Selldén
Sent: Thursday, February 09, 2012 6:00 AM
To: Beagle Board
Subject: [beagleboard] Re: Beagleboard xM - SPI

It would appear as if i only can find .h files in the sysroot/
beagleboard/kernel/arch/arm/mach-omap2/ directory. No board- omap3beagle.c

or

any other .c file there. So i'm afraid i'm really stuck on how to get on

from now on.
In your local.conf file, there is a line that removes the source code after
a successful build. You need to comment out the line:

INHERIT += "rm_work"

Regards,
John

> Hi,
>
> I'm currently working on getting my SPI running and found this thopic
> very interesting. I tried building it like Vasilis and ran into the
> same problem, so now i have followed Brians instructions on using
> thehttp://www.angstrom-distribution.org/building-angstrom. What i have

done is

Hi again!

I have managed to get the git directory, build/tmp-angstrom_2010_x-
eglibc/work/beagleboard-angstrom-linux-gnueabi/linux-3.0.17-r115c/git.
I have been able to edit the board-omap3beagle.c. I have a uImage in
the directory:
build/tmp-angstrom_2010_x-eglibc/work/beagleboard-angstrom-linux-
gnueabi/linux-3.0.17-r115c/git/arch/arm/boot

The problem i have right now is deploying it. I run the deploy but the
files in the directory: build/tmp-angstrom_2010_x-eglibc/deploy/images/
beagleboard are not utdated.

I'm not sure if i might be the one causing the problem or not, when i
looked at the build-angstroms site where you use the "MACHINE=beagle ./
oebb bitbake console-image" i figured that the part "./oebb bitbake"
was a possible way to start the bitbake. So to launch my compile &
deploy i've used "./oebb bitbake -f -c compile linux-3.0.17" and "./
oebb bitbake -f -c deploy linux-3.0.17".

I did some experimenting, i made a change to board-omap3beagle.c, then
i ran compile and on of the notes that was posted was:
NOTE: Tasks Summary: Attempted 304 tasks of which 303 didn't need to
be rerun and all succeeded."
After the compile i could see(by looking at time modified of the file)
that board-omap3beagle.o and uImage was updated.
When i do run the deploy, one of the note says: " NOTE: Tasks Summary:
Attempted 390 tasks of which 390 didn't need to be rerun and all
succeeded."
And i suppose that tells us that it doesnt do or change anything.

Are any of you familiar with this problem?

I greatly appreciate the help you've given me and any tips on solving
this last problem would be great.
Regards,
Tomas

... I have a uImage in
the directory:
build/tmp-angstrom_2010_x-eglibc/work/beagleboard-angstrom-linux-
gnueabi/linux-3.0.17-r115c/git/arch/arm/boot

If you have an uImage there then you can use that. It is the same one
that gets copied over into the images directory during the deploy
phase.

The problem i have right now is deploying it. I run the deploy but the
files in the directory: build/tmp-angstrom_2010_x-eglibc/deploy/images/
beagleboard are not utdated.

Not sure why this is. Sorry.

I'm not sure if i might be the one causing the problem or not, when i
looked at the build-angstroms site where you use the "MACHINE=beagle ./

Hopefully you are setting it to MACHINE=beagleboard :slight_smile:

Regards,

Brian

Hi Brian,

I managed to get it working. I simply started over from the begining
again. I think what confused me a bit was keeping track on all the
different console-image/deploy/compile commands. I've been able to run
the spidev_test and i've also checked the signals with an ociloscope,
all works great =)

So thanks alot for the help!

Regards,
Tomas

Outstanding! Now you'll have to figure out how to do the same thing
with Device Trees so you don't have to modify the board file!
Unfortunately, folks like me that are stuck on older ARM kernels
(2.6.37) still have to modify the board file to configure platform
devices.

Regards,

Brian

Hello! I finally managed to setup SPI drivers for Beagleboard xM
running Ubuntu and ran the spitest program following these
instructions:

http://www.brianhensley.net/2012/02/spi-working-on-beagleboard-xm-rev-c.html
(special thanks to Robert Berger who help me out a lot with some
fundamental stuff)

I have the Trainer xM board now and I want to see if SPI is actually
working. So I hooked up MOSI and MISO on the Trainer and ran the
spitest program. I was surprised to see that nothing happenned. I want
to state that SPI on Beagleboard itself worked fine.

Which SPI did you use? For SPI3 you may have to set direction of the
buffers on the TrainerBoard.

j.

I didn't know that. I have no preference on which SPI to use. Do you
think that if I use SPI4 there will be no such problem? How do you
change the buffer direction on Trainer? Thank you for your response!

Buffers for SPI4 have fixed directions. Directions of buffers for SPI3
is controlled by pins on the BB's expansion connector, so it can be
used as either master or slave. If you followed Brian's tutorial, most
likely you ended up using SPI3. Take a look at the schematic of
Trainer and configure directions of SPI lines going through U1 and U2.

j.

I see. So TPI11 - TPI14 refers to SPI4? That was something useful
indeed! Isn't it possible to run this spitest through SPI4? Basically,
I am not aware of the spitest source code, so I feel a bit blind!

I see. So TPI11 - TPI14 refers to SPI4? That was something useful

Apparently.

indeed! Isn't it possible to run this spitest through SPI4? Basically,
I am not aware of the spitest source code, so I feel a bit blind!

You probably know about spitest more than I do, but I'd start from
shorting MISO and MOSI pins on SPI4 and modifying path passed through
'-D' option.

j.

You probably know about spitest more than I do, but I'd start from
shorting MISO and MOSI pins on SPI4 and modifying path passed through
'-D' option.

Yes it will be my next step. I will let you know if I come up with
anything. Thank you for your support!

It seems that I only have spidev3.0 and spidev3.1 under my /dev
directory on BeagleBoard. I examined the RevB schematic of the Trainer
Board and I saw that SPI3_SOMI and SPI3_SIMO refer to TP21 and TP15
respectively. So I hooked up these pins and still nothing happened. Is
there something I am doing wrong about that? Here are the schematics:
http://www.tincantools.com/assets/trainer_rev-b.pdf
Thank you in advance!

Did you configure buffers?

j.