BPI-M1 CAN Bus
In order to port can4linux to the BananaPi, the CAN module description is needed from the A20 hardware manual. can4linux is a character-driver-based Linux driver used already on desktop PCs and embedded platforms like Freescale FlexCAN (the i.MX series of micro controllers) or Xiliny Zynq.
There is a more detailed document about CAN on the A20 at https://dl.linux-sunxi.org/A20/CAN Bus1.pdf
This is a tutorial for using CAN BUS on bananapi with bananian 15-01
Thank selqcir share this example:
- Download and install "bananian-1501.img" into 8 GB SDCard.
- Expand the root file system using "bananian-config"
- Install missing package:apt-get install gitapt-get updateapt-get upgradereboot
- Get last bananian available, and continu to install missing package:git clone https://github.com/Bananian/linux-bananapiapt-get install build-essential u-boot-tools uboot-mkimageapt-get install libusb-1.0-0 libusb-1.0-0-dev git wget fakeroot kernel-package zlib1g-dev libncurses5-devapt-get install subversion
- Build kernel:cd linux-bananapimake menuconfig
- Exit without saving when menu appearszcat /proc/config.gz > /root/linux-bananapi/.configmake uImage modulesmake 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.oldmv /lib/firmware /lib/firmware.oldmv /root/linux-bananapi/output/lib/modules /lib/modulesmv /root/linux-bananapi/output/lib/firmware /lib/firmware
- Same for uImage:mount /dev/mmcblk0p1 /mntcd /mntmv uImage uImage.oldmv /root/linux-bananapi/arch/arm/boot/uImage /mntreboot
- Create link for further build:cd /lib/modules/3.4.104/ln -s /root/linux-bananapi buildcd ~
- Get Can4Linux and build it:svn checkout https://svn.code.sf.net/p/can4linux/code/trunk can4linux-codecd /root/can4linux-code/can4linux/make TARGET=BANANAPI
- Install module for each startup of the board:insmod can4linux.kocp can4linux.ko /lib/modules/3.4.104/kernel/net/can/depmod -A -vmodprobe -v can4linuxecho "" >> /etc/modules ; echo "can4linux" >> /etc/modulesreboot
- Build CAN exampleapt-get install swigapt-get install python-devcd can4linux-code/can4linux-examples/
- Update CAN speed and device in file "pyCan-example.py"ex:# setting the device numberdevice = 0defaultBaudrate = '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.
Last modified 3yr ago