[SOLVED] GrovePi+ compiled firmware - i2c issue


I downloaded the firmware for the GrovePi from the github repository and compiled it (unchanged) using the Arduino IDE on the Rasperry Pi running Raspian for Robost. The programmer was set to the Raspberry GPIO and the board was set to the Arduino UNO. I copied the generated hex file and used the flasher of firmware version V1.2.7 to flash the firmware on to the GrovePi+. Everything went fine, no errors.
However, when I try to run programs, then read_i2c_byte works fine but read_i2c_block throws an Errno 121, meaning that there is no data available. Modifying the GrovePi+ firmware and utilizing read_i2c_byte I can get all the data, so the GrovePi seems to work as expected.
When I upload the already compiled version V1.2.7 on to the GrovePi, then this error disappears. Therefore, I believe that there is something wrong with my compiling process. Though, I have no clue what that would be. Are there different versions of the Wire.h library?

I am thankful for any help I can get on this one.

Hey @michael57, question for you: what version of Raspbian for Robots are you using? Did you download it from our site?

I think this might be related to this issue we’ve been working with the Raspberry Pi Foundation on here. we have a workaround, I just want to get a better idea of what version of RfR you’re running, and what kernel version you have.

Hello John,
Thank you for the quick reply!

I am using the 2017.04.02_Dexter_Industries_jessie image, which I upgrade over the command line. Currently it runs kernel 4.9.35-v7+ on a RPi 3

I checked the other post and it mentions a change of drivers on the Pi. What throws me off though is that the compiled firmware that I can download from github works without problems while the one I compile myself show this behavior. Is there a workaround for compiling?

Hi @michael57,

The workaround you can do is to change the kernel of your Raspberry Pi as that kernel has an issue with the I2C libraries. @JohnC already pinpointed you to that issue.

From your Raspberry Pi, open up a terminal and type in the following command:

sudo rpi-update 52241088c1da59a359110d39c1875cda56496764

This command will downgrade your kernel version to 4.4.50-v7+.
The newer one has a bug in it (as I have heard) and it won’t work.

Thank you!

Just to add a little to what @RobertLucian mentioned here. There’s a known bug in the updated kernel with repeated starts and devices. That’s outlined and discussed here on github. Until the kernel is updated, the above command that Robert provides should solve the problem. If you update the kernel firmware, you will see some of the functions with the GrovePi work, and you will see a few of them fail. Running the command Robert gives should solve the problem.

Hello @RobertLucian and @JohnC,
The change of the kernel made things work again. Thanks for the update command!
I also went ahead and tried to compile the grovepi firmware under the old kernel and then loaded the new kernel again. However, that does not do the trick. I have to stick with the older kernel.
I am still wondering why the hex file that is offered on github works while the one I compile fails. In principle they should not be any different. Though, we have a working solution now, and I will mark the thread as solved / closed.

Hi @michael57,

I’m glad to hear it works.

As long as the newer kernel has some issues, I think trying to solve that issue right now might be harder since there are multiple factors involved there.
Without a hotfix for the kernel, I think it’s not justifiable to go there and diagnose it.

Anyway, we are keeping our eyes on the development of the Raspberry Pi's kernel, so we’ll definitely be testing it when a newer one is released.

I’ll close this thread now.

Thank you!