10 Replies Latest reply on Mar 1, 2017 1:58 PM by Intel Corporation

    SPI0 Appears to not operate. SPI0 Documentation is unacceptable.

    floydg

      Hi,

       

      SP0 appears to work fine, yet SPI1 appears to not operate using the identical code and just changing spi device instantiation.

       

      I have not found a reference that states that SPI 1 is a "Slave" SPI device. And MRAA does not treat it as a Slave SPI device with the API, and or the documents.

       

      intel-joule-dev-kit-hardware-guide.pdf

       

      Notice Direction of INPUTS and OUTPUTS for MISO and MOSI, are DIFFERENT,  for SPI0 and SPI, is SPI0!

      Is SPI 0 a slave SPI device?

       

      Who designed the Tuchuck board, Intel? SPI0 documentation does not match the Joule SOM document regrading SPI0?

       

       

      SPO1:

        

       

      J13 Connector:

      Note J13.25 SPI_0_CLK, above it is listed as

       

       

      Intel Joule Module data sheet:

       

       

       

      mraa: Intel Joule

      Tuchuck

      Interface notes

      SPI

      Two SPI buses are available, with one chipselect each. Pins listed are MRAA numbered pins. Other chip selects are available if enabled in BIOS/EEPROM but cannot be enabled as BIOS options. You will need the spidev kernel module loaded, Ostro-XT does this by default.

      Bus 0 (32765) MOSI = 2 MISO = 4 CS = 6 CLK = 10

      Bus 1 (32766) MOSI = 67 MISO = 69 CS0 = 59 CS1 = 61 CLK = 65

      (remove 40 from numbers to get pin header number for pins on low speed header 2)

        • 1. Re: SPI0 Appears to not operate. SPI0 Documentation is unacceptable.
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hi Floyd,

          We understand your frustration, and we would like to confirm that this is not only happening on your hardware.
          Could you please provide the code that you’re using so we can test this behavior on our boards too? Also, if you could provide the steps you used that would be great, we want to replicate it as accurate as possible.
          We’ll be waiting for your reply.

          Regards,
          -Pablo

          • 2. Re: SPI0 Appears to not operate. SPI0 Documentation is unacceptable.
            floydg

            Pablo,

             

            we have multiple systems (about 7 Joule's installed on Tuchuck systems). This is not a hardware issue as far as I can tell.

             

            We understand your frustration. It must be difficult to have to rely on the client to provide a test scenario for your product, since you do not have one for SPI, and do not know how to create a test which run successfully on SPI.

             

            Obviously we would have thought you (and your team at Intel) would have ran the example code on SPI1 and provided feedback, that the test was successful, but this maybe to complicated for your team.

             

            Install the latest and greatest BIOS, Ostro and MRAA onto your Joule development system.

             

            It is disrespectful, that I am asked to perform work for what is truly your responsibility, and you should understand, and make a good faith attempt on solving. Please take ownership. This is your company and your job. I do have other obligations.

             

            SPI for mraa only requires a few "simple" c instructions to operate.

             

            Typically SPI1 passes, and SPI0 fails.

             

            Example code (please modify and make compile). Or use the example code from Intel, and configure for SPI1 and test, then SPI0 and test:

             

            #include "mraa.h"

            #include <unistd.h>

            #include <stdint.h>

            #include <string.h>

             

             

            uint8_t cmd = 0xaa;

            uint8_t payload[] = {1, 2, 3};

            uint8_t read_size = 5;

             

             

             

            int main(int argc, char** argv){

             

            printf("Joule Ostro SPI test v1.0\n");

             

            mraa_init();

             

            mraa_spi_context spi0;

            spi0 = mraa_spi_init(0);

             

            mraa_spi_context spi1;

            spi1 = mraa_spi_init(1);

             

             

              if (spi0 == NULL) {

              printf("Initialization of spi0 failed, check syslog for details, exit...\n");

              exit(1);

              }

            else

              printf("SPI0 initialized successfully\n");

             

            data[0] = 0x3C;     // Test Data

            data[1] = 0xA5;     // Test Data

            data[2] = 0x75;     // Test Data

             

             

            recv = mraa_spi_write_buf(spi0, data, 3);

             

              if (spi1 == NULL) {

              printf("Initialization of spi1 failed, check syslog for details, exit...\n");

              exit(1);

              }

            else

              printf("SPI1 initialized successfully\n");

             

            //print_recv(recv, length, read_size);

             

            recv = mraa_spi_write_buf(spi1, data, 3);

             

            }

             

            mraa_spi_stop(spi);

             

            return 0;

            }

            • 3. Re: SPI0 Appears to not operate. SPI0 Documentation is unacceptable.
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              Hi Floyd, 

              Thank you for providing the requested information. We will run some tests with your code and then will let you know how we will proceed regarding this issue with the SPI interfaces. 

              Regards, 
              -Pablo 
               

              • 4. Re: SPI0 Appears to not operate. SPI0 Documentation is unacceptable.
                floydg

                Thanks.

                 

                Or you can try:

                 

                mraa/examples/c++/Spi-pot.cpp

                 

                mraa/Spi-pot.cpp at master · intel-iot-devkit/mraa · GitHub

                 

                The foundation is pretty straight forward:

                 

                #include "mraa.hpp" ...  

                int main() { ...     

                //! [Interesting]    
                mraa::Spi* spi;    

                spi = new mraa::Spi(0);

                ...            

                recv = spi->write(data, 2);           

                if (spi->transfer(data, rxBuf, 2) == mraa::SUCCESS)
                {                
                printf("Writing -%i", i);                
                printf("RECIVED-%i-%i\n", rxBuf[0], rxBuf[1]);           
                }             usleep(100000);         }    
                }    
                delete spi;    //! [Interesting]    

                return mraa::SUCCESS;
                }
                • 5. Re: SPI0 Appears to not operate. SPI0 Documentation is unacceptable.
                  floydg

                  On a side note my colleague was capable of getting "Ubuntu Desktop" SPI0, and SPI1 working based off of the spi-gpio kernel module:

                  Latest Ubuntu, and BIOS

                   

                  Test pattern transferred, no device on the SPI bus (therefore no MISO)

                   

                  Note: the older "linux pin assignment" references were required, which have been removed from the current documentation as far as I can tell.

                   

                  intel-joule-module-datasheet.pdf

                  September 2016 Revision1.1

                   

                  Sampler -

                  • 6. Re: SPI0 Appears to not operate. SPI0 Documentation is unacceptable.
                    PabloM_Intel

                    Hi Floyd,

                     

                    I've been running some tests and had some strange results, however, SPI1 did work as ecpected, at least according to the documentation from these two websites Intel® Joule™ Expansion Board Breakout Definition for Linux* and mraa/joule.md at master · intel-iot-devkit/mraa · GitHub.

                    .

                    Attached is the code that I used for each (I used the same code you shared on your second post but isolate each SPI interface).

                     

                    To test SPI1 I used the following code and got the following images from the image analyzer:

                    #include "mraa.h"
                    #include <unistd.h>
                    #include <stdint.h>
                    #include <string.h>
                    
                    
                    uint8_t cmd = 0xaa;
                    uint8_t payload[] = {1, 2, 3};
                    uint8_t read_size = 5;
                    
                    int main(int argc, char** argv){
                    
                    printf("Joule Ostro SPI test v1.0\n");
                    
                    mraa_init();
                    
                    mraa_spi_context spi1;
                    spi1 = mraa_spi_init(0);
                    
                      if (spi1 == NULL) {
                      printf("Initialization of spi1 failed, check syslog for details, exit...\n");
                      exit(1);
                      }
                    else
                    printf("SPI1 initialized successfully\n");
                    
                    uint8_t data[3];
                    data[0] = 0x3C;     // Test Data
                    data[1] = 0xA5;     // Test Data
                    data[2] = 0x75;     // Test Data
                    
                    uint8_t recv = mraa_spi_write_buf(spi1, data, 3);
                    return 0;
                    }
                    

                     

                     

                     

                    To test SPI0 I used the following code and got the following images from the image analyzer:

                    #include "mraa.h"
                    #include <unistd.h>
                    #include <stdint.h>
                    #include <string.h>
                    
                    uint8_t cmd = 0xaa;
                    uint8_t payload[] = {1, 2, 3};
                    uint8_t read_size = 5;
                    
                    int main(int argc, char** argv){
                    
                    printf("Joule Ostro SPI test v1.0\n");
                    
                    mraa_init();
                    
                    mraa_spi_context spi0;
                    spi0 = mraa_spi_init(1);
                    
                      if (spi0 == NULL) {
                      printf("Initialization of spi1 failed, check syslog for details, exit...\n");
                      exit(1);
                      }
                    else
                    printf("SPI0 initialized successfully\n");
                    
                    uint8_t data[3];
                    data[0] = 0x3C;     // Test Data
                    data[1] = 0xA5;     // Test Data
                    data[2] = 0x75;     // Test Data
                    
                    uint8_t recv = mraa_spi_write_buf(spi0, data, 3);
                    
                    return 0;
                    }
                    

                     

                     

                    I will investigate what is causing this output from SPI0, and will update once I have some more news.

                     

                    Regards,

                    Pablo

                    • 7. Re: SPI0 Appears to not operate. SPI0 Documentation is unacceptable.
                      floydg

                      Pablo,

                       

                      Thanks for the update.

                       

                      you have listed: testing Spi 1 then testing Spi0 (above)

                      yet the code shows:

                      testing Spi 1

                      spi1 = mraa_spi_init(0);          << This is bus 0 for SPI 0, correct? Variable name is confusing, should be spi0, what pins were tested?

                       

                      testing SPi 0

                      spi0 = mraa_spi_init(1);           << This is bus 1 for SPI 1, correct? Variable name is confusing, should be spi1, what pins were tested?

                       

                       

                      mraa_spi_init(BusID), where bus ID=0 or 1. I think your comments are backwards/incorrect.

                       

                       

                       

                      test Data is 0x3C, 0xA5, 0x75

                       

                      It appears that SPI0 logic analyzer capture is displaying the 0x3C and 0xA5 correctly. Does you logic analyzer have a built in protolcol interpreter for SPI (Mode 0), and can you enable that feature? Which would show us the interpreted hex values translated.

                       

                      Other than the delay between bytes the data looks correct.

                      • 8. Re: SPI0 Appears to not operate. SPI0 Documentation is unacceptable.
                        PabloM_Intel

                        Floyd,

                         

                        That’s what I thought at first to be honest, that mraa_spi_init(0) would initialize SPI0 and that mraa_spi_init(1) would initialize SPI1, but found that it is the other way around. While testing and looking at the MRAA documentation (mraa/joule.md at master · intel-iot-devkit/mraa · GitHub) noticed that breakout J12 is considered BUS 0, and breakout J13 is considered BUS 1. As you know, SPI1 is in J12 and SPI0 in J13, that’s why init(0) initializes SPI1 and init(1) initializes SPI0 (sorry if this sounds redundant).

                        The pins I tested were CLK (Channel 0) and MOSI (Channel 1), and yes 0x75 (or what I think is 0x75) is there, but I couldn’t fit the three values in the image because of the delay. I will check if my Logic analyzer has that feature, will update if I find it. 

                         

                        Regards,

                        -Pablo

                        • 9. Re: SPI0 Appears to not operate. SPI0 Documentation is unacceptable.
                          floydg

                          Pablo,

                           

                          interesting.

                          The Pin Mapping and the bus Mapping in the MRAA document are not consistent (logical to physical mapping). Not sure of the benefits for naming "bus 0" to SPI1CLK, ...

                           

                          and "bus 1" to SPI0CLK, ...

                           

                          It is terse, confusing.

                           

                          The good news is it appears to work.

                           

                          I wonder if you perform the following with OSTRO

                          > ls /dev/spi*

                           

                          or

                          > lsmod | grep spi

                           

                          you may see both spi drivers for Bus0 and Bus1, and there pin assignment mapping (during configuration) to mraa  (Spi0 and Spi1) maybe the reason that they are configured backwards.

                           

                          I would jump into this more, but I am using Ubuntu desktop primarily now.

                          • 10. Re: SPI0 Appears to not operate. SPI0 Documentation is unacceptable.
                            Intel Corporation
                            This message was posted on behalf of Intel Corporation

                            Hi Floyd,

                            Yes, the documentation is indeed very confusing and at some point I also thought that SPI0 was not working at all, so I can foresee some other users having the same issues as you and me. Know that I will pass this information to the right team, if they are not able to do some remapping in the future, at least they can make sure the documentation is clear enough for everyone to be aware about this.
                            If you have any other question in the future about SPI don’t hesitate to contact us back.

                            Regards,
                            -Pablo