Bananian
Tutorial: How to use CAN BUS on BananaPi with Bananian
18
22382
View: 22382|Reply: 18
|
[Bananian]
Tutorial: How to use CAN BUS on BananaPi with Bananian
[Copy link]
|
|
Edited by selqcir at Wed Feb 4, 2015 15:55
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
Copy the Code 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
Copy the Code - Build kernel:- cd linux-bananapi
- make menuconfig
Copy the Code - Exit without saving when menu appears- zcat /proc/config.gz > /root/linux-bananapi/.config
- make uImage modules
- make INSTALL_MOD_PATH=output modules_install
Copy the Code - 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
Copy the Code - Same for uImage:- mount /dev/mmcblk0p1 /mnt
- cd /mnt
- mv uImage uImage.old
- mv /root/linux-bananapi/arch/arm/boot/uImage /mnt
- reboot
Copy the Code - Create link for further build:- cd /lib/modules/3.4.104/
- ln -s /root/linux-bananapi build
- cd ~
Copy the Code - 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
Copy the Code - 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
Copy the Code - Build CAN example- apt-get install swig
- apt-get install python-dev
- cd can4linux-code/can4linux-examples/
Copy the Code - 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:- Update CAN speed and device in file "pyCan-example.py"
ex:- # setting the device number
- device = 0
- defaultBaudrate = '250'
Copy the Code - Connect CAN transceiver and CAN bus, and check with for example: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.
|
|
|
|
|
|
|
|
I did ok till here
126 root@bananapi ~ # make INSTALL_MOD_PATH=output modules_install 
make: *** No rule to make target `modules_install'. Stop.
took me a long time...first time i tried compiling a kernal i think me and the screen just became friends.
any ideas were i go from here?
very goog tut
thanks |
|
|
|
|
|
|
|
Since:
The INSTALL_MOD_PATH option specifies the directory where the full module tree will be made available.
do i need this change this ?
make INSTALL_MOD_PATH=../lib/modules/3.4.104+ modules_install
or
make INSTALL_MOD_PATH=../lib/modules/$(KERNALRELEASE) modules_install
/*
Quote
- 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.
*/
Module.symvers is in "/linux-bananapi" theres no "/output" dir there
and change the related mv commands to:
mv /root/linux-bananapi/lib/modules /lib/modules
mv /root/linux-bananapi/lib/firmware /lib/firmware
Am i on the riGht track?
Thanks to your tut, you sparked my interest of something I was afraid of.
Now I wanna play with kernals some more....Very cool....as is the bpi
Im a 60 yr old paint and bodyman i know cars, automobile "can bus" is the present and future....for now.
I need this can bus.
I wont post anymore b4 i RTFM
Thanks |
|
|
|
|
|
|
|
Hello.
I don't know what could be wrong.
Maybe stupid question, but:
Did you use "banana pi" board (first version) ?
Did you build on the banana pi board (not on computer) ?
On my board, i have the /output directory.
This is my new version:- root@bananapi:~/linux-bananapi# uname -a
- Linux bananapi 3.4.104 #1 SMP PREEMPT Wed Feb 4 16:27:59 CET 2015 armv7l GNU/Linux
Copy the Code I can priovide you my "Module.symvers"
Try with this one. |
|
|
|
|
|
|
|
no not stupid question (am i on the wrong version? i'd that pro...depends on wifi )
sata, duall core and canbus made me a buyer
yes version 1
Linux bananapi 3.4.104+ #1 SMP PREEMPT Thu Jan 8 15:40:40 CET 2015 armv7l GNU/Linux
yes built on the banana board
when i origionally ran command
# make uImage modules
the screen appeared to hang and spit out a couple lines of whitespace so i hit enter a couple times then got the command prompt
I'll try your Module symvers.
if not...I am not so far along I cant start with a clean install. I have only added a sata drive since last post.
I just set up debian desktop machine.
normally would that be ok...if i set up the proper environment?
I have openwrt on routers, nslu2, nas200...now its rpi bpi it seems to make sense to cross-compile.
ill post how i make out....
I just cant let go of the can bus issue...I live for the challenge.
thanks
|
|
|
|
|
|
|
|
the warning was there i ...how did i overlook it ?...long nights?... wtf
"Linux bananapi 3.4.104" instead of "Linux bananapi 3.4.104+", because i was unable to find same sources than Bananian
I'm sorry I wasted your time.
i should not have jumped the beginners section ...i seen ur tut wanted that canbus
thank you for your help...
|
|
|
|
|
|
|
|
Update
Started from scratch. and changed the references "3.4.104" to "3.4.104+"
I had a few errors but overall everything went well.
I changed default speed to 1MHZ ...to match high end of the MCP2551 CAN Transceiver used in the schematics from ELM237 OBD to rs232 interpreter (do not use 1mhz on the J1962 interface...I am testing MCP2551)
running "python pyCan-example.py" yielded
....... swig-python wrapper loaded
....... bit rate changed
... sent message
... sent message
... sent message
... sent message
... sent message
Wait 10 sec for an message.....
appears all went well...The rest needs placed in a different thread or forum if anyone is interested.
A big thank you goes to selqcir for the great work
|
|
|
|
|
|
|
|
Edited by orinoco at Thu Mar 19, 2015 06:02
Is there a possibility that canbus support will be in main bananian branch for default? Or build better package that is installed with oneliner from git or even from apt-get? I can follow the instructions but as mentor for some bpi owners & car enthusiasts I would like that all neccesary things will be in the distro if one will choose bananian as the basis of the project.
Could you please post some pics from pinout in the board and canbus connection to the vehicle? |
|
|
|
|
|
|
|
to get the right linux.headers (build folder) just
apt-get install linux-headers
so you don't need to change the kernel
best regards |
|
|
|
|
|
|
|
Edited by bino at Thu Sep 10, 2015 04:11
Dear all, C/Q selqcir
I tried to adapt the steps, but for my cubie board 2
First, here is my FEX modification ...
Base on https://microdotup.wordpress.com/2014/07/04/87/ looks like bananapi it use H20 + H21 as CAN_TX and CAN_RX
- [can_para]
- can_used = 1
- can_tx = port:PH20<4><default><default><default>
- can_rx = port:PH21<4><default><default><default>
Copy the Code
after reboot, I got /dev/can0
But ... dmesg show some error.
And when I tried python example without any other CAN device attached to the bus ... I got
- root@vtis-rover:/usr/local/src/can4linux-code/can4linux-examples# python ./pyCan-example.py
- ....... swig-python wrapper loaded
- ....... bit rate changed
- open can0 none blocking
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2179.079564] Internal error: Oops: 5 [#2] PREEMPT SMP ARM
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2179.954562] Process python (pid: 3425, stack limit = 0xee5142f0)
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2179.963084] Stack: (0xee515dd0 to 0xee516000)
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2179.975372] 5dc0: c00eef3c ee75a240 bf094da4 c00eef0c
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2179.987747] 5de0: c00eef3c ee75a2c0 ef008c00 c00eef48 c00eef3c c047471c eec2dc38 c00eeb20
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.000165] 5e00: 00000001 c0b24418 00000000 ee5dfa30 eccea840 eec83550 eea15250 c00ef20c
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.012551] 5e20: 008e5050 c00ef2ec ee515e3c 00000000 00000000 00000000 eccea840 ee5dfa30
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.025033] 5e40: eec83550 c00e9788 ee515ef8 ee5dfa30 00000802 00000000 00000026 00000001
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.037468] 5e60: 00000000 c00f7edc ee515ef8 01863e8f 00000004 ee5dfa30 00000000 ee515ef8
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.049937] 5e80: ee515f78 ee416000 ee515eb8 ee514000 ee514000 00000000 008e5050 c00f8a0c
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.062450] 5ea0: ee515eb4 140295f1 ffffffff ef152800 00001e0e 00000000 eea15250 eec83550
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.075012] 5ec0: 0022487c d0811ffc 00000000 ee515f78 00000001 ee416000 ffffff9c ffffff9c
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.087650] 5ee0: ee514000 00000000 008e5050 c00f8db4 00000041 c0a15720 eea15250 eec83550
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.100352] 5f00: 01863e8f 00000004 ee416005 00000000 eec2dc38 ee5dfa30 00000101 00000004
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.113121] 5f20: 00000000 00000000 00000001 00000001 ee515f44 c005e754 00000003 ee7cee00
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.125942] 5f40: 008e5050 c07069b8 00000000 00000802 00000000 00000000 00000000 00000802
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.138687] 5f60: ee416000 00000003 00000001 c00ea640 ee515f84 c005e754 00000802 c09f0000
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.151539] 5f80: 00000026 00000100 c0a0f520 b6d778a0 b6bcba5d 00000000 00000005 c000eac4
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.164330] 5fa0: ee514000 c000e940 b6d778a0 b6bcba5d bef128a4 00000802 ffffffff bef128a4
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.177132] 5fc0: b6d778a0 b6bcba5d 00000000 00000005 008e5188 00000001 008d5050 008e5050
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.189940] 5fe0: bef12898 bef12898 b6bc7e2b b6fc1eac 60000010 bef128a4 000042bf 00000000
- Message from syslogd@vtis-rover at Sep 10 10:08:18 ...
- kernel:[ 2180.333501] Code: e5943154 e5911014 e3a04001 e7922101 (e7931002)
- Segmentation fault
Copy the Code
Kindly please give me some enlightenment to fix the problem.
Sincerely
-bino- |
|
|
|
|
|
|