I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Post Reply
symbytech
Posts: 11
Joined: Tue Sep 24, 2019 6:51 pm
languages_spoken: english
Has thanked: 1 time
Been thanked: 1 time
Contact:

I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by symbytech » Tue Oct 01, 2019 1:41 pm

I've got an Odroid-N2 that connects to two TCA9548A I2C multiplexers with ten INA219 sensors attached. The Odroid-N2 can see the two multiplexers and a Sparkfun 9DoF IMU M0.

Code: Select all

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


68 = IMU
70 & 71 = TCA9548A
No INA219 are seen

I found a similar post, viewtopic.php?t=29419, for the Odroid XU3/XU4/MC1/HC1/HC2. It seems to point to the kernel, however, the kernel currently installed should be capable of working with the INA219 behind the TCA9548A on the Odroid-N2. The kernel installed is Kernel 4.9.190-62 #1 SMP Preempt.

We tried to change the kernel from CONFIG_I2C_MUX_PCA954x is not setup to CONFIG_I2C_MUX_PCA954x=y and then recompile however it failed and crashed the install leaving us having to flash a whole new image on the eMMC.

I'm hoping someone can give an utter newbie to Odroid and Linux a step by step guide to remedy the problem.

Linux install: Ubuntu MATE 18.04.3 LTS (v2.0) (Updated / Upgraded)
Odroid: Odroid-N2

User avatar
tobetter
Posts: 4036
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 43 times
Been thanked: 188 times
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by tobetter » Tue Oct 01, 2019 2:53 pm

Can you specify the error you faced after compiling?
Are you able to access the I2C devices IMU and TCA9546A when INA219 is not enabled?

symbytech
Posts: 11
Joined: Tue Sep 24, 2019 6:51 pm
languages_spoken: english
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by symbytech » Tue Oct 01, 2019 4:08 pm

I did the following:

Code: Select all

sudo apt update
sudo apt install git
git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidn2-4.9.y
cd linux
make odroidn2_defconfig
make menuconfig
In the kernel options I select:

I2C Support --->
Multiplexer I2C Chip Support ---> (I2C bus multiplexing support is *)
Philips PCA954x I2C Mux/switches (have selected both * & M)
Saved as .config

Code: Select all

~/linux$ make -j4
~/linux$ sudo make modules_install
~/linux$ sudo cp -f arch/arm64/boot/Image.gz arch/arm64/boot/dts/amlogic/meson64_odroidn2.dtb /media/boot/
~/linux$ sudo sync
~/linux$ sudo reboot
During ~/linux$ make -j4, it gives:

Code: Select all

WARNING: modpost: Found 2 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
The rest goes through fine. Once rebooted, I do the following:

Code: Select all

cd linux
make menuconfig
I do this to verify the kernel is still configured as I saved it. Next I do the following:

Code: Select all

sudo i2cdetect -y 2
And get:

Code: Select all

root@slave:~/linux# sudo i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: 70 71 -- -- -- -- -- --                         
68 = IMU
70 & 71 = Muxes

I don't know how to access them beyond the above.

User avatar
tobetter
Posts: 4036
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 43 times
Been thanked: 188 times
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by tobetter » Thu Oct 03, 2019 1:32 am

You could try the attached patch from your Linux kernel build, after building do copy meson64_odroidn2.dtb to the boot partition.

Code: Select all

$ patch -p1 < odroidn2_pca9548.patch
$ make
But I have not tested this with the mux.

symbytech
Posts: 11
Joined: Tue Sep 24, 2019 6:51 pm
languages_spoken: english
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by symbytech » Thu Oct 03, 2019 10:21 pm

tobetter wrote:
Thu Oct 03, 2019 1:32 am
You could try the attached patch from your Linux kernel build, after building do copy meson64_odroidn2.dtb to the boot partition.
Where do I find the attachment?

User avatar
tobetter
Posts: 4036
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 43 times
Been thanked: 188 times
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by tobetter » Fri Oct 04, 2019 4:28 pm

symbytech wrote:
Thu Oct 03, 2019 10:21 pm
tobetter wrote:
Thu Oct 03, 2019 1:32 am
You could try the attached patch from your Linux kernel build, after building do copy meson64_odroidn2.dtb to the boot partition.
Where do I find the attachment?
I've attached again, please do gunzip and apply the patch.
Attachments
odroidn2_pca9548.patch.gz
(367 Bytes) Downloaded 16 times

symbytech
Posts: 11
Joined: Tue Sep 24, 2019 6:51 pm
languages_spoken: english
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by symbytech » Mon Oct 07, 2019 3:52 am

