Forum Discussion
Altera_Forum
Honored Contributor
12 years agoAltera Linux - How to configure CAN bus?
Hi,
I am working with Altera Linux on a cyclone 5 development board. I am trying to enable the CAN bus and send a message. When I try to turn on the CAN bus, I get:
root@socfpga_cyclone5:/etc# ip link set can0 up type can bitrate 125000
ip: either "dev" is duplicate, or "type" is garbage Is there a different way to setup the CAN bus than what I am doing? How do you do this? I have read online there is a iproute2 that has support for setting up the CAN bus. I am having trouble including this in the rootfs. It just seems to me there is CAN support in the released Altera Linux, but I am not able to start it. A little more info:
root@socfpga_cyclone5:/etc# uname -a
Linux socfpga_cyclone5 3.11.0-00406-g9c73c70-dirty# 1 SMP Wed Oct 30 10:06:30 CDT 2013 armv7l GNU/Linux
root@socfpga_cyclone5:/etc# which ip
/bin/ip
Thanks, John3 Replies
- Altera_Forum
Honored Contributor
All,
I figured out how to get the CAN bus working. I thought I would just share here in case anyone else runs into this question and might find this helpful: 1. Download the 13.1 binaries for Altera Linux http://software.altera.com/linux_socfpga/0dcda22e23aa08c250fb3446daf36231/?version=13.1cb Follow this guide and make sure default release works on development board http://rocketboards.org/foswiki/documentation/gsrdbootlinuxsd 2. Download 3.11 kernel and compile. This is needed for CAN support. If you have not set up the compiler, see this for reference. http://rocketboards.org/foswiki/documentation/gitgettingstarted
Once the kernel finishes building, mount the sd card partition 1 and update the kernel.cd ~ git clone http://git.rocketboards.org/linux-socfpga.git cd linux-socfpga git checkout -b socfpga-3.11 origin/socfpga-3.11 export CROSS_COMPILE=~/gcc-linaro-arm-linux-gnueabihf-4.7-2012.11-20121123_linux/bin/arm-linux-gnueabihf- make ARCH=arm socfpga_defconfig make ARCH=arm uImage LOADADDR=0x8000 make ARCH=arm dtbs make ARCH=arm modules
Verify development board boots and test the kernel version by uname -a You should also see the can bus if you type: ip link show 3. Download Yocto to build the new rootfs. This is needed to add the iproute2 to enable the CAN bus. http://rocketboards.org/foswiki/documentation/gsrdgettingstartedyocto Add the following line to ~/yocto/build/conf/local.confcd ~/linux-socfpga/arch/arm/boot cp zImage sdcard/zImage cp dts/socfpga_cyclone5.dtb sdcard/socfpga.dtb
You will want to build the rootfs by:IMAGE_INSTALL_append = " iproute2"
Look in ~/yocto/build/tmp/deploy/images to find the rootfs. Use a linux machine to dd this to the 2nd partition on the sd card.bitbake altera-gsrd-image
4. Connect to the development board through the usb/serial port. You should now have the right "ip" Initialize the can0:cd ~/yocto/build/tmp/deploy/images dd if=altera-image-socfpga_cyclone5.ext3 of=/dev/sdx2
Helpful reference http://www.armadeus.com/wiki/index.php?title=can_bus_linux_driver Now that the can bus is up and running, I am following an example like the following to send messages. http://en.wikipedia.org/wiki/socketcan There may be a better way going about all this. Let me know if there is. Johnip link set can0 up type can bitrate 125000 ifconfig can0 up - Altera_Forum
Honored Contributor
Thanks for laying out the steps - it is very useful.
A new tutorial for setting up linux can on the cyclone5 (https://rocketboards.org/foswiki/documentation/linuxcanbusonthecyclone5) was recently added to the Rocketboards.org website. The tutorial discusses the setup of the device tree and the Linux configuration for CAN support - specifically for the Cyclone5 Development Kit board. It can be found at https://rocketboards.org/foswiki/documentation/linuxcanbusonthecyclone5 - Altera_Forum
Honored Contributor
--- Quote Start --- Thanks for laying out the steps - it is very useful. A new tutorial for setting up linux can on the cyclone5 (https://rocketboards.org/foswiki/documentation/linuxcanbusonthecyclone5) was recently added to the Rocketboards.org website. The tutorial discusses the setup of the device tree and the Linux configuration for CAN support - specifically for the Cyclone5 Development Kit board. It can be found at https://rocketboards.org/foswiki/documentation/linuxcanbusonthecyclone5 --- Quote End --- Hey, I followed the steps given in the RocketBoards website. While at step 3, when I type this command in the terminal - $ git checkout -b linux-socfpga-can-4.1.33ltsi origin/socfpga-4.1.33-ltsi I am getting the Error message: fatal: Not a git repository (or any of the parent directories): .git Has the files been shifted or a newer version available?