i2c almost working for me, was Re: i2c still not working for me

Emmanuel Vadot manu at bidouilliste.com
Thu Apr 25 13:01:52 UTC 2019


On Thu, 25 Apr 2019 10:37:05 +0300
Daniel Braniss <danny at cs.huji.ac.il> wrote:

> 
> 
> > On 24 Apr 2019, at 16:06, Daniel Braniss <danny at cs.huji.ac.il> wrote:
> > 
> > 
> > 
> >> On 24 Apr 2019, at 14:15, Emmanuel Vadot <manu at bidouilliste.com> wrote:
> >> 
> >> On Wed, 24 Apr 2019 13:02:11 +0200
> >> Emmanuel Vadot <manu at bidouilliste.com <mailto:manu at bidouilliste.com>> wrote:
> >> 
> >>> On Fri, 19 Apr 2019 11:35:09 +0300
> >>> Daniel Braniss <danny at cs.huji.ac.il> wrote:
> >>> 
> >>>> 
> >>>> 
> >>>>> On 19 Apr 2019, at 11:05, Emmanuel Vadot <manu at bidouilliste.com> wrote:
> >>>>> 
> >>>>> On Fri, 19 Apr 2019 10:20:47 +0300
> >>>>> Daniel Braniss <danny at cs.huji.ac.il <mailto:danny at cs.huji.ac.il>> wrote:
> >>>>> 
> >>>>>> 
> >>>>>> 
> >>>>>>> On 18 Apr 2019, at 17:19, Ian Lepore <ian at freebsd.org> wrote:
> >>>>>>> 
> >>>>>>> On Thu, 2019-04-18 at 10:12 +0300, Daniel Braniss wrote:
> >>>>>>>>> On 17 Apr 2019, at 23:26, Emmanuel Vadot <manu at bidouilliste.com>
> >>>>>>>>> wrote:
> >>>>>>>>> 
> >>>>>>>>> On Tue, 16 Apr 2019 09:16:02 +0300
> >>>>>>>>> Daniel Braniss <danny at cs.huji.ac.il <mailto:danny at cs.huji.ac.il>>
> >>>>>>>>> wrote:
> >>>>>>>>> 
> >>>>>>>>>> 
> >>>>>>>>>> 
> >>>>>>>>>>> On 11 Apr 2019, at 09:56, Daniel Braniss <danny at cs.huji.ac.il>
> >>>>>>>>>>> wrote:
> >>>>>>>>>>> 
> >>>>>>>>>>> if no device is connected, I2CRDWR hangs, 
> >>>>>>>>>>> it also happens with i2c(8) -s, only reboot helps.
> >>>>>>>>>>> 
> >>>>>>>>>>> ichb1: twsi_reset: Using IIC_FASTEST/UNKNOWN mode with speed
> >>>>>>>>>>> param=2a
> >>>>>>>>>>> iichb1: TWSI_WRITE: Writing 0 to 18
> >>>>>>>>>>> iichb1: TWSI_WRITE: Writing 2a to 14
> >>>>>>>>>>> iichb1: TWSI_WRITE: Writing 40 to c
> >>>>>>>>>>> iichb1: TWSI_WRITE: Writing c4 to c
> >>>>>>>>>>> iichb1: twsi_transfer: transmitting 2 messages
> >>>>>>>>>>> iichb1: TWSI_READ: read f8 from 10
> >>>>>>>>>>> iichb1: twsi_transfer: status=f8
> >>>>>>>>>>> iichb1: twsi_transfer: msg[0] flags: 0
> >>>>>>>>>>> iichb1: twsi_transfer: msg[0] len: 9
> >>>>>>>>>>> iichb1: TWSI_WRITE: Writing e4 to c
> >> 
> >> So looking at this is seems that the "START condition transmitted"
> >> interrupt is never triggered, I'll see to add some type of timeout
> >> around the pause_sbt.
> > 
> > GREAT! I was about to send you a Nanopi-neo ?, 
> > I might just do that if you send me an address.
> > 
> this patch is not that elegant, but works for me:
> Index: twsi.c
> ===================================================================
> --- twsi.c	(revision 346538)
> +++ twsi.c	(working copy)
> @@ -458,8 +458,15 @@
> 		if (sc->msg->len == 1)
> 			sc->control_val &= ~TWSI_CONTROL_ACK;
> 		TWSI_WRITE(sc, sc->reg_control, sc->control_val | TWSI_CONTROL_START);
> -		while (sc->error == 0 && sc->transfer != 0) {
> -			pause_sbt("twsi", SBT_1MS * 30, SBT_1MS, 0);
> +		{
> +			 int count = 10;
> +			 while (sc->error == 0 && sc->transfer != 0) {
> +				  pause_sbt("twsi", SBT_1MS * 30, SBT_1MS, 0);
> +				  if(count-- == 0) {
> +					   sc->error = EDEADLK;
> +					   break;
> +				  }
> +			 }
> 		}
> 
> 		debugf(dev, "Done with msg[%d]\n", i);

 I think that pause_sbt returns non-zero if the time has elapsed so
check this will possibly be enough.
 I'm more interested on why the controller didn't triggered an
interrupt.

> > danny
> > 
> >> 
> >>>>>>>>>>> and now it?s hung
> >>>>>>>>>> 
> >>>>>>>>>> [?]
> >>>>>>>>> 
> >>>>>>>>> I don't see that on my OrangePi One or Pine64-LTS.
> >>>>>>>> 
> >>>>>>>> well, mine is are Nanopi Neo, maybe it?s a dts issue?
> >>>>>>>> I also have a orangepi-zero but it will take me some time to make
> >>>>>>>> a sdcard
> >>>>>> 
> >>>>>> I managed to boot my OrangePi Zero, and i2c -s has no issues, does not hang.
> >>>>>> still, with the latest (r346368) my NanoPi Neo hangs when no i2c device is present,
> >>>>>> so what is the difference? or where can I look?
> >>>>> 
> >>>>> Are you using the same i2c controller on both ?
> >>>> yes, and have tested with several controllers and nanopies, 
> >>>> 
> >>>>> Could you paste somewhere the overlays or dts patches ?
> >>>> cat ./allwinner/dts/12/h3-i2c.dtso
> >>>> /dts-v1/;
> >>>> /plugin/;
> >>>> 
> >>>> //#include "sun8i-h3-nanopi-neo.dts"
> >>>> 
> >>>> / {
> >>>> compatible = "allwinner,sun8i-h3";
> >>>> };
> >>>> 
> >>>> &i2c0 {
> >>>>        ##frequency = <50000>;
> >>>>        status = "okay";
> >>>> };
> >>>> 
> >>>> &i2c1 {
> >>>>        ##frequency = <50000>;
> >>>>        status = "okay";
> >>>> };
> >>>> 
> >>>> 
> >>> 
> >>> And you have hang on both i2c0 and i2c1 ?
> >>> Also please note that i2c1 pins aren't routed on this PCB, I don't
> >>> think that this could/should make the i2c controller hangs but ...
> >>> 
> >>> -- 
> >>> Emmanuel Vadot <manu at bidouilliste.com> <manu at freebsd.org>
> >>> _______________________________________________
> >>> freebsd-arm at freebsd.org <mailto:freebsd-arm at freebsd.org> mailing list
> >>> https://lists.freebsd.org/mailman/listinfo/freebsd-arm <https://lists.freebsd.org/mailman/listinfo/freebsd-arm>
> >>> To unsubscribe, send any mail to "freebsd-arm-unsubscribe at freebsd.org <mailto:freebsd-arm-unsubscribe at freebsd.org>"
> >> 
> >> 
> >> -- 
> >> Emmanuel Vadot <manu at bidouilliste.com <mailto:manu at bidouilliste.com>> <manu at freebsd.org <mailto:manu at freebsd.org>>
> > 
> > _______________________________________________
> > freebsd-arm at freebsd.org mailing list
> > https://lists.freebsd.org/mailman/listinfo/freebsd-arm
> > To unsubscribe, send any mail to "freebsd-arm-unsubscribe at freebsd.org"


-- 
Emmanuel Vadot <manu at bidouilliste.com> <manu at freebsd.org>


More information about the freebsd-arm mailing list