volts.py output problem

The more technical aspects of Spirit, and carry-over discussion from Kickstarter updates.
Kevin
Posts: 181
Joined: Tue Jul 28, 2015 12:56 am

Re: volts.py output problem

Postby Kevin » Fri Mar 02, 2018 1:23 am

Okay everyone, I been working this today. Sure enough, building up a clean new unit, I get the exact problem as the rest of you.

First observation is the code on at least some of the SD cards is definitely different, even though I purchased them all together. When I went through my own setup steps, a few things were different. The raspi-config system is totally different options.

Looking at a scope, I see there is a problem during the read sequence, which is driven from the Pi side. I can't tell if it's in the chip hardware or somewhere in the software driver for the i2c on the Pi side.

Here are a couple notes I am hoping some of you can play with. Then I will post a bunch of screen dumps in a follow up post of the suggestions you guys had above....

This may be a relevant post:
https://forums.adafruit.com/viewtopic.php?f=19&t=118882

The person says they solved their problem "I had to load the module i2c-bcm2708 additionally to the already loaded module i2c-bcm2835. And after doing this I got a new folder in the /sys/module/ directory named i2c_bcm2708."

I don't know how you would load a module into an already loaded module. (Don't you just HATE HATE HATE :evil: :evil: :evil: when someone says they fixed it but don't post an actual command?).

Anyway, I think this problem is somewhere in one of the smbus modules or the low level i2c driver.

On both units I run lsmod.

On the working unit, I have i2c_bcm2708
On the non working newer unit I have i2c_bcm2835

I'm really hoping someone can help on this. I'll put some dumps in the next post. Thanks everyone. This i2c thing is critical to making the whole thing work like it's supposed to. I can say I'll never design anything with a Pi ever again. Dealing with that thing took a simple project and added about a thousand hours of un-necessary headache.

Kevin
Posts: 181
Joined: Tue Jul 28, 2015 12:56 am

Re: volts.py output problem

Postby Kevin » Fri Mar 02, 2018 1:44 am

Here are some differences between the working and non-working units. If you think anything else will be helpful, please post the exact command I should run and I'll post it up.

Code: Select all

dpkg-query -l | grep -i i2c output:

Working Unit:
ii  i2c-tools                             3.1.1+svn-2                               armhf        heterogeneous set of I2C tools for Linux
ii  python-smbus                          3.1.1+svn-2                               armhf        Python bindings for Linux SMBus access through i2c-dev

Non-Working Unit:
ii  i2c-tools                             3.1.1+svn-2                               armhf        heterogeneous set of I2C tools for Linux
ii  python-smbus                          3.1.1+svn-2                               armhf        Python bindings for Linux SMBus access through i2c-dev
ii  python3-codebug-i2c-tether            0.2.3-1                                   all          CodeBug I2C Tether module.
ii  python3-smbus                         3.1.1+svn-2                               armhf        Python 3 bindings for Linux SMBus access through i2c-dev


Code: Select all

uname -a output:

Working Unit:
Linux raspberrypi 4.1.18-v7+ #846 SMP Thu Feb 25 14:22:53 GMT 2016 armv7l GNU/Linux

Non-Working Unit:
Linux raspberrypi 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux


Code: Select all

cat /boot/config.txt | grep i2c output:  (same between them)

Working Unit:
dtparam=i2c_arm=on
dtparam=i2c_arm_baudrate=400000

Non-Working Unit:
dtparam=i2c_arm=on
dtparam=i2c_arm_baudrate=400000

gpvillamil
Posts: 75
Joined: Fri Jan 26, 2018 5:03 pm

Re: volts.py output problem

Postby gpvillamil » Fri Mar 02, 2018 4:05 am

Kevin, try this:

Code: Select all

lsmod


That will list installed kernel modules (basically device drivers), you might find a discrepancy there.

Then try

Code: Select all

cat /etc/modules


if you need to manually add drivers, you can do it by adding them to that file. For example, my /etc/modules file contains:

i2c-dev
bcm2835-v4l2 // camera driver

You could test without making permanent changes by trying

Code: Select all

sudo modprobe i2c-bcm2708


If volts.py works after that, just add

Code: Select all

i2c-bcm2708
to /etc/modules

I will try this on my Spirit tomorrow.

This article was helpful: http://ozzmaker.com/i2c/ - be aware that you can test by trying modprobe <driver> first before editing any files.

