Jump to content

Mainline Debian Armbian Banana PI PI4J


Recommended Posts


I have a mainline installation of Armbian (Debian) on my banana pi on which I want to control a display from within java.

Version of the kernel: Linux bananapi 4.11.6-sunxi #6 SMP Fri Jun 23 19:56:18 CEST 2017 armv7l GNU/Linux


The connections I use are as followed:

  Python lib PI4J  
WR 23 4  
RD N.U. N.U.  
DC 24 5  
CS N.U. N.U.  
RESET 25 6  
LED 18 1  
D0 8 10  
D1 7 11  
D2 11 14  
D3 9 13  
D4 10 12  
D5 22 3  
D6 27 20  
D7 17 18  


First I have tried to control the io from wiringPi python:

>>apt-get install python-dev
>>git clone https://github.com/LeMaker/RPi.GPIO_BP -b bananapi ~/RpiGpio
>>cd ~/RpiGpio
>>python ~/RpiGpio/setup.py install
And wrote a script in which I can set all my GPIO on my banana PI, no problem.

Attached a test.py for blinking these IO.


So my connections are ok :-) 

After this I installed openJDK 8

>>apt install -t jessie-backports openjdk-8-jdk ca-certificates-java


I installed the snapshot which I have been using on a raspberry..

>>wget http://get.pi4j.com/download/pi4j-1.2-SNAPSHOT.deb
>>dpkg -i pi4j-1.2-SNAPSHOT.deb


And then compiled and run my Main.java

>>javac -classpath .:classes:/opt/pi4j/lib/'*' -d . Main.java

>>java -classpath .:classes:/opt/pi4j/lib/'*' Main

resulting in eth0 going offline. Does anyone know why my eth0 loses connection?


Hope someone can help me :-S




Link to comment
Share on other sites

Same happends if I use the stable libs.


Here are the steps for reproducing.

//***** JRE (java) 1.7
>>apt-get update
>>apt-get install default-jdk
>>cd ~
>>wget http://get.pi4j.com/download/pi4j-1.1.deb
>>dpkg -i pi4j-1.1.deb
>>mkdir test
>>cd test
>>wget https://forum.armbian.com/applications/core/interface/file/attachment.php?id=1481
>>cp attachment.php?id=1481 Main.java
>>rm attachment.php?id=1481
>>javac -classpath .:classes:/opt/pi4j/lib/'*' -d . Main.java
>>java -classpath .:classes:/opt/pi4j/lib/'*' Main


Is it a wrong pinning table? 

The "mainline notes" do mention something about the pinning but I can not find the correct pinning table for the usage with pi4j. 


Any tips?

Link to comment
Share on other sites

Java as language is shit and support is weaker than for python in Linux so use python. Many apps in your distribution is written with python, much less with java. I have worked with C/C++ over 20 years and when java came I was forced to use that all tough with C++ I implemented software faster than my work mates with java. Python works beautifully in Linux, so when you need a interpreted programming language, use python.

Link to comment
Share on other sites

Thank you for your reply.

In my case there is only a specific lib available in java. At the raspberry the pi4j lib works perfect. On the banana pi it does not.


I think in the kernel some gpio io is switched for io of eth0. as pi4j uses wiringPI libs, it probably also happends if I program it in C using wiringPI. But I will try to test this.

Still Java is the platform I have to use so switching is not an option.




Link to comment
Share on other sites

So I have changed a framebuffer driver to just initialize these pins and exactly the same happends.

In the framebuffer I used The wiringPI Python pinnumbers and use the krnel gpio.h functions.


The code is ansi c ( so no java :-p ) function used:

gpio_request_one(pin, val, desc);


If I not use the 5 red pins in my initial post everything works fine. 


Does anyone know what is wrong and hopefully know how I can fix this?



Link to comment
Share on other sites

The problem in the framebuffer is solved.

At the sunxi wiki (http://linux-sunxi.org/GPIO) there is mentioned you have to calculate your pins.

(position of letter in alphabet - 1) * 32 + pin number


If I want to use IO-4 on CON3 then we can lookup the pin on this website:  http://wiki.lemaker.org/BananaPro/Pi:Pin_definition

IO-4 is PH20 => P-((7*32)+20) => P-244


If I lookup all the io and change it in the framebuffer everything is working fine. 

As the problem now only exists in PI4J I will discuss it further on their issuetracker.







Link to comment
Share on other sites

This topic is now closed to further replies.
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines