2010-04-10 12:44:37     Using the adis16350 driver

Document created by Aaronwu Employee on Aug 21, 2013
Version 1Show Document
  • View in full screen mode

2010-04-10 12:44:37     Using the adis16350 driver

Hugh Shane (UNITED STATES)

Message: 88286   

 

This is a continuation of an earlier thread (trouble getting started with SPI on BF537-STAMP) but I think it deserves its own topic.

 

I've built a kernel from the live source that includes the experimental adis16350 driver. The kernel boots without any obvious errors (see attached log). Now I would expect to see something like /dev/adis16350 but this is not the case.

 

What additional steps must I take to use the driver?

 

root:/> find / -name "*spi*" -print

/sys/devices/platform/bfin-spi.0

/sys/devices/platform/bfin-spi.0/spi_master

/sys/devices/platform/bfin-spi.0/spi_master/spi0

/sys/devices/platform/bfin-spi.0/spi0.1

/sys/bus/platform/devices/bfin-spi.0

/sys/bus/platform/drivers/bfin-spi

/sys/bus/platform/drivers/bfin-spi/bfin-spi.0

/sys/bus/spi

/sys/bus/spi/devices/spi0.1

/sys/bus/spi/drivers/adis16350/spi0.1

/sys/class/spi_master

/sys/class/spi_master/spi0

 

root:/> find / -name "*adis*" -print

/sys/bus/spi/drivers/adis16350

 

20100410-boot-message.txt

QuoteReplyEditDelete

 

 

2010-04-11 22:50:28     Re: Using the adis16350 driver

Barry Song (CHINA)

Message: 88301   

 

Pls read documents in linux-2.6.x/drivers/staging/iio/Documentation to know the iio framework. You can read data by sys or a ring. Reference codes:

 

linux-2.6.x/drivers/staging/iio/Documentation/lis3l02dqbuffersimple.c.

 

-barry

QuoteReplyEditDelete

 

 

2010-04-17 21:41:12     Re: Using the adis16350 driver

Hugh Shane (UNITED STATES)

Message: 88547   

 

Let me restate the problem. I am seeing the following line in the boot message:

 

adis16350: at CS1 (irq 0)

 

This leads me to believe that the adis16350 driver is finding the IMU and initializing it properly. However, I don't see /dev/adis16350 (I do see /sys/bus/spi/drivers/adis16350) What else must I do to do to make the device available to my application?

 

Also, to which pin on the BF537-STAMP board must I connect the ADIS16355 data-ready pin in order for interrupts to work properly? Maybe this is why I'm not seeing the device.

QuoteReplyEditDelete

 

 

2010-04-18 02:20:16     Re: Using the adis16350 driver

Mike Frysinger (UNITED STATES)

Message: 88551   

 

and like Barry said, please read the IIO documentation.  the standard IIO interface is not /dev/<device name>.

QuoteReplyEditDelete

 

 

2010-04-18 14:18:44     Re: Using the adis16350 driver

Hugh Shane (UNITED STATES)

Message: 88554   

 

I note the following in iio/Documentation/userspace.txt:

 

Udev will create the following entries under /dev by default:

 

ring_access0 - ring access chrdev

ring_event0 - ring event chrdev

event_line0 - general event chrdev.

 

But I see nothing resembling these in /dev. See attached listing.

 

Furthermore, in the example user program iio/Documentation/lis3l02dqbuffersimple.c, reference is made to the following filenames:

 

static const char *ring_access = "/dev/iio/lis3l02dq_ring_access";

static const char *ring_event = "/dev/iio/lis3l02dq_ring_event";

 

Again, I find nothing remotely similar to these in /dev

 

I've hooked up an oscilloscope to the SPI bus and can see the traffic that one would expect based on the code in adis16350_core.c, so it seems like the driver wants to live. I just can't wrap my head around the userspace interface.

 

I'll ask once more since I suspect this could be part of my problem: to which pin on the BF537-STAMP must I connect the IMU data-ready signal? I've been digging through the driver code and it ain't obvious.

 

Hugh

 

dev-list.txt

QuoteReplyEditDelete

 

 

2010-04-19 02:32:28     Re: Using the adis16350 driver

Barry Song (CHINA)

