1 2 Previous Next 19 Replies Latest reply on Nov 11, 2014 10:05 AM by Intel_Alvarado

    Trouble performing SPI read.

    Simba

      Hi,

      I have integrated an external ADC as a SPI platform device. It's interfaced with SPI 1, so I have removed "spidev" which was interfering during spi registration of ADC.

      Currently SPI registration is successful, but while I am performing SPI read operation it returns as -1 value.

      I have followed steps provided in this link for driver integration.

      AD7606 IIO Multi-Channel Simultaneous Sampling ADC Linux Driver    [Analog Devices Wiki]

       

      I hooked up ~CS[ IIO pin 10 ] to oscilloscope, it seems that it's low always.

       

      If I run the same with Arduino sketch [with default binary] instead of as linux driver, it works fine so hardware wiring between ADC & Galileo should be fine.

       

      BSP: v1.0.0

      SD Boot:

      File: Intel_qrk_plat_galileo.c

      Changes

      1.

      Commented "spidev" module from structure

      static struct spi_board_info spi_onboard_devs[]

       

      2

      Registered ADC by calling  spi_register_board_info(spi_ad7606_dev, ARRAY_SIZE(spi_ad7606_dev));

      in function intel_qrk_gpio_restrict_probe() towards the end.

       

      Is anything else required for interfacing ADC with SPI 1.

      How should I go about debugging this issue?

       

      Regards

      Simba

        • 1. Re: Trouble performing SPI read.
          Intel_Alvarado

          Hi Simba,

           

          I’d recommend you to check the Linux image if the AD7606 driver is enabled. Use the –c menuconfig option.

           

          Regards

          Sergio

          • 2. Re: Trouble performing SPI read.
            Simba

            Hi Sergio,

             

            Yes I have enabled the AD7606, as shown in the link above.

            I added debug prints in the AD7606 probe, to verify. It gets probed.

            When I call start on AD7606, it calls  spi_read()  but returns error from this function.

             

            I hooked up the GPIO's  ~CS [IIO 10] SCLK [IIO 13] MISO [IIO 12], START [IIO 5], Interrupt [IIO 3] to oscilloscope.

             

            Upon sending START from Galileo to ADC, I get the Interrupt signal properly, but I don't see any activity on SCLK, MISO lines and for some strange reason since bootup ~CS stays low.

            If I remove SD card & boot the flash Image, I am able to use Arduino & get the values properly.

             

            I am guessing I have messed up somewhere in SPI interfacing.

             

            Below are the extract from board file, Intel_qrk_plat_galileo.c  showing the changes I have made.

            Is there any thing else I need to do?

            Please suggest debugging tips?

             

            1. SPI board info structure

             

            static struct spi_board_info spi_onboard_devs[] = {

              {

              .modalias = "m25p80",

              .platform_data = &ilb_flash,

              .bus_num = LPC_SCH_SPI_BUS_ID,

              .chip_select = 0,

              },

              {

              .modalias = "ad7298",

              .max_speed_hz = 5000000,

              .platform_data = &ad7298_platform_data,

              .mode = SPI_MODE_2,

              .bus_num = 0,

              .chip_select = 0,

              .controller_data = &qrk_ffrd_spi_0_cs_0,

              },

            // Commenting to check AD7606 spi registration.

              /*{     

              .modalias = "spidev",

              .chip_select = 0,

              .controller_data = &qrk_ffrd_spi_1_cs_0,

              .max_speed_hz = 50000000,

              .bus_num = 1,

              },*/

            };

             

            // Adding AD7606 as a spi platform device on SPI 1.

            #if defined(CONFIG_AD7606) || \

              defined(CONFIG_AD7606_MODULE)

            static struct spi_board_info spi_ad7606_dev[] = {

              {

              /* the modalias must be the same as spi device driver name */

              .modalias = "ad7606-8",  /* Name of spi_driver for this device */

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

              .bus_num = 1,  /* Framework bus number */

              .chip_select = 0,  /* Framework chip select */ // ? TODO Unique value on each bus.

              .platform_data = &ad7606_pdata,

              .controller_data = &qrk_ffrd_spi_1_cs_0,       //  Followed like how AD7298 is done for SPI-0

              .irq = 63, //                                                          //    IIO 3

              .mode = SPI_MODE_3,                      // TODO has to check this and fix this. works for Arduino

              },

            #endif

             

            2.  AD7606 registration as SPI platform device in

            intel_qrk_gpio_restrict_probe(){

             

            -- snip--

             

            i2c:

            :

            :

            --snip--

            // After I2C

             

            ad7606:

            #if defined(CONFIG_AD7606) || \

              defined(CONFIG_AD7606_MODULE)

             

             

              if(ad7606_int_gpio_done)

              goto ad7606_spi;

             

              printk(KERN_WARNING "AD7606: INT gpio line request in restrict probe.\n");

              ret = intel_qrk_ad7606_int_gpio_request();

              if(ret)

              goto end;

              ad7606_int_gpio_done = 1;

             

            ad7606_spi:

              printk(KERN_WARNING "AD7606: spi registration request in restrict probe.\n");

              ret = intel_qrk_spi_reg_ad7606_dev();

              if (ret){

              printk(KERN_ERR "AD7606: SPI registration failed %d.\n",ret);

              // handle busy gpio free activity.

              // intel_qrk_ad7606_int_gpio_free();

                 goto end;

              }

            #endif

             

            }

             

             

            Regards

            Simba

            • 3. Re: Trouble performing SPI read.
              Intel_Alvarado

              Hi Simba,

              Is your image uclibc or glibc?

              Regards

              Sergio

              • 4. Re: Trouble performing SPI read.
                Simba

                Hi Sergio,

                 

                glibc SD Image based on BSP 1.0.0.

                • 5. Re: Trouble performing SPI read.
                  Intel_Alvarado

                  Hi Simba,


                  Are you using a sketch? If not, how are you compiling your code, on Galileo or cross-compiling from host machine? If you are cross-compiling from your host machine how do you compile it?

                  If you are using a sketch, I would suggest going back to the BSP build, change back to uclibc image and add the driver fore your ADC.


                  Regards

                  Sergio

                  • 6. Re: Trouble performing SPI read.
                    Simba

                    Hi Sergio

                     

                    I am not using sketch.

                    I have cross-compiled the code on a ubuntu 12.04 machine. Included the AD7606 driver in the kernel build as a static, using menu config.

                    bitbake -c menuconfig linux-yocto-clanton

                    Built the kernel using

                    bitbake linux-yocto-clanton

                    Copied the kernel image to the SD card along with the file system etc and done a normal boot.

                     

                    The Driver has exposed some sysfs entries to set and get channel values for testing, I am using that to verify the Driver.

                     

                    Initially to verify the hardware & wiring I had used the default image on the galileo, I used Sketch then, SPI -1 it works fine. Keeping the same hardware connections, I shifted LSB image to including the ad7606 iio stagging driver [already present in the main line source] in the kernel so that I have more real time response of the values, unfortunately SPI 1 doesn't respond with this.

                     

                    - Simba

                    • 7. Re: Trouble performing SPI read.
                      Intel_Alvarado

                      Hi Simba,


                      The LSB image, was it built with glibc or uclibc?


                      Regards

                      Sergio

                      • 8. Re: Trouble performing SPI read.
                        Simba

                        Hi Sergio,

                         

                        glibc.

                         

                        - Simba

                        • 9. Re: Trouble performing SPI read.
                          Intel_Alvarado

                          Hi Simba,


                          Why don’t you try with uclibc? After doing this please post your results back.


                          Regards

                          Sergio

                          • 10. Re: Trouble performing SPI read.
                            Simba

                            Hi Sergio,

                             

                            Sure will try it out.

                            Thanks

                            - Simba

                            • 11. Re: Trouble performing SPI read.
                              Intel_Alvarado

                              Hi Simba,


                              Do you still have questions with this post? If you do please let us know so that we may continue to assist you.


                              Regards

                              Sergio

                              • 12. Re: Trouble performing SPI read.
                                Simba

                                Hi Sergio,

                                I am still having trouble with the Tiny build, I am using BSP 1.0.0.

                                 

                                simba@ERB201:~/Galileo/Clanton_Tiny/meta-clanton_v1.0.0/yocto_build$ source poky/oe-init-build-env yocto_build

                                bash: poky/oe-init-build-env: No such file or directory

                                simba@ERB201:~/Galileo/Clanton_Tiny/meta-clanton_v1.0.0/yocto_build$ bitbake image-full

                                Loading cache: 100% |#####################################################################################################################################################| ETA:  00:00:00

                                Loaded 1615 entries from dependency cache.

                                 

                                Build Configuration:

                                BB_VERSION        = "1.18.0"

                                BUILD_SYS         = "x86_64-linux"

                                NATIVELSBSTRING   = "Ubuntu-12.04"

                                TARGET_SYS        = "i586-poky-linux-uclibc"

                                MACHINE           = "clanton"

                                DISTRO            = "clanton-tiny"

                                DISTRO_VERSION    = "1.4.2"

                                TUNE_FEATURES     = "m32 i586"

                                TARGET_FPU        = ""

                                meta             

                                meta-yocto       

                                meta-yocto-bsp    = "clanton:d734ab491a30078d43dee5440c03acce2d251425"

                                meta-intel        = "clanton:048def7bae8e3e1a11c91f5071f99bdcf8e6dd16"

                                meta-oe           = "clanton:13ae5105ee30410136beeae66ec41ee4a8a2e2b0"

                                meta-clanton-distro

                                meta-clanton-bsp  = "<unknown>:<unknown>"

                                 

                                NOTE: Resolving any missing task queue dependencies

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm850-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm850-native

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm437-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm437-native

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm737-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm737-native

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm775-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm775-native

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm851-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm851-native

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm852-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm852-native

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm855-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm855-native

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm857-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm857-native

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm860-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm860-native

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm861-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm861-native

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm862-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm862-native

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm863-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm863-native

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm865-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm865-native

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm866-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm866-native

                                NOTE: multiple providers are available for runtime glibc-gconv-ibm869-native (eglibc-locale, nativesdk-eglibc-locale)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match glibc-gconv-ibm869-native

                                NOTE: multiple providers are available for jpeg (jpeg, libjpeg-turbo)

                                NOTE: consider defining a PREFERRED_PROVIDER entry to match jpeg

                                NOTE: Preparing runqueue

                                NOTE: Executing SetScene Tasks

                                NOTE: Executing RunQueue Tasks

                                WARNING: Failed to fetch URL http://downloads.sourceforge.net/opencvlibrary/opencv-unix/2.4.3/OpenCV-2.4.3.tar.bz2, attempting MIRRORS if available

                                ERROR: Fetcher failure: Fetch command failed with exit code 8, output:

                                http://downloads.sourceforge.net/opencvlibrary/opencv-unix/2.4.3/OpenCV-2.4.3.tar.bz2:

                                2014-10-28 13:30:18 ERROR 404: Not Found.

                                 

                                ERROR: Function failed: Fetcher failure for URL: 'http://downloads.sourceforge.net/opencvlibrary/opencv-unix/2.4.3/OpenCV-2.4.3.tar.bz2'. Unable to fetch URL from any source.

                                ERROR: Logfile of failure stored in: /home/simba/Galileo/Clanton_Tiny/meta-clanton_v1.0.0/yocto_build/tmp/work/i586-poky-linux-uclibc/opencv/2.4.3-r2/temp/log.do_fetch.8106

                                ERROR: Task 446 (/home/simba/Galileo/Clanton_Tiny/meta-clanton_v1.0.0/meta-oe/meta-oe/recipes-support/opencv/opencv_2.4.3.bb, do_fetch) failed with exit code '1'

                                NOTE: Tasks Summary: Attempted 978 tasks of which 965 didn't need to be rerun and 1 failed.

                                Waiting for 0 running tasks to finish:

                                 

                                Summary: 1 task failed:

                                  /home/simba/Galileo/Clanton_Tiny/meta-clanton_v1.0.0/meta-oe/meta-oe/recipes-support/opencv/opencv_2.4.3.bb, do_fetch

                                Summary: There was 1 WARNING message shown.

                                Summary: There were 2 ERROR messages shown, returning a non-zero exit code.

                                simba@ERB201:~/Galileo/Clanton_Tiny/meta-clanton_v1.0.0/yocto_build$

                                 

                                - Regards

                                Simba

                                • 13. Re: Trouble performing SPI read.
                                  Intel_Alvarado

                                  Hi Simba,


                                  As you can see from the link you posted http://downloads.sourceforge.net/opencvlibrary/opencv-unix/2.4.3/OpenCV-2.4.3.tar.bz2 Open CV 2.4.3 is not in the fetch directory update link in .bb, why don’t you try upgrading your version to the latest one found on that website, 2.4.10. You can also try building the BSP with a newer source file, you can find it here https://communities.intel.com/docs/DOC-22226.


                                  Regards

                                  Sergio

                                  • 14. Re: Trouble performing SPI read.
                                    Simba

                                    Hi Sergio,

                                     

                                    I have started build using BSP 1.0.1 +patches of 1.0.4, and I have disabled the I2C fast mode in the kernel CY8C9540A I/O expander, by setting int_i2c_std_mode = 1;

                                    Will test SPI connections once this build is ready.

                                     

                                    A quick question, how does uclibc or eglibc matter to SPI read operations?

                                    Thanks,

                                    - Simba

                                    1 2 Previous Next