Adding CAN Bus (can0) device to BeagleBone

I’m trying to add can0 to my BeagleBone so that I can communicate on the CAN Bus. I’m using the image from April 2012 found here: http://downloads.angstrom-distribution.org/demo/beaglebone/archive/Angstrom-Cloud9-IDE-eglibc-ipk-v2012.04-core-beaglebone-2012.04.09.img.xz.

iproute2 is installed, and i’m trying to add the device by using: ip link add dev can0 type can
The response I get back is: RTNETLINK answers: Operation not permitted

How do I add a CAN device? Is there a way to tell if D_CAN is included in the kernel?

Simple start - does it show up in 'cat /proc/net/dev'?
If not, the device is not present.

No… just lo and eth0. Does this mean I need to reconfigure the kernel?

You need the following kernel configs.

CONFIG_CAN=y

CONFIG_CAN_RAW=y

CONFIG_CAN_BCM=y

CAN Device Drivers

CONFIG_CAN_VCAN is not set

CONFIG_CAN_DEV=y

CONFIG_CAN_CALC_BITTIMING=y

CONFIG_CAN_TI_HECC=y

D_CAN driver for Bosh parts. The TI controller is HECC (high end CAN controller).

Then it works great.

Cheers Mike.

Thanks Mike. I did see this posted somewhere, but I couldn’t find where I need to set this. (I’m still looking) Sorry, but I’m still learning linux, so I’m not familiar with kernel configs. Is this a file located somewhere in the directory on the BeagleBoard? Or do I need to follow the instructions here and build the kernel? Thanks for your help.

You need at least the kernel sources from this repo: https://github.com/koenkooi/linux.git

Setup a proper PATH to your compiler toolchain (for example Linaro, CodeSourcery etc.), export your arch:

export ARCH=arm

execute:

make menuconfig

and go to “Networking support” → “CAN bus subsystem support”

choose Raw CAN protocol

then go to “CAN Device drivers” and select “CAN platform drivers with netlink support” and “CAN bittiming calculation” and “Bosch D_CAN devices” → “Generic Platform Bus based D_CAN driver”

That should be enough. HECC is not available on am335x, but on am3517/15.

I’m not getting anywhere. I downloaded the CodeSourcery toolchain and followed their instructions on how to install it, ran “make menuconfig” and set the options for can. But when I run “make”, I get the following errors:

CC kernel/bounds.s
cc1: error: unrecognized command line option ‘-mlittle-endian’
… ‘mapcs’
… ‘mno-sched-prolog’
kernel/bounds.c:1:0: error: unknown ABI (apcs-gnu) for -mabi= switch

make ARCH=arm <...>

Regards,

Not following… I need to type: “export ARCH=arm” or “export ARCH=armv7”? Or “make ARCH=arm”? I’ve tried all and get the same result. (Actually there is no armv7 directory so that one gives me a different error)

From your kernel source directory, with the correct "defconfig" saved
as ".config"..

Then run:

make ARCH=arm menuconfig
make ARCH=arm CROSS_COMPILE=path/to/codesourcy/arm/cross/gcc uImage modules

Regards,

Where would the defconfig/config file be located? In the arch/arm/configs folder?

When I run “make ARCH=arm CROSS_COMPILE=/opt/CodeSourcery/Sourcery_G++_Lite/bin uImage modules”, I get an error saying gcc: Command not found. I feel like I’m missing something… Do I need the commercial version of CodeSourcery? Or use a different toolchain?

Where would the defconfig/config file be located? In the arch/arm/configs
folder?

From the same place you got the patched kernel source code... Or from
your current running beaglebone..

When I run "make ARCH=arm
CROSS_COMPILE=/opt/CodeSourcery/Sourcery_G++_Lite/bin uImage modules", I get
an error saying gcc: Command not found. I feel like I'm missing
something... Do I need the commercial version of CodeSourcery? Or use a
different toolchain?

Nah, just not fully complete..

CROSS_COMPILE=/opt/CodeSourcery/Sourcery_G++_Lite/bin/arm-linux-gnueabi-

But double check the "bin" dir and adjust accordingly, encase it's
slightly different...

Regards,

Thanks, that got me further. I’m in the process of compiling, but getting lots of errors and having to exclude some configurations from the config file. Is this normal? Is there a base config file that I should start from?

You can also try Buildroot.

Get source:

git clone git://git.buildroot.net/buildroot

then choose BeagleBone config:

make beaglebone_defconfig

and make the first build:

make

after that you can configure the kernel:

make linux-menuconfig

The images are placed under build/images

Brent, sounds like you got a random source then..

For the source/config currently used by Angstrom, look at :
https://github.com/beagleboard/kernel

git clone git://github.com/beagleboard/kernel.git
cd kernel
git checkout origin/beaglebone-3.2 -b beaglebone-3.2
./patch.sh

config is in patches/beaglebone/defconfig

and the patched source is under kernel dir.

Regards,

Ah, that makes sense. I was using the one here:
https://github.com/koenkooi/linux.git. I'll try this over the
weekend. Thanks for all your help!

Robert,

I’ve tried compiling from the source you suggested (git://github.com/beagleboard/kernel.git), and I keep getting errors about not being able to find asm/leds.h. Do you know anything about this? Here is the output:
arch/arm/mach-versatile/core.c:42:22: fatal error: asm/leds.h: No such file or directory
compilation terminated.
make[1]: *** [arch/arm/mach-versatile/core.o] Error 1
make: *** [arch/arm/mach-versatile] Error 2

I’ve tried a different compilier and still no luck.

ah.. "mach-versatile"? It looks like you forgot to copy the defconfig
from patches/beagleboard/defconfig and save it as .config in kernel
directory right..

Regards,

Thanks, that helped a lot! I had an issue about not finding the firmware, but I found your post here to resolve that one.

I feel like I’m seeing the light at the end of the tunnel. Hopefully these are the last questions… Is the output in the arch/arm/boot/ directory? Is there a procedure somewhere on how to get the files on the SD card?

Your going to copy the uImage to where your boot script looks for it..
(older looked in the fat16 partition, newer ones look under /boot/ on
the extX partition..)

For the modules just do:

make ARCH=arm CROSS_COMPILE=${CC} modules_install INSTALL_MOD_PATH=/media/rootfs

or wherever you have your mmc's rootfs mounted...

Regards,