Patching Beagle Board xM for SPI

Assuming that you use the angstrom / openembedded way:
Then the procedure would be
MACHINE=beagleboard bitbake u-boot -c configure

Then go to :
/home/hansan/Beagleboard/setup-scripts/build/tmp-angstrom_2008_1/work/beagleboard-angstrom-linux-gnueabi/u-boot-2011.02+r75+gitrc7977858dcf1f656cbe91ea0dc3cb9139c6a8cc8-r75/git/board/ti/beagle/
There are two files beagle.c and beagle.h
those two control the pin muxing in u-boot.
you can for instance copy the pin-mux for the tincan tool trainer and zippy
to get the right mux settings for spidev4.0

then
MACHINE=beagleboard bitbake u-boot -c compile -f
MACHINE=beagleboard bitbake u-boot -c deploy -f

But I have to admit that I don’t get the spidev working with the latest u-boot: u-boot_2010.3 works very well, but u-boot_2011.2 doesn’t work at my board: that is the spidev devices do not appear in the /dev file system.
I have not find a way to solve this yet.

I hope someone else has a good tip on how to make this work.

Greetings,

Han

May be this link is useful for you. This guy got it working.

http://beagleboardxm.org/blog/2011/03/22/progress-spi-is-working-on-the-beagleboard-xm/

Thank you,
Johnson

I had read through that previously, and it unfortunately lacks enough
detail to make it useful.

I think I'm almost to the point where I understand how this is
supposed to work, but still no luck actually getting it working.

Correct me if I have anything wrong, but this is what I understand
needs to be done to get SPI working.

1. modify board-omap3beagle.c to set up the pins and initialize the
SPI modules in the kernel
2. compile the kernel with these changes and the options to enable SPI
3. Compile u-boot with the pins set up correctly (if using some of the
extension boards this may be unnecessary)

This is what I've done and I'm still stuck with the spidev program
running, but not actually outputting anything onto the pins.

There seems to be a lot of variation on the exact versions to compile
and patches to use from different people. To the people who have this
working.

What versions of the kernel/angstrom/u-boot are you using and exactly
what changes did you need to make?
Did you compile it with code sourcery or with openembedded?

Jon,

How are you checking for output on the pins of your beagleboard?
Are you able to see the spi devices(spidev3.0...etc) in the /dev/ directory?
From the steps I've read in your posts, it looks like your on the right track.

David

I can see the spidev's fine. To test I'm running the code found in
Documentation/spi/spidev_test.c , which can be viewed here
http://lxr.free-electrons.com/source/Documentation/spi/spidev_test.c .
To see if SPI is really working I'm scoping the SCLK pin (21 on the P9
expansion header) and looking at the output of the spidev program when
I short MOSI and MISO.

Hello,

I haven't been able to get the ethernet to work with linux 2.6.35.9 patched with Xenomai. I've been in menuconfig turning on anything and everything related to networking and usb and still nothing.

David

OpenEmbedded is not that difficult and can make life a bit easy. Also
it builds a much better toolchain than the codesourcery (unless you
ask it not to).

Here are a few links I found useful:
Reference manuals:
http://docs.openembedded.org/usermanual/usermanual.html
http://www.yoctoproject.org/docs/poky-ref-manual/poky-ref-manual.html
(most of it still applies)

Example workflow:
http://www.slimlogic.co.uk/2011/05/openembeddedangstrom-kernel-workflow/

Thanks,
Joel

I finally got this all working! Here's a brief guide to what I did.

