1 2 Previous Next 22 Replies Latest reply on Nov 26, 2014 3:03 PM by KurtE

    I2C with Edison Breakout board


      As I have mentioned on a few threads, I have been playing around with having Arduino IDE support for the Edison using the Breakout board.


      One of the things I thought I should test was I2C and since I had a simple I2C compass (CMPS03), that I tried out on the Edison Arduino board, I thought I would test out the same code on the Breakout board.  So I made sure I had the pin table configured to switch logical pins 6 and 8 which are connected to Edison pins(GP27 and GP28 SCL/SDA on buss 6).  I downloaded the program, watched the output on the logic analyzer and there was none and then I started to get lots of broadcast messages on all PuTTY windows (I had 2) connected to this board.  Looking at the output from dmesg, I see lots of messages like:

      [   66.748337] ------------[ cut here ]------------

      [   66.748385] WARNING: at /home/kurt/edison-src/build/tmp/work/edison-poky-linux/linux-yocto/3.10.17+gitAUTOINC+6ad20f049a_c03195ed6e-r0/linux/drivers/i2c/busses/i2c-designware-core.c:1236 i2c_dw_xfer+0x1d2/0x5b0()

      [   66.748403] Device: i2c-designware-pci

      [   66.748403] controller timed out

      [   66.748419] Modules linked in: usb_f_acm u_serial g_multi libcomposite bcm_bt_lpm bcm4334x(O)

      [   66.748484] CPU: 1 PID: 282 Comm: i2c_HMC5883L Tainted: G        W  O 3.10.17-poky-edison+ #2

      [   66.748500] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

      [   66.748514]  f5405ea0 f5405ea0 f5405e68 c18617e0 f5405e90 c123e79e c1a978d4 f5405ebc

      [   66.748573]  000004d4 c16132f2 c16132f2 f67d2c00 f5405f24 f67d2c24 f5405ea8 c123e7f3

      [   66.748628]  00000009 f5405ea0 c1a978d4 f5405ebc f5405edc c16132f2 c1a978f8 000004d4

      [   66.748684] Call Trace:

      [   66.748720]  [<c18617e0>] dump_stack+0x16/0x18

      [   66.748751]  [<c123e79e>] warn_slowpath_common+0x5e/0x80

      [   66.748779]  [<c16132f2>] ? i2c_dw_xfer+0x1d2/0x5b0

      [   66.748803]  [<c16132f2>] ? i2c_dw_xfer+0x1d2/0x5b0

      [   66.748831]  [<c123e7f3>] warn_slowpath_fmt+0x33/0x40

      [   66.748858]  [<c16132f2>] i2c_dw_xfer+0x1d2/0x5b0

      [   66.748890]  [<c160d9e5>] __i2c_transfer+0x55/0x70

      [   66.748919]  [<c160e7cd>] i2c_transfer+0x4d/0xc0

      [   66.748946]  [<c1316183>] ? __kmalloc+0x113/0x1f0

      [   66.748974]  [<c160e8cd>] i2c_master_recv+0x3d/0x50

      [   66.749001]  [<c1610ee7>] i2cdev_read+0x57/0xc0

      [   66.749029]  [<c145e5c7>] ? file_has_perm+0x87/0x90

      [   66.749057]  [<c1610e90>] ? i2cdev_notifier_call+0x40/0x40

      [   66.749083]  [<c131ad10>] vfs_read+0x80/0x150

      [   66.749111]  [<c145e98c>] ? selinux_file_ioctl+0x4c/0xf0

      [   66.749138]  [<c131b439>] SyS_read+0x49/0x90

      [   66.749170]  [<c18671a8>] syscall_call+0x7/0xb

      [   66.749192] ---[ end trace dbdeae862c056a0d ]---

      [   66.749214] i2c-designware-pci 0000:00:09.1: ===== REGISTER DUMP (i2c) =====

      [   66.749314] i2c-designware-pci 0000:00:09.1: DW_IC_CON:               0x65

      [   66.749389] i2c-designware-pci 0000:00:09.1: DW_IC_TAR:               0x1e

      [   66.749462] i2c-designware-pci 0000:00:09.1: DW_IC_SS_SCL_HCNT:       0x2f8

      [   66.749534] i2c-designware-pci 0000:00:09.1: DW_IC_SS_SCL_LCNT:       0x37b

      [   66.749606] i2c-designware-pci 0000:00:09.1: DW_IC_FS_SCL_HCNT:       0x87

      [   66.749678] i2c-designware-pci 0000:00:09.1: DW_IC_FS_SCL_LCNT:       0x10a

      [   66.749751] i2c-designware-pci 0000:00:09.1: DW_IC_INTR_STAT:         0x0

      [   66.749822] i2c-designware-pci 0000:00:09.1: DW_IC_INTR_MASK:         0x246

      [   66.749894] i2c-designware-pci 0000:00:09.1: DW_IC_RAW_INTR_STAT:     0x10

      [   66.749966] i2c-designware-pci 0000:00:09.1: DW_IC_RX_TL:             0x20

      [   66.750037] i2c-designware-pci 0000:00:09.1: DW_IC_TX_TL:             0x20

      [   66.750109] i2c-designware-pci 0000:00:09.1: DW_IC_ENABLE:            0x1

      [   66.750179] i2c-designware-pci 0000:00:09.1: DW_IC_STATUS:            0x2

      [   66.750250] i2c-designware-pci 0000:00:09.1: DW_IC_TXFLR:             0x6

      [   66.750321] i2c-designware-pci 0000:00:09.1: DW_IC_RXFLR:             0x0

      [   66.750392] i2c-designware-pci 0000:00:09.1: DW_IC_TX_ABRT_SOURCE:    0x0

      [   66.750463] i2c-designware-pci 0000:00:09.1: DW_IC_DATA_CMD:          0x0

      [   66.750532] i2c-designware-pci 0000:00:09.1: ===============================

      [   66.750599] sending NMI to all CPUs:

      [   66.750624] NMI backtrace for cpu 1

      [   66.750635] CPU: 1 PID: 282 Comm: i2c_HMC5883L Tainted: G        W  O 3.10.17-poky-edison+ #2

      [   66.750640] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

      [   66.750648] task: f56f1640 ti: f5404000 task.ti: f5404000

      [   66.750656] EIP: 0060:[<c12213bb>] EFLAGS: 00000206 CPU: 1

      [   66.750669] EIP is at default_send_IPI_mask_logical+0x8b/0xd0

      [   66.750677] EAX: 00000000 EBX: 03000000 ECX: c1b16660 EDX: fffff000

      [   66.750683] ESI: 00000206 EDI: 00000002 EBP: f5405e8c ESP: f5405e7c

      [   66.750690]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068

      [   66.750697] CR0: 8005003b CR2: b6b54028 CR3: 35061000 CR4: 001007f0

      [   66.750703] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000

      [   66.750707] DR6: ffff0ff0 DR7: 00000400

      [   66.750710] Stack:

      [   66.750733]  00000800 00002710 f5405f24 f67d2c24 f5405e98 c12214d0 00002710 f5405ea8

      [   66.750754]  c122163c c1a132d5 f67d2c00 f5405edc c161355a f64e3864 c1a3549c 00000000

      [   66.750775]  c1a6f751 40004e7d f67d2c98 00000001 0004b77c f67d2c98 00000000 c1b5ce90

      [   66.750778] Call Trace:

      [   66.750796]  [<c12214d0>] default_send_IPI_all+0x60/0x70

      [   66.750810]  [<c122163c>] arch_trigger_all_cpu_backtrace+0x4c/0x80

      [   66.750823]  [<c161355a>] i2c_dw_xfer+0x43a/0x5b0

      [   66.750840]  [<c160d9e5>] __i2c_transfer+0x55/0x70

      [   66.750855]  [<c160e7cd>] i2c_transfer+0x4d/0xc0

      [   66.750867]  [<c1316183>] ? __kmalloc+0x113/0x1f0

      [   66.750882]  [<c160e8cd>] i2c_master_recv+0x3d/0x50

      [   66.750895]  [<c1610ee7>] i2cdev_read+0x57/0xc0

      [   66.750908]  [<c145e5c7>] ? file_has_perm+0x87/0x90

      [   66.750922]  [<c1610e90>] ? i2cdev_notifier_call+0x40/0x40

      [   66.750935]  [<c131ad10>] vfs_read+0x80/0x150

      [   66.750949]  [<c145e98c>] ? selinux_file_ioctl+0x4c/0xf0

      [   66.750962]  [<c131b439>] SyS_read+0x49/0x90

      [   66.750978]  [<c18671a8>] syscall_call+0x7/0xb

      [   66.751101] Code: b3 ff ff 89 f8 09 d0 80 ce 04 83 ff 02 0f 44 c2 8b 15 54 6b b1 c1 89 82 00 b3 ff ff f7 c6 00 02 00 00 74 14 e8 67 f7 0a 00 56 9d <83> c4 04 5b 5e 5f 5d c3 90 8d 74 26 00 56 9d e8 51 f3 0a 00 83

      [   66.751110] NMI backtrace for cpu 0

      [   66.751125] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W  O 3.10.17-poky-edison+ #2

      [   66.751130] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 466 2014.06.23:19.20.05

      [   66.751139] task: c1b0e120 ti: c1b08000 task.ti: c1b08000

      [   66.751148] EIP: 0060:[<c14f8eae>] EFLAGS: 00200046 CPU: 0

      [   66.751160] EIP is at intel_idle+0x8e/0xe0

      [   66.751167] EAX: 00000060 EBX: 00000080 ECX: 00000001 EDX: 00000000

      [   66.751174] ESI: 00000060 EDI: c1b4be54 EBP: c1b09f5c ESP: c1b09f44

      [   66.751180]  DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068

      [   66.751188] CR0: 8005003b CR2: b76d0000 CR3: 01c3e000 CR4: 001007f0

      [   66.751193] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000

      [   66.751198] DR6: ffff0ff0 DR7: 00000400

      [   66.751200] Stack:

      [   66.751224]  00000007 00000003 00000000 c1b4bd60 f73f3200 c1b4be54 c1b09f80 c1640041

      [   66.751245]  00000003 00001391 8ee945e2 0000000f c1b08000 c1b4bd60 000000e4 c1b09fa0

      [   66.751265]  c1640182 c1b4bd60 00000000 f73f3200 c1b08000 00099800 c1b0b800 c1b09fa8

      [   66.751269] Call Trace:

      [   66.751290]  [<c1640041>] cpuidle_enter_state+0x31/0xd0

      [   66.751306]  [<c1640182>] cpuidle_idle_call+0xa2/0x220

      [   66.751322]  [<c120821d>] arch_cpu_idle+0xd/0x30

      [   66.751335]  [<c1284405>] cpu_startup_entry+0x65/0x200

      [   66.751351]  [<c184e2c1>] rest_init+0x71/0x80

      [   66.751366]  [<c1b98a0b>] start_kernel+0x311/0x317

      [   66.751379]  [<c1b98531>] ? repair_env_string+0x51/0x51

      [   66.751393]  [<c1b98361>] i386_start_kernel+0x137/0x13a

      [   66.751512] Code: 8b 42 08 a8 08 75 24 31 c9 8d 42 08 89 ca 0f 01 c8 0f ae f0 89 f6 89 e0 25 00 e0 ff ff 8b 40 08 a8 08 75 07 b1 01 89 f0 0f 01 c9 <85> 1d 58 bd b4 c1 75 0d 8d 55 f0 b8 05 00 00 00 e8 8d 34 d9 ff

      [   66.752109] i2c-6: recovery ignore


      I decided to checkout what MRAA did on this board and it looked similar, so I ran the test program i2c_HMC5883L again no outputs on the IO pins.


      Then I also noticed that the IO pins were low (i.e. no Pull-ups ).  So I tried:

      echo pullup > /sys/kernel/debug/gpio_debug/gpio27/current_pullmode

      echo pullup > /sys/kernel/debug/gpio_debug/gpio28/current_pullmode


      I reran the MRAA test program and I see stuff on the Logic Analyzer and no more error broadcasts...


      I then reran the Arduino test program and it also no longer appears to be causing system broadcast errors, and also it does show up stuff on the Logic Analyzer.

      So far the CMPS03 is not responding, but that could be because I am only giving it 3.3v instead of 5v.  Or maybe I hooked up the Adafruit 4 Bidirectional level shifter (the one that they say is compatible with I2C) wrong.


      So my question to myself and others is, Should the Arduino IDE and likewise MRAA automagically pull up these internal resistors?  Or should there be some other command to do so?  Or should the documentation be that on these boards you MUST use an external PU resistor?



        • 1. Re: I2C with Edison Breakout board

          I do not know of any chip that its internal resistor is strong enough to act as a proper pull up for I2C. That would be one of the first things i would look into.

          • 2. Re: I2C with Edison Breakout board

            Thanks Mike,


            Yes I agree that in most cases, you need to install external Pull Up resistors.  That is for example what I recommended to another board member a few days ago when their 9DOF IMU was not working properly on the Edison.


            But was wondering on the Edison, about the statements in section 2.2 of the Edison Breakout Board Hardware Guide, where it stated:


                 "Inputs have programmable pullups or pulldowns. Pullup value can be 2, 20, or 50 kohm. I2C pins also have an additional 910 ohm value."


            Also in the description of the pins, it showed, that the I2C pins were open collector: Example:

                 J17 - pin 7     GP27    I2C6_SCL     GPIO,IC26 SCL output open collector.

            So I figured that the value would be high as it was on the Arduino breakout board...


            Note: I need to check my wiring as I know some of soldering of the header pins was not great as I am not used to trying to solder these types of pins into such a thick board, where the pins do not extend out the other side.  So maybe some bad and/or cold solder joints.


            Thanks again

            • 3. Re: I2C with Edison Breakout board

              Some other related questions, whose answers may be obvious...


              1) I assume with the Breakout board that you need to have a level shifter connected up to the I2C pins.  But Figure 1 of the Arduino breakout board shows the I2C pins going directly to the MUX whereas it shows the GPIO pins going to a level shifter and then to Mux.


              2) Not all level shifters are created equal.  When I was playing with SPI and the Adafruit 2.8" TFT display, I was using the Adafruit 8 pin bidirectional converter based on the TXB0108 chip, but it mentions that not good for I2C as the stronger PU resistors can screw up the bidirectional... So using the 4 channel converter that they list as I2C safe.


              3) When using external PU resistors and level converter, which side of the level converter is it best to hook up the PU resistors?   Actually it looks like this level converter may have a built in 10K PUs, so need to check voltages and connections...  But if it did not, which side?

              • 4. Re: I2C with Edison Breakout board

                Hi KurtE,


                I don't know if you already checked this site, but there is an example of how to set the I2C in Edison. I'd suggest you to check it, it could be helpful for you: EmutexLabs




                • 5. Re: I2C with Edison Breakout board

                  Thanks, I have that page bookmarked!  However it is pretty specific to the Arduino breakout board and not as much for the simple breakout board.


                  Side note on Level converter that I have for the I2C appears to have 10K on both sides of the mos-fet transistors.

                  • 6. Re: I2C with Edison Breakout board

                    The issue you are seeing likely relates to the fact edison only delivers 3mA on all IO pins. Likely your i2c sensor doesn't quite follow the spec and so is causing issues. We've had more success at 3.3V than at 5V with such sensors, I'd recommend you switch the J9 jumper to position 2-3 which will switch your IO to 3.3V.

                    1 of 1 people found this helpful
                    • 7. Re: I2C with Edison Breakout board

                      arfoll, the Edison mini breakout board doesn't have a jumper J9.

                      It exposes edison's native 1.8V I/Os.  Document 331190-004 The specified item was not found.

                      Also it states  Pullup value can be 2, 20, or 50 kohm. I2C pins also have an additional 910 ohm value.

                      • 8. Re: I2C with Edison Breakout board

                        Well on the miniboard the issue is different, I believe i2c signalling level is still 3.3V on the miniboard unlike the arduino board where it can be 5V or 3.3V.


                        The pullup values can be changed but honestly it likely won't help you much. Feel free to play. What's your issue?

                        • 9. Re: I2C with Edison Breakout board

                          No issue, I noticed KurtE referred to JP17 (as such the mini breakout board) which was stated as 1.8v in the docs.

                          Adding the 910 extra phms on the I2C pins KurtE hadn't mentioned, might help with his side -

                          I over course am following his success and failure as a learning experience for my own development


                          Can you look into whether I2C is 3.3V on the mini breakout - that might make a big difference?

                          • 10. Re: I2C with Edison Breakout board

                            Thanks for the inputs.  As deium mentioned for this test I am using the mini breakout (mini board as far MRAA is concerned.


                            Yesterday I had some more success with it.  I used my better soldering station (one with a fine tip) and touched up the soldering of the breakout pins.  So I think the pins are all making better contact now.


                            So far I have not enabled the built in PUs as the voltage level converter (4-channel I2C-safe Bi-directional Logic Level Converter [BSS138] ID: 757 - $3.95 : Adafruit Industries, Unique & fun DIY…) I am using has I believe 10K PUs on both sides of the level converter.  Although I only count 7 resistors...


                            Yesterday some of the time, I could get the simple sample program to talk to the device, which showed some valid output, both with the Serial.prints and output on LA.


                            However: once I would get the cmps03 to talk, the whole processor would semi stop working.  That is my Putty window would not echo characters for many seconds, and the like.  The Top command did not show anything using much processor. I kill the process and still the system does not respond for many seconds... Again Top command shows very little usage. I upload a new program and the commands to upload (I am using my wifi hacks) take a long long time, but finally does run.  This sketch renames the sketch to .old, copies the log files that the Arduino sketches create to my home directory (as they are in ram) and then reboots...  After the reboot, system is running fine.  So I am trying to see what is causing the system to not respond.


                            My Arduino definitions for the two pins is pretty simple:

                            mux_sel_t MuxDesc6[] = {{ 27, PIN_MODE_0, FN_GPIO } ,  // GPIO mode

                                                    { 27, PIN_MODE_1, FN_I2C }};  // I2C mode

                            mux_sel_t MuxDesc7[] = {{ 20, PIN_MODE_0, FN_GPIO } }; // GPIO mode

                            mux_sel_t MuxDesc8[] = {{ 28, PIN_MODE_0, FN_GPIO } , // GPIO mode

                                                    { 28, PIN_MODE_1, FN_I2C }};  // I2C mode


                            So the I2C code should simply change the Edison pins 27 and 28 to mode1.


                            My wiring is: From the edison, I take the two power outputs 1.8 and 3.3v and gnd and run to breadboard. I jumper from these to the two sides of level converter. I run logical pin 6 and 8 (J17-7 and J17-(, to the breadboard (low side of level converter) and jumper from CMPS03 SCL/SDA to high side of level converter.

                            However one issue is: I don't have +5v for the device... Right now I am using V-SYS (J20-1), which at least appears to work some...


                            So first obvious question is, is using 1.8v side to feed J17-7 and J17-9 (SCL/SDA) wrong?  Are these 3.3v pins.  Have not seen anything in documentation,


                            Test program:

                            #include <Wire.h>

                            int LoopCount = 0;


                            #define ADDRESS 0x60 //defines address of compass


                            void setup(){


                              Wire.begin(); //conects I2C



                              Wire.beginTransmission(ADDRESS);      //starts communication with cmps03

                              Wire.write(0);                         //Sends the register we wish to read



                              Wire.requestFrom(ADDRESS, 1);        //requests high byte

                              WaitForData(1, 250);

                              uint8_t bVersion = Wire.read();           //reads the byte as an integer

                              Serial.print("Version: ");

                              Serial.println(bVersion, DEC);




                            void loop(){

                              if (LoopCount < 50) {


                                byte highByte;

                                byte lowByte;


                                Wire.beginTransmission(ADDRESS);      //starts communication with cmps03

                                Wire.write(2);                         //Sends the register we wish to read


                                Wire.requestFrom(ADDRESS, 2);        //requests high byte

                                if (!WaitForData(2, 250)) return;

                                highByte = Wire.read();           //reads the byte as an integer

                                lowByte = Wire.read();

                                int bearing = ((highByte<<8)+lowByte)/10;









                            boolean WaitForData(uint8_t cBytes, uint32_t ulWait) {

                              uint32_t ulTimeStart = millis();

                              while (Wire.available() < cBytes) {

                                if ((millis()-ulTimeStart) > ulWait) {

                                  Serial.println(" *TO* ");

                                  return false;



                              return true;


                            I thought I would also try a simple test using mraa directly on the board.  So far it has not talked to the device (I just get NAK on LA).

                            #define ADDRESS 0x60 //defines address of compass



                            main(int argc, char **argv)




                            //! [Interesting]

                                mraa_i2c_context i2c;

                                i2c = mraa_i2c_init(0);


                                mraa_i2c_address(i2c, ADDRESS);

                                uint8_t bVer = mraa_i2c_read_byte_data(i2c, 0);   // read one byte

                                printf("CMPS03 Version: %d\n\r", bVer);



                                for(;;) {

                                    mraa_i2c_address(i2c, ADDRESS);

                                    direction = mraa_i2c_read_word_data(i2c,  2);

                                    printf("Heading : %d\n", direction) ;




                            Again I am mainly doing this for completeness, that is if someone wishes to use the Arduino IDE with this board, it would be nice if most of the features like: GPIO, SPI, I2C, UART worked ok with my hacks...


                            Note: In my test program I see one issue, that the wait for input function, is missing a delay(1), that it had before, which kept the sketch for eating CPU for long periods...

                            • 11. Re: I2C with Edison Breakout board

                              KurtE just sounding off here, I personally don't feel comfortable attempting 3.3V until confirmed.

                              I haven't seen anything other than 1.8V until a moment ago.  As you saw I asked arfoll if he could confirm.

                              • 12. Re: I2C with Edison Breakout board

                                I totally agree.  I tried to ask the same question in posting 3, where it did not look like the I2C pins went through voltage level translator on the Arduino board but went direct to MUX.   I also don't feel comfortable with not going through translation, as if I look at an I2c conversation with the new Saleae Logic 8 which can show analog values as well, you see:


                                Edison I2C Voltage.jpg

                                And the top voltages shown are about 1.825v.


                                Note: this is using my MRAA version of the program and I2c pins only connected to LA pins... No device not conversion...

                                • 13. Re: I2C with Edison Breakout board

                                  Thanks KurtE

                                  • 14. Re: I2C with Edison Breakout board

                                    You are welcome deium


                                    From the email response, I think you were asking where I purchased the LA... Looks like message was edited, but just in case anyone is looking for it, I purchased mine directly from the company ( saleae.com) This is the third one of theirs I have.  I first purchased the original 8, than later picked up the 16, which was faster.  when they announced the pre-order for these, I ordered one, which was something like 4-6 months before they shipped.  I do like the new one as it has the ability to show analog information...   But now back to topic.


                                    I think there may have been a few issues.  One, running this over USB only power, plus I am using wifi... Today the barrel power connector arrived from digikey, which I soldered on.  I was surprised that it uses a different size plug than you use for the Arduino board.  Luckily have converter plus used for my lipo battery charger.  When I plugged in to 12v wall wart, I found V_VSYS did not have any good voltage, so a Jerry rigged, using an Arbotix M board, and taking plus +5v and ground from it to breadboard, for the High side and the power for the CMPS03, which is now a lot happier.  The Arduino program ran OK, and no longer appears to kill the board. 


                                    I also ran my MRAA version, which gives results now... I need to look at their code to see about read word at as it is not giving the values I expect.  Example:

                                    Edison I2C Voltage.jpg

                                    This time to verify things were working I hook up LA probes to both sides of the level converter, which you can see appear to be valid.  Also you can see the LV side is in the 1.8v range and the HV side is on the 5v range.


                                    But: the code running:

                                       mraa_i2c_address(i2c, ADDRESS);
                                        direction = mraa_i2c_read_word_data(i2c,  2);
                                        printf("Heading : %d\n", direction) ;

                                    Printed out:

                                    Heading : 10


                                    Which is the value of the first byte.


                                    Making progress

                                    1 2 Previous Next