Message: 88567   

 

You can connect data ready to any gpio interrupt and pls change board file according to your connection.

 

Remember to enable

 

   x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x

  x x                             --- Industrial I/O support                                                                         x x

  x x                             [*]   Enable ring buffer support within IIO                                                        x x

  x x                             <*>     Industrial I/O lock free software ring                                                     x x

to support ring.

 

-barry

QuoteReplyEditDelete

 

 

2010-04-19 23:35:35     Re: Using the adis16350 driver

Hugh Shane (UNITED STATES)

Message: 88606   

 

I had tried this previously. The build fails:

 

drivers/built-in.o: In function `adis16350_data_rdy_ring_predisable':

drivers/staging/iio/imu/adis16350_ring.c:170: undefined reference to `iio_trigger_dettach_poll_func'

drivers/built-in.o: In function `adis16350_data_rdy_ring_postenable':

drivers/staging/iio/imu/adis16350_ring.c:162: undefined reference to `iio_trigger_attach_poll_func'

drivers/built-in.o: In function `adis16350_trigger_bh_to_ring':

drivers/staging/iio/imu/adis16350_ring.c:131: undefined reference to `iio_trigger_notify_done'

drivers/built-in.o: In function `adis16350_remove_trigger':

drivers/staging/iio/imu/adis16350_trigger.c:124: undefined reference to `iio_trigger_unregister'

drivers/staging/iio/imu/adis16350_trigger.c:126: undefined reference to `iio_free_trigger'

drivers/built-in.o: In function `adis16350_probe_trigger':

drivers/staging/iio/imu/adis16350_trigger.c:88: undefined reference to `iio_allocate_trigger'

drivers/staging/iio/imu/adis16350_trigger.c:103: undefined reference to `iio_trigger_register'

drivers/staging/iio/imu/adis16350_trigger.c:115: undefined reference to `iio_free_trigger'

drivers/built-in.o: In function `adis16350_data_rdy_trig_poll':

drivers/staging/iio/imu/adis16350_trigger.c:27: undefined reference to `iio_trigger_poll'

drivers/built-in.o:(.data+0x2f70): undefined reference to `iio_trigger_read_name'

make[1]: *** [.tmp_vmlinux1] Error 1

