1 2 Previous Next 16 Replies Latest reply on Feb 15, 2017 9:27 PM by WalkingThrough

    Accessing i2c-anything Joule 570x

    WalkingThrough

      Configuration:

      Joule 570x, ubuntu 16.04.1 LTS 64-bit.  16 GB SDHC card.  12V @ 3A power supply and everything comes up running: reliable boot.

       

      I run i2cdetect -y 0  and there are two responding devices: 0x37 and 0x50.  I have another device wired to i2c-0 on J12.11 (SDA) and J12.13 (SCL).  That device works on other computers and comes up on them as 0x67.

       

      i2cdetect doesn't see anything at 0x67.

       

      The level shifter for this port does not have 100K-to-3.3 volt pull-up resistors.  I conenct two 100K resistors from board-supplied 3.3V to the two signal lines and connect a 'scope.

       

      I see 3.3 volts.  But putting i2cdetect into a bash while-loop does not produce any change in signal level.

       

      Using the MRAA libraries doesn't get anywhere.

       

      i2c-tools use smbus-style calls... but try as I might, there's nothing coming out of those two signal pins.

       

      Running i2cdetect -y 1 or 2  produces all zeros (expected) but the cursor jitters while producing the map. Connecting my 0x67 device to i2c-1 or i2c-2 produces no result.

       

      Your time is appreciated.

       

      Mark

        • 1. Re: Accessing i2c-anything Joule 570x
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello Mark,

          Thank you for interest in the Intel® Joule™ Products.

          The fact that your device is not recognized by the i2cdetect command can be caused by certain circumstances:
          •    mraa library needs to be updated
          •    device incompatibility
          •    I2C setup procedure

          Could you please provide more information regarding how are you setting up your I2C, and about the device wired to J12.11 and J12.13? 

          I’ll be waiting for your response.

          Regards,
          Andres

          • 2. Re: Accessing i2c-anything Joule 570x
            WalkingThrough

            Hello Andres -

             

            Apologies for the delay.  I'd posted this and another question to the Communities and only saw one pop up on login.

             

            You wrote:

            >

            > mraa library needs to be updated

            >

             

            I'm game.  I followed the instructions for adding "middleware" libraries and thought that would be sufficient when running an apt-get update and apt-get upgrade cycle.  Instructions would be appreciated.

             

            >

            > [ device incompatibility ]

            >

             

            One device tried is a Holtek HT16K33.  Adafruit makes an 8x8 LED array that's driven by this thing and I've gotten it running against a Raspberry Pi Model 2B.  A SparkFun BOB-12009 level shifter was used to interface (Joule supplying 3.3V to the "LV" pin, +5V to the HV pin).

             

            I did see the warning about cascading level shifters and, agreed, not getting it right can lead to problems.  Still, I think I'm good.  The 12009 level shifter has a 10K pull-up to the "LV" pin connected to 3.3V from the Joule.  The Joule Expansion board schematic indicates the pull-ups aren't installed (shown as "empty").  The 'scope ..should.. be showing ..something on J12.11 and J12.13 .

             

            >

            > [ initialization ]

            >

            #include    <mraa/types.h>

            #include    <mraa/common.h>

            #include    <mraa.h>

             

            unsigned char SETUP[] = {0x21};

            unsigned char ENABLE[] = {0x81};

            unsigned char BRIGHTNESS[] = {0xE0};

             

            void check_error(mraa_result_t result)

            {

                if (result != MRAA_SUCCESS) {

                    mraa_result_print(result);

                    exit(1);

                }

            }

             

            int main()

            {

                /* Initialize MRAA    */

                mraa_init();

             

                mraa_result_t    result;

                  

                fprintf(stdout, "hello mraa\n Version: %s\n Running on %s.\n",

                    mraa_get_version(), board_name);

             

                mraa_i2c_context    m_i2c;

             

                /*

                 Not sure why raw mode... but get NULL back if non_raw.

                */

                m_i2c = mraa_i2c_init_raw(0);    /* Wired to bus i2c-0.    */

             

                if (m_i2c == NULL) {

                    fputs("Unable to initialize i2c interface\n", stderr);

                    return 1;

                } else {

                    fputs("Initialization success.\n", stderr);

                }

              

                check_error(mraa_i2c_address(m_i2c, 0x70));    /* Set address    */

             

                // This turns on the HT16K33's internal oscillator.

                check_error(mraa_i2c_write(m_i2c, SETUP, sizeof(SETUP));     <--- Nothing seen on oscilloscope to i2c-0 SCL.

             

                // Enable the display.

                check_error(mraa_i2c_write(m_i2c, ENABLE, sizeof(ENABLE)); <-- Nothing seen on oscilloscope to i2c-0 SCL.

             

            This was run in a root bash shell.  SDA and SCL had 100K resistors connected to Joule-supplied 3.3 volts.

             

            The only other program I have accessing the bus is i2cdetect  part of i2c-tools.  This was downloaded... and it "sees" something at 0x37 and 0x50.  It never sees the HT16K33 at 0x70.  I asked myself, "How is i2cdetect looking at the bus?" and downloaded sources.

             

            i2cdetect uses smbus.  These are defined in in /usr/include/linux/i2c-dev.h .  I can recompile i2cdetect and it runs... but still doesn't see anything at 0x70.

             

            I don't see a signal on the J12 side of the i2c_0 level shifter; it's floating along at about 3.3 volts.

             

            I've tried i2c-1 and i2c-2.  Both initialize.  But there's no output from them on J13 {31, 33, 35, 37} either.

             

            Is my copy of the mraa libraries out of date?.  mraa_get_version() reports "1.5.1" .

             

            Mark

            • 3. Re: Accessing i2c-anything Joule 570x
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              Hello Mark,

              Your mraa library is up to date (v1.5.1). You seem to have followed this guide https://software.intel.com/en-us/updating-libraries-for-joule, please confirm.

              I’ll be needing more time to analyze if there are compatibility issues and to check your initialization method. I’ll contact you through this post as soon as I find relevant information.

              Thank you for your patience.

              Regards,
              Andres

              • 4. Re: Accessing i2c-anything Joule 570x
                floydg

                Some thoughts:

                 

                We have had preliminary success with I2C and mraa using "Ubuntu core", and verified clock and data output using the command "mraa-i2c" while in Ubunto core "classic" comand line. Note: no I2C device was on the bus! So only the device address was sent, and a NAK occurred.

                 

                test scenario:

                1. current BIOS for Intel Joule
                2. current Ubuntu Core
                3. Intel Tuchuck Board
                4. SDA snd CLK were accessed from Tuchuck 40 pin connector.

                 

                 

                set bus 0 device 75(0x4B) reg A5 value (Not transmitted), data value X (not transmitted). Note: no Slave Device on I2C Bus.

                 

                Misc:

                regarding I2C detect()

                mraa: libmraa Internals

                Careful - on alot of platforms i2cdetect will often crash. To findi your i2c addresses please look at your sensor's datasheet! If using i2cdetect most platforms do not support SMBus quick write so use the '-r' flag.

                • 5. Re: Accessing i2c-anything Joule 570x
                  WalkingThrough

                  Hello Andes (and ?Floyd?) .

                   

                  This is GREAT news: Ubuntu Core shows the i2c signalling!  Right now I've an SDHC loaded with Ubuntu Developer in there; I will see about loading up Core and trying with that.  MMIC is loaded with Ostro and I must admit I haven't tried that.  That will happen before installing Core.

                   

                  I did see the warning about crashing when using i2cdetect.  But there's nothing (yet!) on i2c_1 or i2c_2.  _1 and _2 were my initial starting point... and when nothing was seen there I moved to _0.  Why there?  Because i2cdetect showed two devices responding.  Again, though, that was under Developer.

                   

                  That 'scope-shot is a thousand words!  It looks like the default SCL clock rate is 400 KHz (2.5 usec period).  One of the things I had tried was reducing the clock (there are enum'ed symbols in the MRAA libraries for the three supported rates (3.4 MHz, 400 KHz, and 100 KHz).  All my devices are 100 KHz.

                   

                  I'll check it out ASAP.

                   

                  Mark

                  • 6. Re: Accessing i2c-anything Joule 570x
                    floydg

                    Hi,

                     

                    I connected up (with wire jumps) an I2C peripheral PCA9685 to bus 0 (Sparkfun PWM Block) t the Intel Joule Tuchuck Board (ubuntu Core > sudo Classic).

                    1.8 to 3.3 voltage level shifter is implemented on thePWM Block board. I2C defaults to 400KBits

                     

                    Tuchuck                                        PWM Block Board

                    J12 - Pin 11          I2C0SDA          gp19 I2C 1 SCL

                    J12 - Pin 13          I2C0SCL          gp20 I2C 1 SDA

                    J12 - Pin 39          GND                  U1 Pin 14

                    J13 - Pin 8            3.3v                   VSYS/2.??

                    J13 - Pin 10          1.8v                   1.8V U2 pin 1

                     

                    I2C Slave address of 112 is a reserved startup address for the PCA9685

                    The following is a request for internal mode register 0 (default is 0x11):

                     

                    Command: get 0 112 0

                    Register 00 = 0X11

                     

                     

                     

                     

                     

                     

                    Also read Mode register 1 (default is 0x4):

                    Command: get 0 112 1

                    Register 0X1 = 0X4

                     

                     

                    Note: I recommend you set the address, the default for the PWM Block board is 0x7F (7bit) which is invalid according to spec sheet.

                    reserved for future use’ I2C-bus addresses (0000 011, 1111 1XX)

                     

                    I shorted A5 pad which should change the address from 0x7F to 0x5F, but was unable to get an ack for I2C commands. Still needs investigating

                    • 7. Re: Accessing i2c-anything Joule 570x
                      Intel Corporation
                      This message was posted on behalf of Intel Corporation

                      Hello WalkingThrough,

                      I was wondering if you had the chance to try the suggestion provided by floydg.

                      Regards,
                      Andres
                       

                      • 8. Re: Accessing i2c-anything Joule 570x
                        WalkingThrough

                        Hello Andres -

                         

                        I am having a truly trying time getting logged into Ubuntu Core.  I get the image written, it comes up, wants to be configured, gets configured, and then it wants me to log in. I ..try.. and I'm doing something wrong.

                         

                        A few more things to try.

                         

                        On another front.. the device I'm trying to run with the i2c bus is rated up to 100 KHz.  There's an MRAA command to change the i2c bus clock.

                         

                        In /usr/include/mraa/types.hpp there is a #define for i2c clock rates (I have to type this over my shoulder...):

                        enum {

                             I2C_STD   = 0,   // up to 100 KHz

                             I2C_FAST = 1,   // up to 400 KHz

                             I2C_HIGH =  2   // up to 3.4 MHz

                        } I2cMode;

                         

                        I have to get that Core loaded....

                         

                        Mark

                        • 9. Re: Accessing i2c-anything Joule 570x
                          floydg

                          Mark,

                           

                          regarding Ubuntu Core:

                           

                          did you follow the cookbook at Intel Joule | Developer and perform every step?

                           

                          Is your key configured?

                          User account prerequisiteshttps://developer.ubuntu.com/core/get-started/intel-joule?_ga=1.241880514.1541534324.1475435800#user-account-prerequisites

                          An Ubuntu SSO account is required to create the first user on an Ubuntu Core installation.

                          1. Start by creating an Ubuntu SSO account
                          2. Import an SSH Key into your Ubuntu SSO account on this page. Instructions to generate an SSH Key on your computer can be found here.

                          It sounds like you can ssh in, or you are using the comm port.

                           

                          Note: Win7 cygwin ssh worked, putty ssh did not work on my system (Strange)!

                          • 10. Re: Accessing i2c-anything Joule 570x
                            WalkingThrough

                            Hello -

                             

                            It was a dark and stormy night (I'm in the Boston, MA area and it has been snowing all day.  A good time to get into this "little" problem).

                             

                            Core and I seem to have a running disagreement about something.  I did register for an SSO account.  I can log into it and see the information that Core wants for me to log it.

                             

                            Unfortunately, Core "doesn't wanna".  I mean, seriously?  By the steps and it won't let me log in.  Time for a little ..brute..force.  Pull the SDHC card, stick it into a USB adapter, boot up Ubuntu Developer 16.04.1 LTS 64-bit, and go hunting for passwd and shadow.  Found 'em.  Remove the 'x' in the password field in passwd, completely removed the line in shadow, dismount, plug back into the Joule, turn it on, boot from sdhc...

                             

                            And it automatically logged me in as root.  Hello snappy-land.

                             

                            There are instructions for running Ubuntu Developer while in snappy-land.

                             

                            Result?  No dice.  It shows two addresses on i2c-0.  Think it was 0x37 and 0x50.

                             

                            Well, I've tried Developer and Core, the next thing to try is .. Ostro.

                             

                            Hey!  /dev/ttyS2 is working under Ostro!  I can log into it!  An Intel person said I'd have to enable it in the BIOS and solder wires to the expansion board.  Funny.  Don't have to do that when installing Ostro.  Fact is, Ostro's installer makes noises over that port.

                             

                            The wifi works!  I can SSH using Putty from Windows XPSP3 (PuTTY Release 0.60).

                             

                            I follow the instructions on loading up the "middleware" libraries and install MRAA 1.5.1.  mraa-gpio version reports "Version v1.5.1-24-g2ea6810 on Intel GT Tuchuck".  Forward progress.  Run mraa-i2c detect 0 and am rewarded with:

                            00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

                            10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

                            20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

                            30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

                            40: -- --  -- -- -- -- -- -- -- -- -- -- -- -- -- --

                            50: 50 51 52 53 -- -- -- -- 58 59 5a 5b -- -- -- --

                            60: -- -- -- -- -- -- -- -- -- -- -- 6b -- -- -- --

                            70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

                             

                            This is a Red Letter Day!  The schematic lists what's connected to i2c-0 and everything is there.  The 'scope shows electrical activity on SCL-0.

                             

                            There is no electrical activity on either i2c-1.SCL or i2c-2.SCL.

                             

                            It's possible that the system design (where the Joule is going) can use just one i2c bus.  But that clock needs to get down to 100 KHz.  I see on my 'scope what you see on the logic analyzer: the default clock rate is 400 KHz.  /usr/include/mraa/types.h  has an enum for MRAA_I2C_STD and so I tried this:

                            // ============================

                            #include <stdio.h>

                            #include <mraa/types.h>

                            #include <mraa/common.h>

                            #include <mraa/mraa.h>

                             

                            int main(int argc, char *argv[])

                            {

                                 mraa_result_t          result;

                                 mraa_i2c_context    i2c;

                             

                                 if ((i2c = mraa_i2c_init_raw(0)) == NULL) {

                                      fputs("Cannot initialize interface\n", stderr);

                                      return 0;

                                 }

                                

                                 result = mraa_i2c_frequency(i2c, MRAA_I2C_STD); // Set for 100 KHz clock.

                                 if (result == MRAA_SUCCESS) fputs("IT WORKED\n", stderr);

                                                                                   else mraa_result_print(result);

                                 mraa_i2c_stop(i2c);

                                 return 0;

                            }

                            // ============================

                            Result:

                                 MRAA: Feature not supported by Hardware

                            // ============================

                            Admittedly, changing the clock on SCL0 might not be a good idea: that would change clock to all devices on i2c-0.  But how to enable i2c-1 and i2c-2 ?

                            Went digging for that and found this:

                             

                                      Changing the I2C Frequency

                             

                            A kernel recompile?

                             

                            Floydg, do you see any activity on i2c-1 or i2c-2 with your analyzer?  Even something like:

                             

                            while `true`; do mraa-i2c detect 1; done

                             

                            will generate a clock on i2c-1.SCL .

                             

                            Mark

                            • 11. Re: Accessing i2c-anything Joule 570x
                              Sonartek

                              This this accurate?

                               

                              J12 - Pin 11          I2C0SDA          gp19 I2C 1 SCL

                              J12 - Pin 13          I2C0SCL          gp20 I2C 1 SDA

                               

                              Normally, I've always connected SDA to SDA and SCL to SCL - I've never swapped them.  Are you sure this is correct?

                              • 12. Re: Accessing i2c-anything Joule 570x
                                WalkingThrough

                                Oh my.  I hadn't thought of that.

                                 

                                I wonder if the i2c-1 and i2c-2 buses are somehow configured as GPIO pins and MRAA can't "fix" it.  Maybe this fix is as easy as recompiling an installable driver and using modprobe to stuff it in there.

                                 

                                On the flip side of that... might there be a schematic error for the expansion board, J13 pins 31, 33, 35, and 37?

                                 

                                I was about to download Ostro sources and go hunting...

                                 

                                Mark

                                • 13. Re: Accessing i2c-anything Joule 570x
                                  floydg

                                  Hi,

                                   

                                  I2C with Ostro (12/16 build) for I2C0, I2C1, and I2C2 , appear to be working (with preliminary testing, more analysis required).

                                   

                                  Note:

                                  1. there was not an I2C peripheral device connected to the bus for any of these tests, just verifying that the first byte has the clocks and the data for the device address. Clock pulse 9 displays SDA high for NAK.
                                  2. Intel Joule 570x
                                  3. Tuchuck Board
                                  4. MRAA and OSTRO version:

                                   

                                  Pin assignment used:

                                   

                                  I2C0:

                                  Clock and data are working for I2C bus 0

                                  Pin 11 I2C0SDA

                                  pin 13 I2C0SCL

                                   

                                   

                                  I2C1:

                                  Pin 15 I2C1SDA

                                  Pin 17 I2C1SCL

                                  Set 1 7 8 9

                                   

                                   

                                   

                                  I2C2:

                                  Pin 19 I2C2SDA

                                  Pin 21 I2C2SCL

                                  Set 2 4 6 8

                                   

                                   

                                   

                                  FYI: if you are trying to do a test with two I2C buses connected "together" this maybe a possibility (refine as needed):

                                  1. Setup I2C BusX as Master
                                  2. Setup I2C BusY as the peripheral device (client, non master)
                                  3. connect SDA to SDA
                                  4. connect SCL to SCL
                                  5. initialize the peripheral device "7 Bit address"
                                  6. The Master will drive the bus Clock
                                  7. Use a slow clock rate 100KBits or less (no need for speed at first), small steps
                                  8. Perform a Master write (or read) to the peripheral device with the correct "7-bit address" , and verify with the sniffer/scope, or monitor the ACK/Nak on the Master, or registers in the Peripheral device.

                                   

                                  Note:

                                  I have not performed this test, and or verified a number of items, including peripheral device configuration with the mraa API, and Intel Joule capabilities.

                                  • 14. Re: Accessing i2c-anything Joule 570x
                                    WalkingThrough

                                    Hello Floyd -

                                     

                                    I see a clock on ISH_I2C_0.

                                     

                                    I..was..looking..at..the..wrong..pins??

                                     

                                    I2C_0_SDA_LS is on pin J12.11, I2C_0_SCL_LS on pin J12.13 (page 20 of the Joule Expansion board schematic)  So I went looking for I2C_1_SDA and I2C_1_SCL.

                                     

                                    And there they are, on page 21 connected to pins on J13.

                                     

                                    The MRAA names don't match anything in the schematic.  Back to page 20.  J12 has ISH_I2C_0_SDA_LS as /dev/i2c_1 and ISH_I2C_1_SDA_LS as

                                    /dev/i2c_2 .

                                     

                                    OH!  I see what someone did.  I'm looking at the Compute Module datasheet.  7 master i2c interfaces.. okay.

                                     

                                    i2c_0 holds configuration data.  It shows up using mraa-i2c detect 0 .

                                     

                                    i2c_1 and i2c_2 (in that table) are "General Usage" and routed to the expansion board... but are _not_ what /dev/i2c_1 and /dev/i2c_2 refer to.  No, /dev/i2c_1 and /dev/i2c_2 refer to devices at the bottom of that table, ISH_i2C_0 maps to /dev/i2c_1 and ISH_I2C_1 maps to /dev/i2c_2 .  Those are also "General Usage".

                                     

                                    I have to stare at MRAA pin numbering and numbering on J12 and J13.  If J12 goes 1-40 then J13 goes 41-80 ?

                                     

                                    The clock on /dev/i2c_1 is running at 400 KHz.  Here is a link to the MRAA page    

                                              mraa: /iotdk/jenkins/workspace/mraa-doc/api/mraa/i2c.h File Reference

                                     

                                    There is the call to mraa_i2c_frequency().  MRAA responds with "MRAA  Feature not supported by Hardware".

                                     

                                    Yes, the documentation says, "Most platforms do not support this."

                                     

                                    Is there a ..special.. version of MRAA available that can lower the clock to 100 KHz?

                                     

                                    Mark

                                    1 2 Previous Next