BananaPi

Einge (unstrukturiere) Hinweise zum BananaPi

Where else to look

My blog (or something like that.

And of course the Lemaker forum

Whats in it?

Cortex-A7 CPU Allwinner A20, and the interesting fact, it has an integrated CAN controller, which currently is supported by can4linux.

Burn the Image

I think, creating the SD card is clear. There are many tutorials online. Personally I like the
RaspberryPi.org description much more.

Resize the SD Card root partition

There are instructions at
gleenders.blogspot.de/2014/08/banana-pi-resizing-sd-card-root.html
An it worked for me.

Setting a fixed IP address

In order to have always the same IP address in the local network, it is useful to give the Banana a fixed IP address. The default configurationn (Lubuntu) is using DHCP to get a IP address from the DHCP server, which typical is the home internet router.
Edit the file:

sudo vi /etc/network/interfaces

The following line:

iface eth0 inet dhcp

Or like on my Banana, add after the line
source-directory /etc/network/interfaces.d

Has to be replaced by something like:

iface eth0 inet static
address 192.168.2.20
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers 192.168.2.1 8.8.8.8

The above used IP addresses have to fit somehow the local LAN addresses used by the router.

192.168.2.20   - the fixed IP for the Banana
255.255.255.0  -  netmask for a class C network
192.168.2.1    - the gateway routers IP

On my Banana are man pages installed. More information are available by

man interfaces

And in German Ubuntu Wiki.

VNC

Zuerst das System auf dem BananPi aktualisieren

sudo apt-get update
sudo apt-get upgrade

Das kann schon etwas dauern. Anschließend den VNC Server installieren

sudo apt-get install tightvncserver

Siehe auch Remote Control: VNC Server installieren. Oder den Artikel.

Auf der PC Seite benötigt man einen VNC server. Für Linux, unter SuSE, tut es ein

zypper install gtk-vnc-tools

Was auf Windows zu tun ist? Keine Hanung, vielleicht schribt es mir mal jemend.
Wurde der vncserver auf dem BananaPi gestartet, reicht ein

vncviewer host:display

etwa

vncviewer 192.168.2.106:1

oder

vncviewer banana:1

Controlling Relays via GPIO

I Have a 4 relay module, size: 755520mm.

Connector 3 Pin 5 of the BananaPi ist GPIO1 (durch probieren)
Bedienung
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/gpio/sysfs.txt

sudo su -
/sys/class/gpio
echo 1 > export
echo 1 > gpio1/active_low
echo high > gpio1/direction

while true; do echo 1 > gpio1/value; sleep 1; echo 0 > gpio1/value; sleep 1; done

Dumm nur, dass 0 das Relais einschaltet
daher echo 1 > gpio1/active_low

Changing the host name

See Raspberry

Banana Pro

Da der BananaPi gut läuft, can4linux darauf portiert ist, soll es nun auch weiter gehen.
Der Pro hat den großen Vorteil (für mich) mit Wifi daher zu kommen und er hat mehr IO Pins.
Bei Lemaker nachgesehen, und die SD Card mit Lubuntu_1404_For_BananaPi_v3_1_1.img bespielt.
Unglücklicherweise, ist das On-Board wifi mit den aktuellen OS Images nicht unterstützt. Das Forum sagt, am 24.12, wird es neue Images geben.

Using the new December 2014 Image

I did wait some days for this December 2014 image. It now should have the local WiiFi driver invluded.

I think, creating the SD card is clear. There are many tutorials online.

add favorite user account

In order to have easy access to the Banana Pro and use my files on the NFS server, I always crate the same user account as on my server also on the embedded devices.. First use nmap to obtain the new IP address given by the DHCP server to the device

nmap 192.168.2.1/24
....
Nmap scan report for 192.168.2.121
Host is up (0.00027s latency).
Not shown: 999 closed ports
PORT   STATE SERVICE
22/tcp open  ssh
...

I know the IP adddress range for DHCP clients and some know devices. 192.168.2.121 is the new connected device. Try:

ssh bananapi@192.168.2.121
bananapi@192.168.2.121's password:*bananapi*

and after a successful login:

uname -a
Linux lemaker 3.4.103 #4 SMP PREEMPT Thu Dec 18 12:55:58 CST 2014 armv7l armv7l armv7l GNU/Linux                  

and asking

ifconfig

The command shows, that a wlan? device now is available. For now I will stay with my cable eth0 connection. But the new Banana Pro should get a unique host name. (Remember: the root password is still bananapi):

sudo vi /etc/hosts
change 'lemaker' to 'bananapro'
sudo vi /etc/hostname
change 'lemaker' to 'bananapro'

Here I used vi as editor. It is more powerful than the default editor nano configured for the Lubuntu image. The next step is changing the system default editor fron nano to 'vim'

sudo update-alternatives --config editor 

The Lubuntu image knows the group adm, but in the sudoers file only the group admin is mentioned to get root access. So I change this using the visudo command, and later add my new user account to the adm group.

Add user account

sudo adduser oe --uid 1005
sudo adduser oe adm
sudo adduser oe users
logout

And now the standard login should work with the previous IP address but without give a user name::

ssh 192.168.2.122

Setting the local time zone and locale language settings

If you don't live in the CST, select your time zone and do:

sudo rm /etc/localtime
sudo ln -s  /usr/share/zoneinfo/Europe/Berlin /etc/localtime

sudo locale-gen de_DE
sudo locale-gen de_DE.utf8

Setting up WLAN connection

All my embedded devices have assigned fixed IP addresses.

That's my setting for the internet connections, /etc/network/interfaces:

# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
#source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

# give the standard interface a fixed IP address

auto eth0

iface eth0 inet static
address 192.168.2.21
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers 192.168.2.1 8.8.8.8

iface wlan2 inet static
address 192.168.2.25
netmask 255.255.255.0
gateway 192.168.2.1
dns-nameservers 192.168.2.1 8.8.8.8
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan2

_/etc/wpa_supplicant/wpasupplicant.conf with access rights "-rw------- 1 root root"

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

ap_scan=1

network={
    ssid="my-ssid"
    scanssid=1
    psk="my-passwd"
    proto=RSN
    key_mgmt=WPA-PSK
    pairwise=TKIP
    group=TKIP
    #auth_alg=OPEN
}

Useful German wiki pages.

Installing the nfs client

I do host many files on my main server at home. To get access, e.g. later to the Banana Linux files for the driver development, access via NFS is great.
Only need to install

apt-get install nfs-common

Than create an empty directory somewhere, called mount point, with a unique name like development. And mount the remote file from your server to the local mount point like:

sudo mount 192.168.2.105:/opt/development  ~/development

Installing development tools

For later software development native on the Banana Pro, some additional tools are needed, and easily can be installed:

sudo apt-get install make gcc subversion u-boot-tools git libusb-1.0-0-dev
sudo apt-get install ncurses-devel

For the kernel driver module development I cloned the kernel source from lemaker on my server

 git clone https://github.com/LeMaker/lemaker-bsp
./configure BananaPro

And mounted this directory on the Banana Pro, On the Banana now it is possible to compile native

cd lemaker-bsp
make linux

can4linux

The main documentation is avalailbe at sunxi.
The cpu manual.
The CAN manual.

copy can4linux.ko to /lib/modules/uname -r/..
add the can4linux module name at /etc/modules.

Banana Plus can4linux image: Because I could not manage to compile the can4linux kernel module for the current Lemaker OS image, I compiled the kernel and all modules including the can4linux.ko. You can currently download the complete image based on kernel 3.4.103 at this server. The image comes with installed make, gcc, and CAN utilities.
Updated version (SVN version 473, March 2015) of the can4linux driver and binary tools are available at here again. Please exchange with existing files on the above image.

Phyton using can4linux

To use Phyton with can4linux it is necessary to get the Phyton swig wrapper compiled.
Take care of Python 2.7 or 3.x)

sudo apt-get install swig
sudo apt-get install python-dev

WLAN configuration

http://www.welzels.de/blog/2012/12/raspberry-pi-netzwerk-und-wlan-konfigurieren/

Create an encrypted key, use:

wpa_passphrase MY_ESSID MY_WPA_KEY
network={
    ssid="MY_ESSID"
    #psk="MY_WPA_KEY"
    psk=aebd5aac8952f958dae0ed73f797b9bfe074bcc008e045a5a7028a6dec342f9c
}

Installing a Twitter client

TwitterBot Guide explains in German language how to install a Twitter client. Use to send tweets whenever you boot your Banana or shut it down, send every hour the room temperature or whatever.