make[1]: Leaving directory `/home/hugh/Projects/thesis/kernel/blackfin-sources/uclinux-dist/linux-2.6.x'

make: *** [linux] Error 1

 

 

By the way, I did a 'svn update' on the entire uclinux-dist tree over the weekend.

QuoteReplyEditDelete

 

 

2010-04-20 00:05:07     Re: Using the adis16350 driver

Hugh Shane (UNITED STATES)

Message: 88607   

 

Progress! In addition to Barry's previous instruction I also selected the following in the config menu:

 

[*]   Enable triggered sampling support

 

I also added a .irq line in stamp.c:

 

#if defined(CONFIG_ADIS16350) \

    || defined(CONFIG_ADIS16350_MODULE)

    {

        .modalias = "adis16350",

        .max_speed_hz = 1000000,     /* max spi clock (SCK) speed in HZ */

        .bus_num = 0,

        .chip_select = 1, /* CS, change it for your board */

        .platform_data = NULL, /* No spi_driver specific config */

        .mode = SPI_MODE_3,

        .irq =  IRQ_PF6, // ********** new ***********

    },

 

Now the buils succeeds and I see some promising looking entries in the /dev tree:

 

/dev

crw-rw----    1 root     root      252,   2 Jan  5 07:17 ring_access0

crw-rw----    1 root     root      252,   1 Jan  5 07:17 ring_event_line0

 

/dev/input

crw-rw-r--    1 root     root      252,   0 Jan  5 07:17 event_line0

 

More results to follow....

QuoteReplyEditDelete

 

 

2010-04-27 00:43:18     Re: Using the adis16350 driver

Hugh Shane (UNITED STATES)

Message: 88929   

 

CRASH!

 

I've been svn updating so my code is current. The driver appears to be loading properly and seems to be using the correct interrupt line (the one to which I've connected the "ready" signal from the ADIS16355). This is confirmed by activity on the SPI bus which I monitor with an oscilloscope as well as by this boot message:

 

adis16350: at CS1 (irq 56)

 

I modified the example user program found in drivers/staging/iio/Documentation to communicate with the ADIS16355. (See attached listing.) When I run this program I get the diagnostic messages shown below. The program then hangs and after several seconds the processor reboots without any warning.

 

search location /sys/class/iio/device0/name

BaseDirectoryName =  /sys/class/iio/device0/

search location /sys/class/iio/trigger0/name

TriggerDirectoryName =  /sys/class/iio/trigger0/

RingBufferDirectoryName =  /sys/class/iio/device0/ring_buffer0/

Successful write to current_trigger file

Successfully opened the ring buffer length file

Successfully opened the ring buffer control file

Successfully allocated space for userspace data store

Successfully opened /dev/ring_access0

Successfully opened /dev/ring_event_line0

 

Looking at the 'scope display just after the start of the program, I can see the "ready" signal from the IMU turning on and off at exactly the IMU sample rate. However, after an initial burst of activity, on the SPI bus, I don't see any evidence of the CPU reading data from the IMU. I'm guessing that the interrupt service routine is failing but I have no idea how to debug it. It's also possible that I did something horribly wrong in my test application but I have no idea what that might be.

 

I can send more details, scope traces, etc. Just ask.

 

Hugh

 

imu_daq.c

QuoteReplyEditDelete

 

 

2010-04-27 01:25:59     Re: Using the adis16350 driver

Barry Song (CHINA)

Message: 88931   

 

I think you haven't filled right irq number in your board file, give you an example:

 

#if defined(CONFIG_ADIS16300) \

        || defined(CONFIG_ADIS16300_MODULE)

        {  

                .modalias = "adis16300",

                .max_speed_hz = 1000000,     /* max spi clock (SCK) speed in HZ */

                .bus_num = 0,

                .chip_select = 5, /* CS, change it for your board */

                .platform_data = NULL, /* No spi_driver specific config */

                .mode = SPI_MODE_3,

                .irq = IRQ_PF4,

        }, 

#endif

 

 

-barry

QuoteReplyEditDelete

 

 

2010-04-27 08:45:42     Re: Using the adis16350 driver

Hugh Shane (UNITED STATES)

Message: 88962   

 

Barry,

 

In an earlier post I indicated that I was using

 

.irq =  IRQ_PF6

 

Is there some reason that I shouldn't be using PF6 as an interrupt source? On the BF537-STAMP this line connects to connector P9, pin 14, which I've tied to D01 on the IMU. But it wouldn't be too hard for me to switch this to PF4.

 

Hugh

QuoteReplyEditDelete

 

 

2010-04-29 00:38:12     Re: Using the adis16350 driver

Hugh Shane (UNITED STATES)

Message: 89002   

 

I checked out the latest source which has the modification to the board file

 

.irq = IRQ_PF4,

 

I also connected the IMU ready line to PF4. Now the test program runs without crashing but I see no evidence of date being acquired, no activity on the SPI bus.

 

I switched back to

 

.irq = IRQ_PF6,

 

and the kernel crashes as before. Once thing I noticed while looking at the SPI bus on the scope is that the burst read sequence which occurs just once before the kernel crashes is completely wrong. (It should look like Figure 26 in the ADIS16350 data sheet, rev A.) Check out adis16350_spi_read_burst() in adis16350_core.c. It's just wrong.

QuoteReplyEditDelete

 

 

2010-04-29 04:36:44     Re: Using the adis16350 driver

Barry Song (CHINA)

Message: 89032   

 

Hugh,

 

The driver has not tested yet, but will be done soon. If you have any patch, you can send to us.

 

-barry

QuoteReplyEditDelete

 

 

2010-05-15 15:56:18     Re: Using the adis16350 driver

Hugh Shane (UNITED STATES)

Message: 89435   

 

Barry,

 

I haven't had much luck getting this driver to work. So I wrote an application which just uses the spi driver and polls the gpio port for the ready signal. It almost works but isn't quite fast enough to catch all of the ready signals and I'm missing alot of samples. So now I'm back to trying to figure out how to make the adis16350 driver work. I've attached my program, which has a "burst read" function that works correctly.

 

Hugh

 

imu_daq.c

Outcomes