Kernel 3.13 and above: How to enable dcan_1 and GPIOs

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

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

this:

https://groups.google.com/forum/#!topic/beagleboard/WuCvPyi9bqk

suggests that you might be more interested in this:

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

…the instructions are pretty lousy. If it’s incomprehensible say so. I’ll help.

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 :slight_smile: ) 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] Beagleboard:Capes 3.8 to 3.14 - eLinux.org

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 :slight_smile: ) 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,

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](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… :slight_smile:

Hope you can help me once again!

Thanks a lot!!!

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:

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... :slight_smile:

Regards,

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

Regards,

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

[1] wget -c https://raw.github.com/RobertCNelson/tools/master/pkgs/dtc.sh
[2] wget -c https://raw.github.com/RobertCNelson/tools/master/pkgs/dtc.sh

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?)

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! :slight_smile:

→ 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

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..

Regards,