Kernel 3.13 and above: How to enable dcan_1 and GPIOs

174 views
Skip to first unread message

Marco Steger

unread,
Nov 24, 2014, 7:40:57 AM11/24/14
to beagl...@googlegroups.com

Hi folks!

For some reasons (mainly the kernel support for IEEE 802.11s) I need to use Debian (kernel 3.13 or higher; I’m currently running 3.16.1-bone4) on my BBB. For my project, I will also use the CAN interface of the BBB and some IO pins (mainly for LEDs and switches...).

This is my first BBB project so I searched the web for the easiest / best solution for using the GPIO pins of my BBBs.

In many tutorials about BBB GPIO and can-bus the use of the capemgr is suggested. But as you all know there is no capemgr in 3.16.

Now I would really need your help to find the best way to enable the can-bus (dcan_1) and also control some other GPIO pins. Can I do this from userspace some how? Or do I have to reconfigure and rebuild the kernel?

@GPIO pins: I think the easiest solution is to use "echo [GPIO No.] > /sys/class/gpio/export"  and then set the value & direction etc. using echo. Am I right here?

Thanks a lot for your help and hints,
Marco

Marco Steger

unread,
Nov 25, 2014, 3:55:31 AM11/25/14
to beagl...@googlegroups.com

Hi again!

I spent some more hours on how to enable the d_can interfaces on my BBB.

I found Robert Nelsons "Really Simple Cape Manager" (RSCM) here [1]. This looks very promising at first. There is a folder for 3.13-bone and the README says that

3.13-rc6-bone2 should be installed.


I'm currently working on 3.16.1-bone4. As far as I understand the idea behind Robert’s  RSCM I would need the original .dts file of my BBB. Than add the needed lines to enable d_can1 (to enable d_can0 I would have to disable I2C2. Am I right?). The build a dtb file using dtc (patched by Robert … he is present everywhere on the BBB I think!
J) .

Finally I can move this file to /boot/dtbs/3.16.1-bone4/ on my BBB (replace the existing dtb file(s).

But where can I find the dts file of my BBB? I wasn’t able to locate it on my board. Can I use the dts file from 3.13? Can I (permanently) damage my BBB when playing around here?

 

Would be great if someone can help me!!!


[1] https://github.com/RobertCNelson/rscm

Jason Lange

unread,
Nov 25, 2014, 4:39:49 AM11/25/14
to Beagle Board

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Lange

unread,
Nov 25, 2014, 5:16:33 AM11/25/14
to Beagle Board
...the instructions are pretty lousy.  If it's incomprehensible say so.  I'll help.

Marco Steger

unread,
Nov 25, 2014, 6:25:27 AM11/25/14
to beagl...@googlegroups.com

Hi Jason!

Thanks for your help! The dtb-rebuilder looks like a very promising solution for me. Although, in Robert's GitHub repo is just a branch for kernel "3.14-ti". So a very similar question then in my last post: Can I use the scripts and the dts file also on my 3.16-bone4 kernel?
Do you think that it would be possible to permanently damage my BBB, if I try to use the scripts on my 3.16 BBB?

If this is possible, then I think (or more hope
:) ) it would be really easy to enable d_can1:

1.) Like suggested in [1] I would take the am335x-boneblack.dtb file.

2.) It looks like that includes can be added easily:


/* can1: P9_24, P9_26 */

#include "am335x-can1.dtsi" (Already there)

#include "am335x-boneblack-can1.dts" (add this line; But I’m not sure if .dts files can be included like .dtsi file?!)

/* #include "am335x-bone-can1.dtsi" */

 

3.) Build dtb file using dtb-rebuilder.

4.) Copy to /boot/dtbs/ dir.

5.) reboot


Would be great if you can help me once more here!

[1] http://elinux.org/Beagleboard:Capes_3.8_to_3.14#Custom_dtb

Robert Nelson

unread,
Nov 25, 2014, 7:37:12 AM11/25/14
to Beagle Board
On Tue, Nov 25, 2014 at 5:25 AM, Marco Steger <marco....@gmail.com> wrote:
>
> Hi Jason!
>
> Thanks for your help! The dtb-rebuilder looks like a very promising solution for me. Although, in Robert's GitHub repo is just a branch for kernel "3.14-ti". So a very similar question then in my last post: Can I use the scripts and the dts file also on my 3.16-bone4 kernel?
> Do you think that it would be possible to permanently damage my BBB, if I try to use the scripts on my 3.16 BBB?

Yes and No... It'll boot, but not everything will work, the 3.14-ti
branch contains a lot of patches that are both heading and hitting
mainline. Many post "3.16".. Lot's of the can patches have been
posted this last month for review for "3.19"..

