9 Replies Latest reply on Nov 30, 2015 5:27 PM by CMata_Intel

    How to use the I2C on Arduino Board?

    sdssly

      I am testing some I2C devices using the Edison + Arduino expansion board. which ports are using for the I2C? I tested the SCL/SDA and A4/A5, but failed.

      I also found without connected any devices, the "i2cdetect -y -r 6" command failed with below messages, is there any command/step I missed?

       

      [  144.139643] Code: 10 b3 ff ff 89 f8 09 d0 80 ce 04 83 ff 02 0f 45 d0 a1 94 72 bd c1 89 90 00 b3 ff ff f7 c6 00 02 00 00 74 15 e8 20 58 0b 00 56 9d <83> c4 04 5b 5e 5f 5d c3 8d b6 00 00 00 00 56 9d e8 39 5b 0b 00

      [  144.139652] NMI backtrace for cpu 0

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

      [  144.139672] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48

      [  144.139681] task: c1bce1c0 ti: c1bc8000 task.ti: c1bc8000

      [  144.139690] EIP: 0060:[<c151f894>] EFLAGS: 00200046 CPU: 0

      [  144.139703] EIP is at intel_idle+0x94/0xf0

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

      [  144.139717] ESI: 00000060 EDI: c1c16164 EBP: c1bc9f5c ESP: c1bc9f48

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

      [  144.139731] CR0: 8005003b CR2: b6a54900 CR3: 01d17000 CR4: 001007f0

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

      [  144.139741] DR6: ffff0ff0 DR7: 00000400

      [  144.139743] Stack:

      [  144.139766]  00000003 00000000 00000003 c1c16080 000000e4 c1bc9f84 c166e91e 00000000

      [  144.139787]  00002336 8bf12600 00000021 f73f3500 00000002 c1c16080 000000e4 c1bc9fa8

      [  144.139808]  c166ea65 00000000 c1c16080 00000000 f73f3500 00000002 00099800 c1bc8000

      [  144.139811] Call Trace:

      [  144.139834]  [<c166e91e>] cpuidle_enter_state+0x2e/0xd0

      [  144.139851]  [<c166ea65>] cpuidle_idle_call+0xa5/0x220

      [  144.139867]  [<c120865d>] arch_cpu_idle+0xd/0x30

      [  144.139880]  [<c128903f>] cpu_startup_entry+0x6f/0x230

      [  144.139896]  [<c18caec1>] rest_init+0x71/0x80

      [  144.139912]  [<c1c7e90b>] start_kernel+0x2e2/0x2e7

      [  144.139925]  [<c1c7e2ac>] i386_start_kernel+0x82/0x86

        • 1. Re: How to use the I2C on Arduino Board?
          John_Quin

          it works on bus i2c bus 1.

          I think edison uses bus 6 for its own purposes

          • 2. Re: How to use the I2C on Arduino Board?
            YONGYONG

            I found the below commands, but I still cannot use the I2C after execute these commands

             

            echo 28 > /sys/class/gpio/export

            echo 27 > /sys/class/gpio/export

            echo 204 > /sys/class/gpio/export

            echo 205 > /sys/class/gpio/export

            echo 236 > /sys/class/gpio/export

            echo 237 > /sys/class/gpio/export

            echo 14 > /sys/class/gpio/export

            echo 165 > /sys/class/gpio/export

            echo 212 > /sys/class/gpio/export

            echo 213 > /sys/class/gpio/export

            echo 214 > /sys/class/gpio/export

            echo low > /sys/class/gpio/gpio214/direction

            echo high > /sys/class/gpio/gpio204/direction

            echo high > /sys/class/gpio/gpio205/direction

            echo in > /sys/class/gpio/gpio14/direction

            echo in > /sys/class/gpio/gpio165/direction

            echo low > /sys/class/gpio/gpio236/direction

            echo low > /sys/class/gpio/gpio237/direction

            echo in > /sys/class/gpio/gpio212/direction

            echo in > /sys/class/gpio/gpio213/direction

            echo mode1 > /sys/kernel/debug/gpio_debug/gpio28/current_pinmux

            echo mode1 > /sys/kernel/debug/gpio_debug/gpio27/current_pinmux

            echo high > /sys/class/gpio/gpio214/direction

            • 3. Re: How to use the I2C on Arduino Board?
              YONGYONG

              Using the below commands, I can detect the I2C devices on the SCL/SDA connectors:

              echo 28 > /sys/class/gpio/export

              echo 27 > /sys/class/gpio/export

              echo 204 > /sys/class/gpio/export

              echo 205 > /sys/class/gpio/export

              echo 236 > /sys/class/gpio/export

              echo 237 > /sys/class/gpio/export

              echo 14 > /sys/class/gpio/export

              echo 165 > /sys/class/gpio/export

              echo 212 > /sys/class/gpio/export

              echo 213 > /sys/class/gpio/export

              echo 214 > /sys/class/gpio/export

               

              echo low > /sys/class/gpio/gpio214/direction

              echo low > /sys/class/gpio/gpio204/direction

              echo low > /sys/class/gpio/gpio205/direction

              echo in > /sys/class/gpio/gpio14/direction

              echo in > /sys/class/gpio/gpio165/direction

              echo low > /sys/class/gpio/gpio236/direction

              echo low > /sys/class/gpio/gpio237/direction

              echo in > /sys/class/gpio/gpio212/direction

              echo in > /sys/class/gpio/gpio213/direction

              echo mode1 > /sys/kernel/debug/gpio_debug/gpio28/current_pinmux

              echo mode1 > /sys/kernel/debug/gpio_debug/gpio27/current_pinmux

              echo high > /sys/class/gpio/gpio214/direction

              • 4. Re: How to use the I2C on Arduino Board?
                CMata_Intel

                Hi sdssly,

                 

                Did you try with YONGYONG suggestion?

                Also, which image do you have in your board (configure_edison --version) and how are you testing the lines?

                 

                Regards,

                Charlie

                • 5. Re: How to use the I2C on Arduino Board?
                  sdssly

                  Problem fixed, the key commands are:

                  echo low > /sys/class/gpio/gpio204/direction

                  echo low > /sys/class/gpio/gpio205/direction

                  • 6. Re: How to use the I2C on Arduino Board?
                    krlkv

                    sdssly

                     

                    echo low > /sys/class/gpio/gpio204/direction

                     

                    results in:

                     

                    -sh: /sys/class/gpio/gpio204/direction: No such file or directory" error message.

                     

                    YONGYONG

                     

                     

                    Please help as I cannot enable I2C.

                    • 7. Re: How to use the I2C on Arduino Board?
                      sdssly

                      On My Edison board, I can find these items, can you find them on your Edison board ?

                      edison:~# ls -l /sys/class/gpio/

                      --w-------    1 root     root          4096 Jan  1  2000 export

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpio124 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio124

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpio125 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio125

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpio126 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio126

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpio127 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio127

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpio128 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio128

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpio129 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio129

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpio130 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio130

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpio131 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio131

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpio132 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio132

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpio133 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio133

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpio134 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio134

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpiochip0 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpiochip0

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpiochip200 -> ../../devices/pci0000:00/0000:00:08.0/i2c-1/1-0020/gpio/gpiochip200

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpiochip216 -> ../../devices/pci0000:00/0000:00:08.0/i2c-1/1-0021/gpio/gpiochip216

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpiochip232 -> ../../devices/pci0000:00/0000:00:08.0/i2c-1/1-0022/gpio/gpiochip232

                      lrwxrwxrwx    1 root     root             0 Jan  1  2000 gpiochip248 -> ../../devices/pci0000:00/0000:00:08.0/i2c-1/1-0023/gpio/gpiochip248

                      --w-------    1 root     root          4096 Jan  1  2000 unexport

                      • 8. Re: How to use the I2C on Arduino Board?
                        krlkv

                        sdssly

                         

                        I have this:

                         

                        root@edisonclient:~/client# ls -l /sys/class/gpio/

                        --w-------    1 root     root          4096 Nov 26 23:38 export

                        lrwxrwxrwx    1 root     root             0 Nov 26 23:38 gpio124 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio124

                        lrwxrwxrwx    1 root     root             0 Nov 26 23:38 gpio125 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio125

                        lrwxrwxrwx    1 root     root             0 Nov 26 23:38 gpio126 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio126

                        lrwxrwxrwx    1 root     root             0 Nov 26 23:38 gpio127 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio127

                        lrwxrwxrwx    1 root     root             0 Nov 26 23:38 gpio128 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio128

                        lrwxrwxrwx    1 root     root             0 Nov 26 23:38 gpio129 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio129

                        lrwxrwxrwx    1 root     root             0 Nov 26 23:38 gpio130 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio130

                        lrwxrwxrwx    1 root     root             0 Nov 26 23:38 gpio131 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio131

                        lrwxrwxrwx    1 root     root             0 Nov 26 23:38 gpio132 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio132

                        lrwxrwxrwx    1 root     root             0 Nov 26 23:38 gpio133 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio133

                        lrwxrwxrwx    1 root     root             0 Nov 26 23:38 gpio134 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpio134

                        lrwxrwxrwx    1 root     root             0 Nov 26 23:38 gpiochip0 -> ../../devices/pci0000:00/0000:00:0c.0/gpio/gpiochip0

                        lrwxrwxrwx    1 root     root             0 Nov 26 23:38 gpiochip232 -> ../../devices/pci0000:00/0000:00:08.0/i2c-1/1-0022/gpio/gpiochip232

                        lrwxrwxrwx    1 root     root             0 Nov 26 23:38 gpiochip248 -> ../../devices/pci0000:00/0000:00:08.0/i2c-1/1-0023/gpio/gpiochip248

                        --w-------    1 root     root          4096 Nov 26 23:38 unexport

                        • 9. Re: How to use the I2C on Arduino Board?
                          CMata_Intel

                          Hi krlkv

                           

                          Which image are you using? Run configure_edison --version

                          Also, try with

                          # echo 28 > /sys/class/gpio/export
                          # echo 27 > /sys/class/gpio/export
                          
                          

                          And then try to export again the gpio204 and gpio205.

                           

                          Regards,

                          Charlie