New build - PicoBorg Reverse fails to load.

I just built my DiddyBorg this morning and have updated all the software as instructed. When trying to run any of the example scripts (diddySequence.py and diddyWeb.py) I receive the following message:

Loading PicoBorg Reverse on bus 1, address 44
Found a device at 44, but it is not a PicoBorg Reverse (ID 00 instead of 15)
PicoBorg Reverse was not found
Trying bus 0 instead
Loading PicoBorg Reverse on bus 0, address 44
Traceback (most recent call last):
File "./diddySequence.py", line 15, in
PBR.Init()
File "/home/pi/diddyborg/PicoBorgRev.py", line 264, in Init
self.Init(False)
File "/home/pi/diddyborg/PicoBorgRev.py", line 234, in Init
self.bus = smbus.SMBus(self.busNumber)
IOError: [Errno 2] No such file or directory

Any help would be appreciated as I'm new to this. Thank you.

Randy

piborg's picture

Not to worry, we have seen this problem as well and it seems to be just a software issue :)

From what I can tell it looks like recent versions of the Linux kernel for Raspbian (after 4.4.X) have some trouble with the I2C driver. This causes the commands which read data to receive 0s instead of the real values.

We found it could be fixed by setting the kernel to an older version, the most recent working one being 4.4.50. This can be done using rpi-update with the correct code for the 4.4.50 version:

sudo rpi-update 5224108

This issue affects most of our boards at the moment. Hopefully this will get sorted in the future and it will not be necessary to go back to an earlier kernel version.

Let us know if this fixes the problem for you as well.

Hi, I had the same issue and applied your fix which has worked. Annoying, however, that we can't update our OS. Is there any permanent fix in sight? Thanks. JB

piborg's picture

Unfortunately the problem is not with our code, but somewhere in newer versions Raspbian itself.

Basically the updates seem to stop I2C reads working on any level (always read 00), but I am not sure what has caused the problem or when it will be fixed.

On a side note using rpi-update is not really recommended for keeping up to date as it installs the latest "bleeding-edge" versions of things which are not yet considered stable.

I've had a similar problem but did not run RPI-update, but did run the standard update/upgrade commands...

sudo apt-get update && sudo apt-get dist-upgrade

on a Pi 3b which also stopped the two PiBorg PicoBorg Reverses I have installed from working!

On other pi the update/upgrade also caused pan tilt software and relay controls to stop working. So guess Pi Foundation has changed how GPIO is addressed too???

piborg's picture

This has all proven a bit strange, we are hoping to look into what is going on sometime this week but at this point it is rather unclear who is at fault and what exactly changed.

What we do know is the problem is not limited to Raspberry Pis. Someone else is trying to get the PicoBorg Reverse working on BeagleBone and having the same reading troubles: PicoBorg Reverse and Beaglebone. This is especially curious as he has other I2C devices behaving on the same board.

We found early on that the Raspberry Pi was not behaving well with clock stretching enabled. This is a mechanism which allows the device to let the processor know when it is ready to continue. Because of this the board instead works as fast as it can to try and get the data ready before the Raspberry Pi starts reading the values.

At the moment I am thinking along the lines that they have now implemented the clock stretching (which would be good), but in the process they have changed the timing when clock stretching is not used. If this is the case it can be fixed by changing the code on the PicoBorg Reverse itself, the downside is it requires a PICKit 2 or 3 to re-program the board.

I ran a update/upgrade on various Pi 10 days ago and hit a problem with python scripts that set gpio to high/low based on temperatures and a web enabled touch screen for relay switching using WebIOpi. On reboot it put all the set gpio to high, even though WebIOpi setup should set to them to out/low on boot. I had to scrap and use a back up version to reinstate a relay switching pi with pan/tilt camera etc as almost nothing worked. Sadly ignored this problem and rad update/upgrade on pi(s) with Reverses on them :-(

Your backdating solution worked for the Borgs.

piborg's picture

I just had a thought, could you try these two sequences and tell us the returned values:

i2cset -y 1 0x44 2
i2cget -y 1 0x44

and

i2cget -y 1 0x44 2 w

On a working copy with the LED off we see: 0x02 and 0x0002.

OK, not really sure what your asking me to do
If I type the code snippets you supplied at the the command line I get "Error: Read failed"

Here is the result from "sudo i2cdetect -y 1"

With two Reverses and one Ultra.

:~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- 0a 0b -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- 36 -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

This is on a pi that has had the kernel backdated as

sudo rpi-update 5224108

Sorry, I'm guessing i need to type

i2cset -y 1 0x44 2
i2cget -y 1 0x44

and

i2cget -y 1 0x44 2 w

into somthing other than the command line at pi@MyRaspberry:~ $
I am very happy to help though...?

piborg's picture

They are just simple command line programs to talk with I2C based devices.

The problem is I have given you commands for the standard PicoBorg Reverse I2C address, yours have been changed. The error is simply saying it failed to talk to a device at address 0x44.

Try with the 0x0A address instead:

i2cset -y 1 0x0A 2
i2cget -y 1 0x0A

and

i2cget -y 1 0x0A 2 w

Ah, I see... :-)
I get
0x00
and
0x0002