Thanks for the patch. Downloaded and did the following:

Code: Select all

root@slave:/home/odroid/Downloads# patch -p1 < odroidn2_pca9548.patch
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dts b/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dts
|index 4ece5798b1eb..4e77fb614c59 100644
|--- a/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dts
|+++ b/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dts
--------------------------
File to patch: 
There's an error "can't find file to patch at input line 5". What should I do here? How is this problem resolved? My apologies for all the questions. I'm a complete newbie to Linux and Odroid-N2.

User avatar
tobetter
Posts: 4036
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 43 times
Been thanked: 188 times
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by tobetter » Mon Oct 07, 2019 11:27 am

symbytech wrote:
Mon Oct 07, 2019 3:52 am
Thanks for the patch. Downloaded and did the following:

Code: Select all

root@slave:/home/odroid/Downloads# patch -p1 < odroidn2_pca9548.patch
can't find file to patch at input line 5
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dts b/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dts
|index 4ece5798b1eb..4e77fb614c59 100644
|--- a/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dts
|+++ b/arch/arm64/boot/dts/amlogic/meson64_odroidn2.dts
--------------------------
File to patch: 
There's an error "can't find file to patch at input line 5". What should I do here? How is this problem resolved? My apologies for all the questions. I'm a complete newbie to Linux and Odroid-N2.
I don't think that the "Download" directory is the top of the Linux kernel source tree.

symbytech
Posts: 11
Joined: Tue Sep 24, 2019 6:51 pm
languages_spoken: english
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by symbytech » Tue Oct 08, 2019 5:15 am

Thanks for your info. Patch installed as per history below:

Code: Select all

 407  git clone --depth 1 https://github.com/hardkernel/linux.git -b odroidn2-4.9.y
  408  cd linux
  409  make odroidn2_defconfig
  410  make menuconfig
  411  ls
  412  cp /home/odroid/Downloads/odroidn2_pca9548.patch .
  413  ls
  414  patch -p1 < odroidn2_pca9548.patch
  415  make
  416  make modules_install
  417  cp -f arch/arm64/boot/Image.gz arch/arm64/boot/dts/amlogic/meson64_odroidn2.dtb /media/boot/
  418  sync
  419  reboot
Result is as follows:

Code: Select all

root@slave:~# i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: UU 71 -- -- -- -- -- --                         
What is the UU for and how do we resolve this? Please let me know if there's any faults. Perhaps you could provide a small guide to follow?

User avatar
tobetter
Posts: 4036
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 43 times
Been thanked: 188 times
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by tobetter » Tue Oct 08, 2019 8:28 am

Are able to see more I2C device nodes? Please do use command "ls /dev/i2c*" .

"Tapatalk wishes you to have fun with ODROID"


symbytech
Posts: 11
Joined: Tue Sep 24, 2019 6:51 pm
languages_spoken: english
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by symbytech » Wed Oct 09, 2019 4:04 am

We created a second channel as there are two muxes, one @70 & one @71.

Code: Select all

root@slave:~# ls /dev/i2c*
/dev/i2c-10  /dev/i2c-13  /dev/i2c-16  /dev/i2c-19  /dev/i2c-3  /dev/i2c-7
/dev/i2c-11  /dev/i2c-14  /dev/i2c-17  /dev/i2c-2   /dev/i2c-5  /dev/i2c-8
/dev/i2c-12  /dev/i2c-15  /dev/i2c-18  /dev/i2c-20  /dev/i2c-6  /dev/i2c-9
Now all the channels are seen including those not in use.

How do we get the address of each INA219 sensor in order to get the data?

How are the unused channels disabled to avoid address conflicts?

User avatar
tobetter
Posts: 4036
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 43 times
Been thanked: 188 times
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by tobetter » Wed Oct 09, 2019 5:36 am

symbytech wrote:
Wed Oct 09, 2019 4:04 am
We created a second channel as there are two muxes, one @70 & one @71.

Code: Select all

root@slave:~# ls /dev/i2c*
/dev/i2c-10  /dev/i2c-13  /dev/i2c-16  /dev/i2c-19  /dev/i2c-3  /dev/i2c-7
/dev/i2c-11  /dev/i2c-14  /dev/i2c-17  /dev/i2c-2   /dev/i2c-5  /dev/i2c-8
/dev/i2c-12  /dev/i2c-15  /dev/i2c-18  /dev/i2c-20  /dev/i2c-6  /dev/i2c-9
Now all the channels are seen including those not in use.

How do we get the address of each INA219 sensor in order to get the data?

How are the unused channels disabled to avoid address conflicts?
How many INA219 are wired with TCA9548? Can you share the block diagram or schematic only about the connection of I2C bus?

