thank selqcir share it :
Hi. This is a tutorial for using CAN BUS on bananapi with bananian 15-01.
-
Download and install “bananian-1501.img” into 8 GB SDCard.
-
Expand the root file system using “bananian-config”
-
Install missing package:
apt-get install git apt-get update apt-get upgrade reboot Get last bananian available, and continu to install missing package:
git clone https://github.com/Bananian/linux-bananapi apt-get install build-essential u-boot-tools uboot-mkimage apt-get install libusb-1.0-0 libusb-1.0-0-dev git wget fakeroot kernel-package zlib1g-dev libncurses5-dev apt-get install subversion
Build kernel:
cd linux-bananapi
make menuconfig
Exit without saving when menu appears
zcat /proc/config.gz > /root/linux-bananapi/.config
make uImage modules
make INSTALL_MOD_PATH=output modules_install
At this step, kernel should be compiled and “Module.symvers” should be available Then rename modules and firmware provide by Bananian, and replace by the new one.
mv /lib/modules /lib/modules.old
mv /lib/firmware /lib/firmware.old
mv /root/linux-bananapi/output/lib/modules /lib/modules
mv /root/linux-bananapi/output/lib/firmware /lib/firmware
Same for uImage:
mount /dev/mmcblk0p1 /mnt
cd /mnt
mv uImage uImage.old
mv /root/linux-bananapi/arch/arm/boot/uImage /mnt
reboot
Create link for further build:
cd /lib/modules/3.4.104/
ln -s /root/linux-bananapi build
cd ~
Get Can4Linux and build it:
svn checkout https://svn.code.sf.net/p/can4linux/code/trunk can4linux-code
cd /root/can4linux-code/can4linux/
make TARGET=BANANAPI
Install module for each startup of the board:
insmod can4linux.ko
cp can4linux.ko /lib/modules/3.4.104/kernel/net/can/
depmod -A -v
modprobe -v can4linux
echo "" >> /etc/modules ; echo "can4linux" >> /etc/modules
reboot
Build CAN example
apt-get install swig
apt-get install python-dev
cd can4linux-code/can4linux-examples/
At this step, if you want to use python sample, you should make some modification:
edit file “Makefile” and replace line 190:
$(CC) $(CFLAGS) -c -fpic -I/usr/include/python
by
$(CC) $(CFLAGS) -c -fpic -I/usr/include/python2.7 \
Build example:
make
make pyCan
Update CAN speed and device in file “pyCan-example.py” ex:
# setting the device number
device = 0
defaultBaudrate = '250'
Connect CAN transceiver and CAN bus, and check with for example:
python pyCan-example.py
That’s all
With this method, kernel version is “Linux bananapi 3.4.104” instead of “Linux bananapi 3.4.104+”, because i was unable to find same sources than Bananian 15-01 , but CAN bus work !
Feel free to comment or update.
Enjoy.