User avatar
joan
Posts: 14473
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: New device tree kernel is in testing

Wed Dec 03, 2014 9:47 pm

Does this mean we won't be able to load/unload modules for SPI/I2C?

It suggests that a Pi must be pre-purposed prior to boot.

If so, the solution may be worse than the problem.

Will there be no way of switching I2C/SPI on/off after boot?

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

Re: New device tree kernel is in testing

Wed Dec 03, 2014 10:31 pm

As far as I know, you are still free to use a blacklist and manually insert and remove modules, if that is how you prefer to work - you just need to use an overlay that enables the devices. I suggest you choose one of the audio card overlays - hifiberry-dac-overlay.dtb should be OK - and use it while you experiment. You'll get some complaints about missing hardware, but nothing fatal.

User avatar
joan
Posts: 14473
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: New device tree kernel is in testing

Wed Dec 03, 2014 10:46 pm

PhilE wrote:As far as I know, you are still free to use a blacklist and manually insert and remove modules, if that is how you prefer to work - you just need to use an overlay that enables the devices. I suggest you choose one of the audio card overlays - hifiberry-dac-overlay.dtb should be OK - and use it while you experiment. You'll get some complaints about missing hardware, but nothing fatal.
So device tree is a good name. I suppose I'm not used to things being appropriately named. I'd have thought a blank device tree adding the /dev/spidevx.x and /dev/i2c-x devices would be useful.

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

Re: New device tree kernel is in testing

Thu Dec 04, 2014 11:34 am

A .dts to enable /dev/i2c-0 and -1 (provided you are loading i2c-dev) and /dev/spidev0.x looks like this:

Code: Select all

// Enable the i2c-1, spidev-0 & spidev-1 devices
/dts-v1/;
/plugin/;

/ {
	compatible = "brcm,bcm2708";

	[email protected] {
		target = <&i2c0>;
		__overlay__ {
			status = "okay";
		};
	};

	[email protected] {
		target = <&i2c1>;
		__overlay__ {
			status = "okay";
		};
	};

	[email protected] {
		target = <&spi0>;
		__overlay__ {
			status = "okay";
		};
	};
};
Compile it like this:

Code: Select all

dtc [email protected] -I dts -O dtb -o enable-i2c-spi-overlay.dtb enable-i2c-spi-overlay.dts
using an updated dtc (see my earlier post) and you get this output (decode with "base64 -d txtfile > dtbfile"):

Code: Select all

0A3+7QAAAfAAAAA4AAAByAAAACgAAAARAAAAEAAAAAAAAAAoAAABkAAAAAAAAAAAAAAAAAAAAAAA
AAABAAAAAAAAAAMAAAANAAAAAGJyY20sYmNtMjcwOAAAAAAAAAABZnJhZ21lbnRAMAAAAAAAAwAA
AAQAAAAL3q2+7wAAAAFfX292ZXJsYXlfXwAAAAADAAAABQAAABJva2F5AAAAAAAAAAIAAAACAAAA
AWZyYWdtZW50QDEAAAAAAAMAAAAEAAAAC96tvu8AAAABX19vdmVybGF5X18AAAAAAwAAAAUAAAAS
b2theQAAAAAAAAACAAAAAgAAAAFmcmFnbWVudEAyAAAAAAADAAAABAAAAAverb7vAAAAAV9fb3Zl
cmxheV9fAAAAAAMAAAAFAAAAEm9rYXkAAAAAAAAAAgAAAAIAAAABX19maXh1cHNfXwAAAAAAAwAA
ABUAAAAZL2ZyYWdtZW50QDA6dGFyZ2V0OjAAAAAAAAAAAwAAABUAAAAeL2ZyYWdtZW50QDE6dGFy
Z2V0OjAAAAAAAAAAAwAAABUAAAAjL2ZyYWdtZW50QDI6dGFyZ2V0OjAAAAAAAAAAAgAAAAIAAAAJ
Y29tcGF0aWJsZQB0YXJnZXQAc3RhdHVzAGkyYzAAaTJjMQBzcGkwAA==
Finally, put that file in /boot/overlays (I would call it enable-i2c-spi-overlay.dtb), add the following line to your config.txt:

Code: Select all

device_tree_overlay=overlays/enable-i2c-spi-overlay.dtb
then reboot.

User avatar
joan
Posts: 14473
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: New device tree kernel is in testing

Thu Dec 04, 2014 11:39 am

