pmc
Posts: 36
Joined: Sun Mar 31, 2013 8:07 pm

Pi touch i2c and device tree

Thu Dec 17, 2015 1:49 am

Have the Pi touch screen and an Adafruit audio amplifier. When all is set for i2c, and no device tree, then i2cdetect displays the device value of the amplifier, however the touch screen stops working, because there is no device tree loaded.

When I enable the device tree, then the i2cdetect can't find the Adafruit device.

Any solid suggestions of how can I get the touch screen to work, and have the i2c working too.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9499
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Pi touch i2c and device tree

Thu Dec 17, 2015 8:08 am

Which version of Pi are you using? And exactly which adafruit audio card?
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

pmc
Posts: 36
Joined: Sun Mar 31, 2013 8:07 pm

Re: Pi touch i2c and device tree

Thu Dec 17, 2015 5:29 pm

Thanks for the response. Two different Pi's, model B and Pi2. Tried both with different SD cards.

MAX9744, this one https://www.adafruit.com/products/1752

Have tried with Wheezy and Jessie. Done all the upgrades. Tried RPI-update too. and that sent the mouse cursor flying everywhere, but where I wanted it.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9499
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Pi touch i2c and device tree

Thu Dec 17, 2015 6:19 pm

B with touchscreen takes both I2C controllers, so no you can't have one then talking to your amp. See viewtopic.php?f=108&t=120460&start=25#p862747 and viewtopic.php?f=44&t=129171.
I'm assuming you've jumpered I2C-1 across to the touchscreen to get it to work rather than the hack some people have done to hook into the camera I2C pins.

Pi2 should be OK.

I trust you are using I2C-1 / GPIOs 2&3 / pins 3&5 as your I2C pins to the amp. There should be no issue there, just need to add dtparam=i2c_arm=on to boot/config.txt
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

pmc
Posts: 36
Joined: Sun Mar 31, 2013 8:07 pm

Re: Pi touch i2c and device tree

Thu Dec 17, 2015 8:42 pm

I use:

pin 1 to power the screen, and pin 6 for its ground

pin 3 to power 5v to the amp vi2c pin and pin 9 for its ground. The Pi2 will not boot when the logic is 3.3 volts. It sits with both led's on.

The SCA1 and SCL1 are pins 3 & 5 to the amp's pins of the same.

There is nothing blacklisted

In modules:
snd-bcm2835
12c-bcm2708
i2c-dev

In config.txt
dtparam=i2c_arm=on
dtparam=i2c1=on

SPI is off, the i2c and device tree are on

i2cdetect comes up with nothing. I can get it to work without the touch screen.

FWIW, the plan is to put the touch screen into a car dashboard, thus the need for the 20 watt amp and to be able to control its volume via i2c.

User avatar
joan
Posts: 15038
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Pi touch i2c and device tree

Thu Dec 17, 2015 8:51 pm

Typo? i2c-bcm2708 or 12c-bcm2708?

Having i2c-bcm2708 in /etc/modules will stop I2C working if you have I2C enabled in device tree.

So remove or comment out i2c-bcm2708 from /etc/modules.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9499
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Pi touch i2c and device tree

Thu Dec 17, 2015 9:10 pm

dtparam=i2c_arm=on and dtparam=i2c1=on are aliases for the same thing on all but the rev1 model B.

joan is right - you shouldn't need i2c-bcm2708 in /etc/modules for i2c when you're using device tree. I wasn't aware that it threw a wobbler if you did put it in there though.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

pmc
Posts: 36
Joined: Sun Mar 31, 2013 8:07 pm

Re: Pi touch i2c and device tree

Thu Dec 17, 2015 11:24 pm

To ease the trial and error I installed VNC server so that I could remotely access the Pi with the touch screen.

Yes it was a typo, and I did remove it... when the setting stays in modules, then i2cdetect complains it can't find /dev/i2c-1 file.

Am thinking I should reboot the Pi twice when I change the config because other things change. I can now get the 3.3v logic connected and the Pi will now boot with it. It is reconnected to 5v. I just wanted to see if there was a difference with i2cdetect. However, I get nothing with i2cdetect.

To add further insult, I dumped the Pi screen and now can't get the i2c device to show up at all, where as I had it working previously without the screen connected. Have no idea on the why etc. :)

pmc
Posts: 36
Joined: Sun Mar 31, 2013 8:07 pm

Re: Pi touch i2c and device tree

Fri Dec 18, 2015 1:55 am

After tracing my steps, i2cdetect is finding the amp again. I turned off the device tree to make it re-appear.

Again, to use the Pi touch screen, I need the device tree up. Will work on it :)

Thanks to Joan for the summary of settings in another message.

viewtopic.php?t=98407

pmc
Posts: 36
Joined: Sun Mar 31, 2013 8:07 pm

Re: Pi touch i2c and device tree

Fri Dec 18, 2015 4:34 am

My depth on this is not as great as yours, appreciate this in the question.

Is it possible to map the amp SDA/SDL to other ports on the Pi... or create a pathway in the device tree to see the SDA/SDL. ie: a similated device attaches to a real device in i2c ? Am trying to understand the direction of the device tree and i2c. Other minds closer to the device, know better than I.

User avatar
joan
Posts: 15038
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Pi touch i2c and device tree

Fri Dec 18, 2015 9:17 am

pmc wrote:My depth on this is not as great as yours, appreciate this in the question.

Is it possible to map the amp SDA/SDL to other ports on the Pi... or create a pathway in the device tree to see the SDA/SDL. ie: a similated device attaches to a real device in i2c ? Am trying to understand the direction of the device tree and i2c. Other minds closer to the device, know better than I.
The Pi has two I2C buses, i2c-0, and i2c-1. i2c-0 uses GPIO 0/1 and i2c-1 uses GPIO 2/3. Consider those GPIO fixed, i.e. you can't move those buses to different GPIO.

