Discussion:
[uClinux-dev] Accessing SPI
Eric Fowler
2014-01-28 23:45:04 UTC
Permalink
I have an Emcraft distro with a SPI device at /dev/spi. I wish to access
the device for (for instance) controlling the chip select pin, read, write,
etc.

I have seen a document on controlling a SPI driver on ucLinux from user
space (
http://www.uclinux.org/pub/uClinux/ports/blackfin/docs/pdf-docs/SPI_device_driver.pdf)
, but it references IOCTLs that are not in my source tree.

I did find a file, linux/spi/spidev.h, that has a struct defined that seems
to be used by user mode SPI code, but it is not clear how I am to use it,
in particular, which IOCTLs are available, and how I can get access to the
interface at low levels.

How in general do ucLinux app developers access SPI devices?

Eric
--
cc:NSA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.uclinux.org/pipermail/uclinux-dev/attachments/20140128/e405f09c/attachment.html>
Larry Baker
2014-01-28 23:53:48 UTC
Permalink
Post by Eric Fowler
cc:NSA
More likely bcc:NSA me thinks. :) Thanks for the grins.

Larry Baker
US Geological Survey
650-329-5608
baker at usgs.gov

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.uclinux.org/pipermail/uclinux-dev/attachments/20140128/9268a7e9/attachment.html>
Merrill Harriman
2014-01-29 02:44:35 UTC
Permalink
cc:NSA - LOL ...

What platform?

I have very recently been through a long process of getting the spidev working on an Emcraft STM-SOM with STM32F4. The documentation was lacking but once I got the right hint from emcraft support I was able to get it going. I am using SPI1 and SPI2 as built in kernel modules. I am then using ioctl ops on the /dev/spidev0.0 and /dev/spidev1.0. The supported ioctl accesses are defined in .../A2F/root/usr/include/linux/spi/spidev.h.

Here is a brief overview of the process:

make kmenuconfig => enable spis
make bmenuconfig => enable mdev

In .../linux/arch/arm/mach-stm32/...
iomux.c - configure required port.pins for alternate functions
spi.c - add board info structs for each spidev

In .../linux/drivers/spi/...
spi_stm32.c - configure spi_cr1 for correct format
spidev.c - instrument as necessary with debug printk's to see progress

I am sure there is some stuff I left out here. I have a demo spidev project from emcraft that uses spi2 and spi5 - if you would like that I can forward it to your private email ... I think some of the key ingredients are the configurations they used in initramfs, busybox, kernel config, and rc. These are in the demo project also ...

Good luck ...








Date: Tue, 28 Jan 2014 15:45:04 -0800
From: eric.fowler at gmail.com
To: uclinux-dev at uclinux.org
Subject: [uClinux-dev] Accessing SPI

