###################################################################################### # Document..: INSTALL_BANANAPI.TXT # Purpose...: How to install Slackware ARM on the LeMaker Banana Pi. # Author....: Stuart Winter # For questions and support, please use the Slackware ARM forum # http://www.linuxquestions.org/questions/slackware-arm-108/ # Reference : https://wiki.debian.org/InstallingDebianOn/Allwinner # Date......: 01-Aug-2015 ###################################################################################### # Change Log ############# # 01-Aug-2015 # * Included instructions to support installation on the Banana Pi Pro. # 09-Jun-2015 # * With U-Boot v2015 the Frame Buffer is now available. Adjusted the U-Boot config # lines to use it. # Section 3.1: Added new variable 'slkconsole' # Section 5.1: Added new variable 'slkconsole' to 'setenv bootargs ...' # To make these changes take effect, in to the U-Boot command prompt:- # 1. Paste in the new 'setenv slkconsole ..' line from section 3.1. # 2. Paste in the new 'setenv bootargs ..' line from section 5.1. # 3. saveenv; reset # 14-May-2015 # * Moved order of U-Boot commands to load FDT, initrd and zImage for the Installer # launch. # Thanks to Reynald Poittevin for the report. # 01-Mar-2015 # * First version ####################################################################################### 0.0 Banana Pi hardware and accessories requirements ----------------------------------------------- - Banana Pi and an appropriate power cable/PSU - Banana Pi SATA cable https://www.newit.co.uk/shop/All-Banana-Pi/BananaPi/BPiSATACable - 2.5inch SATA drive Note that the Banana Pi SATA cable _only_ works with 2.5" SATA drives. 3.5" SATA drives require more power than a Banana Pi can provide. - PL2303 serial cable with wires terminating in pin blocks that can sit on the UART interface of the Banana Pi. The author uses this product, but there are many others available:- 'PL2303HX USB to TTL to UART RS232 COM Cable module Converter' https://www.amazon.co.uk/gp/product/B008AGDTA4 You must connect the pins according to the vendor's documentation; please see section 'Using the TTL serial port' of the following page: http://wiki.lemaker.org/BananaPro/Pi:How_to_login_to_the_system If the pages have been removed, there are some copies of the most important sections here. All copyrights remain with LeMaker. http://ftp.arm.slackware.com/slackwarearm/platform/arm/refs/allwinner/A20/docs - SD Card This document covers installing the Slackware Operating System on to the 2.5" SATA drive. The SD card is only used for the boot loader ('U-Boot') which is a few hundred KBytes in size. Any SD card whose capacity is a few MBytes (the author uses a 16MByte SD card) will suffice -- using a large SD card is wasteful in this documented setup. - SD Card slot in your x86 host, or a USB SD Card reader/writer 1.0 Assumptions ----------- Several assumptions -- in the form of IP addresses and directory paths -- are made to help writing the examples for this documentation. These values are easy to modify to suit your environment. Network environment: ```````````````````` - You have a host machine running an existing Slackware system. Any other Unix/Linux system will suffice, but each Linux distribution is different so you'll have to make some adjustments. This machine will house the Slackware ARM tree, NFS/HTTP & TFTP server. - Your host machine has Internet access, or some method of obtaining the Slackware ARM tree. - You have a secure (you trust the people using it) LAN, on 192.168.1.0/24 - Your host machine has the IP 192.168.1.1 - You can NFS export the Slackware ARM tree, or can run the Python 'SimpleHTTPServer' module within a local copy of the Slackware ARM tree. - You can run a TFTP daemon on your host - You want to use /export to house the Slackware ARM tree. Usage profile of the Banana Pi: ``````````````````````````````` - You will be installing the Slackware Operating System on to an external SATA drive. Other options are available, but this document only covers the author's personal set up. If you would like to contribute to the expansion of use cases, please send the author a diff. 2.0 Configuring your environment ---------------------------- 2.1 Downloading Slackware ARM -------------------------- Assumptions: [ ] Your current user has read/write/execute access to /export Make the directory that we'll download Slackware ARM into: # mkdir -p /export/slackwarearm # cd /export/slackwarearm Download: The easiest way to download Slackware ARM is to use rsync. # rsync \ --exclude '*/source/*' \ --delete -Pavv \ ftp.arm.slackware.com::slackwarearm/slackwarearm-14.2 . Whilst it is possible to use the FTP or HTTP installation over the Internet, it's recommended to download the full tree first, as in this example, and install from a local NFS export or local HTTP server. This is because if something were to go wrong during the installation, you do not need to download the packages from the Internet again. The full download will be approximately 3GB. You may choose a mirror site - some are listed on the Slackware ARM web page: http://arm.slackware.com 2.2 Setting up the data export service ---------------------------------- Unless you already have an existing NFS configuration set up on your machine, the easiest way to make the Slackware ARM tree available is to run the simple Python-based HTTP server. Choose the most appropriate option for you and setup either an HTTP server or an NFS export, detailed in the two sections below. 2.2.1 HTTP server ----------- On your Slackware host, change into the directory into which you downloaded the Slackware ARM tree, and launch the Python HTTP server: You may wish to start this under 'screen' or at least in another shell - and preferably as a non-root user unless you are on a secure LAN: # cd /export/slackwarearm && python -m SimpleHTTPServer 2.2.2 NFS export ---------- On your Slackware host, add a line similar to the example below: /export/slackwarearm 192.168.1.0/255.255.255.0(ro,nohide,root_squash,sync,no_subtree_check) If you don't have an NFS server already running: # chmod +x /etc/rc.d/{rc.rpc,rc.nfsd} # /etc/rc.d/rc.nfsd restart If you have an NFS server already running: # exportfs -va 2.3 Setting up your TFTP boot server -------------------------------- Slackware ships a tftpd (TFTP boot daemon) in the 'tftp-hpa' package which can be found in the 'n/' package series. Ensure that inetd is running: # chmod +x /etc/rc.d/rc.inetd # /etc/rc.d/rc.inetd restart By default, the line in /etc/inetd.conf that loads the TFTP server is commented out. # tftp dgram udp wait root /usr/sbin/in.tftpd in.tftpd -s /tftpboot -r blksize Uncomment that line. Note: If you want to use a directory other than /tftpboot to house the data, you may do so - but note that the instructions in this document refer to /tftpboot, so please remember to adjust the paths as you go. Cause inetd to re-load its configuration file: # killall -HUP inetd 2.4 Populating the /tftpboot directory ---------------------------------- Assumptions: [ ] Your current user has read/write/execute access to /tftpboot To begin the installation on the Banana Pi, we'll boot the Linux Kernel and Initial RAM disk via TFTP. Copy the Kernel and Initial RAM disk images into the tftpboot directory: # mkdir -vpm755 /tftpboot/slackwarearm-14.2 # cd /export/slackwarearm/slackwarearm-14.2/ Copy the Slackware ARM installer: # cp -fav isolinux/initrd-armv7.img /tftpboot/slackwarearm-14.2/ The Linux Kernel & the DTB files (Device Tree Blob): # cp -fav kernels/armv7/{zImage*,dtb} /tftpboot/slackwarearm-14.2/ The Initial RAM disk, used for booting the OS after installation (This shouldn't be needed, but it's useful as a fall back in case your system cannot load the OS initrd from the local media for some reason): # cp -fav kernels/armv7/initrd* /tftpboot/slackwarearm-14.2/ 2.5 Writing the U-Boot boot loader to the SD card --------------------------------------------- On your Slackware x86 host, you will need to write the U-Boot image to the SD card from which your Banana Pi will boot. ********************************************************************************** ** The following are _examples_ only. You must determine what the correct ** ** device name is for your SD card, otherwise you will most likely destroy data ** ** on your hard disk, or of another SD card !! ** ********************************************************************************** Download the U-Boot image: # cd /tmp For the Banana Pi: # wget http://ftp.arm.slackware.com/slackwarearm/platform/arm/bootware/bin/bananapi.sdcard_latest.img.xz For the Banana Pi Pro: # wget http://ftp.arm.slackware.com/slackwarearm/platform/arm/bootware/bin/bananapro.sdcard_latest.img.xz As root on your Slackware x86 machine, write U-Boot loader to an SD card:- # xzcat *sdcard_latest.img.xz > /dev/mmcblkXXX ## Replace XXX with the correct value (usually '0' or '1') Write U-Boot loader to the SD card that is in a USB SD card reader/writer:- e.g. xzcat *sdcard_latest.img.xz > /dev/mmcblk9 ## Replace XXX with the correct value (usually '0' or '1') 3.0 Connecting to the Banana Pi via the Serial Port ------------------------------------------------ You must have connected the PL2303 USB to serial converter cable to the UART interface of the Banana Pi at this point. 1. Configure your terminal software with the following settings: In Slackware you can use 'screen' which provides great terminal emulation and also allows you to connect to the device's serial port: 'screen' in the 'ap' series To use 'screen': # screen -T screen-256color /dev/ttyS0 115200,-crtscts 2. Connect the serial cable that comes with the Banana Pi to your PC. 4. Power on the Banana Pi. 5. Open the connection to the Banana Pi serial port Example (check the output of 'dmesg' to see what ttyUSB value it should be) # screen -T screen-256color /dev/ttyUSB0 115200,-crtscts 8. You should see the output from the Banana Pi appearing in your terminal window. 9. You will see a prompt saying you can press any key to interrupt the boot process. Press ENTER a few times and you will be dropped into the U-Boot console, and sit at the 'sun7i# ' prompt. 3.1 Configuring the Banana Pi -------------------------- 1. Reset U-Boot configuration to factory defaults: sun7i# env default -a 2. Set or request an IP address for the Banana Pi: The Banana Pi U-Boot console needs an IP address temporarily to contact the TFTP boot server. If you are running a DHCP server on your network, you may prefer to request an IP address by DHCP. To set an IP statically: sun7i# setenv ipaddr 192.168.1.20 To request an IP via DHCP: sun7i# dhcp 3. Set the IP address of the TFTP server: This is the IP address of your Slackware x86 host on which the TFTP daemon runs. sun7i# setenv serverip 192.168.1.1 4. Set generic boot configurations: The following settings apply to both the Slackware Installer and the installed Slackware OS, with the exception of the Linux console setting. You won't need to change these again. The long line must be pasted in correctly and as a single line, otherwise the configuration will be incorrect. You may need to paste in the long lines by pasting in one piece at a time, since U-Boot on the Banana Pi does not seem to cater for the pasting of long lines. sun7i# setenv fdt_addr 0x43000000 sun7i# setenv kernel_addr_r 0x47000000 sun7i# setenv ramdisk_addr_r 0x48000000 sun7i# setenv bootcmd_generic 'debug earlyprintk sunxi_g2d_mem_reserve=0 sunxi_ve_mem_reserve=0 disp.screen0_output_mode=EDID:1280x720p50 hdmi.audio=EDID:0' After the OS has been installed, you have the choice of using the 'simplefb' Framebuffer to access your Linux console over the Banana Pi's HDMI port or through the serial port. Note: All U-Boot configuration changes still need to be configured using the serial port console. The installer will also use the serial console. To configure the installed OS's Linux console to use the _serial_ port, paste in the following:- sun7i# setenv slkconsole "console=ttyS0,115200n8" To configure the installed OS's Linux console to use the _HDMI_ port, paste in the following:- sun7i# setenv slkconsole "console=tty1" 5. Save the settings and reboot the device: sun7i# saveenv ; reset The device will reboot. Press ENTER to stop the automatic boot process. 4.0 Slackware ARM installation -------------------------- Power cycle/reset (as you will have in the previous step) the Banana Pi and interrupt the boot process again by pressing the ENTER Key. 4.1 Booting the installer --------------------- ** Note that the variable names used below should be pasted in verbatim - U-Boot will expand them automatically to what was configured in step 3 of section 3.1 above. ** For the Banana Pi: sun7i# tftp ${fdt_addr} slackwarearm-14.2/dtb/sun7i-a20-bananapi.dtb For the Banana Pi Pro: sun7i# tftp ${fdt_addr} slackwarearm-14.2/dtb/sun7i-a20-bananapro.dtb Applicable to both: sun7i# fdt addr ${fdt_addr} 0x40000 sun7i# tftp ${kernel_addr_r} slackwarearm-14.2/zImage-armv7 sun7i# tftp ${ramdisk_addr_r} slackwarearm-14.2/initrd-armv7.img Set the initial boot environment, and boot the installer: The installer will be operated via the serial console. If you have configured the output to be HDMI (see above) then this choice will take effect after the OS has been installed and has booted. sun7i# setenv bootargs "console=ttyS0,115200n8 ${bootcmd_generic} TERM=screen-256color nodhcp root=/dev/ram rw" sun7i# bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr} 4.1.2 Starting the network automatically (most likely preferred option if you are using DHCP) --------------------------------------------------------------------------------------- To save manual effort, you may wish to have the Slackware installer boot and automatically: - have the IP address assigned by DHCP (requires a DHCP server on your network); - start the SSH server This way you can SSH directly to the Banana Pi without any further work via the serial console. However, the serial console support works perfectly in the installer so SSH is just an option if you prefer to use it. To do this, adjust the "bootargs" above (in step 4.1) to be: sun7i# setenv bootargs "${bootcmd_generic} console=ttyS0,115200n8 TERM=screen-256color nic=auto:eth0:dhcp root=/dev/ram rw" sun7i# bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr} ; reset 4.2 Starting the network manually ----------------------------- If you would rather bring up networking manually, or you do not have a DHCP server on your network, you need to follow this section. Before you can mount the NFS share, you need to setup networking in the installer. # ifconfig eth0 You should see a stanza for eth0. If you have a DHCP server on your network, you can request an IP address by dhcp: # dhcpcd eth0 # ifconfig eth0 Note down the IP address. You can complete the installation via SSH if you wish, or conduct it all via the serial connection that you have open. If you don't have a DHCP server then you need to configure the network address manually: # ifconfig eth0 192.168.1.20 netmask 255.255.255.0 Remember that you'll need to adjust these network settings for your own LAN! 4.3 Begin the setup --------------- Slackware ARM has an identical installer to Slackware x86, so the same tools are available, including fdisk. The installation will be conducted via the serial console. 4.3.1 Partitioning your hard disk --------------------------- You should find your SATA drive identified as /dev/sda. Use the following partitioning scheme: /dev/sda1 - 400MB Linux Swap /dev/sda2 - The remainder of the disk which will be used as the root file system ('/'). 'Format' this as ext4. You can create the partition table using fdisk or cfdisk. 4.3.2 Start the installer menu ------------------------ Either using the SSH or the serial console session to the Banana Pi, start up the installer menu: # setup The first thing to do is 'ADD SWAP'. Select this menu option and let the installer locate the swap partition and format it. From now on the installer will progress automatically on to the next steps. 4.3.3 Setting up filesystems ---------------------- The Slackware installer will first present a list of available "Linux" type partitions, and ask which one should be the root ('/') partition. If you are following the partition layout as suggested in this document then you should choose /dev/sda2, and format it as ext4. The next step to "Select other Linux partitions for /etc/fstab" 4.3.4 Source media selection ---------------------- Depending upon your choice in section 2.2, you must now choose the corresponding installation source - NFS or HTTP. 4.3.4.1 Installing from an NFS export ----------------------------- Choose menu option '3 - Install from NFS (Network Filesystem)' Enter the IP address: 192.168.1.1 Enter the directory : /export/slackwarearm/slackwarearm-14.2/slackware 4.3.4.2 Installing from an HTTP server ----------------------------- Choose menu option '4 Install from FTP/HTTP server' Enter the URL......: http://192.168.1.1:8000 Enter the directory: /slackware/ 4.3.5 Package selection ----------------- Slackware ARM has all of the Slackware packages apart from those which are x86 only. It's up to you which packages you install, but we recommend a full installation. 4.3.5.1 Choosing an X Window Manager ---------------------------- Whilst works on the ARM platform, it's not recommended since it's very resource heavy. You can choose any of them, but it's recommended to choose something light weight such as WindowMaker or Fluxbox. 5.0 Booting the Slackware ARM OS ---------------------------- Congratulations! After you've completed the installation of Slackware ARM, you will be prompted to reboot - choose 'Yes'. The Banana Pi will now reboot back into the U-Boot console. ** Note: If you find that your system does not reboot, you will need to press the 'reset' button your Banana Pi ** Once again, interrupt the U-Boot boot process, and you'll be dropped into the familiar 'sun7i#' U-Boot console. We now need to tell the Banana Pi how to boot the Operating System. In section 4.3.1 (Partitioning your hard disk), you chose a disk layout and chose which filesystem to use. If you followed the example in this document, you won't need to change anything below. If you chose your own disk layout, here follows an explanation of some of the values contained in the U-Boot configuration below: The first line: root=/dev/sda2 This is where Linux will find its root filesystem ('/'). rootfstype=ext4 The filesystem (e.g. ext2,ext3,ext4,xfs,jfs,reiserfs) used on the root filesystem. Paste these lines (all text after the 'sun7i# ' prompt) into your Banana Pi U-Boot console, adjusting any necessary settings, as described above: For the Banana Pi: sun7i# setenv bootcmd_dtb 'ext4load scsi 0:2 ${fdt_addr} /boot/dtb/sun7i-a20-bananapi.dtb ; fdt addr ${fdt_addr} 0x40000' For the Banana Pi Pro: sun7i# setenv bootcmd_dtb 'ext4load scsi 0:2 ${fdt_addr} /boot/dtb/sun7i-a20-bananapro.dtb ; fdt addr ${fdt_addr} 0x40000' Applicable to both: sun7i# setenv bootcmd_slk 'scsi reset ; scsi scan ; run bootcmd_dtb ; ext4load scsi 0:2 ${kernel_addr_r} /boot/zImage-armv7 ; ext4load scsi 0:2 ${ramdisk_addr_r} /boot/initrd-armv7' sun7i# setenv bootargs "${slkconsole} ${bootcmd_generic} root=/dev/sda2 waitforroot=3 rootfstype=ext4" sun7i# setenv bootcmd 'run bootcmd_slk ; bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr} ; reset' Finally, save the settings and reboot the device: sun7i# saveenv ; reset The Banana Pi will reboot and should begin running the Linux Kernel, and booting into your new Slackware ARM installation. 6.0 Help support the Slackware ARM project -------------------------------------- Maintainance of the Slackware ARM port takes not only a lot of time, but also has financial costs such as the on-going use of electricity, Internet hosting and purchasing and maintainance of ARM hardware. Once you find yourself enjoying using the ARM port of Slackware, please take a few moments to show your appreciation by sponsoring either through * A one-off donation: https://paypal.me/armedslack * or (preferably, for this author) a monthly appreciation payment: https://www.patreon.com/armedslack More information on this subject may be found here: http://arm.slackware.com/sponsor 6.1 Helping support the upstream Slackware project ---------------------------------------------- Please consider donating to the parent Slackware project also, developed and maintained by Patrick Volkerding. Without this project, the ARM port of Slackware would, in short order, cease to exist. https://www.patreon.com/slackwarelinux/overview 7.0 Suggestions/alterations ----------------------- If you have any suggestions, recommendations or corrections(!) for this document, please do email me. Thanks! Stuart Winter. -- Stuart Winter mozes@slackware.com