Add tutorial on installing Debian on A20 board.
[www.vanrenterghem.biz.git] / Linux / Installing_Debian_on_Lime2.shtml
diff --git a/Linux/Installing_Debian_on_Lime2.shtml b/Linux/Installing_Debian_on_Lime2.shtml
new file mode 100644 (file)
index 0000000..bf134a3
--- /dev/null
@@ -0,0 +1,492 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" />
+   <meta name="author" content="Frederik Vanrenterghem" />
+   <meta name="Description" content="Personal homepage - GNU/Linux stuff - Connecting to i-Mode with iPAQ" />
+   <title>vanrenterghem.biz - GNU/Linux - Debian armhf on A20-OLinuXino-Lime2</title>
+<link rel="stylesheet" href="/styles/header.css" type="text/css" />
+<link rel="stylesheet" href="/styles/main.css" type="text/css" />
+</head>
+<body>
+<!--#include virtual='/header.shtml' -->
+
+<h1>Installing Debian GNU/Linux to your A20-OLinuXino-Lime2.</h1>
+<p>
+So you bought an open hardware <a href="https://www.olimex.com/wiki/A20-OLinuXino-LIME2">Lime2 board</a>, and 
+now would like to install Debian on it, without resorting to pre-compiled images offered on the Olimex wiki. Since
+February 2015, this is actually possible using Debian-provided binaries.
+</p>
+<h2>Prepare u-boot</h2>
+<p>
+Easiest is to use <a href="http://ftp.au.debian.org/debian/pool/main/u/u-boot/u-boot-sunxi_2014.10+dfsg1-4_armhf.deb">u-boot from unstable</a>, and extract <code>/usr/lib/u-boot/A20-OLinuXino-Lime2/u-boot-sunxi-with-spl.bin</code> from it.
+Alternatively, you will need to cross-compile u-boot for your A20 board on your Debian GNU/Linux box. The needed architecture
+for this processor is armhf.
+</p>
+<p>
+<code>
+sudo dpkg --add-architecture armhf<br />
+sudo update<br />
+sudo apt-get install crossbuild-essential-armhf<br />
+</code>
+<p>
+Download the <a href="ftp://ftp.denx.de/pub/u-boot/u-boot-latest.tar.bz2">latest release of u-boot</a>, 
+at the time of writing <a href="ftp://ftp.denx.de/pub/u-boot/u-boot-2015.01.tar.bz2">u-boot-2015.01</a>.
+This version already supports everything needed to get Debian on your Lime2 using an SD card, USB stick and 
+a network install of the OS.
+</p>
+<p>
+Compile u-boot as follows:
+</p>
+<p>
+<code>
+make A20-OLinuXino-Lime2_config ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-<br />
+make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
+</code>
+</p>
+<h2>Copy u-boot to an SD card</h2>
+<p>
+Copy the compiled or extracted u-boot image to your micro SD card. No need for partitioning it - one VFAT or ext2 partition should do.
+</p>
+<p>
+<code>
+sudo dd if=~/Downloads/u-boot-2015.01/u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8
+</code>
+</p>
+<h2>Prepare the Debian Installer</h2>
+<p>
+At the time of writing, the weekly images of the CD build are broken, so the <a href="https://wiki.debian.org/InstallingDebianOn/Allwinner#Installing_from_a_USB_stick">excellent tutorial on installing Debian on the Allwinner</a> cannot be fully followed. Instead, unpack the <a href="http://d-i.debian.org/daily-images/armhf/daily/hd-media/hd-media.tar.gz">hd-media image of d-i</a> 
+on your USB stick. Next, download 2 files.
+</p>
+<code>
+wget http://d-i.debian.org/daily-images/armhf/daily/netboot/vmlinuz<br />
+wget http://d-i.debian.org/daily-images/armhf/daily/netboot/initrd.gz<br />
+</code>
+<p>  
+and overwrite the copy of <code>vmlinuz</code> on the USB stick with this one.
+</p>
+<p>
+We will modify the initrd.gz image slightly.
+Since you may not have a console cable, it's useful to perform the install using preseeding. This way, the Debian
+installer will get its answers from a file instead of through your input. I opted to automate as many answers as possible,
+except for the partitioning. These can be answered by logging in to the installer using SSH. It's truly an awesome,
+versatile tool, d-i!
+</p>
+<p>
+First, create <code>preseed.cfg</code>. For Debian Jessie, the following file will work.
+</p>
+<p>
+<code>
+
+#### Contents of the preconfiguration file (for jessie)<br />
+### Localization<br />
+# Preseeding only locale sets language, country and locale.<br />
+d-i debian-installer/locale string en_AU<br />
+<br />
+# The values can also be preseeded individually for greater flexibility.<br />
+#d-i debian-installer/language string en<br />
+#d-i debian-installer/country string NL<br />
+#d-i debian-installer/locale string en_GB.UTF-8<br />
+<br />
+# Keyboard selection.<br />
+d-i keyboard-configuration/xkb-keymap select au<br />
+# d-i keyboard-configuration/toggle select No toggling<br />
+<br />
+### Network configuration<br />
+# netcfg will choose an interface that has link if possible. This makes it<br />
+# skip displaying a list if there is more than one interface.<br />
+d-i netcfg/choose_interface select auto<br />
+<br />
+# To pick a particular interface instead:<br />
+#d-i netcfg/choose_interface select eth1<br />
+<br />
+# To set a different link detection timeout (default is 3 seconds).<br />
+# Values are interpreted as seconds.<br />
+#d-i netcfg/link_wait_timeout string 10<br />
+<br />
+# If you have a slow dhcp server and the installer times out waiting for<br />
+# it, this might be useful.<br />
+#d-i netcfg/dhcp_timeout string 60<br />
+#d-i netcfg/dhcpv6_timeout string 60<br />
+<br />
+# If you prefer to configure the network manually, uncomment this line and<br />
+# the static network configuration below.<br />
+d-i netcfg/disable_autoconfig boolean true<br />
+<br />
+# If you want the preconfiguration file to work on systems both with and<br />
+# without a dhcp server, uncomment these lines and the static network<br />
+# configuration below.<br />
+#d-i netcfg/dhcp_failed note<br />
+#d-i netcfg/dhcp_options select Configure network manually<br />
+<br />
+# Static network configuration.<br />
+#<br />
+# IPv4 example<br />
+d-i netcfg/get_ipaddress string 192.168.2.10<br />
+d-i netcfg/get_netmask string 255.255.255.0<br />
+d-i netcfg/get_gateway string 192.168.2.1<br />
+d-i netcfg/get_nameservers string 192.168.2.1<br />
+d-i netcfg/confirm_static boolean true<br />
+#<br />
+# Any hostname and domain names assigned from dhcp take precedence over<br />
+# values set here. However, setting the values still prevents the questions<br />
+# from being shown, even if values come from dhcp.<br />
+d-i netcfg/get_hostname string YOURHOSTNAME<br />
+d-i netcfg/get_domain string YOURDOMAIN.TLD<br />
+<br />
+# If you want to force a hostname, regardless of what either the DHCP<br />
+# server returns or what the reverse DNS entry for the IP is, uncomment<br />
+# and adjust the following line.<br />
+#d-i netcfg/hostname string somehost<br />
+<br />
+# Disable that annoying WEP key dialog.<br />
+d-i netcfg/wireless_wep string<br />
+# The wacky dhcp hostname that some ISPs use as a password of sorts.<br />
+#d-i netcfg/dhcp_hostname string radish<br />
+<br />
+# If non-free firmware is needed for the network or other hardware, you can<br />
+# configure the installer to always try to load it, without prompting. Or<br />
+# change to false to disable asking.<br />
+d-i hw-detect/load_firmware boolean true<br />
+<br />
+### Network console<br />
+# Use the following settings if you wish to make use of the network-console<br />
+# component for remote installation over SSH. This only makes sense if you<br />
+# intend to perform the remainder of the installation manually.<br />
+d-i anna/choose_modules string network-console<br />
+#d-i network-console/authorized_keys_url string http://10.0.0.1/openssh-key<br />
+d-i network-console/password password STRONGPASSWORD<br />
+d-i network-console/password-again password STRONGPASSWORD<br />
+<br />
+### Mirror settings<br />
+# If you select ftp, the mirror/country string does not need to be set.<br />
+#d-i mirror/protocol string ftp<br />
+d-i mirror/country string Australia<br />
+d-i mirror/http/hostname string ftp.au.debian.org<br />
+d-i mirror/http/directory string /debian<br />
+d-i mirror/http/proxy string<br />
+<br />
+# Suite to install.<br />
+d-i mirror/suite string testing<br />
+# Suite to use for loading installer components (optional).<br />
+#d-i mirror/udeb/suite string testing<br />
+<br />
+### Account setup<br />
+# Skip creation of a root account (normal user account will be able to<br />
+# use sudo).<br />
+#d-i passwd/root-login boolean false<br />
+# Alternatively, to skip creation of a normal user account.<br />
+#d-i passwd/make-user boolean false<br />
+<br />
+# Root password, either in clear text<br />
+d-i passwd/root-password password VERYSTRONG<br />
+d-i passwd/root-password-again password VERYSTRONG<br />
+# or encrypted using an MD5 hash.<br />
+#d-i passwd/root-password-crypted password [MD5 hash]<br />
+<br />
+# To create a normal user account.<br />
+d-i passwd/user-fullname string Your Full Name<br />
+d-i passwd/username string yoursystemname<br />
+# Normal user's password, either in clear text<br />
+d-i passwd/user-password password REALLYSTRONG<br />
+d-i passwd/user-password-again password REALLYSTRONG<br />
+# or encrypted using an MD5 hash.<br />
+#d-i passwd/user-password-crypted password [MD5 hash]<br />
+# Create the first user with the specified UID instead of the default.<br />
+#d-i passwd/user-uid string 1010<br />
+<br />
+# The user account will be added to some standard initial groups. To<br />
+# override that, use this.<br />
+#d-i passwd/user-default-groups string audio cdrom video<br />
+<br />
+### Clock and time zone setup<br />
+# Controls whether or not the hardware clock is set to UTC.<br />
+d-i clock-setup/utc boolean true<br />
+<br />
+# You may set this to any valid setting for $TZ; see the contents of<br />
+# /usr/share/zoneinfo/ for valid values.<br />
+d-i time/zone string Australia/Perth<br />
+<br />
+# Controls whether to use NTP to set the clock during the install<br />
+d-i clock-setup/ntp boolean true<br />
+# NTP server to use. The default is almost always fine here.<br />
+#d-i clock-setup/ntp-server string ntp.example.com<br />
+<br />
+### Partitioning<br />
+<br />
+## Partitioning example<br />
+# If the system has free space you can choose to only partition that space.<br />
+# This is only honoured if partman-auto/method (below) is not set.<br />
+#d-i partman-auto/init_automatically_partition select biggest_free<br />
+<br />
+# Alternatively, you may specify a disk to partition. If the system has only<br />
+# one disk the installer will default to using that, but otherwise the device<br />
+# name must be given in traditional, non-devfs format (so e.g. /dev/hda or<br />
+# /dev/sda, and not e.g. /dev/discs/disc0/disc).<br />
+# For example, to use the first SCSI/SATA hard disk:<br />
+#d-i partman-auto/disk string /dev/sda<br />
+# The SD card of your OLinuXino-Lime2 will probably be mmcblk0<br />
+#d-i partman-auto/disk string /dev/mmcblk0<br />
+<br />
+# In addition, you'll need to specify the method to use.<br />
+# The presently available methods are:<br />
+# - regular: use the usual partition types for your architecture<br />
+# - lvm:     use LVM to partition the disk<br />
+# - crypto:  use LVM within an encrypted partition<br />
+#d-i partman-auto/method string lvm<br />
+<br />
+# If one of the disks that are going to be automatically partitioned<br />
+# contains an old LVM configuration, the user will normally receive a<br />
+# warning. This can be preseeded away...<br />
+#d-i partman-lvm/device_remove_lvm boolean true<br />
+# The same applies to pre-existing software RAID array:<br />
+#d-i partman-md/device_remove_md boolean true<br />
+# And the same goes for the confirmation to write the lvm partitions.<br />
+#d-i partman-lvm/confirm boolean true<br />
+#d-i partman-lvm/confirm_nooverwrite boolean true<br />
+<br />
+# You can choose one of the three predefined partitioning recipes:<br />
+# - atomic: all files in one partition<br />
+# - home:   separate /home partition<br />
+# - multi:  separate /home, /var, and /tmp partitions<br />
+#d-i partman-auto/choose_recipe select atomic<br />
+<br />
+# This makes partman automatically partition without confirmation, provided<br />
+# that you told it what to do using one of the methods above.<br />
+#d-i partman-partitioning/confirm_write_new_label boolean true<br />
+#d-i partman/choose_partition select finish<br />
+#d-i partman/confirm boolean true<br />
+#d-i partman/confirm_nooverwrite boolean true<br />
+<br />
+<br />
+# This makes partman automatically partition without confirmation.<br />
+#d-i partman-md/confirm boolean true<br />
+#d-i partman-partitioning/confirm_write_new_label boolean true<br />
+#d-i partman/choose_partition select finish<br />
+#d-i partman/confirm boolean true<br />
+#d-i partman/confirm_nooverwrite boolean true<br />
+<br />
+## Controlling how partitions are mounted<br />
+# The default is to mount by UUID, but you can also choose "traditional" to<br />
+# use traditional device names, or "label" to try filesystem labels before<br />
+# falling back to UUIDs.<br />
+d-i partman/mount_style select uuid<br />
+<br />
+### Base system installation<br />
+# Configure APT to not install recommended packages by default. Use of this<br />
+# option can result in an incomplete system and should only be used by very<br />
+# experienced users.<br />
+#d-i base-installer/install-recommends boolean false<br />
+<br />
+# The kernel image (meta) package to be installed; "none" can be used if no<br />
+# kernel is to be installed.<br />
+#d-i base-installer/kernel/image string linux-image-586<br />
+<br />
+### Apt setup<br />
+# You can choose to install non-free and contrib software.<br />
+#d-i apt-setup/non-free boolean true<br />
+#d-i apt-setup/contrib boolean true<br />
+# Uncomment this if you don't want to use a network mirror.<br />
+#d-i apt-setup/use_mirror boolean false<br />
+# Select which update services to use; define the mirrors to be used.<br />
+# Values shown below are the normal defaults.<br />
+d-i apt-setup/services-select multiselect security, updates<br />
+d-i apt-setup/security_host string security.debian.org<br />
+<br />
+# Additional repositories, local[0-9] available<br />
+#d-i apt-setup/local0/repository string \<br />
+#       http://local.server/debian stable main<br />
+#d-i apt-setup/local0/comment string local server<br />
+# Enable deb-src lines<br />
+#d-i apt-setup/local0/source boolean true<br />
+# URL to the public key of the local repository; you must provide a key or<br />
+# apt will complain about the unauthenticated repository and so the<br />
+# sources.list line will be left commented out<br />
+#d-i apt-setup/local0/key string http://local.server/key<br />
+<br />
+# By default the installer requires that repositories be authenticated<br />
+# using a known gpg key. This setting can be used to disable that<br />
+# authentication. Warning: Insecure, not recommended.<br />
+#d-i debian-installer/allow_unauthenticated boolean true<br />
+<br />
+### Package selection<br />
+tasksel tasksel/first multiselect standard<br />
+<br />
+# Individual additional packages to install<br />
+d-i pkgsel/include string openssh-server<br />
+# Whether to upgrade packages after debootstrap.<br />
+# Allowed values: none, safe-upgrade, full-upgrade<br />
+d-i pkgsel/upgrade select none<br />
+<br />
+# Some versions of the installer can report back on what software you have<br />
+# installed, and what software you use. The default is not to report back,<br />
+# but sending reports helps the project determine what software is most<br />
+# popular and include it on CDs.<br />
+popularity-contest popularity-contest/participate boolean false<br />
+<br />
+### Boot loader installation<br />
+# Grub is the default boot loader (for x86). If you want lilo installed<br />
+# instead, uncomment this:<br />
+#d-i grub-installer/skip boolean true<br />
+# To also skip installing lilo, and install no bootloader, uncomment this<br />
+# too:<br />
+#d-i lilo-installer/skip boolean true<br />
+<br />
+<br />
+# This is fairly safe to set, it makes grub install automatically to the MBR<br />
+# if no other operating system is detected on the machine.<br />
+d-i grub-installer/only_debian boolean true<br />
+<br />
+# This one makes grub-installer install to the MBR if it also finds some other<br />
+# OS, which is less safe as it might not be able to boot that other OS.<br />
+d-i grub-installer/with_other_os boolean true<br />
+<br />
+# Due notably to potential USB sticks, the location of the MBR can not be<br />
+# determined safely in general, so this needs to be specified:<br />
+#d-i grub-installer/bootdev  string /dev/sda<br />
+# To install to the first device (assuming it is not a USB stick):<br />
+#d-i grub-installer/bootdev  string default<br />
+<br />
+# Alternatively, if you want to install to a location other than the mbr,<br />
+# uncomment and edit these lines:<br />
+#d-i grub-installer/only_debian boolean false<br />
+#d-i grub-installer/with_other_os boolean false<br />
+#d-i grub-installer/bootdev  string (hd0,1)<br />
+# To install grub to multiple disks:<br />
+#d-i grub-installer/bootdev  string (hd0,1) (hd1,1) (hd2,1)<br />
+<br />
+# Optional password for grub, either in clear text<br />
+#d-i grub-installer/password password r00tme<br />
+#d-i grub-installer/password-again password r00tme<br />
+# or encrypted using an MD5 hash, see grub-md5-crypt(8).<br />
+#d-i grub-installer/password-crypted password [MD5 hash]<br />
+<br />
+# Use the following option to add additional boot parameters for the<br />
+# installed system (if supported by the bootloader installer).<br />
+# Note: options passed to the installer will be added automatically.<br />
+#d-i debian-installer/add-kernel-opts string nousb<br />
+<br />
+### Finishing up the installation<br />
+# During installations from serial console, the regular virtual consoles<br />
+# (VT1-VT6) are normally disabled in /etc/inittab. Uncomment the next<br />
+# line to prevent this.<br />
+d-i finish-install/keep-consoles boolean true<br />
+<br />
+# Avoid that last message about the install being complete.<br />
+d-i finish-install/reboot_in_progress note<br />
+<br />
+</code>
+</p>
+<p>
+Next, add your <code>preseed.cfg</code> to the downloaded initrd.gz
+</p>
+<code>
+mkdir /tmp/initrd && cd /tmp/initrd<br />
+gzip -d < ~/Downloads/initrd.gz |cpio --extract --verbose --make-directories --no-absolute-filenames</br />
+cp ~/preseed.cfg .</br />
+find . | cpio -H newc --create --verbose |         gzip -9 > ../initrd.gz<br />
+</code>
+<p>
+Copy the new initrd.gz to your USB stick.
+</p>
+<h2>Install Debian on your Lime2</h2>
+<p>
+If you want to follow along on a console (not really necessary, but easier to debug things this way.)
+</p>
+<code>
+sudo apt-get install minicom
+sudo minicom --device /dev/ttyUSB0
+</code>
+<p>
+Now plug in the micro SD card as well as the USB stick and power up your Lime2. After a little while, you will 
+be able to <code>ssh installer@192.168.2.10</code> with your chosen password to set up the partitions. A while later,
+your Lime2 will be ready to use!
+</p>
+
+<h2>Installing wireless</h2>
+<p>
+I purchased a USB Wireless N WIFI dongle based on an Atheros chip. At the moment, this is the only chipset with 
+a free firmware implementation supporting 802.11n. Please consider doing the same, to ensure this technology remains 
+available for customers.
+</p>
+<p>
+<a href="https://wiki.debian.org/ath9k_htc/open_firmware">Build and install the firmware as explained on the Debian wiki.</a> 
+This will take a while, as the whole toolchain to build the firmware will be compiled for some reason.
+</p>
+<p>
+Once you've installed the compiled firmware as explained, plug in the wifi dongle. The firmware will be 
+loaded automatically. 
+</p>
+
+<h2>Configuring your Lime2 as a wireless access point</h2>
+<p>
+Given the total lack of support for free software on ADSL2 modems, I have a very simple one and use my Lime2
+board as wireless router. This instead of acquiring an expensive modem/router combo running proprietary software. The combined price is equivalent, and I have an option of installing some other software on the Lime2 too. Too bad one needs to ringfence an ADSL2 modem in your own house as if it's part of the internet, but that seems to be today's reality.
+</p>
+<p>
+On the Lime2, install the following:
+</p>
+<p>
+<code>
+sudo apt-get install iw wireless-tools hostapd isc-dhcp-server<br /> 
+</code></p>
+<p>
+Edit 3 files as in the examples below.<br />
+</p>
+
+<h3>/etc/network/interfaces</h3>
+
+<p><code>
+auto wlan<br />
+iface wlan0 inet static<br />
+        address 192.168.3.1<br />
+        netmask 255.255.255.0<br />
+        hostapd /etc/hostapd/hostapd.conf<br />
+</code></p>
+<h3>/etc/hostapd/hostapd.conf</h3>
+<p>
+<code>
+interface=wlan0<br />
+driver=nl80211<br />
+ssid=YOURSSID<br />
+hw_mode=g<br />
+<br />
+# 802.11n support<br />
+ieee80211n=1<br />
+wmm_enabled=1<br />
+<br />
+# set country code<br />
+country_code=AU<br />
+ieee80211d=1<br />
+<br />
+channel=9<br />
+wpa=2<br />
+wpa_passphrase=PASSPHRASE<br />
+wpa_key_mgmt=WPA-PSK<br />
+wpa_pairwise=TKIP CCMP<br />
+wpa_ptk_rekey=600<br />
+macaddr_acl=0<br />
+</code>
+</p>
+<h3>/etc/dhcp/dhcpd.conf</h3>
+<p>
+To configure your DHCP server, get your <a href="http://www.opennicproject.org/nearest-servers/">OpenNic DNS servers in the area</a> - most of the server operators respect your privacy by not maintaining logs.
+</p>
+<p>
+<code>
+subnet 192.168.3.0 netmask 255.255.255.0 {<br />
+    range 192.168.3.20 192.168.3.100;<br />
+    option domain-name-servers 103.25.56.238, 111.223.227.125;<br />
+    option routers 192.168.3.1;<br />
+    interface wlan0;<br />
+    }<br />
+</code>
+</p>
+<p>
+Restart networking & start the DHCP server, or reboot the system and you should be good to go.
+</p>
+<!--#include virtual='/footer.shtml' -->
+</body>
+</html>
+