There seems to have been a change to the /dev/ttyAMA0 permissions.

Linux harry 3.12.33+ #724
crw-rw---- 1 root dialout 204, 64 /dev/ttyAMA0

Linux harry 3.17.4+ #727
crw--w---- 1 root tty 204, 64 /dev/ttyAMA0

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

Re: New device tree kernel is in testing

Thu Dec 04, 2014 11:55 am

On a clean, updated raspbian, I get:

Code: Select all

crw------- 1 pi   tty     204, 64 Dec  4 09:45 /dev/ttyAMA0

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

Re: New device tree kernel is in testing

Thu Dec 04, 2014 12:04 pm

P.S. Anybody following this on a clean, updated system and wondering why the /dev entries haven't appeared, you need to empty/comment out the contents of

Code: Select all

/etc/modprobe.d/raspi-blacklist.conf
This will allow the i2c and spi modules to be loaded at the next boot, and will cause the /dev/spidev0.0 and /dev/spidev0.1 devices to appear. The i2c-dev module is also needed if you want /dev/i2c-x, so add it to /etc/modules to get /dev/i2c-0 and /dev/i2c-1 after a reboot.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5370
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: New device tree kernel is in testing

Mon Dec 08, 2014 4:28 pm

3.18 kernel has just gone stable, so I've pushed out a 3.18 version of DT enabled kernel.

Code: Select all

sudo BRANCH=next rpi-update

Testers are welcome. Please report if you test it (even if to just say it works just like 3.12 and 3.17 for you) as we may skip 3.17 kernel for 3.18 if there don't seem to be any regressions.

DirkS
Posts: 10017
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: New device tree kernel is in testing

Mon Dec 08, 2014 5:07 pm

3.18 kernel has just gone stable, so I've pushed out a 3.18 version of DT enabled kernel.
Updated and seems to be running find... :)

Two questions:
* I see these modules loaded (lsmod output)

Code: Select all

uio_pdrv_genirq         3666  0
uio                     9897  1 uio_pdrv_genirq
Can't rememver seeing them before. What are they?
* I think it would be useful if a basic device tree with enabled i2c and spi is added to the update.

Gr.
Dirk.

User avatar
DougieLawson
Posts: 36570
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: New device tree kernel is in testing

Mon Dec 08, 2014 5:09 pm

dom wrote:3.18 kernel has just gone stable, so I've pushed out a 3.18 version of DT enabled kernel.

Code: Select all

sudo BRANCH=next rpi-update

Testers are welcome. Please report if you test it (even if to just say it works just like 3.12 and 3.17 for you) as we may skip 3.17 kernel for 3.18 if there don't seem to be any regressions.
I've just gone off you. I'm still battling with 3.17.4 to try to get my enc28j60 SPI ethernet working with it.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5370
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: New device tree kernel is in testing

Mon Dec 08, 2014 7:31 pm

DirkS wrote: * I see these modules loaded (lsmod output)

Code: Select all

uio_pdrv_genirq         3666  0
uio                     9897  1 uio_pdrv_genirq
Can't rememver seeing them before. What are they?
Seems to be "Userspace I/O platform driver with generic IRQ handling code" from here

I believe these were also present with the 3.17 DT kernel. Not sure currently what is requiring them. Perhaps Phil knows?
* I think it would be useful if a basic device tree with enabled i2c and spi is added to the update.
I think there is a plan for overlays for these. It's arguable if they should be enabled by default.

DirkS
Posts: 10017
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: New device tree kernel is in testing

Mon Dec 08, 2014 7:39 pm

dom wrote:
* I think it would be useful if a basic device tree with enabled i2c and spi is added to the update.
I think there is a plan for overlays for these. It's arguable if they should be enabled by default.
Cheers, Dom. Having them available would be fine with me.
I actually managed to compile the dts file from the source given earlier in this topic.
Modules are loaded, and seem to be working fine.

Gr.
Dirk.

User avatar
DougieLawson
Posts: 36570
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: New device tree kernel is in testing

Tue Dec 09, 2014 9:14 pm

PhilE wrote:A .dts to enable /dev/i2c-0 and -1 (provided you are loading i2c-dev) and /dev/spidev0.x looks like this: ...
I've built a 3.18.0 kernel with support for my enc28j60 (which works OK on the 3.12.34 kernel I built).