>
> If this is possible, then I think (or more hope :) ) it would be really easy to enable d_can1:
>
> 1.) Like suggested in [1] I would take the am335x-boneblack.dtb file.
>
> 2.) It looks like that includes can be added easily:
>
>
> /* can1: P9_24, P9_26 */
>
> #include "am335x-can1.dtsi" (Already there)
>
> #include "am335x-boneblack-can1.dts" (add this line; But I’m not sure if .dts files can be included like .dtsi file?!)
>
> /* #include "am335x-bone-can1.dtsi" */

I have setup that file simpler then that, to enable can1 just
un-comment the 2nd line (pinmux) aka:

/* can1: P9_24, P9_26 */
#include "am335x-can1.dtsi"
#include "am335x-bone-can1.dtsi"

The first include is the device "perhiperal" the second include is the pinmux.

Regards,

--
Robert Nelson
http://www.rcn-ee.com/

Marco Steger

unread,
Nov 25, 2014, 9:14:11 AM11/25/14
to beagl...@googlegroups.com

Hi Robert,
thanks for your comments.
Yes and No...  It'll boot, but not everything will work, ...
I'm not that sure about that. I just tried this and the BBB doesn't boot afterwards. But maybe I did a bad mistake. Here my steps:

1.) Downloaded your DTB-rebuilder "
git clone -b 3.14-ti https://github.com/RobertCNelson/dtb-rebuilder.git"
2.) Uncommented line 53 (/* #include "am335x-bone-can1.dtsi" */) in file dtb-rebuilder/src/arm/am335x-boneblack.dts.
3.) make
4.) copied the am335x-boneblack.dtb file to /boot/dtbs/3.16.1-bone4/
5.) Reboot. Without result. After running modprobe can; modprobe can-dev; modprobe can-raw there was no CAN interface when typing ifconfig -a
6.) So I checked the uEnv file in /boot dir. There was a line "#dtb="
7.) Then I uncommented this line and used dtb=/boot/dtbs/3.16.1-bone4/am335x-boneblack.dtb
8.) After reboot all 4 LEDs stay lid and after lets say 30 seconds its seems that the board reboots again.

What did I wrong here? Any ideas?

In the meantime I will reflash my board and start again... :)

Hope you can help me once again!

Thanks a lot!!!

Robert Nelson

unread,
Nov 25, 2014, 9:25:35 AM11/25/14
to Beagle Board
On Tue, Nov 25, 2014 at 8:14 AM, Marco Steger <marco....@gmail.com> wrote:
>
> Hi Robert,
> thanks for your comments.
>>
>> Yes and No... It'll boot, but not everything will work, ...
>
> I'm not that sure about that. I just tried this and the BBB doesn't boot
> afterwards. But maybe I did a bad mistake. Here my steps:
>
> 1.) Downloaded your DTB-rebuilder "
>
> git clone -b 3.14-ti https://github.com/RobertCNelson/dtb-rebuilder.git"
>
> 2.) Uncommented line 53 (/* #include "am335x-bone-can1.dtsi" */) in file
> dtb-rebuilder/src/arm/am335x-boneblack.dts.
> 3.) make
> 4.) copied the am335x-boneblack.dtb file to /boot/dtbs/3.16.1-bone4/
> 5.) Reboot. Without result. After running modprobe can; modprobe can-dev;
> modprobe can-raw there was no CAN interface when typing ifconfig -a

Do you have can enabled?

The can "pinmux" relies on this patchset in my v3.14.x tree:

https://github.com/RobertCNelson/ti-linux-kernel-dev/tree/ti-linux-3.14.y/patches/beaglebone/pinmux-helper

> 6.) So I checked the uEnv file in /boot dir. There was a line "#dtb="
> 7.) Then I uncommented this line and used
> dtb=/boot/dtbs/3.16.1-bone4/am335x-boneblack.dtb

Yuck, don't do that, just the file name.. (i need to add the exact
path to the lookup function in u-boot so user's don't break their boot
via ^^^^that^^^)

> 8.) After reboot all 4 LEDs stay lid and after lets say 30 seconds its seems
> that the board reboots again.
>
> What did I wrong here? Any ideas?
>
> In the meantime I will reflash my board and start again... :)

Robert Nelson

unread,
Nov 25, 2014, 9:32:55 AM11/25/14
to Beagle Board
btw, just to refresh everyone on all the branches.

Right now i'm mainly focusing on the "v3.14-ti" branch, as a stepping
stone off "v3.8.x"

Otherwise, i'm staying in sync with mainline, as dt "overlay's" are
getting so close:

http://www.spinics.net/lists/devicetree/msg59480.html

Marco Steger

unread,
Nov 26, 2014, 3:20:30 AM11/26/14
to beagl...@googlegroups.com
Hi Robert, Hi all,

I reflashed my board, updated the kernel to 3.16.1-bon4, installed the dtc using [1] and downloaded dtb-rebuilder via [2]. But still wasn't able to enable CAN1...

> 4.) copied the am335x-boneblack.dtb file to /boot/dtbs/3.16.1-bone4/
> 5.) Reboot. Without result. After running modprobe can; modprobe can-dev;
> modprobe can-raw there was no CAN interface when typing ifconfig -a