Nickw58
Posts: 20
Joined: Sun Oct 15, 2017 11:13 am

Re: volts.py output problem

Postby Nickw58 » Fri Mar 02, 2018 10:02 am

Hi,

For comparison outputs from my Non-working unit.

Code: Select all

lsmod


Module                  Size  Used by
bnep                   12051  2
hci_uart               20020  1
btbcm                   7916  1 hci_uart
bluetooth             365511  22 hci_uart,bnep,btbcm
brcmfmac              222874  0
brcmutil                9092  1 brcmfmac
joydev                  9988  0
spidev                  7373  0
snd_bcm2835            24427  1
cfg80211              543027  1 brcmfmac
snd_pcm                98501  1 snd_bcm2835
snd_timer              23968  1 snd_pcm
rfkill                 20851  4 bluetooth,cfg80211
snd                    70032  5 snd_timer,snd_bcm2835,snd_pcm
i2c_bcm2835             7167  0
spi_bcm2835             7596  0
bcm2835_gpiomem         3940  2
evdev                  12423  4
fixed                   3285  0
uio_pdrv_genirq         3923  0
uio                    10204  1 uio_pdrv_genirq
i2c_bcm2708             5994  0
i2c_dev                 6913  0
fuse                   99603  3
ipv6                  408971  46


Code: Select all

dpkg-query -l | grep i2c

ii  i2c-tools                             3.1.1+svn-2                                armhf        heterogeneous set of I2C tools for Linux
ii  libi2c-dev                            3.1.1+svn-2                                all          userspace I2C programming library development files
ii  python-smbus                          3.1.1+svn-2                                armhf        Python bindings for Linux SMBus access through i2c-dev


Code: Select all

uname -a

Linux raspberrypi 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux



Code: Select all

cat /boot/config.txt | grep i2c

#dtparam=i2c_arm=on
dtparam=i2c_arm=on
dtparam=i2c1=on
dtparam=i2c_arm_baudrate=400000



Code: Select all

cat /etc/modules

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

i2c-dev
i2c-bcm2708

Kevin
Posts: 181
Joined: Tue Jul 28, 2015 12:56 am

Re: volts.py output problem

Postby Kevin » Fri Mar 02, 2018 4:59 pm

Thanks gpvillamil.

I tried

Code: Select all

sudo modprobe i2c-bcm2708
after running the commands below and just tried volts again and it didn't work. I wonder if the other driver must be removed first? (the i2c_bcm2835).

Here are the outputs requested....

Code: Select all

lsmod

Working Unit:
Module                  Size  Used by
bnep                   10336  2
hci_uart               13533  1
btbcm                   4196  1 hci_uart
bluetooth             317981  22 bnep,btbcm,hci_uart
brcmfmac              177546  0
brcmutil                5501  1 brcmfmac
cfg80211              389253  1 brcmfmac
rfkill                 16036  4 cfg80211,bluetooth
snd_bcm2835            19802  0
i2c_bcm2708             4920  0
spi_bcm2835             7074  0
bcm2835_gpiomem         2860  2
bcm2835_rng             1763  0
snd_pcm                73442  1 snd_bcm2835
snd_timer              18792  1 snd_pcm
snd                    50779  3 snd_bcm2835,snd_timer,snd_pcm
uio_pdrv_genirq         2944  0
uio                     7753  1 uio_pdrv_genirq
i2c_dev                 5671  0
fuse                   80694  1
ipv6                  338574  32

Non-Working Unit:
Module                  Size  Used by
bnep                   12051  2
hci_uart               20020  1
btbcm                   7916  1 hci_uart
bluetooth             365511  22 hci_uart,bnep,btbcm
brcmfmac              222874  0
brcmutil                9092  1 brcmfmac
cfg80211              543027  1 brcmfmac
rfkill                 20851  4 bluetooth,cfg80211
spidev                  7373  0
snd_bcm2835            24427  0
snd_pcm                98501  1 snd_bcm2835
snd_timer              23968  1 snd_pcm
i2c_bcm2835             7167  0
snd                    70032  3 snd_timer,snd_bcm2835,snd_pcm
bcm2835_gpiomem         3940  2
spi_bcm2835             7596  0
uio_pdrv_genirq         3923  0
uio                    10204  1 uio_pdrv_genirq
fixed                   3285  0
i2c_dev                 6913  0
fuse                   99603  1
ipv6                  408971  38



Code: Select all

cat /etc/modules

