Bananian

How to use CAN BUS with bananian distrib ? [SOLVED]

5 5554
selqcir  
Edited by selqcir at Wed Feb 4, 2015 15:56

Hi all,
I just got ma banana pi board, and it work perfecltly at the moment.
I don't have a lot of knowledge on how building some linux drivers, but I was able to install OWFS and use 18B20 sensor.
Now, i would like to use CAN BUS in order to send and received CAN datas.
After reading a lot of post on different forum, i'm unable to understand how i can use this CAN BUS.
I'v got a "VP220" transiver from TI, so i think i could connect it to PIN 16 & 18.
I would like to use python script to read and write CAN datas.
I read on other forum than can4linux was succesful ported to the BananaPi (http://wiki.lemaker.org/Peripheral_interface_development#CAN_Bus)
I've got the last bananian image (Updated : 2015-01-11), but i think CAN BUS is not yet set.
Is there someone than could explain me in details how i could install can4linux with this latest image file ?
Should i compile something special or just enable something ?
Does can4linux is the best driver for banana pi with bananian image file ?

thank you very much.

selqcir  
Edited by selqcir at Tue Jan 27, 2015 15:36

Hi all,
below is a sumary of what i have done:
  1. git clone https://github.com/LeMaker/linux-bananapi.git
  2. zcat /proc/config.gz > /root/linux-bananapi/.config
Copy the Code
copy Module.symvers into linux-bananapi directory
  1. apt-get install libncurses5-dev
  2. apt-get install build-essential
  3. apt-get install u-boot-tools
  4. apt-get install uboot-mkimage
  5. apt-get install kernel-package
  6. apt-get install zlib1g-dev
  7. apt-get install subversion
  8. apt-get update
  9. apt-get dist-upgrade
  10. reboot
  11. cd linux-bananapi
  12. make menuconfig       (Let default value, save and exit when menu appear)
  13. make prepare
  14. make scripts
  15. cd /lib/modules/3.4.104+/
  16. ln -s /root/linux-bananapi build
  17. cd ~
  18. svn checkout https://svn.code.sf.net/p/can4linux/code/trunk can4linux-code
  19. cd /root/can4linux-code/can4linux/
  20. make TARGET=BANANAPI
  21. insmod can4linux.ko
  22. cp can4linux.ko /lib/modules/3.4.104+/kernel/net/can/
  23. depmod -A -v
  24. modprobe -v can4linux
  25. echo "" >> /etc/modules ; echo "can4linux" >> /etc/modules
Copy the Code
After that, i can see in /proc/sys/dev/Can some data, so i think can has been installed.
Then i build can example:
  1. cd can4linux-code/can4linux-examples/
  2. make
Copy the Code
Then i can read baudrate with:
  1. cat /proc/sys/dev/Can/Baud
Copy the Code
and result is 125.
If i want to change to 250, i use binary example:
  1. ./baud /dev/can0 250
Copy the Code
the example says that baudrate has been set to 250 Kbit/s, but when i check again with:
  1. cat /proc/sys/dev/Can/Baud
Copy the Code
I still have 125 ...

I also would like to use python script, but i'm unable to use the example. I had error message
  1. python pyCan-example.py
  2. Traceback (most recent call last):
  3.   File "pyCan-example.py", line 2, in <module>
  4.     import pyCan
  5. ImportError: No module named pyCan
Copy the Code
Is there someone that could help me to understand what is wrong ?
Maybe Can0 should be initialyse by hardware or something like that.

I also plug transiver on rx-can and tx-can (3.3V & gnd), but i can not see any trafic.
Transiver is: Sn65hvd230 CAN Board Network Transceiver Evaluation Development Module Kit 3.3V bought on ebay.
3.3V -> pin 17
GND -> pin 14
CAN_TX -> pin 16
CAN_RX -> pin 18






Module.zip

140.45 KB, Downloads: 39

sazure  
Hi Have you made it? I'm following same steps, but I also got format error.

radius  
Hi selqcir,
where did you find/get Module.zip?

With this, I can finally compile wifi driver
http://forum.lemaker.org/forum.p ... 2&fromuid=68512

when I try make modules, modules symvers created, but without luck of compilig the driver

Radius

selqcir  
Hi Radius.
I found this on the net, but it seems that this one is not the good one.
I'm working at the moment on a tutorial on how to build Can4Linux with bananian, and it seems to work.
We could generate Module.symvers file with a new kernel, but this one is 103+ instead of 104+.
We could be able to build pyCan also and use python example.
We need to make some other test, but i think we are on the good way.
I will let you know when everything will be ok.

selqcir  

You have to log in before you can reply Login | Sign Up

Points Rules