So the same as your result. But what happens with latest kernel and how to fix that is well beyond my already over extended ability!

piborg's picture

I got a chance to test this today, I can confirm that the latest download from raspberrypi.org works fine, but after a sudo apt-get dist-upgrade things stop working.

The problem is not limited to PicoBorg Reverse either, the same effect can be seen on UltraBorg and our ThunderBorg prototypes.

I did some playing around, as far as I can tell this is a slight change in behaviour from either the SMBus library or the actual I2C driver. What we found is using raw file I/O to do the write and read as separate calls seems to work.

I have re-written the ThunderBorg.py script to use the io and fcntl libraries instead of the smbus library, and all seems to be well for both write commands and read commands :)

This is good news as it seems that the only thing which needs to be change is the Python library itself, not the code on the board. In other words we should be able to update the code on the website to fix the problem.

We will do some more detailed testing tomorrow to confirm that everything does indeed work, then I will make a start on fixing the PicoBorg Reverse and UltraBorg libraries so they work as well.

I will wait for your updates before updating Rpi from the foundation. Its a shame there is nothing on their web site / forum explaining this as it affects more than just Borg! Also waiting for my Thunderborg... :-)

piborg's picture

Hopefully we will get the changes made and tested today, if not probably tomorrow.

This sort of problem has happened before, either the Raspberry Pi B+ or 2 when first released seemed to have timing issues. This affected both GPIO and I2C behaviour, in particular it stopped the software PWM functionality from WiringPi behaving correctly :(

We are expecting to start shipping ThunderBorgs sometime next week, we are nearly ready :)

I was about to do a dist-upgrade on my DiddyBorg Pi 3 as I haven't up-dated it for a while. Will this affect my 18 month old PicoBorg Reverse and UltraBorg? Should I wait until you've sorted this out as I don't want my Diddy to get sick and baddy!

piborg's picture

I would recommend waiting, both boards will probably stop working after the update at the moment.

Hopefully we will have updated libraries later today, otherwise it will probably be tomorrow.

piborg's picture

We have finished testing the new logic on the PicoBorg Reverse library, it seems to work well on both the old and new versions of Raspbian ^_^

There are three ways you can go about updating the library on your Raspberry Pi:

1. Update PicoBorgRev.py only

This will keep any changes you have made to other scripts intact :)

For PicoBorg Reverse itself:

cd ~/picoborgrev
mv PicoBorgRev.py PicoBorgRev.old
wget -O PicoBorgRev.py https://www.piborg.org/downloads/picoborgrev/PicoBorgRev.txt

Additionally for DiddyBorg installs:

cd ~/diddyborg
mv PicoBorgRev.py PicoBorgRev.old
wget -O PicoBorgRev.py https://www.piborg.org/downloads/picoborgrev/PicoBorgRev.txt

Additionally for DiddyBorg Red Edition installs:

cd ~/diddyred
mv PicoBorgRev.py PicoBorgRev.old
wget -O PicoBorgRev.py https://www.piborg.org/downloads/picoborgrev/PicoBorgRev.txt

2. Re-install the examples

This will loose any changes you have made to scripts and any other scripts in the examples folder, but is much less typing.

For PicoBorg Reverse itself:

cd ~
rm -r picoborgrev
bash <(curl https://www.piborg.org/installer/install-picoborgrev.txt)

Additionally for DiddyBorg installs:

cd ~
rm -r diddyborg
bash <(curl https://www.piborg.org/installer/install-diddyborg.txt)

Additionally for DiddyBorg Red Edition installs:

cd ~
rm -r diddyred
bash <(curl https://www.piborg.org/installer/install-diddyred.txt)

3. Copy / view the new code

This should work in all cases, but is much more manual.

You can view the new version of the library here: Improved PicoBorgRev.py script. This should be used to replace any copies of PicoBorgRev.py.

You can tell if the script is new or old by looking at the import section (starts around line 30).
Old script:

# Import the libraries we need
import smbus
import types
import time

New script:

# Import the libraries we need
import io
import fcntl
import types
import time

No other scripts need to be changed, all of the same functions are available and work in the same way ^_^

UltraBorg

We are fairly certain the same problem exists with UltraBorg and the same changes will fix it. I am going to start working on the UltraBorg library today and will let you know when an updated version is available.

piborg's picture

We have made the same changes for UltraBorg as well, this solves the ID reading as FF in the updated Raspbian in the same way.

See the full post here: UltraBorg library fix.

Great, will give both a go in next few days and re update Pi from RPF

GeekyTim's picture

I think you need to update the Python3 version of the library too.

piborg's picture

I have updated the Python 3 version with a new copy based on the same changes.

It can be downloaded from here: https://piborg.org/downloads/picoborgrev/PicoBorgRev3.py.txt

Greetings,
I was wondering if you guys could update your Github repository with the newest fix.
https://github.com/piborg/diddyborg

Thank you for the fix!

piborg's picture

Thanks for pointing this out.

I will update the PicoBorgRev.py file in GitHub on Monday when I am back in the office :)

piborg's picture

The library has now been updated in the DiddyBorg repository ^_^

Much appreciated, thank you!

Subscribe to Comments for &quot;New build - PicoBorg Reverse fails to load.&quot;