BPI-R1 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:
    1
    apt-get install git
    2
    apt-get update
    3
    apt-get upgrade
    4
    reboot
    Copied!
  • Get last bananian available, and continu to install missing package:
    1
    git clone https://github.com/Bananian/linux-bananapi
    2
    apt-get install build-essential u-boot-tools uboot-mkimage
    3
    apt-get install libusb-1.0-0 libusb-1.0-0-dev git wget fakeroot kernel-package zlib1g-dev libncurses5-dev
    4
    apt-get install subversion
    Copied!
  • Build kernel:
    1
    cd linux-bananapi
    2
    make menuconfig
    Copied!
  • Exit without saving when menu appears
    1
    zcat /proc/config.gz > /root/linux-bananapi/.config
    2
    make uImage modules
    3
    make INSTALL_MOD_PATH=output modules_install
    Copied!
  • 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.
    1
    mv /lib/modules /lib/modules.old
    2
    mv /lib/firmware /lib/firmware.old
    3
    mv /root/linux-bananapi/output/lib/modules /lib/modules
    4
    mv /root/linux-bananapi/output/lib/firmware /lib/firmware
    Copied!
  • Same for uImage:
    1
    mount /dev/mmcblk0p1 /mnt
    2
    cd /mnt
    3
    mv uImage uImage.old
    4
    mv /root/linux-bananapi/arch/arm/boot/uImage /mnt
    5
    reboot
    Copied!
  • Create link for further build:
    1
    cd /lib/modules/3.4.104/
    2
    ln -s /root/linux-bananapi build
    3
    cd ~
    Copied!
  • Get Can4Linux and build it:
    1
    svn checkout https://svn.code.sf.net/p/can4linux/code/trunk can4linux-code
    2
    cd /root/can4linux-code/can4linux/
    3
    make TARGET=BANANAPI
    Copied!
  • Install module for each startup of the board:
    1
    insmod can4linux.ko
    2
    cp can4linux.ko /lib/modules/3.4.104/kernel/net/can/
    3
    depmod -A -v
    4
    modprobe -v can4linux
    5
    echo "" >> /etc/modules ; echo "can4linux" >> /etc/modules
    6
    reboot
    Copied!
  • Build CAN example
    1
    apt-get install swig
    2
    apt-get install python-dev
    3
    cd can4linux-code/can4linux-examples/
    Copied!
  • Update CAN speed and device in file "pyCan-example.py"
    ex:
    1
    # setting the device number
    2
    device = 0
    3
    defaultBaudrate = '250'
    Copied!
  • Connect CAN transceiver and CAN bus, and check with for example:
1
python pyCan-example.py
Copied!
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.
Copy link