Installing Debian Linux on a Bananapi Pro
Release date: 2019-01-05
As of October 2018 it is possible to install a regular Debian Linux armhf with a Debian or Vanilla Kernel on the Bananapi Pro without the need to use a super-specialised distribution.
Booting a system like this with u-boot is not straight forward but possible once you understood the syntax. In the following lines I will try to give you some additional information concerning this issue.
You will need a 16 GB SD-card, a host system with a recent Debian Linux and a working SD-card reader to perform the installation.
I recommend a single-partition installation, using ext4 as a filesystem. All data on the sd-card will be erased!
Theoretically it would also be possible to use the "stable" distribution of Debian Linux if you do not want to use "testing", but you should use at least "buster" which 10/2018 is "testing". To change, switch testing to stable in the qemu-debootstrap and sources.list entries.
You use all of this information at your own risk!!! There is absolutely no warranry!!!
BananaPRO BOOT Archive
I collected some files which proved to be very helpful for setting up a Bananapi PRO and packaged them in this archive. Please feel free to use them. It is absolutely possible that the contents may be outdated by the time you are planning to use them and workarounds like the patch to activate the internal wifi will not be necessary any more as they were in 10/2018.
File | Description |
0001-ARM-dts-sun7i-Disable-OOB-IRQ-for-brcm-wifi-on-Cubie.patch | device-tree patch to make internal wifi work (necessary 10/2018) |
boot.cmd | recommended boot script (raw file) |
boot.scr | recommended boot script (image file) |
brcmfmac43362-sdio.bin | firmware needed for internal wifi |
brcmfmac43362-sdio.txt | firmware needed for internal wifi |
gen_boot.scr | script to create the boot script image file |
sun7i-a20-bananapro_DISABLED_OOB-IRQ.dtb | patched device-tree (there may be a newer version packaged with a recent linux kernel) |
u-boot-sunxi-with-spl.bin | u-boot binary (there may be a newer version packaged with a recent u-boot) |
Prepare the host-system
- The following packages need to be installed on the host-system: u-boot-tools, qemu-user-static, debootstrap
On a recent Debian/Linux they can be installed with:
aptitude install u-boot-tools qemu-user-static debootstrap |
Prepare the client-system
- First identify the sd-card using dmesg to get its device (eg /dev/sdX) and substitute this value for ${card}. Please be absolutely sure of the device name.
- Please be absolutely sure that ${card} points to the right device! Severe data-loss could be caused if wrong!!!
- IF YOU ARE NOT ABSOLUTELY SURE OF THE DEVICE NAME, ABORT NOW ! ! !
- Do NOT FORGET to substitute the right device name for ${card} EVERY TIME
- All data on the device (hopefully your new empty sd-card) will be erased if you continue!
- To be on safe side erase the first part of your SD Card (also clears the partition table)
dd if=/dev/zero of=${card} bs=1M count=10 |
- Partition the harddisk using fdisk and reserve all availabe space for the first partition
/sbin/sfdisk --label dos ${card} <<\EndOfFile |
, |
EndOfFile |
- Create an ext4-filesystem on the newly created partition and mount it unter /mnt
(may be "${card}p1" instead of "${card}1" on some systems)
/sbin/mkfs.ext4 "${card}1" |
/sbin/tune2fs -c0 -i0 "${card}1" |
mount "${card}1" /mnt -o rw |
Install Debian Linux on the client-system
- Install Debian Linux testing armhf for example with the following command:
/usr/sbin/qemu-debootstrap --include=net-tools,wpasupplicant,aptitude,joe,linux-image-armmp-lpae,locales,console-data,tzdata,console-setup,keyboard-configuration,aptitude,dbus,u-boot-sunxi,u-boot-tools,firmware-linux,sudo --arch armhf --components=main,contrib,non-free testing /mnt http://ftp.debian.org/debian |
An error message concerning creation of the initrd-image can safely be ignored. The system will start anyway and the error will be corrected on the first boot.
- Install the firmware
(after extracting the files from the archive)
dd if=/mnt/usr/lib/u-boot/Bananapro/u-boot-sunxi-with-spl.bin of=${card} bs=1024 seek=8 |
mkdir -p /mnt/lib/firmware/brcm |
cp brcmfmac43362-sdio.bin brcmfmac43362-sdio.txt /mnt/lib/firmware/brcm |
cp sun7i-a20-bananapro_DISABLED_OOB-IRQ.dtb /mnt/boot |
Configure the client-system
(You need to create the following files)
- /boot/boot.cmd
(adapt the root entry if necessary)
(see boot.cmd, boot.scr and gen_boot.scr in the archive)
cat <<\EndOfFile > /mnt/boot/boot.cmd |
setenv bootargs console=tty0 hdmi.audio=EDID:0 root=/dev/mmcblk0p1 rootwait panic=10 net.ifnames=0 ${extra} |
ext4load mmc 0:1 0x47000000 boot/sun7i-a20-bananapro_DISABLED_OOB-IRQ.dtb |
ext4load mmc 0:1 0x46000000 vmlinuz |
ext4load mmc 0:1 0x48000000 initrd.img |
bootz 0x46000000 0x48000000:${filesize} 0x47000000 |
EndOfFile |
mkimage -C none -A arm -T script -d /mnt/boot/boot.cmd /mnt/boot/boot.scr |
- /etc/fstab
(adapt the root entry if necessary)
cat <<\EndOfFile > /mnt/etc/fstab |
# /etc/fstab: static file system information. |
# |
#<file system> <mount point> <type> <options> <dump> <pass> |
/dev/mmcblk0p1 / auto errors=remount-ro,relatime 0 1 |
tmpfs /tmp tmpfs defaults,auto 0 0 |
|
EndOfFile |
- /etc/network/interfaces
cat <<\EndOfFile >> /mnt/etc/network/interfaces |
|
auto lo |
iface lo inet loopback |
|
allow-hotplug eth0 |
iface eth0 inet dhcp |
|
allow-hotplug wlan0 |
allow-hotplug wlan1 |
|
iface wlan0 inet dhcp |
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf |
|
iface wlan1 inet dhcp |
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf |
|
EndOfFile |
- /etc/apt/sources.list
cat <<\EndOfFile > /mnt/etc/apt/sources.list |
|
deb http://ftp.debian.org/debian testing main contrib non-free |
deb http://security.debian.org/ testing/updates main contrib non-free |
|
EndOfFile |
- /etc/hostname
cat <<\EndOfFile > /mnt/etc/hostname |
bananapro |
EndOfFile |
- /etc/rc.local
cat <<\EndOfFile > /mnt/etc/rc.local |
#!/bin/sh |
|
passwd --quiet --delete root && |
yes | aptitude install && |
( rm -r /debootstrap > /dev/null 2>&1; exit 0; ) && |
cp /etc/profile /etc/profile.SIC && |
/bin/echo -e 'dpkg-reconfigure locales keyboard-configuration tzdata console-setup &&\n\nmv /etc/profile.SIC /etc/profile\n' >> /etc/profile && |
/bin/echo -e '#!/bin/sh\n\nexit 0' > /etc/rc.local |
|
exit 0 |
EndOfFile |
chmod 755 /mnt/etc/rc.local |
Completing the installation
- OPTIONAL: Create aliases for "dir"
This somewhat dirty hack can be used to change the behaviour of the dir command if wanted
for i in etc/bash.bashrc etc/profile etc/skel/.bashrc etc/skel/.profile root/.bashrc root/.profile; do /bin/echo -e "\nalias dir='ls -ahl --color'\n" >> /mnt/$i; done |
- Unmount the sd-card
- Insert the sd-card into the Bananapi Pro, power it up and hope for the best...
- After successful booting and logging in as root set the root password and create a regular user account
passwd root |
adduser pi |
adduser pi sudo |
- Setup your wifi account
Substitute ${ssid} and ${passphrase} for the real values in your network
wpa_passphrase ${ssid} ${passphrase} > /etc/wpa_supplicant/wpa_supplicant.conf |
- After everything including network is working, consider to install a graphical desktop...
aptitude update |
aptitude full-upgrade |
aptitude install task-lxde-desktop |
References
http://sunxi.org/Bootable_SD_card#Cleaning
https://wiki.debian.org/InstallingDebianOn/Allwinner
http://wiki.lemaker.org/BananaPro/Pi:Setting_up_the_Linux_distribution_root_file_system
http://linux-sunxi.org/Mainline_Debian_HowTo#Setting_up_the_SD-card
http://linux-sunxi.org/Mainline_U-Boot
HOME
© 2018-2019 by Bodo Giannone
Alle Angaben ohne Gewähr !!! Caveat lector