Difference between revisions of "Banana Pi"

From Organic Design wiki
(Banana Pi M1+ board layout: antenna connector)
m
 
(58 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[http://www.banana-pi.org/ Banana Pi] is an open source hardware project lead by [http://wiki.banana-pi.org/About_BPI GuangDong BiPai technology co., LTD]. It focuses on the open source hardware development board of ARM and MCU series, provides open software and hardware platform, and creates the basic technology development platform. Full series open source hardware products, complete integration of voice, data, video system platform. Developers can flexibly build various application platforms on the open source hardware foundation platform. It can be applied in the Internet of things, AI artificial intelligence, industrial Internet control, STEAM education and other aspects.  
 
[http://www.banana-pi.org/ Banana Pi] is an open source hardware project lead by [http://wiki.banana-pi.org/About_BPI GuangDong BiPai technology co., LTD]. It focuses on the open source hardware development board of ARM and MCU series, provides open software and hardware platform, and creates the basic technology development platform. Full series open source hardware products, complete integration of voice, data, video system platform. Developers can flexibly build various application platforms on the open source hardware foundation platform. It can be applied in the Internet of things, AI artificial intelligence, industrial Internet control, STEAM education and other aspects.  
  
The Banana Pi boards are inspired by the [[Raspberry Pi]] project, and some of the models have an equivalent Raspberry version which is hardware compatible and exactly the same size so that they can work as drop-in replacements for projects that are designed around Raspberry Pi boards. The Banana Pi boards are more powerful than the Raspberry boards, and have more features, for example many Banana Pis such as the [http://wiki.banana-pi.org/Banana_Pi_BPI-M1%2B Banana Pi M1+] come with a SATA port. This means they can run off a proper hard drive rather than an SD card which has been the cause of a lot of reliability trouble with these single-board computers.
+
The Banana Pi boards are inspired by the [[Raspberry Pi]] project, and some of the models have an equivalent Raspberry version which is hardware compatible and exactly the same size so that they can work as drop-in replacements for projects that are designed around Raspberry Pi boards. The Banana Pi boards are more powerful than the Raspberry boards, and have more features, for example many Banana Pis such as the [http://wiki.banana-pi.org/Banana_Pi_BPI-M1%2B Banana Pi M1+] come with a SATA port, an on-board microphone and an IR receiver. Having a SATA port means it's easy to run the system off a proper hard drive rather than an SD card which makes the board into a far more reliable system suitable for long-running busy server solutions.
  
Note that the concept of a "drop-in" replacement only goes so far in the world of single-board computers, because OS images need to be built specifically for each board. The [[Debian]]-based [https://armbian.com Armbian] project is very good for this because it's been designed to be able to quickly support new boards and OS releases as they come out. They currently support about fifty different boards including the whole Banana Pi series.
+
Note that the concept of a "drop-in" replacement only goes so far in the world of single-board computers, because OS images need to be built specifically for each board. The [[Debian]]-based [https://armbian.com Armbian] project is very good for this because it's been designed to be able to quickly support new boards and OS releases as they come out, and it has a great tool for post-installation setup called the [https://docs.armbian.com/User-Guide_Armbian-Config/ Armbian config utility]. They currently support over 300 different boards including the whole Banana Pi series!
  
 
== Banana Pi M1+ board layout ==
 
== Banana Pi M1+ board layout ==
 +
[[File:Banana PI M1+.jpg]]
 +
 +
== External wifi antenna ==
 +
Compared to the [[Raspberry Pi]], the Banana Pi's wifi signal seems extremely weak, but the Raspberry Pi actually has an on-board micro antenna (shown on the left below) and it works extremely well - the signal is a lot better than many home wifi routers. The Banana Pi boards don't come with any on-board antenna solution, and so an external antenna is necessary if the board is intended to be using the wifi for anything serious such as a hotspot. An antenna is attached via the on-board [[w:Hirose U.FL|U.FL]] micro-connector shown in the photo below to the right.
 
{{table
 
{{table
|[[File:Banana PI M1+.jpg]]
+
|[[File:Raspberry Pi micro antenna.jpg|509px|thumb|The Raspberry Pi 3's wifi micro-antenna]]
|[[File:Banana Pi U.FL connector.jpg|right|500px|thumb|Close-up of the wifi chip and it's [[w:Hirose U.FL|U.FL]] antenna connector - click image to zoom]]
+
|[[File:Banana Pi U.FL connector.jpg|452px|thumb|The Banana Pi M1+ wifi chip and it's [[w:Hirose U.FL|U.FL]] antenna connector]]
 +
|[[File:External antenna.jpg|325px|thumb|Antenna with a U.FL connector]]
 
}}
 
}}
  
== Armbian and headless installation ==
+
== Armbian headless installation ==
[https://armbian.com Armbian] is a great source of up to date OS images with versions available for the Banana Pi series. But one problem with the default minimal server images is that they are not truly headless, you need to set a root password on the first run before SSH logins will work. This is a big problem for us because we don't have keyboards and monitors lying around - occasionally we have TV available, but definitely not a keyboard since we only use laptops, phones and tablets. This is constantly being raised with the developers but they won't budge on it because their perspective is that providing a fully headless version would lead to their OS being used in malicious bot-nets.
+
[https://armbian.com Armbian] is a great source of up to date OS images with versions available for the Banana Pi series. But one problem with the default minimal server images is that they are not truly headless, you need to set a root password on the first boot before SSH logins will work. This is a big problem for us because we don't have keyboards and monitors lying around - occasionally we have a TV near by, but definitely no keyboards since we only use laptops, phones and tablets. This issue is regularly being raised by users, but the developers won't budge on it because their perspective is that providing a fully headless version out of the box would lead to their OS being used in malicious bot-nets.
  
However, we do have access to the full OS file-structure, so we can use ''qemu'' and ''chroot'' to open a shell inside the SD card OS and then set the root password before putting the card into the Pi (see [https://wiki.debian.org/QemuUserEmulation this Debian wiki page] and final comments in [https://forum.armbian.com/topic/3365-first-login-via-ssh-password-1234-does-not-work/ this Armbian forum post] for more detail).
+
However, since we have access to the full OS file-structure, we can use ''qemu'' and ''chroot'' to open a shell inside the file structure while it still resides on our local system. We can then set the root password before inserting the card into the Pi for it's first boot (see [https://wiki.debian.org/QemuUserEmulation this Debian wiki page] and final comments in [https://forum.armbian.com/topic/3365-first-login-via-ssh-password-1234-does-not-work/ this Armbian forum post] for more detail).
  
Here's how we can do it where XX is the path to your mounted SD card or Armbian image file. You could also do any other basic setup you may wish to do here such as create a non-root user, change over to key-based logins, set up your networking details such as wifi access (in ''/boot/armbian_first_run.txt'' based on ''/boot/armbian_first_run.txt.template'') etc.
+
Here's how we can do it where OS_PATH (highlighted) is the path to your mounted SD card or Armbian image file (see [https://askubuntu.com/questions/236263/browse-img-without-mounting this] if you want to mount and modify the image file). You could also do any other basic setup you may wish to do here too, such as adding a public key and changing over to key-based logins, or set up your networking details such as wifi access (this is done in ''/boot/armbian_first_run.txt'' which must be initially copied from ''/boot/armbian_first_run.txt.template'').
 
<source lang="bash">
 
<source lang="bash">
 
apt install qemu-user-static
 
apt install qemu-user-static
cp /usr/bin/qemu-arm-static XX/usr/bin
+
cp /usr/bin/qemu-arm-static {!OS_PATH!}/usr/bin
chroot XX
+
chroot {!OS_PATH!}
 
passwd root
 
passwd root
 +
...
 +
exit
 +
sync
 
</source>
 
</source>
  
'''Important:''' If you have an M1+ you need to add <tt>fdtfile=sun7i-a20-bananapi-m1-plus.dtb</tt> to your ''/boot/armbianEnv.txt'' file otherwise it will be recognised as just an M1 with no wifi!
+
'''Important:''' If you have an M1+ you need to add '''<tt>fdtfile=sun7i-a20-bananapi-m1-plus.dtb</tt>''' to your ''/boot/armbianEnv.txt'' file, otherwise it will be recognised as a model M1 with no wifi!
 +
 
  
You can then power up with the card scan for you device on the subnet as usual and ssh into it with the updated details you provided.
+
You can then power up with the card scan for you device on your subnet as usual and ssh into it with the updated details you provided (use your own subnet details).
 
<source lang="bash">
 
<source lang="bash">
 
nmap -sP 192.168.0.0/24
 
nmap -sP 192.168.0.0/24
Line 33: Line 42:
 
When you ssh into the IP you'll be asked to create an initial non-root user.
 
When you ssh into the IP you'll be asked to create an initial non-root user.
  
Now it's a good idea to run through the awesome [https://docs.armbian.com/User-Guide_Armbian-Config/ Armbian config utility] to configure everything the way you want it. You can even choose to configure your ''wlan'' interface as a hotspot from here!
+
Next it's a good idea to run through the awesome [https://docs.armbian.com/User-Guide_Armbian-Config/ Armbian config utility] to configure everything the way you want it. You can even choose to configure your ''wlan'' interface as a hotspot from here!
 
<source lang="bash">
 
<source lang="bash">
 
armbian-config
 
armbian-config
 
</source>
 
</source>
  
== Getting wifi to work on the M1+ ==
+
== Booting from a SATA drive ==
Armbian for some reason thinks that the M1+ is an M1 which you can see with the following command. This means that the system does not register any evidence of a wifi chip and there will be no ''wlan0'' interface in ''ifconfig'' and nothing will show in ''iwconfig''.
+
Using an SD card as the primary drive for the operating system has poor performance and is also not very reliable, because it can get corrupted easily if the device is spontaneously powered down. So if you have a board with a SATA interface, then using that for your root FS drive is a good idea. In the case of the Banana Pi you'll need a slightly non-standard SATA connector that uses a small connection to the 5v power supply rather than the usual [[w:Molex connector|Molex connector]].
<source>
+
{{table
# cat /proc/device-tree/model
+
|[[File:Banana Pi SATA cable.jpg|554px]]
LeMaker Banana Pi
+
|[[File:BananaPi with external drives and SATA.jpg|452px]]
</source>
+
}}
 +
 
 +
The board currently is only capable of booting from SD card, but you can reduce the role of the card down to handling nothing else but the boot process itself, and then have it switch over to use the SATA as the main partition containing the ''root'' filesystem. Switching the root FS over to the SATA drive was simply a matter of copying everything in the root partition over to the SATA drive (which was formatted as a single EXT4 partition), and then changing the '''rootenv''' parameter in the card's ''/boot/armbianEnv.txt'' to the UUID of your new SATA device. You should also update the UUID of the root mount point in the new device's ''/etc/fstab''.
  
If you get this result, then edit <tt>/boot/armbianEnv.txt</tt> and add the following line to the end of the file:
+
After you've completed those steps, reboot and then check if it's working using '''lsblk -o NAME,SIZE,MODEL,MOUNTPOINT''' or similar:
 
<source>
 
<source>
fdtfile=sun7i-a20-bananapi-m1-plus.dtb
+
NAME          SIZE  MODEL                  MOUNTPOINT
 +
{!sda          111.8G KINGSTON_SA400S37120G  !}
 +
{! └─ sda1      111.8G                        /!}
 +
sdb            1.8T ST2000LM003_HN-M201RAD
 +
└─ sdb1        1.8T                        /backup
 +
mmcblk0        14.5G                       
 +
└─ mmcblk0p1  14.3G                       
 +
zram0            50M                        /var/log
 +
zram1        498.8M                        [SWAP]
 
</source>
 
</source>
  
After rebooting, you should now see the following result from the command instead and you should now have a ''wlan0'' network interface.
+
If it's not working, you'll need to remove the card and change the ''armbianEnv.txt'' back from another computer before you can boot back in to find the problem. Here's some related links:
<source>
+
*https://forum.armbian.com/topic/329-moving-linux-to-sata-or-external-drive/
# cat /proc/device-tree/model
+
*https://forum.htpcguides.com/Thread-Problem-pointing-boot-to-hdd
Banana Pi BPI-M1-Plus
+
*https://www.htpcguides.com/move-linux-banana-pi-sata-setup/
</source>
 
  
== Useful commands ==
+
== Useful Armbian commands ==
 
Monitor the power voltage:
 
Monitor the power voltage:
 
<source lang="bash">
 
<source lang="bash">
 
while true ; do echo "$(awk '{printf ("%0.2f",$1/1000000); }' </sys/power/axp_pmu/ac/voltage)V"; sleep 1; done
 
while true ; do echo "$(awk '{printf ("%0.2f",$1/1000000); }' </sys/power/axp_pmu/ac/voltage)V"; sleep 1; done
 
</source>
 
</source>
 +
 +
 +
What kind of device are you running?
 +
<source>
 +
sudo cat /proc/device-tree/model
 +
</source>
 +
This is especially useful if you have an M1+ which, by default, may think it's just a wifi-less M1. The output of the command above shows "Banana Pi BPI-M1-Plus" for an M1+, or "LeMaker Banana Pi" for a plain M1. See the note in the installation section above for how to fix this if it's showing M1 instead of M1+.
  
 
== Banana Pi resources ==
 
== Banana Pi resources ==
Line 67: Line 92:
 
*[http://forum.banana-pi.org/ Banana Pi forum]
 
*[http://forum.banana-pi.org/ Banana Pi forum]
 
*[https://www.s-config.com/goodbye-raspberry-pi-hello-banana-pi/ Some headless tweaks]
 
*[https://www.s-config.com/goodbye-raspberry-pi-hello-banana-pi/ Some headless tweaks]
 +
*[https://dev-boards.blogspot.com/2014/12/building-u-boot-for-banana-pi.html Building u-boot for the Banana Pi]
  
 
== See also ==
 
== See also ==
 +
*[[Pi projects]]
 
*[[Raspberry Pi]]
 
*[[Raspberry Pi]]
 
*[[Hotspot]]
 
*[[Hotspot]]

Latest revision as of 15:50, 15 February 2020

Banana Pi is an open source hardware project lead by GuangDong BiPai technology co., LTD. It focuses on the open source hardware development board of ARM and MCU series, provides open software and hardware platform, and creates the basic technology development platform. Full series open source hardware products, complete integration of voice, data, video system platform. Developers can flexibly build various application platforms on the open source hardware foundation platform. It can be applied in the Internet of things, AI artificial intelligence, industrial Internet control, STEAM education and other aspects.

The Banana Pi boards are inspired by the Raspberry Pi project, and some of the models have an equivalent Raspberry version which is hardware compatible and exactly the same size so that they can work as drop-in replacements for projects that are designed around Raspberry Pi boards. The Banana Pi boards are more powerful than the Raspberry boards, and have more features, for example many Banana Pis such as the Banana Pi M1+ come with a SATA port, an on-board microphone and an IR receiver. Having a SATA port means it's easy to run the system off a proper hard drive rather than an SD card which makes the board into a far more reliable system suitable for long-running busy server solutions.

Note that the concept of a "drop-in" replacement only goes so far in the world of single-board computers, because OS images need to be built specifically for each board. The Debian-based Armbian project is very good for this because it's been designed to be able to quickly support new boards and OS releases as they come out, and it has a great tool for post-installation setup called the Armbian config utility. They currently support over 300 different boards including the whole Banana Pi series!

Banana Pi M1+ board layout

Banana PI M1+.jpg

External wifi antenna

Compared to the Raspberry Pi, the Banana Pi's wifi signal seems extremely weak, but the Raspberry Pi actually has an on-board micro antenna (shown on the left below) and it works extremely well - the signal is a lot better than many home wifi routers. The Banana Pi boards don't come with any on-board antenna solution, and so an external antenna is necessary if the board is intended to be using the wifi for anything serious such as a hotspot. An antenna is attached via the on-board U.FL micro-connector shown in the photo below to the right.

The Raspberry Pi 3's wifi micro-antenna
The Banana Pi M1+ wifi chip and it's U.FL antenna connector
Antenna with a U.FL connector

Armbian headless installation

Armbian is a great source of up to date OS images with versions available for the Banana Pi series. But one problem with the default minimal server images is that they are not truly headless, you need to set a root password on the first boot before SSH logins will work. This is a big problem for us because we don't have keyboards and monitors lying around - occasionally we have a TV near by, but definitely no keyboards since we only use laptops, phones and tablets. This issue is regularly being raised by users, but the developers won't budge on it because their perspective is that providing a fully headless version out of the box would lead to their OS being used in malicious bot-nets.

However, since we have access to the full OS file-structure, we can use qemu and chroot to open a shell inside the file structure while it still resides on our local system. We can then set the root password before inserting the card into the Pi for it's first boot (see this Debian wiki page and final comments in this Armbian forum post for more detail).

Here's how we can do it where OS_PATH (highlighted) is the path to your mounted SD card or Armbian image file (see this if you want to mount and modify the image file). You could also do any other basic setup you may wish to do here too, such as adding a public key and changing over to key-based logins, or set up your networking details such as wifi access (this is done in /boot/armbian_first_run.txt which must be initially copied from /boot/armbian_first_run.txt.template).

apt install qemu-user-static
cp /usr/bin/qemu-arm-static OS_PATH/usr/bin
chroot OS_PATH
passwd root
...
exit
sync

Important: If you have an M1+ you need to add fdtfile=sun7i-a20-bananapi-m1-plus.dtb to your /boot/armbianEnv.txt file, otherwise it will be recognised as a model M1 with no wifi!


You can then power up with the card scan for you device on your subnet as usual and ssh into it with the updated details you provided (use your own subnet details).

nmap -sP 192.168.0.0/24

When you ssh into the IP you'll be asked to create an initial non-root user.

Next it's a good idea to run through the awesome Armbian config utility to configure everything the way you want it. You can even choose to configure your wlan interface as a hotspot from here!

armbian-config

Booting from a SATA drive

Using an SD card as the primary drive for the operating system has poor performance and is also not very reliable, because it can get corrupted easily if the device is spontaneously powered down. So if you have a board with a SATA interface, then using that for your root FS drive is a good idea. In the case of the Banana Pi you'll need a slightly non-standard SATA connector that uses a small connection to the 5v power supply rather than the usual Molex connector.

Banana Pi SATA cable.jpg
BananaPi with external drives and SATA.jpg

The board currently is only capable of booting from SD card, but you can reduce the role of the card down to handling nothing else but the boot process itself, and then have it switch over to use the SATA as the main partition containing the root filesystem. Switching the root FS over to the SATA drive was simply a matter of copying everything in the root partition over to the SATA drive (which was formatted as a single EXT4 partition), and then changing the rootenv parameter in the card's /boot/armbianEnv.txt to the UUID of your new SATA device. You should also update the UUID of the root mount point in the new device's /etc/fstab.

After you've completed those steps, reboot and then check if it's working using lsblk -o NAME,SIZE,MODEL,MOUNTPOINT or similar:

NAME          SIZE   MODEL                  MOUNTPOINT
sda           111.8G KINGSTON_SA400S37120G   
 └─ sda1      111.8G                        /
sdb             1.8T ST2000LM003_HN-M201RAD 
 └─ sdb1        1.8T                        /backup
mmcblk0        14.5G                        
 └─ mmcblk0p1  14.3G                        
zram0            50M                        /var/log
zram1         498.8M                        [SWAP]

If it's not working, you'll need to remove the card and change the armbianEnv.txt back from another computer before you can boot back in to find the problem. Here's some related links:

Useful Armbian commands

Monitor the power voltage:

while true ; do echo "$(awk '{printf ("%0.2f",$1/1000000); }' </sys/power/axp_pmu/ac/voltage)V"; sleep 1; done


What kind of device are you running?

sudo cat /proc/device-tree/model

This is especially useful if you have an M1+ which, by default, may think it's just a wifi-less M1. The output of the command above shows "Banana Pi BPI-M1-Plus" for an M1+, or "LeMaker Banana Pi" for a plain M1. See the note in the installation section above for how to fix this if it's showing M1 instead of M1+.

Banana Pi resources

See also