Do you have can enabled?

The can "pinmux" relies on this patchset in my v3.14.x tree:

https://github.com/RobertCNelson/ti-linux-kernel-dev/tree/ti-linux-3.14.y/patches/beaglebone/pinmux-helper

I hope I got you rigth here. I went to the github repo from above and look at the file "0011-pinmux-helper-can1.patch ". In this patch file there is just one change in file "am335x-bone-common-pinmux.dtsi":
- pinctrl-single,pins = <0x180 0x32>; }; /* Mode 2, Pull-Up, RxActive */ //This line changes to
+ pinctrl-single,pins = <0x180 0x12>; }; /* Mode 2, Pull-Up, RxActive */ //this one

So I looked into this file on my BBB (dtb-rebuilder/src/arm/am335x-bone-common-pinmux.dtsi) and the change
<0x180 0x12> was already there. Finally I uncommented line 53 (/* #include "am335x-bone-can1.dtsi" */) in file dtb-rebuilder/src/arm/am335x-boneblack.dts.

Then make and copy the dtb-file to the /boot/dbts/... dir.

> 6.) So I checked the uEnv file in /boot dir. There was a line "#dtb="
> 7.) Then I uncommented this line and used
> dtb=/boot/dtbs/3.16.1-bone4/am335x-boneblack.dtb

Yuck, don't do that, just the file name.. (i need to add the exact
path to the lookup function in u-boot so user's don't break their boot
via ^^^^that^^^)

Thanks for that hint. Now I just use "dtb=am335x-boneblack.dtb". And the board restarts without problems

After running the modprobe steps (can, can-dev, can-raw) I checked if I can see the can interface now using ifconfig -a but still there is no can0 interface.

What did I miss? Do you have any ideas or hints for me?

Best regards and thanks again for your help,
Marco

Jason Lange

unread,
Nov 26, 2014, 4:31:22 AM11/26/14
to Beagle Board
Hi Marco,

I just enabled can0 using kernel 3.14.25-ti-r37 and the dtb-rebuilder (it's showing up with "ifconfig -a", I haven't tested it further).  It was pretty painless.  Is there a strong reason not to use this kernel?  If not a simple "apt-get install linux-image-3.14.25-ti-r37" could be all you really need.

Good luck.

ps. I did have to apply this patch even though I did a "git pull" before modifying the .dts   (@Robert is this right?)
Message has been deleted

Marco Steger

unread,
Nov 28, 2014, 7:00:20 AM11/28/14
to beagl...@googlegroups.com
Hi Jason, Hi all,

thanks for your hints. So I just used "apt-get install linux-image-3.14.25-ti-r37"
 like you preferred and it works like a charm ... After one reboot the can0 interface was there! :)
-> So for everyone who needs a kernel >3.8: Use kernel 3.14.25-ti-r37 and dtb-builder. For more information see [1].

So I will use this configurations for some tests with can0.
@Robert: Is there a plan to add dtb-rebuilder also to 3.16 kernel?

Once again thanks for your great help and fast support.

Best regards,
Marco

[1] http://elinux.org/Beagleboard:Capes_3.8_to_3.14#Custom_dtb

2014-11-26 11:50 GMT+01:00 Jason Lange <j.b....@gmail.com>:
Hi Marco,

About the patch:  I think I made a mistake and changed a similar line by hand.  I wasn't checking too carefully because I'm not actually using can0 -- I just wanted to tell you that it was going to work so you could stop wasting your time.  I reverted the repo to be sure, and now I can't find the line.  Probably a "git pull" is all you need to ensure you have the latest and greatest code.

Cheers.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/r9HSvN4JH4k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard...@googlegroups.com.

Robert Nelson

unread,
Nov 28, 2014, 5:35:15 PM11/28/14
to Beagle Board
On Fri, Nov 28, 2014 at 6:00 AM, Marco Steger <marco....@gmail.com> wrote:
> Hi Jason, Hi all,
>
> thanks for your hints. So I just used "apt-get install
> linux-image-3.14.25-ti-r37"
> like you preferred and it works like a charm ... After one reboot the can0
> interface was there! :)
> -> So for everyone who needs a kernel >3.8: Use kernel 3.14.25-ti-r37 and
> dtb-builder. For more information see [1].
>
> So I will use this configurations for some tests with can0.
> @Robert: Is there a plan to add dtb-rebuilder also to 3.16 kernel?

Honestly, i'm in a little bit of holding pattern till v3.19-rc1 drops...

Specifically:
https://lkml.org/lkml/2014/11/24/806

Which is one of the really really big frameworks that's in our v3.8.x
kernel but not in mainline.

But yeah, when that drops i'll extend the dtb-rebuilder, because it's
very useful, and depending on the above patch-set i may restructure
things..
Reply all
Reply to author
Forward
0 new messages