You shouldn't use i2c-0 unless nothing else works as doing so may break (I think) the correct operation of HATs and the camera module.

You could enable i2c-0 and use pins 27/28 (where GPIO 0/1 are located). You will need to add pull-up resistors to 3V3 of say 2k to those pins for proper bus operation.

This shouldn't be needed, as I2C is a bus. You should be able to get your audio device working on i2c-1. It should only fail if more than one device is using the same address.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9499
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Pi touch i2c and device tree

Fri Dec 18, 2015 9:23 am

TBH it sounds like your real problem (at least on the Pi2) is that you haven't got your audio amp working with device tree. Forget the display temporarily and get device tree running, then add the display in and it should just work.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

pmc
Posts: 36
Joined: Sun Mar 31, 2013 8:07 pm

Re: Pi touch i2c and device tree

Sun Dec 20, 2015 5:41 am

In the file dt-blob.dts, there is a pin_config, pin@default that is set to use i2c1.

pin@p2 { function = "i2c1"; termination = "pull_up"; }; // I2C 1 SDA
pin@p3 { function = "i2c1"; termination = "pull_up"; }; // I2C 1 SCL

and the pin defines

pin_define@DISPLAY_SDA {
type = "internal";
number = <2>;
};
pin_define@DISPLAY_SCL {
type = "internal";
number = <3>;
};

I am assuming these can be pasted into any of the Pi models that are listed below the default, to then create the blob file to boot with.

pmc
Posts: 36
Joined: Sun Mar 31, 2013 8:07 pm

Re: Pi touch i2c and device tree

Sun Dec 20, 2015 6:22 am

I pasted the wrong text, and wanted to know if these values are correct for making the blob... obtained from e-linux.

pin_define@I2C1_SDA {
type = "internal";
number = <2>;
};
pin_define@I2C1_SCL {
type = "internal";
number = <3>;

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9499
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Pi touch i2c and device tree

Sun Dec 20, 2015 9:04 am

??? What are you trying to do with that lot?
dt-blob.dts sets up the initial GPIO config from the GPU.
The Linux device tree then updates it based on the drivers that you load. eg Adding dtparam=i2c_arm=on will use https://github.com/raspberrypi/linux/bl ... -b.dts#L26 and change the mode of the defined pins (in this case 2&3) to expose the function.

Take a recent image.
Add "i2c_arm=on" to /boot/config.txt
Add "i2c-dev" to /etc/modules
Reboot
/dev/i2c-1 should now be present and all the pin muxing done to put it on GPIOs 2&3.
Use it to talk to your MAX9744 from a language of your choice.


Just looking back on joan's comments, using i2c-0 WILL break the touchscreen control as well as the camera and probably HATs.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

pmc
Posts: 36
Joined: Sun Mar 31, 2013 8:07 pm

Re: Pi touch i2c and device tree

Sun Dec 20, 2015 11:38 am

Thanks for the reply... the pinouts are confusing across models. I am using different images. Have an FM Tx, and it has the same issues. If and when I get this resolved, I will update this.

pmc
Posts: 36
Joined: Sun Mar 31, 2013 8:07 pm

Re: Pi touch i2c and device tree

Sun Dec 20, 2015 12:01 pm

I should add for info purposes... my intent is to have a Pi2 Touch inside a 15 year old car that currently has an FM `cassette player'... seen any of these lately LOL.. If the touch screen hogs things, then I have the option of having another Pi to run the specific device, and then I need the I/O for it to the touch screen Pi. Using a network connection and a crossover cable being a consideration. I considered taking another Pi and keeping it headless, using the GPIO's for my device (amp & FM Rx/Tx) purposes, thus the change of the blob, was considered... will I get there... at this rate.. perhaps :)

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 9499
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Pi touch i2c and device tree

Sun Dec 20, 2015 10:18 pm

On a Pi2 the display will have no impact whatsoever on the availability of GPIO pins. It uses i2c-0, which is reserved for the GPU to talk to the camera, display, and HATs.

Pinouts - stick with the Pi2 and refer to http://www.element14.com/community/docs ... ock-pinout
That should be standard between Pi2, A+, B+, and Zero, so that covers all the mainstream Pi flavours.
Minor potential for confusion in that I'll refer to GPIO number which is the GPIO pin on the SoC, not the pin number on the header. The diagram quotes both anyway. (wiringPi does have a different numbering that is unique to itself, but can also work with SoC GPIO numbers).

For I2C you want GPIOs 2&3, which are pin numbers 3 & 5 on the 40 way header. Don't forget to include a ground between the devices as well. Those pins already have 1k8ohm I2C pull ups fitted, so you don't even need to worry about those. Just don't forget that the Pi only works with 3.3V signals - feeding 5V into GPIO pins will probably kill them.

From what you have posted of wanting to talk to an I2C controlled amplifier, FM Tx/Rx, and display, that is all perfectly feasible on one Pi. Unless you need the physical separation don't waste time on splitting it into 2 parts.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

pmc
Posts: 36
Joined: Sun Mar 31, 2013 8:07 pm

Re: Pi touch i2c and device tree

Sun Dec 20, 2015 10:44 pm

Other methods would be using the usb ports for the devices. SDR being the fm radio and more... same for the Tx. Then, I would only need to get the amp hooked into the i2c1. Want to keep some usb ports open for other devices... flash drive, memory stick etc.

Thanks for the reply.

Return to “Official Foundation Display”