symbytech
Posts: 11
Joined: Tue Sep 24, 2019 6:51 pm
languages_spoken: english
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by symbytech » Wed Oct 09, 2019 3:57 pm

There are two TCA9548, each currently has five INA219 sensors.

Attached is a flow diagram and the wiring (very untidy, sorry).

The INA219 sensors pass data to the TCA9548 muxes (two TCA9548 muxes with five INA219 sensors per TCA9548). The TCA9548 passes the data to a passive I2C bus (simply to bring together non-conflicting addressed devices). The I2C bus also has an IMU connected. The combined data goes from the bus to the I2C-2 channel.
Attachments
I2C Wiring.jpeg
I2C Wiring.jpeg (306.05 KiB) Viewed 210 times
I2C Layout.png
I2C Layout.png (12.11 KiB) Viewed 210 times

User avatar
tobetter
Posts: 4036
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 43 times
Been thanked: 188 times
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by tobetter » Thu Oct 10, 2019 5:26 pm

This is very messy... :o

Have you succeeded to get data from INA219 directly without multiplexer? Just curious if INA219 driver can work or not with your kernel.
Also, can you look into /sys/bus/i2c what are there with the multiplexers?

symbytech
Posts: 11
Joined: Tue Sep 24, 2019 6:51 pm
languages_spoken: english
Has thanked: 1 time
Been thanked: 1 time
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by symbytech » Thu Oct 10, 2019 9:22 pm

tobetter wrote:
Thu Oct 10, 2019 5:26 pm
This is very messy... :o
It is messy. Once all the hardware is tested, I'll install it nicely :-)
tobetter wrote:
Thu Oct 10, 2019 5:26 pm
Have you succeeded to get data from INA219 directly without multiplexer? Just curious if INA219 driver can work or not with your kernel.
I've not tested the INA219 sensor on its own. However, I've tested the two TCA9548A muxes & ten INA219 sensors in the same configuration using an Arduino Mega & I2C scanner code which detected all the muxes & INA219 sensors.
tobetter wrote:
Thu Oct 10, 2019 5:26 pm
Just curious if INA219 driver can work or not with your kernel.
Below is my kernel details.

Code: Select all

root@slave:/sys/bus/i2c/devices# uname -a
Linux slave 4.9.190+ #3 SMP PREEMPT Tue Oct 8 13:30:46 SAST 2019 aarch64 aarch64 aarch64 GNU/Linux
tobetter wrote:
Thu Oct 10, 2019 5:26 pm
Also, can you look into /sys/bus/i2c what are there with the multiplexers?

Code: Select all

root@slave:/sys/bus/i2c/devices# ls
2-0070  3-0051  i2c-11  i2c-13  i2c-15  i2c-17  i2c-19  i2c-20  i2c-5  i2c-7  i2c-9
2-0071  i2c-10  i2c-12  i2c-14  i2c-16  i2c-18  i2c-2   i2c-3   i2c-6  i2c-8
I believe 2-0070 & 2-0071 are the muxes. i2c-2 is the bus in use & i2c-3 is the additional bus. I would imagine the Sparkfun 9DoF Razor IMU M0 is 3-0051. There 16 channels that I believe may be the INA219 sensors. Perhaps this explains the 21 I2C channels above?

Code: Select all

root@slave:/sys/bus/i2c/devices# i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- 1a -- -- -- -- -- 
20: 20 -- -- -- -- -- 26 27 28 -- 2a -- 2c -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: UU UU -- -- -- -- -- --                         
The interesting thing is when I run i2cdetect -y 2 immediately again I get the result below where most of the addresses vanish.

Code: Select all

root@slave:/sys/bus/i2c/devices# i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: UU UU -- -- -- -- -- --                         
Are we allowed to request for paid services on this forum?

User avatar
tobetter
Posts: 4036
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 43 times
Been thanked: 188 times
Contact:

Re: I2C Mux Driver TCA9548A & INA219 Sensor on Odroid-N2

Unread post by tobetter » Fri Oct 11, 2019 5:04 pm

I wonder how you are going to interact with INA219 on your system. When I read the datasheet of PCA9548, it has a control register that can select a channel and a select channel can be accessed through PCA9548. After reading the driver of PCA9548, it has a function to select a channel, I guess PCA9548 allows to access a child component through /dev/i2c-*. Since I do not have the hardware, what I am not sure is which device node is which channel connected to PCA9548. Maybe you could discover more from /sys/bus/i2c/devices/i2c-*.

Post Reply

Return to “Issues”

Who is online

Users browsing this forum: No registered users and 1 guest