* install dependencies listed here : http://wiki.openembedded.net/index.php/OEandYourDistro
* Installed python 2.6 and python2.6-dev to replace 2.7 and followed
these instructions to switch :
http://tareqalam.wordpress.com/2008/11/28/change-the-default-python-version-in-ubuntu/
* installed psyco python JIT compiler : http://psyco.sourceforge.net/psycoguide/sources.html
* set up open embedded for the beagle board and angstrom by
following : http://www.angstrom-distribution.org/building-angstrom
* for a given session to load the environment for bitbake run : .
~/.oe/environment-2008
* Modify the bitbake recipe sources/openembedded/recipes/linux/linux-
omap-psp_2.6.32.bb : add the line file://beagleboard-xmc/custom-spi.patch
\ to the list of files in SRC_URI_append_beagleboard
* Make the file sources/openembedded/recipes/linux/linux-omap-
psp-2.6.32/beagleboard-xmc/custom-spi.patch and add the code here
http://elinux.org/BeagleBoard/SPI/Patch-2.6.37
* run MACHINE=beagleboard bitbake console-image this should take
several hours
* Following the advice here http://wh1t3s.com/2009/05/07/modifying-and-rebuilding-u-boot/
when it gets up to modifying the file I found it here setup-scripts/
build/tmp-angstrom_2008_1/work/beagleboard-angstrom-linux-gnueabi/u-
boot-2011.02+r75+gitrc7977858dcf1f656cbe91ea0dc3cb9139c6a8cc8-r75/git/
board/ti/beagle . Edit beagle.h and add the lines

      MUX_VAL(CP(MCBSP1_CLKR), (IEN | PTU | DIS | M1)) /
*MCSPI4_CLK*/\
      MUX_VAL(CP(MCBSP1_DX), (IDIS | PTU | DIS | M1)) /
*MCSPI4_SIMO*/\
      MUX_VAL(CP(MCBSP1_DR), (IEN | PTU | EN | M1)) /
*MCSPI4_SOMI*/\
      MUX_VAL(CP(MCBSP1_FSX), (IDIS | PTU | DIS | M1)) /
*MCSPI4_CS0*/

to #define MUX_BEAGLE()

* load the files onto the SD card. First set up card with
http://elinux.org/BeagleBoardBeginners#SD_card_setup I found the files
deployed to setup-scripts/build/tmp-angstrom_2008_1/deploy/glibc/
images/beagleboard . I copied them to the SD card as follows where the
partitions on my sd card were called boot and Angstrom

  1. cp MLO-beagleboard /media/boot/MLO
  2. cp u-boot-beagleboard.bin /media/boot/u-boot.bin
  3. sudo cp Angstrom-helloworld-image-glibc-ipk-2011.03-
beagleboard.rootfs.tar.bz2 /media/Angstrom/
  4. cd /media/Angstrom/
  5. tar -jxvf Angstrom-helloworld-image-glibc-ipk-2011.03-
beagleboard.rootfs.tar.bz2

* Once the board booted up I installed the native toolchain on the
beagle board with opkg install task-sdk-native coppied the code from
http://lxr.free-electrons.com/source/Documentation/spi/spidev_test.c
and compiled it with gcc -o spitest spidev_test.c
* I ran it such that it used /dev/spidev4.0, and if I shorted MOSI and
MISO I got their test signal back

There are a few things that could be improved, and I would apreciate
any advice on how to do them. First it would be a lot easier to cross
compile spidev_test.c, instead of building it natively. I've read the
tutorials like the one here http://www.gumstix.org/software-development/open-embedded/160-bitbake-tutorial.html
, but when I followed the instructions and tried to install the ipk
files (spitest-dbg_1.0-r0.6_armv7a.ipk spitest-dev_1.0-
r0.6_armv7a.ipk) the dev said it was missing a dependancy and the dbg
that there was an unsatisfied recommendation.

Second It would be a lot nicer to just make a patch for u-boot and add
it to the recipe, but I am unfamilar with how to go about it.

I finally got this all working! Here's a brief guide to what I did.

