pmunts
Posts: 5
Joined: Fri Nov 08, 2013 7:19 pm

I2C is broken by latest commit

Sun Jun 16, 2019 5:32 pm

This recent commit to the kernel source tree:

Code: Select all

commit 2f8d963db206ce596f9a9e951ec425e9c3e1b4d9
Author: Annaliese McDermond <[email protected]>
Date:   Sat Jun 8 10:14:43 2019 -0700

    i2c: bcm2835: Model Divider in CCF

seems to have broken I2C:

Code: Select all

i2c-bcm2835 3f804000.i2c: Could not register clock
i2c-bcm2835: probe of 3f804000.i2c failed with error -12

The result is that /dev/i2c-1 is not created. I verified that after
backing up one commit and building a new kernel, /dev/i2c-1 is created correctly.

Should there have been corresponding changes to bcm283x.dtsi?

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

Re: I2C is broken by latest commit

Sun Jun 16, 2019 6:22 pm

Seeing as I've only just seen that commit accepted into the mainline kernel I suspect you're building off one of the upstream staging branches, and not a release. In which case all bets are off, and any issue ought to be reported upstream to the maintainers and mailing lists (linux-rpi-kernel, and linux-i2c).

Whilst you may get us to look at it, all we'll do (assuming we can replicate) is to report it upstream as well.
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.

pmunts
Posts: 5
Joined: Fri Nov 08, 2013 7:19 pm

Re: I2C is broken by latest commit

Mon Jun 17, 2019 7:38 am

AFAIK I'm building from the tip of the official Raspberry Pi kernel tree 4.19 branch:

Code: Select all

[email protected]:/usr/src/linux-rpi$ git remote -v
origin	https://github.com/raspberrypi/linux.git (fetch)
origin	https://github.com/raspberrypi/linux.git (push)
[email protected]:/usr/src/linux-rpi$ git status
On branch rpi-4.19.y
Your branch is up-to-date with 'origin/rpi-4.19.y'.
nothing to commit, working tree clean

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

Re: I2C is broken by latest commit

Mon Jun 17, 2019 9:00 am

Apologies - I'd missed that it had been backported on Thursday. I'd only seen it on the mainline mailing lists.
I'll check to see if Phil has seen any issues.
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.

es30
Posts: 2
Joined: Mon Jun 17, 2019 3:54 pm

Re: I2C is broken by latest commit

Mon Jun 17, 2019 4:13 pm

I have encountered the same problem with the same commit in the Arch Linux ARM distribution of kernel 4.19.50-1. I have reported it on their forums here: https://archlinuxarm.org/forum/viewtopi ... 23&t=13719

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2432
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2C is broken by latest commit

Tue Jun 18, 2019 4:48 pm

I'm not seeing this at the moment. Error 12 is ENOMEM - which model of RPi are you testing with?

es30
Posts: 2
Joined: Mon Jun 17, 2019 3:54 pm

Re: I2C is broken by latest commit

Tue Jun 18, 2019 5:54 pm

In my case, the kernel was built and tested on a Raspberry Pi 3 Model B (not plus).

I neglected to include in my first post what may be a critical piece of information. My config file for building 4.19.50-1 (once again, this was Arch Linux ARM rather than Raspbian) makes some changes to the stock config:

Code: Select all

$ diff config config.original
3c3
< # Linux/arm 4.19.50-1 Kernel Configuration
---
> # Linux/arm 4.19.49-1 Kernel Configuration
2836c2836
< CONFIG_I2C_BCM2835=y
---
> CONFIG_I2C_BCM2835=m
4945,4946c4945
< CONFIG_RTC_HCTOSYS=y
< CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
---
> # CONFIG_RTC_HCTOSYS is not set
4958c4957
< # CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
---
> CONFIG_RTC_INTF_DEV_UIE_EMUL=y
4966c4965
< CONFIG_RTC_DRV_DS1307=y
---
> CONFIG_RTC_DRV_DS1307=m

(This configuration has worked properly with kernel 4.19.49-1 and prior.)

Could building in rather than loading the I2C_BCM2835 driver be the source of my difficulties?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2432
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2C is broken by latest commit

Wed Jun 19, 2019 7:55 am

Yes - that breaks it. Leave it with me...

pmunts
Posts: 5
Joined: Fri Nov 08, 2013 7:19 pm

Re: I2C is broken by latest commit

Wed Jun 19, 2019 8:10 am

I've also been building a mostly monolithic kernel. I tried changing CONFIG_I2C_BCM2835=y to CONFIG_I2C_BCM2835=m and it does seem to work that way.

anna.mcdermond
Posts: 1
Joined: Wed Jun 19, 2019 8:12 am

Re: I2C is broken by latest commit

Wed Jun 19, 2019 8:15 am

It's really late here on the US West Coast, but I'll see if I can take a look tomorrow at the issue.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2432
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2C is broken by latest commit

Wed Jun 19, 2019 2:10 pm

I've commented on the original Pull Request to rpi-4.19.y (https://github.com/raspberrypi/linux/pull/3011), but the problem is caused by:

1. a failure to detect that the clock provider hadn't yet been initialised,
2. which causes clock registration to proceed without a name for the parent clock,
3. which is misinterpreted as an allocation failure, hence -ENOMEM.

A quick fix is to return -EPROBE_DEFER in the case that the parent clock name is not set (after first freeing the IRQ which has already been claimed). However, the probe function where all this happens is short of proper error handling so a larger revamp may be advisable.

Return to “Interfacing (DSI, CSI, I2C, etc.)”