I have an Emcraft distro with a SPI device at /dev/spi. I wish to access the device for (for instance) controlling the chip select pin, read, write, etc.
I have seen a document on controlling a SPI driver on ucLinux from user space (http://www.uclinux.org/pub/uClinux/ports/blackfin/docs/pdf-docs/SPI_device_driver.pdf) , but it references IOCTLs that are not in my source tree.

I did find a file, linux/spi/spidev.h, that has a struct defined that seems to be used by user mode SPI code, but it is not clear how I am to use it, in particular, which IOCTLs are available, and how I can get access to the interface at low levels.

How in general do ucLinux app developers access SPI devices?
Eric
--
cc:NSA



_______________________________________________
uClinux-dev mailing list
uClinux-dev at uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev at uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.uclinux.org/pipermail/uclinux-dev/attachments/20140128/a9e3d898/attachment.html>
Geert Uytterhoeven
2014-01-29 10:19:09 UTC
Permalink
Post by Eric Fowler
I did find a file, linux/spi/spidev.h, that has a struct defined that seems
to be used by user mode SPI code, but it is not clear how I am to use it, in
particular, which IOCTLs are available, and how I can get access to the
interface at low levels.
Please see the Linux kernel documentation, with examples:

Documentation/spi/spidev
Documentation/spi/spidev_fdx.c
Documentation/spi/spidev_test.c

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Natarajan BLR
2014-01-29 11:05:26 UTC
Permalink
I am an engineer cum linux enthu. I have written a book in Unix,
essentially to understand most of the concepts based on which Unix (Now,
Linux) work.
This is in Tamil.

http://www.sangapalagai.in/tamil-book/Tamilil-Unix/1001

What makes ordinary man different from Knowledgeable and intelligent?

http://www.sangapalagai.in/tamil-book/Knowledge-Go-Get-It!/989
Post by Merrill Harriman
Post by Eric Fowler
I did find a file, linux/spi/spidev.h, that has a struct defined that
seems
Post by Eric Fowler
to be used by user mode SPI code, but it is not clear how I am to use
it, in
Post by Eric Fowler
particular, which IOCTLs are available, and how I can get access to the
interface at low levels.
Documentation/spi/spidev
Documentation/spi/spidev_fdx.c
Documentation/spi/spidev_test.c
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 --
geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
_______________________________________________
uClinux-dev mailing list
uClinux-dev at uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev at uclinux.org
http://mailman.uclinux.org/mailman/options/uclinux-dev
--
N Natarajan
http://science-of-good-living.blogspot.com/
http://economic-theories-and-poverty.blogspot.in/
http://www.sangapalagai.in/author/N-Natarajan/136
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.uclinux.org/pipermail/uclinux-dev/attachments/20140129/d888c473/attachment.html>
LaksCEO
2014-01-29 11:56:14 UTC
Permalink
Kudoos Mr.Nataraj
-lakshmanan
Coimbatore
----- Original Message -----
From: Natarajan BLR
To: uClinux development list
Sent: Wednesday, January 29, 2014 4:35 PM
Subject: Re: [uClinux-dev] Accessing SPI


I am an engineer cum linux enthu. I have written a book in Unix, essentially to understand most of the concepts based on which Unix (Now, Linux) work.
This is in Tamil.


http://www.sangapalagai.in/tamil-book/Tamilil-Unix/1001


What makes ordinary man different from Knowledgeable and intelligent?


http://www.sangapalagai.in/tamil-book/Knowledge-Go-Get-It!/989
Post by Eric Fowler
I did find a file, linux/spi/spidev.h, that has a struct defined that seems
to be used by user mode SPI code, but it is not clear how I am to use it, in
particular, which IOCTLs are available, and how I can get access to the
interface at low levels.
Please see the Linux kernel documentation, with examples:

Documentation/spi/spidev
Documentation/spi/spidev_fdx.c
Documentation/spi/spidev_test.c

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
_______________________________________________
uClinux-dev mailing list
uClinux-dev at uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev at uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev






--

N Natarajan

http://science-of-good-living.blogspot.com/
http://economic-theories-and-poverty.blogspot.in/

http://www.sangapalagai.in/author/N-Natarajan/136





------------------------------------------------------------------------------


_______________________________________________
uClinux-dev mailing list
uClinux-dev at uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev at uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.uclinux.org/pipermail/uclinux-dev/attachments/20140129/8e123d11/attachment.html>
LaksCEO
2014-01-29 11:59:51 UTC
Permalink
Where Can i get the copy?
----- Original Message -----
From: Natarajan BLR
To: uClinux development list
Sent: Wednesday, January 29, 2014 4:35 PM
Subject: Re: [uClinux-dev] Accessing SPI


I am an engineer cum linux enthu. I have written a book in Unix, essentially to understand most of the concepts based on which Unix (Now, Linux) work.
This is in Tamil.


http://www.sangapalagai.in/tamil-book/Tamilil-Unix/1001


What makes ordinary man different from Knowledgeable and intelligent?


http://www.sangapalagai.in/tamil-book/Knowledge-Go-Get-It!/989
Post by Eric Fowler
I did find a file, linux/spi/spidev.h, that has a struct defined that seems
to be used by user mode SPI code, but it is not clear how I am to use it, in
particular, which IOCTLs are available, and how I can get access to the
interface at low levels.
Please see the Linux kernel documentation, with examples:

Documentation/spi/spidev
Documentation/spi/spidev_fdx.c
Documentation/spi/spidev_test.c

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
_______________________________________________
uClinux-dev mailing list
uClinux-dev at uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev at uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev






--

N Natarajan

http://science-of-good-living.blogspot.com/
http://economic-theories-and-poverty.blogspot.in/

http://www.sangapalagai.in/author/N-Natarajan/136





------------------------------------------------------------------------------


_______________________________________________
uClinux-dev mailing list
uClinux-dev at uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev at uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.uclinux.org/pipermail/uclinux-dev/attachments/20140129/1778620b/attachment.html>
Eric Fowler
2014-01-29 23:07:57 UTC
Permalink
Thank you, Geert.

Now I am able to create /dev/spidev1.1 and open it from the test code
in Documents/spi.

Now I am not able to see any activity on the hardware, even though all
software seems fine.

Here is the setup:
- SmartFusion2 board, Emcraft 1.12 distro
- The test app Geert mentioned, built in Emcraft tree and renamed
- No slave device, just the naked demo board
- Oscilloscope

First I verify that the scope sees the reference signal provided by
the scope itself. It does.
When I probe pin 17 (P7->17) on the breadboard, I see it HIGH. This
looks like SPI1_SS/ (it is doc'd as such).
When I probe pin 18 on the breadboard, looking for SPI1_CLK, it is
LOW. When the port is idle, this is expected.

When I fire up the test code, I expect to see SPI1_SS/ move LOW and
the clock signal asserted during the transfer.
------I SEE NOTHING-----


Have I overlooked a step?


On Wed, Jan 29, 2014 at 2:19 AM, Geert Uytterhoeven
Post by Geert Uytterhoeven
Post by Eric Fowler
I did find a file, linux/spi/spidev.h, that has a struct defined that seems
to be used by user mode SPI code, but it is not clear how I am to use it, in
particular, which IOCTLs are available, and how I can get access to the
interface at low levels.
Documentation/spi/spidev
Documentation/spi/spidev_fdx.c
Documentation/spi/spidev_test.c
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
_______________________________________________
uClinux-dev mailing list
uClinux-dev at uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev at uclinux.org
http://mailman.uclinux.org/mailman/options/uclinux-dev
--
cc:NSA
Continue reading on narkive:
Loading...