* install dependencies listed here : http://wiki.openembedded.net/index.php/OEandYourDistro
* Installed python 2.6 and python2.6-dev to replace 2.7 and followed
these instructions to switch :
http://tareqalam.wordpress.com/2008/11/28/change-the-default-python-version-in-ubuntu/
* installed psyco python JIT compiler : http://psyco.sourceforge.net/psycoguide/sources.html
* set up open embedded for the beagle board and angstrom by
following : http://www.angstrom-distribution.org/building-angstrom
* for a given session to load the environment for bitbake run : .
~/.oe/environment-2008
* Modify the bitbake recipe sources/openembedded/recipes/linux/linux-
omap-psp_2.6.32.bb : add the line file://beagleboard-xmc/custom-spi.patch
\ to the list of files in SRC_URI_append_beagleboard
* Make the file sources/openembedded/recipes/linux/linux-omap-
psp-2.6.32/beagleboard-xmc/custom-spi.patch and add the code here
http://elinux.org/BeagleBoard/SPI/Patch-2.6.37
* run MACHINE=beagleboard bitbake console-image this should take
several hours
* Following the advice here http://wh1t3s.com/2009/05/07/modifying-and-rebuilding-u-boot/
when it gets up to modifying the file I found it here setup-scripts/
build/tmp-angstrom_2008_1/work/beagleboard-angstrom-linux-gnueabi/u-
boot-2011.02+r75+gitrc7977858dcf1f656cbe91ea0dc3cb9139c6a8cc8-r75/git/
board/ti/beagle . Edit beagle.h and add the lines

 MUX\_VAL\(CP\(MCBSP1\_CLKR\),    \(IEN  | PTU | DIS | M1\)\) /

*MCSPI4_CLK*/\
MUX_VAL(CP(MCBSP1_DX), (IDIS | PTU | DIS | M1)) /
*MCSPI4_SIMO*/\
MUX_VAL(CP(MCBSP1_DR), (IEN | PTU | EN | M1)) /
*MCSPI4_SOMI*/\
MUX_VAL(CP(MCBSP1_FSX), (IDIS | PTU | DIS | M1)) /
*MCSPI4_CS0*/

to #define MUX_BEAGLE()

* load the files onto the SD card. First set up card with
http://elinux.org/BeagleBoardBeginners#SD_card_setup I found the files
deployed to setup-scripts/build/tmp-angstrom_2008_1/deploy/glibc/
images/beagleboard . I copied them to the SD card as follows where the
partitions on my sd card were called boot and Angstrom

   1\. cp MLO\-beagleboard /media/boot/MLO
   2\. cp u\-boot\-beagleboard\.bin /media/boot/u\-boot\.bin
   3\. sudo cp Angstrom\-helloworld\-image\-glibc\-ipk\-2011\.03\-

beagleboard.rootfs.tar.bz2 /media/Angstrom/
4. cd /media/Angstrom/
5. tar -jxvf Angstrom-helloworld-image-glibc-ipk-2011.03-
beagleboard.rootfs.tar.bz2

* Once the board booted up I installed the native toolchain on the
beagle board with opkg install task-sdk-native coppied the code from
http://lxr.free-electrons.com/source/Documentation/spi/spidev_test.c
and compiled it with gcc -o spitest spidev_test.c
* I ran it such that it used /dev/spidev4.0, and if I shorted MOSI and
MISO I got their test signal back

There are a few things that could be improved, and I would apreciate
any advice on how to do them. First it would be a lot easier to cross
compile spidev_test.c, instead of building it natively. I've read the

Why is it difficult to build it natively?

tutorials like the one here http://www.gumstix.org/software-development/open-embedded/160-bitbake-tutorial.html
, but when I followed the instructions and tried to install the ipk
files (spitest-dbg_1.0-r0.6_armv7a.ipk spitest-dev_1.0-
r0.6_armv7a.ipk) the dev said it was missing a dependancy and the dbg
that there was an unsatisfied recommendation.

You can script installing all the dependencies once you know what has
changed. Maybe you can elaborate a bit more on what your problem is?

Second It would be a lot nicer to just make a patch for u-boot and add
it to the recipe, but I am unfamilar with how to go about it.

Check some other patches people have written and see how its done? :slight_smile:

Regs.
Joel

It’s not complicated, but it does take awhile to install the tool chain, and it would be nice to have this whole setup+ test ready to go when you finish the cross compilation.

To Jon and anyone else in the future reading this,

I don’t know if people are still struggling with getting SPI to work. I’ve taken some time to try and write up a good walk through on how to do so from start to finish with as much details as possible. I myself was a novice about 2-3 weeks ago on this topic and decided to make a good walk through for people. To most of it is using scripts written by Robert Nelson, but for a novice user this can come in very handy. Best of luck to everyone on their SPI journey!

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

Cheers,

Brian Hensley
www.brianhensley.net