SOLVED-ish - getting i2c_1 working

Discussion in 'Kernels' started by peter247, May 8, 2014.

  1. peter247

    peter247 Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Hi , what do I need to modify to get the i2c(1) port working on the iMX6 side , I`ve read the manual and I can totally say I don`t understand it one bit of it .
    I downloaded and decompressed the kernel to look at the file mentioned :-

    /kernel/arch/arm/mach-mx6/board-mx6_seco_UDOO.c
    /kernel/arch/arm/mach-mx6/board-mx6qd_seco_UDOO.h

    I can find many references to the ( pin / pad ) in the mx6qd_seco_UDOO.h file I need to set , but not sure which it uses to set the function .

    #define MX6Q_PAD_EIM_D21__GPIO_MODE IMX_GPIO_NR(3, 21) <--- line 75 / 76
    #define MX6Q_PAD_EIM_D28__GPIO_MODE IMX_GPIO_NR(3, 28)

    MX6Q_PAD_EIM_D21__I2C1_SCL, // I2C1_SCL - SMB <---- line 202/203
    MX6Q_PAD_EIM_D28__I2C1_SDA, // I2C1_SDA - SMB

    MX6Q_PAD_EIM_D21__GPIO_MODE, <---- line 422/423
    MX6Q_PAD_EIM_D28__GPIO_MODE,

    or have I got it wrong and I should be looking in board-mx6_seco_UDOO.c ?

    any anyone help me please ... Peter A
     
  2. TomFreudenberg

    TomFreudenberg Member

    Joined:
    May 12, 2014
    Messages:
    59
    Likes Received:
    2
    Re: getting i2c_1 working

    Hi,

    if I do understand the documentation, you have to "comment out" the GPIO macros

    // MX6Q_PAD_EIM_D21__GPIO_MODE, <---- line 422/423
    // MX6Q_PAD_EIM_D28__GPIO_MODE,

    so I2C1 ist enabled in new compiled kernel

    --------

    I am asking, why you want to do it like this?

    As I thought, the I2C default device should be enabled and available by the iMX6

    If you wish to use the I2C as well on Arduino part (sam3x) than you should be able to use the I2C1 on Arduino without changing kernel. You only have to use Wire1 instead of Wire like Wike1.begin();

    --------

    This is all my theory, I have not get it work by now to have a I2C communication between iMX6 and sam3x.
     
  3. peter247

    peter247 Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: getting i2c_1 working

    I`ve had both wire and wire1 working on the sam side , it`s the ImX6 side I`ve not tried to getting working yet .

    I`ve tried placing a device on both port test it out on the sam arduino side then test for it on the imx6 side , NO JOY ,
    so both ports are not set to use the i2c by default ( IMX6 side )
     
  4. TomFreudenberg

    TomFreudenberg Member

    Joined:
    May 12, 2014
    Messages:
    59
    Likes Received:
    2
    Re: getting i2c_1 working

    I guess you are still at the same point as me ... I2C is not yet working on the iMX6 side.

    Just to repeat / clarify what my state is:

    From documentation: http://udoo.org/download/files/pinout/U ... iagram.pdf

    I took the ports SDA (gpio92) and SCL (gpio85)

    and

    additional the ports SDA1 and SCL1 (top ports right jumper side)

    I then wired and connected them with

    SDA connected SDA1 and both are pulled up via resistor to 3,3V
    SCL connected SCL1 and both are pulled up via resistor to 3,3V

    I made a small test sketch on SAM side with

    Code:
    Wire.begin(); // Master
    Wire1.begin(3); // Slave addressed 3
    
    Then I could successfully send messages between Master and Slave.

    First question:

    Code:
    Wire.begin(); // referres to ports SDA/SCL ???
    Wire1.begin(); // referres to ports SDA1/SCL1 ???
    
    Next I tried to bring up the master on the iMX6 side

    HMMMM when I was typing this here, I again checked the document: http://udoo.org/download/files/schemati ... matics.pdf

    With deeper look, I found the ports for I2C1_SDA and I2C1_SCL
    They are on port D21/D28 and it seems that they have to be commented out as gpio ports to function as I2C

    But there is another direct I2C named I2C3_SDA/I2C3_SCL. They are available on Jumper CN13 and/or CN11.
    They are also named as GPIO5 and GPIO6

    It seems that the kernel macros are already set for I2C communication

    Code:
        MX6Q_PAD_GPIO_5__I2C3_SCL,                      //      I2C3_SCL
        MX6Q_PAD_GPIO_6__I2C3_SDA,
    
    Additional there is a I2C2 element configured in the .h file

    Code:
            MX6Q_PAD_KEY_COL3__I2C2_SCL,                            // I2C2_SCL
            MX6Q_PAD_KEY_ROW3__I2C2_SDA,                          // I2C2_SDA
    
    But here my next question is:

    Where are these ports located?

    where is COL3 or ROW3 ????

    ------

    However, instead of changing config and preparing a own kernel, maybe it is just a question where to pickup the signal.
    So I would give it a try to use CN11 or CN13

    with I2C3

    ------

    For testing the iMX6 communication I used a small python / smbus script:

    Code:
    #!/usr/bin/env python
    import smbus
    mySlave = 0x03
    
    ## Initialize an smbus object. The parameter passed is the number of the I2C
    ##   bus; for the Arduino-ish headers on the pcDuino, it will be "2".
    i2c = smbus.SMBus(0)
    
    i2c.write_byte(mySlave, 77)
    
     
  5. TomFreudenberg

    TomFreudenberg Member

    Joined:
    May 12, 2014
    Messages:
    59
    Likes Received:
    2
    Re: getting i2c_1 working

    Next look in diagram shows up, that COL3 and ROW3 is located in the HDMI connector.

    Maybe it is neccessary for HDMI as well, not sure for that.

    I will give I2C3 a try when back at the office.
     
  6. peter247

    peter247 Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: getting i2c_1 working

    I think i2c_3 is used for the touch screen?.

    I tried to comment out the gpio line 422 and 423 and all I got was kernel panic`s .
    Just in case it was some other fault I deleted my kernel image and started again without any changes and that`s running without fault.

    P.S.

    I have read the manual again and think I understand it a little better , I need to change it in 2 places

    Try i2cdetect -y 1 with a hdmi monitor and it will show a device at 0x37 !!!!
     
  7. peter247

    peter247 Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: getting i2c_1 working

    TomFreudenberg @ have you compiled the kernel ? , if I try to mod mx6qd_seco_UDOO.h it will not boot for me. ?

    Code:
    Starting kernel ...
    
    [    0.000000] Initializing cgroup subsys cpu
    [    0.000000] Linux version 3.0.35-g3b2c06e-dirty (root@Udoo) (gcc version 4.8.2 (Debian 4.8.2-16) ) #1 SMP PREEMPT Mon May 12 22:16:32 BST 2014
    [    0.000000] CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c53c7d
    [    0.000000] CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
    [    0.000000] Machine: SECO i.Mx6 UDOO Board
    [    0.000000] Kernel ver:
    [    0.000000] Memory policy: ECC disabled, Data cache writealloc
    [    0.000000] CPU identified as i.MX6Q, silicon rev 1.2
    [    0.000000] PERCPU: Embedded 7 pages/cpu @8c008000 s5504 r8192 d14976 u32768
    [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 227328
    [    0.000000] Kernel command line: console=ttymxc1,115200 root=/dev/sda1 fbmem=24M video=mxcfb0:dev=hdmi,1920x1080M@60,bpp=32
    [    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
    [    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
    [    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
    [    0.000000] Memory: 640MB 256MB = 896MB total
    [    0.000000] Memory: 895912k/895912k available, 152664k reserved, 0K highmem
    [    0.000000] Virtual kernel memory layout:
    [    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    [    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    [    0.000000]     DMA     : 0xf4600000 - 0xffe00000   ( 184 MB)
    [    0.000000]     vmalloc : 0xc0800000 - 0xf2000000   ( 792 MB)
    [    0.000000]     lowmem  : 0x80000000 - 0xc0000000   (1024 MB)
    [    0.000000]     pkmap   : 0x7fe00000 - 0x80000000   (   2 MB)
    [    0.000000]     modules : 0x7f000000 - 0x7fe00000   (  14 MB)
    [    0.000000]       .init : 0x80008000 - 0x8003a000   ( 200 kB)
    [    0.000000]       .text : 0x8003a000 - 0x80b6e054   (11473 kB)
    [    0.000000]       .data : 0x80b70000 - 0x80bd7140   ( 413 kB)
    [    0.000000]        .bss : 0x80bd7164 - 0x80c28800   ( 326 kB)
    [    0.000000] SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
    [    0.000000] Preemptible hierarchical RCU implementation.
    [    0.000000] NR_IRQS:624
    [    0.000000] MXC GPIO hardware
    [    0.000000] sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 1431655ms
    [    0.000000] arm_max_freq=1GHz
    [    0.000000] MXC_Early serial console at MMIO 0x21e8000 (options '115200')
    [    0.000000] bootconsole [ttymxc1] enabled
    [    0.000000] Console: colour dummy device 80x30
    [    0.218298] Calibrating delay loop... 1581.05 BogoMIPS (lpj=7905280)
    [    0.306622] pid_max: default: 32768 minimum: 301
    [    0.311594] Mount-cache hash table entries: 512
    [    0.317012] Initializing cgroup subsys cpuacct
    [    0.321535] Initializing cgroup subsys devices
    [    0.325994] Initializing cgroup subsys freezer
    [    0.330483] Initializing cgroup subsys blkio
    [    0.334819] CPU: Testing write buffer coherency: ok
    [    0.339978] hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 7 counters available
    [    0.440524] CPU1: Booted secondary processor
    [    0.520524] CPU2: Booted secondary processor
    [    0.600546] CPU3: Booted secondary processor
    [    0.640010] Brought up 4 CPUs
    [    0.655838] SMP: Total of 4 processors activated (6324.22 BogoMIPS).
    [    0.662732] devtmpfs: initialized
    [    0.683643] print_constraints: dummy:
    [    0.687622] NET: Registered protocol family 16
    [    0.696498] print_constraints: vddpu: 725 <--> 1300 mV at 1150 mV fast normal
    [    0.704080] print_constraints: vddcore: 725 <--> 1300 mV at 1150 mV fast normal
    [    0.711822] print_constraints: vddsoc: 725 <--> 1300 mV at 1200 mV fast normal
    [    0.719492] print_constraints: vdd2p5: 2000 <--> 2775 mV at 2400 mV fast normal
    [    0.727258] print_constraints: vdd1p1: 800 <--> 1400 mV at 1100 mV fast normal
    [    0.734937] print_constraints: vdd3p0: 2625 <--> 3400 mV at 3000 mV fast normal
    [    0.744041]
    [    0.744047] > UDOO quad
    [    0.747819] > rev C Called set_gpios_direction
    [    0.752499] Test and set gpios directions and values by Gionji feat. Ekirei test
    [    0.783489] Resetting ethernet physical layer.
    [    0.826803] hw-breakpoint: found 6 breakpoint and 1 watchpoint registers.
    [    0.833637] hw-breakpoint: 1 breakpoint(s) reserved for watchpoint single-step.
    [    0.840997] hw-breakpoint: maximum watchpoint size is 4 bytes.
    [    0.846879] L310 cache controller enabled
    [    0.850922] l2x0: 16 ways, CACHE_ID 0x410000c7, AUX_CTRL 0x02070000, Cache size: 1048576 B
    [    0.888144] bio: create slab <bio-0> at 0
    [    0.895710] mxs-dma mxs-dma-apbh: initialized
    [    0.900422] print_constraints: vmmc: 3300 mV
    [    0.905537] vgaarb: loaded
    [    0.909081] SCSI subsystem initialized
    [    0.914017] usbcore: registered new interface driver usbfs
    [    0.919650] usbcore: registered new interface driver hub
    [    0.925158] usbcore: registered new device driver usb
    [    0.930239] Freescale USB OTG Driver loaded, $Revision: 1.55 $
    [    0.950008] imx-ipuv3 imx-ipuv3.0: IPU DMFC NORMAL mode: 1(0~1), 5B(4,5), 5F(6,7)
    [    0.970004] imx-ipuv3 imx-ipuv3.1: IPU DMFC NORMAL mode: 1(0~1), 5B(4,5), 5F(6,7)
    [    0.977834] mxc_mipi_csi2 mxc_mipi_csi2: i.MX MIPI CSI2 driver probed
    [    0.984313] mxc_mipi_csi2 mxc_mipi_csi2: i.MX MIPI CSI2 dphy version is 0x3130302a
    [    0.992042] MIPI CSI2 driver module loaded
    [    0.996376] Advanced Linux Sound Architecture Driver Version 1.0.24.
    [    1.003619] Bluetooth: Core ver 2.16
    [    1.007327] NET: Registered protocol family 31
    [    1.011796] Bluetooth: HCI device and connection manager initialized
    [    1.018171] Bluetooth: HCI socket layer initialized
    [    1.023070] Bluetooth: L2CAP socket layer initialized
    [    1.028217] Bluetooth: SCO socket layer initialized
    [    1.033557] cfg80211: Calling CRDA to update world regulatory domain
    [    1.041004] i2c-core: driver [max17135] using legacy suspend method
    [    1.047290] i2c-core: driver [max17135] using legacy resume method
    [    1.053518] Switching to clocksource mxc_timer1
    [    1.072905] Unable to handle kernel NULL pointer dereference at virtual address 000000e3
    [    1.081022] pgd = 80004000
    [    1.083738] [000000e3] *pgd=00000000
    [    1.087342] Internal error: Oops: 5 [#1] PREEMPT SMP
    [    1.092323] Modules linked in:
    [    1.095405] CPU: 0    Not tainted  (3.0.35-g3b2c06e-dirty #1)
    [    1.101185] PC is at kmem_cache_alloc+0xa8/0x100
    [    1.105828] LR is at con_insert_unipair+0xb8/0x104
    [    1.110635] pc : [<800f4b70>]    lr : [<802c5390>]    psr: 60000093
    [    1.110640] sp : bff8bed8  ip : 8003b5e0  fp : 00000000
    [    1.122157] r10: 00000001  r9 : 80b85cc0  r8 : 000000d0
    [    1.127398] r7 : 0bfd0000  r6 : bff8a000  r5 : bfff9300  r4 : 000000e3
    [    1.133944] r3 : 80b85cc0  r2 : 802c5390  r1 : 00002d94  r0 : 20000013
    [    1.140493] Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
    [    1.147911] Control: 10c53c7d  Table: 1000404a  DAC: 00000015
    [    1.153673] Process swapper (pid: 1, stack limit = 0xbff8a2f0)
    [    1.159523] Stack: (0xbff8bed8 to 0xbff8c000)
    [    1.163896] bec0:                                                       80be6288 0000207f
    [    1.172100] bee0: bfe3ba80 000000fc bfe92204 80baa04a 80baa048 000000fc 00000001 802c5390
    [    1.180304] bf00: 80baa054 00000000 00000001 bfe3ba80 000000fc 802c5fc0 80bf40fc 80baa054
    [    1.188507] bf20: 80bf42dc bfff0000 00000000 00000001 00000014 80bf4500 00000002 00000004
    [    1.196709] bf40: 00000000 80020f50 00000000 8002046c 00000000 80bf43dc 00000001 80020964
    [    1.204913] bf60: 80acaa7c 801484d0 80bf3ed8 00000000 80040a7c 00000013 80bd7180 8001fdb0
    [    1.213116] bf80: 80a968b0 00000013 8002da84 8002da84 8002df7c 8003a5c0 800b4814 80be0d14
    [    1.221320] bfa0: 80b81080 bff8a018 000001df 00000013 00000000 37340f80 00000039 00000000
    [    1.229523] bfc0: 00000270 8002da84 8002df7c 80040a7c 00000013 00000000 00000000 00000000
    [    1.237726] bfe0: 00000000 80008930 00000000 00000000 80008870 80040a7c 0a00000f e5923000
    [    1.245943] [<800f4b70>] (kmem_cache_alloc+0xa8/0x100) from [<802c5390>] (con_insert_unipair+0xb8/0x104)
    [    1.255464] [<802c5390>] (con_insert_unipair+0xb8/0x104) from [<802c5fc0>] (con_set_default_unimap+0xe4/0x16c)
    [    1.265507] [<802c5fc0>] (con_set_default_unimap+0xe4/0x16c) from [<8002046c>] (console_map_init+0x44/0x50)
    [    1.275286] [<8002046c>] (console_map_init+0x44/0x50) from [<80020964>] (vty_init+0x18c/0x19c)
    [    1.283930] [<80020964>] (vty_init+0x18c/0x19c) from [<8001fdb0>] (tty_init+0x12c/0x144)
    [    1.292063] [<8001fdb0>] (tty_init+0x12c/0x144) from [<8003a5c0>] (do_one_initcall+0x11c/0x174)
    [    1.300797] [<8003a5c0>] (do_one_initcall+0x11c/0x174) from [<80008930>] (kernel_init+0xc0/0x144)
    [    1.309708] [<80008930>] (kernel_init+0xc0/0x144) from [<80040a7c>] (kernel_thread_exit+0x0/0x8)
    [    1.318524] Code: 1afffff3 e595b014 e2811004 e3a0a001 (e794b00b)
    [    1.324690] ---[ end trace 60f60b23e6fa95d6 ]---
    [    1.329353] Kernel panic - not syncing: Attempted to kill init!
    [    1.335313] [<80046bc8>] (unwind_backtrace+0x0/0xf4) from [<805b3044>] (panic+0x84/0x198)
    [    1.343548] [<805b3044>] (panic+0x84/0x198) from [<80078480>] (complete_and_exit+0x0/0x1c)
    [    1.351859] [<80078480>] (complete_and_exit+0x0/0x1c) from [<bff8bcb8>] (0xbff8bcb8)
    [    1.359649] CPU1: stopping
    [    1.362385] [<80046bc8>] (unwind_backtrace+0x0/0xf4) from [<8003a338>] (do_IPI+0x144/0x154)
    [    1.370771] [<8003a338>] (do_IPI+0x144/0x154) from [<8003f9cc>] (__irq_svc+0x4c/0xe8)
    [    1.378624] Exception stack(0xbffadea8 to 0xbffadef0)
    [    1.383694] dea0:                   00000000 8bffe3e0 80095794 00000000 bff15b64 bff15b00
    [    1.391898] dec0: 00000002 80b98ba0 8c010660 bfd8d288 800381c8 00000009 80b85cc0 bffadef0
    [    1.400098] dee0: 800957b4 8022fe48 60000113 ffffffff
    [    1.405175] [<8003f9cc>] (__irq_svc+0x4c/0xe8) from [<8022fe48>] (key_put+0x0/0x38)
    [    1.412873] [<8022fe48>] (key_put+0x0/0x38) from [<800957b4>] (put_cred_rcu+0x20/0x9c)
    [    1.420829] [<800957b4>] (put_cred_rcu+0x20/0x9c) from [<800b65b4>] (__rcu_process_callbacks+0x160/0x350)
    [    1.430432] [<800b65b4>] (__rcu_process_callbacks+0x160/0x350) from [<8007a1a8>] (__do_softirq+0xf0/0x188)
    [    1.440119] [<8007a1a8>] (__do_softirq+0xf0/0x188) from [<8007a768>] (irq_exit+0xa4/0xa8)
    [    1.448327] [<8007a768>] (irq_exit+0xa4/0xa8) from [<8003a304>] (do_IPI+0x110/0x154)
    [    1.456098] [<8003a304>] (do_IPI+0x110/0x154) from [<8003f9cc>] (__irq_svc+0x4c/0xe8)
    [    1.463949] Exception stack(0xbffadf90 to 0xbffadfd8)
    [    1.469017] df80:                                     80bde720 80000093 bffadfc0 00000000
    [    1.477220] dfa0: bffac000 80b88ed4 80bd7224 805bc7e0 1000406a 412fc09a 00000000 00000000
    [    1.485422] dfc0: 00000000 bffadfd8 8004ea98 80040b5c 40000013 ffffffff
    [    1.492062] [<8003f9cc>] (__irq_svc+0x4c/0xe8) from [<80040b5c>] (default_idle+0x24/0x28)
    [    1.500269] [<80040b5c>] (default_idle+0x24/0x28) from [<80040cb8>] (cpu_idle+0xa0/0x104)
    [    1.508475] [<80040cb8>] (cpu_idle+0xa0/0x104) from [<105af9d4>] (0x105af9d4)
    [    1.515632] CPU2: stopping
    [    1.518367] [<80046bc8>] (unwind_backtrace+0x0/0xf4) from [<8003a338>] (do_IPI+0x144/0x154)
    [    1.526751] [<8003a338>] (do_IPI+0x144/0x154) from [<8003f9cc>] (__irq_svc+0x4c/0xe8)
    [    1.534603] Exception stack(0xbffb5f90 to 0xbffb5fd8)
    [    1.539671] 5f80:                                     80bde720 80000093 bffb5fc0 00000000
    [    1.547875] 5fa0: bffb4000 80b88ed4 80bd7224 805bc7e0 1000406a 412fc09a 00000000 00000000
    [    1.556077] 5fc0: 00000000 bffb5fd8 8004ea98 80040b5c 40000013 ffffffff
    [    1.562717] [<8003f9cc>] (__irq_svc+0x4c/0xe8) from [<80040b5c>] (default_idle+0x24/0x28)
    [    1.570924] [<80040b5c>] (default_idle+0x24/0x28) from [<80040cb8>] (cpu_idle+0xa0/0x104)
    [    1.579129] [<80040cb8>] (cpu_idle+0xa0/0x104) from [<105af9d4>] (0x105af9d4)
    [    1.586285] CPU3: stopping
    [    1.589020] [<80046bc8>] (unwind_backtrace+0x0/0xf4) from [<8003a338>] (do_IPI+0x144/0x154)
    [    1.597403] [<8003a338>] (do_IPI+0x144/0x154) from [<8003f9cc>] (__irq_svc+0x4c/0xe8)
    [    1.605254] Exception stack(0xbff01f90 to 0xbff01fd8)
    [    1.610323] 1f80:                                     80bde720 60000093 bff01fc0 00000000
    [    1.618526] 1fa0: bff00000 80b88ed4 80bd7224 805bc7e0 1000406a 412fc09a 00000000 00000000
    [    1.626728] 1fc0: 00000000 bff01fd8 8004ea98 80040b5c 40000013 ffffffff
    [    1.633368] [<8003f9cc>] (__irq_svc+0x4c/0xe8) from [<80040b5c>] (default_idle+0x24/0x28)
    [    1.641574] [<80040b5c>] (default_idle+0x24/0x28) from [<80040cb8>] (cpu_idle+0xa0/0x104)
    [    1.649779] [<80040cb8>] (cpu_idle+0xa0/0x104) from [<105af9d4>] (0x105af9d4)
     
  8. TomFreudenberg

    TomFreudenberg Member

    Joined:
    May 12, 2014
    Messages:
    59
    Likes Received:
    2
    Re: getting i2c_1 working

    Hi Peter,

    I have not tried to compile the right now but I used the I2C3 on Pins 12 and 19 on Connector CN13.

    When I opened this with

    Code:
    i2c = smbus.SMBus(2)
    it works fine for me. No need to recompile kernel anymore for me.

    In case that this is a bus and it it also connected to CN11 (CAM)
    I think that it is no problem to use, even if you want to connect a touch screen.
    It may only be a wireing quest.

    Tom
     
  9. TomFreudenberg

    TomFreudenberg Member

    Joined:
    May 12, 2014
    Messages:
    59
    Likes Received:
    2
    Re: getting i2c_1 working

    Comment to Arduino Wire Library:

    Wire.begin()

    referres to Pins SCL1 and SDA1 on Jumper Block J21

    Wire1.begin()

    referres to Pins SCL and SDA (gpio92 / gpio85) on Jumper Block J5
     
  10. peter247

    peter247 Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: getting i2c_1 working

    Well I tried following the manual and if you change mx6qd_seco_UDOO.h it will not boot , so the manuals not factual there.
    Don`t like the look at wiring up CN11-Cam and not sure how .
    But CN13 looks like it`s just a case of getting the right plug , any clue of the right plug/socket ?
     
  11. TomFreudenberg

    TomFreudenberg Member

    Joined:
    May 12, 2014
    Messages:
    59
    Likes Received:
    2
    Re: getting i2c_1 working

    Hi, I also will proceed with plug for CN13.

    Have not found the right plug by now.

    I will check at a local distributor and show him the Board, maybe he has an idea.

    I you find something on the internet, it would be nice if you could share it.
     
  12. peter247

    peter247 Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: getting i2c_1 working

    This is what I`ve found on the plugs for the udoo :-

    post1926.html#p1926

    How ?
     
  13. TomFreudenberg

    TomFreudenberg Member

    Joined:
    May 12, 2014
    Messages:
    59
    Likes Received:
    2
    Re: getting i2c_1 working

    Hi, I prepared myself two small connectors (clips) using a heat shrink tube.
    and put this on Pins 12 and 19 in Connector CN13.

    After that I put the wirer from Pin12 and 19 to Pins named SCL1 and SDA1.
    They are locate on upper right side see diagramm
    http://udoo.org/download/files/pinout/U ... iagram.pdf

    Arduino
    Code:
     // Slave-Board
    #include <Wire.h>
     
    // the setup routine runs once when you press reset:
    void setup() {                
      Wire1.begin(3);
      Wire1.onReceive(receiveI2cData);
      Wire1.onRequest(sendI2cData);
    }
    
    // the loop routine runs over and over again forever:
    void loop() {
      delay(10);
    }
    
    void receiveI2cData(int AnzahlBytes)
    {
      while(Wire1.available())
      {
        int recData = Wire1.read();
        // proceed with the recData
      }
    }
    
    void sendI2cData()
    {
      // unkown command received
      Wire1.write(255);
    }
    
    And the linux sampler in python:
    Code:
    #!/usr/bin/env python
    
    import smbus
    
    mySlave = 0x03
    
    ## Use ID 2 for I2C3 interface
    i2c = smbus.SMBus(2)
    
    i2c.write_byte(mySlave, 77)
    
    print i2c.read_byte(mySlave)
    
    
    This worked for me as a Test.

    You could also place the wires to lower right SDA and SCL Pins, but then you have to use Wire instead of Wire1


    Good luck!
     
  14. TomFreudenberg

    TomFreudenberg Member

    Joined:
    May 12, 2014
    Messages:
    59
    Likes Received:
    2
  15. peter247

    peter247 Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: getting i2c_1 working

    That sounds promising and a good working test, it looks like you have had better luck than me trying i2c_1

    I`ve looked at digiKey which is £12 shipping on order of less than £50 and other web site which only deal in 1000s.
    I hate 2 mm pitch connectors !!!!! , I`ve always had problems trying to source them.

    root@Udoo:~# i2cdetect -y 2
    0 1 2 3 4 5 6 7 8 9 a b c d e f
    00: -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- --
    root@Udoo:~#

    I`ve tried the same method and it does find my device which is on 0x23 ... wow i2c_2 works !!!!
     
  16. peter247

    peter247 Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: getting i2c_1 working

    This is my simple test using a mcp23017 chip and a led / resistor and going to leave it flashing to it`s self all night to see what happens.

    0.7% cpu 0.4% memory


    Code:
    #! /usr/bin/python
    
    import smbus , time , sys 
    
    LED_CHIP_ADDRESS = 0x23
    LED_REG = 0x13
    
    bus = smbus.SMBus(2)
    
    bus.write_byte_data(LED_CHIP_ADDRESS , 1 , 0 )	#  all OUTs
    
    while 1:
    
    	bus.write_byte_data(LED_CHIP_ADDRESS , LED_REG , 0x00 )	
    	time.sleep(.03)
    	bus.write_byte_data(LED_CHIP_ADDRESS , LED_REG , 0xff )	
    	time.sleep(.03)
     
  17. TomFreudenberg

    TomFreudenberg Member

    Joined:
    May 12, 2014
    Messages:
    59
    Likes Received:
    2
    Re: getting i2c_1 working

    Great, so you also had been able to use the i2c bus from iMX6 side.

    I really wonder why they have not linked the pins also to the standard connectors and drop two gpios. There are a already more than enough.

    Well ... so this thread is finished now :)

    If I find some cable I will add the info here.

    Bye
     
  18. peter247

    peter247 Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: getting i2c_1 working

    Now you have put me on the right track that i2c_2 is the only port working by default or can be made to work now , I`m going to also try to find out why i2c_1 isn`t working and what did they do to get i2c_2 working in the kernel .
    If not it`s back to trying to find that 24 pin 2mm pitch plug , at low cost in quantities of one.

    A request for support has been created and assigned ticket 22xxxx , wow that a lot of support tickets .
     
  19. TomFreudenberg

    TomFreudenberg Member

    Joined:
    May 12, 2014
    Messages:
    59
    Likes Received:
    2
    Re: getting i2c_1 working

    Hi Peter,

    I case of the cabling stuff, I looked once more for the CAM Adapter.

    For that you can find wires named FLEXCONN 16 PIN

    Checkout Youtube for a video how to connect camera to UDOO camera port.

    On this breakout CN11 you could fetch them same I2C3 SLC/SDA as on CN13

    Maybe it is easier for you to find a cable and connector for this board connector.
     
  20. peter247

    peter247 Member

    Joined:
    Mar 10, 2014
    Messages:
    263
    Likes Received:
    2
    Re: getting i2c_1 working

    My code is still flashing away !!!

    oops , I`ve made a mistake which you documented , but It`s only just clicked .

    i2c_3 is smbus(2)
    i2c_1 on j21 is sam side only
    so i2c_1 imx on j5 must be smbus(0) , and wire on sam side.
    so where is i2c_2 , smbus(1) ?
     

Share This Page