I've tried your overlay dtb and I'm not getting my SPI device coming active. The two I2C devices show up as /dev/i2c-0 /dev/i2c-1. (I've not yet tested either of those with an MCP23017)

spi-bcm2708 is loaded.
[email protected] ~ # dmesg | grep spi
[ 6.329297] bcm2708_spi bcm2708_spi.0: master is unqueued, this is deprecated
[ 6.336725] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)
[email protected] ~ #
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
DougieLawson
Posts: 36570
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: New device tree kernel is in testing

Thu Dec 11, 2014 11:43 am

I've done some more testing on my A+.

Now, I can get the device_tree stuff running and both /dev/spidev.0 & /dev/spidev.1 appear.

But my enc28j60 module won't run (modprobe's OK but eth0 doesn't appear) and the pi camera won't run vcgencmd get_camera shows enabled but not detected.

Reverting back to 3.12.33+ with my RYO enc28j60 kernel and both bits of kit work OK (so the hardware is wired up OK).

What diagnostics do you need?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

milhouse
Posts: 641
Joined: Mon Jan 16, 2012 12:59 pm

Re: New device tree kernel is in testing

Fri Dec 12, 2014 11:06 am

Since switching to the device tree enabled kernel (3.17.4, then 3.18), I've experienced three hard lock ups requiring a power cycle to restart Raspbian. With the old 3.12.y kernel I would run for months without a problem. I've also had OpenELEC lockup once since enabling device tree (I can't remember if it was with the 3.17.5 or 3.18 kernel), which is again unusual.

Is anyone else seeing lockups? Unfortunately I've got zero information as there is nothing written to the logs at the time of the lock up.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5370
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: New device tree kernel is in testing

Fri Dec 12, 2014 1:39 pm

milhouse wrote:Since switching to the device tree enabled kernel (3.17.4, then 3.18), I've experienced three hard lock ups requiring a power cycle to restart Raspbian. With the old 3.12.y kernel I would run for months without a problem. I've also had OpenELEC lockup once since enabling device tree (I can't remember if it was with the 3.17.5 or 3.18 kernel), which is again unusual.

Is anyone else seeing lockups? Unfortunately I've got zero information as there is nothing written to the logs at the time of the lock up.
Obviously a reproducable test case would be useful.

Does this affect both 3.17 and 3.18 versions?
I'd be interested if the latest DT kernel with DT disabled (device_tree="" added to config.txt) is good or bad.

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

Re: New device tree kernel is in testing

Fri Dec 12, 2014 2:38 pm

Dougie,

Sorry about the lack of response - I didn't receive a notification about your posts. I need to check my settings.

I'm happy that SPI is working for you now. The camera still functioned for me with DT, admittedly using a B+. So I started experimenting with overlays to enable the I2C ports, with a view to getting you to see if the camera could be seen on i2c0, and a curious thing happened - my camera disappeared.

So I can now point the finger at enabling i2c0 on the ARM side. To paraphrase a well known film, "All these ports are yours, except i2c0", which really belongs to the GPU. So here's a slightly safer overlay: extract as before, and call it something like "enable-i2c1-spi-overlay.dtb":

Code: Select all

0A3+7QAAAXsAAAA4AAABWAAAACgAAAARAAAAEAAAAAAAAAAjAAABIAAAAAAAAAAAAAAAAAAAAAAA
AAABAAAAAAAAAAMAAAANAAAAAGJyY20sYmNtMjcwOAAAAAAAAAABZnJhZ21lbnRAMAAAAAAAAwAA
AAQAAAAL3q2+7wAAAAFfX292ZXJsYXlfXwAAAAADAAAABQAAABJva2F5AAAAAAAAAAIAAAACAAAA
AWZyYWdtZW50QDEAAAAAAAMAAAAEAAAAC96tvu8AAAABX19vdmVybGF5X18AAAAAAwAAAAUAAAAS
b2theQAAAAAAAAACAAAAAgAAAAFfX2ZpeHVwc19fAAAAAAADAAAAFQAAABkvZnJhZ21lbnRAMDp0
YXJnZXQ6MAAAAAAAAAADAAAAFQAAAB4vZnJhZ21lbnRAMTp0YXJnZXQ6MAAAAAAAAAACAAAAAgAA
AAljb21wYXRpYmxlAHRhcmdldABzdGF0dXMAaTJjMQBzcGkwAA==
With a bit of luck your camera should spring back into life.

Just FYI, I'm working on a neater way of enabling interfaces and tweaking small settings like this without the need for extra overlays.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: New device tree kernel is in testing

Fri Dec 12, 2014 2:47 pm

PhilE wrote:0x1b is claimed by the tas5713 driver, as used by the hifiberry-amp card. 0x3b is the wm8804 used by the hifiberry-digi.

Once DT is working, those entries will go away.
They should have never been there in the first place.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: New device tree kernel is in testing

Fri Dec 12, 2014 2:49 pm

PhilE wrote:They aren't "broken", they are disabled in the device tree. If they were enabled by default then the are some circumstances where they would need to be blacklisted, resulting in two configuration mechanisms where we would rather have one.

It is up to the loaded overlay to enable the needed devices. Ideally these would be written specifically for each peripheral card, but since I2C supports a run-time configuration mechanism it might be useful to have a few generic overlays such as i2c1-on-spi-on-overlay.dtb .

If you give me a list of generic overlays you would like and/or the specifics of your applications, I will write and compile some .dts's for you.
i2c-1
i2c-0
spi
all bundled please
no reserved i2c addresses either.
Last edited by Richard-TX on Fri Dec 12, 2014 2:55 pm, edited 2 times in total.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
DougieLawson
Posts: 36570
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: New device tree kernel is in testing

Fri Dec 12, 2014 2:51 pm

Hi Phil,

That dtb overlay fails in exactly the same way as your original. When I diff'd the two versions they're identical.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

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

Re: New device tree kernel is in testing

Fri Dec 12, 2014 2:53 pm

They should have never been there in the first place.
Even with extensive use of 'rebase', I can't rewrite history, just improve the future.
i2c-1
i2c-0
spi
If you've been following this thread you should now have (i2c-0 + i2c-1 + spi) and (i2c-1 + spi). You should also have the tools to construct your own, just by cutting down the .dts I posted and recompiling. But if that sounds like too much work, just wait a few days and something better will come round the corner.

milhouse
Posts: 641
Joined: Mon Jan 16, 2012 12:59 pm

Re: New device tree kernel is in testing

Fri Dec 12, 2014 2:54 pm

dom wrote:Obviously a reproducable test case would be useful.

Does this affect both 3.17 and 3.18 versions?
I'd be interested if the latest DT kernel with DT disabled (device_tree="" added to config.txt) is good or bad.
I wish I knew how to reproduce, it seems to take 2-3 days for the lockup to occur and happens even when the device is basically idle, so not being hammered either in terms of CPU or network.

I've seen it twice in 7 days with 3.17.4 in Raspbian, and once more with 3.18 Raspbian (I updated to 3.18 on 10 Dec 10:30, it locked up this morning 12 Dec 09:55).

I'll add device_tree= and let you know in a few days if it's had any effect.
Last edited by milhouse on Fri Dec 12, 2014 5:27 pm, edited 2 times in total.

User avatar
DougieLawson
Posts: 36570
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: New device tree kernel is in testing

Fri Dec 12, 2014 2:56 pm

I've got

[email protected] /dev # uname -a
Linux aplus 3.18.0+ #726 PREEMPT Mon Dec 8 16:01:09 GMT 2014 armv6l GNU/Linux
[email protected] /dev # ls -la i2* spi*
crw-rw---T 1 root i2c 89, 0 Dec 12 14:45 i2c-0
crw-rw---T 1 root i2c 89, 1 Dec 12 14:45 i2c-1
crw-rw---T 1 root spi 153, 0 Jan 1 1970 spidev0.0
crw-rw---T 1 root spi 153, 1 Jan 1 1970 spidev0.1
[email protected] /dev #

And a camera that doesn't work.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

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

Re: New device tree kernel is in testing

Fri Dec 12, 2014 2:56 pm

@dougielawson: you're right - edited.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: New device tree kernel is in testing

Fri Dec 12, 2014 2:59 pm

PhilE wrote:
They should have never been there in the first place.
Even with extensive use of 'rebase', I can't rewrite history, just improve the future.
and for that I am eternally grateful and in your debt. Thank you.
i2c-1
i2c-0
spi
If you've been following this thread you should now have (i2c-0 + i2c-1 + spi) and (i2c-1 + spi). You should also have the tools to construct your own, just by cutting down the .dts I posted and recompiling. But if that sounds like too much work, just wait a few days and something better will come round the corner.
I responded serially. I should have read the entire thread before responding.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

Return to “Advanced users”