Both units produce this output:

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

i2c-dev


gpvillamil
Posts: 75
Joined: Fri Jan 26, 2018 5:03 pm

Re: volts.py output problem

Postby gpvillamil » Sat Mar 03, 2018 12:52 am

Hi Kevin,

I believe that what you want to do is create the file /etc/modprobe.d/raspi-blacklist.conf if it doesn't exist.

To this file, add the names of modules that you don't want to load. So for example your file would look like:

Code: Select all

# blacklist spi and i2c by default (many users don't need them)

blacklist i2c-bcm2835


That will prevent the i2c-bcm2835 module from loading, and then you could add i2c-bcm2708 to /etc/modules.

With this you should have the same modules loaded as your working unit. It's weird that I2C would work with one chip but not another.

FWIW the switch from the 2708 driver to the 2835 driver happened with the update to Raspbian 4.9, and I am hearing reports of similar issues with other programs. (Broadcom 2708 is the original chip used as the RPis CPU, and Broadcom 2835 is the same core but in a SOC which includes RAM as part of the same package)

Nickw58
Posts: 20
Joined: Sun Oct 15, 2017 11:13 am

Re: volts.py output problem

Postby Nickw58 » Sat Mar 03, 2018 9:59 am

Hi Guys,

I have tried adding i2c_bcm2835 to the blacklist.conf file. When I do this it stops i2c working, running i2cdetect fails with 'cannot open file' .
If I edit the blacklist file and change the line to 'blacklist i2c_bcm2708, so i12c_bcm2835 is loaded, i2cdetect now works but the Volts.py module still fails.

I also did a NOOBS fresh install on another Pi I have, then checked which module is loaded. By default i2c is not enabled on a fresh install so 'lsmod' showed no i2c_bcm2708 or 2835. Enabling i2c via the Pi Pixel interface I see module i2c_bcm2835 loaded and i2cdetect now works.

So for both my Pi's I need to have i2c_bcm2835 loaded for i2cdetect to run, but I think for your working unit Kevin you have i2c_bcm2708 loaded.

Kevin
Posts: 181
Joined: Tue Jul 28, 2015 12:56 am

Re: volts.py output problem

Postby Kevin » Sat Mar 03, 2018 7:11 pm

Nickw58 wrote:So for both my Pi's I need to have i2c_bcm2835 loaded for i2cdetect to run, but I think for your working unit Kevin you have i2c_bcm2708 loaded.


Yea I'm thinking this may be it. How can we make 2835 not load at all, but instead load 2708? If we could try that and things work I would be very happy but I don't know how to try that.

I haven't done this yet but hope to have time this afternoon to swap the cards between the two units and make absolute sure it is purely a software issue (and not that they changed something in the hardware or in the broadcom chip on the actual Pi).

If someone can do this, please share exactly what you edit or what commands should be run.

Thanks again everyone. I couldn't do this without you all. :)

Kevin
Posts: 181
Joined: Tue Jul 28, 2015 12:56 am

Re: volts.py output problem

Postby Kevin » Sat Mar 03, 2018 7:13 pm

gpvillamil wrote:FWIW the switch from the 2708 driver to the 2835 driver happened with the update to Raspbian 4.9, and I am hearing reports of similar issues with other programs. (Broadcom 2708 is the original chip used as the RPis CPU, and Broadcom 2835 is the same core but in a SOC which includes RAM as part of the same package)


Are you saying the chip is physically a different model? That could be big problems depending on how exactly they implemented the i2c hardware.

Is there a command I can run to determine exactly what hardware version or exactly what chip is installed?

gpvillamil
Posts: 75
Joined: Fri Jan 26, 2018 5:03 pm

Re: volts.py output problem

Postby gpvillamil » Sat Mar 03, 2018 7:18 pm

All Pi 3s should have the same hardware.

The switch is from a driver that referenced the original CPU core (2708) to referencing the new SOC (2835). The new SOC that is used in all Pi3s is apparently a 2708 packaged together with RAM in one chip and called a 2835.

I don't know why the drivers would have changed, or why it should have such an effect. However, I do see a lot of chatter about reverting to the 2708 drivers, to avoid I2C comms issues.

Kevin wrote:Are you saying the chip is physically a different model? That could be big problems depending on how exactly they implemented the i2c hardware.

Is there a command I can run to determine exactly what hardware version or exactly what chip is installed?


Who is online

Users browsing this forum: No registered users and 2 guests