Skip to main content.
Navigation:
DENX
>
DULG
>
AN2011_04_DebianOnTwister
Translations:
Edit
|
Attach
|
Raw
|
Ref-By
|
Printable
|
More
DULG
Sections of this site:
DENX Home
|
DULG
|
ELDK-5
|
Know
|
Training
|
U-Boot
|
U-Bootdoc
Topics
DULG Home
BoardSelect
Manual
FAQ
Application Notes
Changes
Index
List of pages in DULG
Search
---+!! Installation of Debian (Squeeze) on the TAM3517 "Twister" Board %TOC% ---++ Author This document was written by Wolfgang Denk (wd {at} denx {dot} de). ---++ Introduction This application note describes how to install the Debian "squeeze" Linux distribution on a SDCard for using it as operating system for the TAM3517 "Twister" board. For development (building the Linux kernel image) and bootstrapping (initial installation of Debian on that platform) we will use the DENX Embedded Linux Development Kit (ELDK) Release 5.0 for =armv7a= systems. This document describes the whole procedure how to perform the installation from scratch. If you are just interested in getting Debian running on your "Twister" board, you probably want to skip to section [[#InstallSnapshot]["Installation from a Snapshot"]] and start from existing tarballs from our [[ftp://ftp.denx.de/pub/os-images/debian-6.0/arm/][FTP server]]. #PrepareSdCard ---++ Prepare a SDCard In this example we use a Micro-SDCard of 2 GB size (3862528 512-byte logical blocks) which we organize as 3 partitions: 1 Mount point ="/boot"=, formatted as =VFAT= file system: %BR% used to store the Linux kernel image. 1 Mount point ="/"=, formatted as =ext4= file system: %BR% used to store the root file system. 1 Swap space, formatted as =swap= Note: you can of course use bigger SDCards as well. Please adjust the partition sizes accordingly. Usually you will add the additional space to the root file system. * Attach the SDCard to your host using any suitable Micro-SD-Card reader. * To find out as which device it was registered, run for example: <verbatim> $ dmesg | tail -40 ... ... kernel: [576512.948487] sd 18:0:0:2: [sdg] 3862528 512-byte logical blocks: (1.97 GB/1.84 GiB) ... kernel: [576512.953356] sd 18:0:0:2: [sdg] Write Protect is off ... kernel: [576512.953363] sd 18:0:0:2: [sdg] Assuming drive cache: write through ... kernel: [576512.955979] sd 18:0:0:2: [sdg] Assuming drive cache: write through ... kernel: [576512.955986] sdg: sdg1 ... kernel: [576512.961490] sd 18:0:0:2: [sdg] Assuming drive cache: write through ... kernel: [576512.961495] sd 18:0:0:2: [sdg] Attached SCSI removable disk </verbatim> In this case the SD-Card has been registered as ="sdg"=. %BR% %BR% *%RED%WARNING:%ENDCOLOR%* Be careful and double-check the data! Using the wrong device may corrupt your host computer's hard disk or destroy other important data! %BR% %BR% *%RED%WARNING 2:%ENDCOLOR%* Keep in mind that all occurrences of ="/dev/sdg"= and ="/dev/sdgX"= in the following example will need to be replaced with the appropriate values on your system! %BR% %BR% *%RED%WARNING 3:%ENDCOLOR%* If the Linux distribution you use on your host has automount, make sure you unmount the SD-Card before using ="fdisk"= * Use ="fdisk"= to show and delete any existing partitions <verbatim> $ sudo fdisk /dev/sdg Command (m for help): p Disk /dev/sdg: 1977 MB, 1977614336 bytes 18 heads, 52 sectors/track, 4126 cylinders, total 3862528 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x51dd12ca Device Boot Start End Blocks Id System /dev/sdg1 2048 3862527 1930240 b W95 FAT32 Command (m for help): d Selected partition 1 </verbatim> Create new partitions: <verbatim> Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4, default 1): 1 First sector (2048-3862527, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-3862527, default 3862527): +8M </verbatim> <verbatim> Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4, default 2): 2 First sector (18432-3862527, default 18432): Using default value 18432 Last sector, +sectors or +size{K,M,G} (18432-3862527, default 3862527): +1536M </verbatim> <verbatim> Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4, default 3): 3 First sector (3164160-3862527, default 3164160): Using default value 3164160 Last sector, +sectors or +size{K,M,G} (3164160-3862527, default 3862527): Using default value 3862527 </verbatim> Set file system types and boot flag: <verbatim> Command (m for help): a Partition number (1-4): 1 </verbatim> <verbatim> Command (m for help): t Partition number (1-4): 1 Hex code (type L to list codes): b Changed system type of partition 1 to b (W95 FAT32) </verbatim> <verbatim> Command (m for help): t Partition number (1-4): 3 Hex code (type L to list codes): 82 Changed system type of partition 3 to 82 (Linux swap / Solaris) </verbatim> Verify settings and write partition table to SDCard <verbatim> Command (m for help): p Disk /dev/sdg: 1977 MB, 1977614336 bytes 18 heads, 52 sectors/track, 4126 cylinders, total 3862528 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x51dd12ca Device Boot Start End Blocks Id System /dev/sdg1 * 2048 18431 8192 b W95 FAT32 /dev/sdg2 18432 3164159 1572864 83 Linux /dev/sdg3 3164160 3862527 349184 82 Linux swap / Solaris Command (m for help): w The partition table has been altered! </verbatim> * Create file systems and format swap space: <verbatim> $ sudo mkfs.vfat /dev/sdg1 $ sudo mkfs.ext4 -L root /dev/sdg2 $ sudo mkswap -L swap /dev/sdg3 </verbatim> #DownloadSources ---++ Download source files * Download the ="xuk-src.tar.bz2"= tarball which includes the Linux Kernel source tree from the [[http://www.technexion.com/index.php/support-center/downloads/arm-cpu-modules/78-tam-3517][Technexion]] download page: <verbatim> $ wget -O xuk-src.tar.bz2 http://www.technexion.com/index.php/support-center/downloads/arm-cpu-modules/tam-3517/389-xuk-src-tar/download </verbatim> At the time this document was written, this was the version marked as "Uploaded: 24.03.11": <verbatim> $ sha256sum -b xuk-src.tar.bz2 23bb9f608ab0a1cee416621db612e683e5393acb50a2ab71f882e99c07be4fc8 *xuk-src.tar.bz2 </verbatim> #BuildLinuxKernel ---++ Configure and Build a Linux Kernel Image * Unpack the Linux kernel tree: <verbatim> $ tar -jxf xuk-src.tar.bz2 tam3517/kernel </verbatim> * Prepare ELDK 5.0 build environment <verbatim> $ export PATH=/opt/eldk-5.0/armv7a/sysroots/x86_64-oesdk-linux/usr/bin/armv7a-linux-gnueabi:$PATH $ export ARCH=arm $ export CROSS_COMPILE=armv7a- </verbatim> * Patch kernel code for ELDK 5.0 tool chain: %BR% The vendor-provided Linux kernel for the "Twister" board is relatively old (v2.6.32 based) and therefore not compatible with recent tool chains as used in ELDK 5.0. To fix this, a [[ftp://ftp.denx.de/pub/os-images/debian-6.0/arm/twister-kernel.patch][patch]] needs to be applied to the Linux kernel code: <verbatim> $ cd tam3517/kernel/ $ wget -O /tmp/twister-kernel.patch ftp://ftp.denx.de/pub/os-images/debian-6.0/arm/twister-kernel.patch $ patch -p0 -z -b.ORIG </tmp/twister-kernel.patch </verbatim> If you forget to do this, error messages like this will result: %BR% =Error: selected processor does not support ARM mode `smc #0'= * Configure and build the Linux kernel image, using [[ftp://ftp.denx.de/pub/os-images/debian-6.0/arm/twister-kernel.config][this]] kernel configuration file: <verbatim> $ cd tam3517/kernel/ $ cp /tmp/twister.config .config $ make oldconfig $ make -j4 uImage </verbatim> #InstallLinuxKernel * Install Linux kernel image on both the TFTP server and the SDCard <verbatim> $ cp -vp arch/arm/boot/uImage /tftpboot/twister/ </verbatim> <verbatim> $ sudo mount /dev/sdg1 /mnt/tmp/ $ sudo cp -vp arch/arm/boot/uImage /mnt/tmp/ $ sudo umount /dev/sdg1 </verbatim> A copy of the resulting =uImage= fil can be found [[ftp://ftp.denx.de/pub/os-images/debian-6.0/arm/twister-uImage][here]]. ---++ Boot "Twister" Board with Roof File System over NFS * Make sure the "Twister" board is powered off. * Insert the SDCard into the board. * Power on the board, and interrupt the initial countdown by pressing any key. #UbootEnvNfs * Prepare environment settings for boot with root file system mounted over NFS: <verbatim> TAM3517 # setenv ipaddr 192.168.20.29 TAM3517 # setenv serverip 192.168.1.1 TAM3517 # setenv gatewayip 192.168.1.254 TAM3517 # setenv netmask 255.255.0.0 TAM3517 # setenv hostname twister TAM3517 # setenv netdev eth1 TAM3517 # setenv addtty 'setenv bootargs ${bootargs} console=ttyS0,115200n8' TAM3517 # setenv addip 'setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}:${netdev}:off' TAM3517 # setenv addmisc 'setenv bootargs ${bootargs} mem=${memsize} mpurate=${mpurate} console=${console} omapfb.vram=0:${vram_size} eth0addr=${eth0addr} eth1addr=${eth1addr} eth2addr=${eth2addr} eth3addr=${eth3addr} ${android_args} ${sys_mode} ${board_info} ${auto_run} omapdss.def_disp=${def_disp} ${disp_mode} mtdparts=${nandparts}' TAM3517 # setenv fixup 'setenv bootargs ${bootargs} panic=1 ads7846.swap_left_right=1 ads7846.swap_top_down=1' TAM3517 # setenv nfsargs 'setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath}' TAM3517 # setenv rootpath /opt/eldk-4.2-arm/armVFP TAM3517 # setenv mmc_nfs 'mmc init;fatload mmc 0 ${kernel_load} uImage;run def_disp_mode nfsargs addip addtty addmisc fixup;bootm ${kernel_load}' TAM3517 # saveenv </verbatim> * Boot board using the Linux kernel from the SDCard and the root file sytem from the NFS server: <verbatim> TAM3517 # run mmc_nfs mmc1 is available reading uImage 2992268 bytes read ## Booting kernel from Legacy Image at 81000000 ... Image Name: Linux-2.6.32 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2992204 Bytes = 2.9 MiB Load Address: 80008000 Entry Point: 80008000 Verifying Checksum ... OK Loading Kernel Image ... OK OK Starting kernel ... ... Mounting NFS filesystems: [ OK ] Mounting other filesystems: [ OK ] Starting xinetd: [ OK ] DENX ELDK version 4.2 build 2008-11-24 Linux 2.6.32 on a armv7l twister login: </verbatim> Login as user "root". ---++ Bootstrap Debian * Attach SDCard as storage for the new (to be created) Debian root file system <verbatim> -bash-3.2# mkdir /mnt/tmp -bash-3.2# mount -t ext4 /dev/mmcblk0p2 /mnt/tmp -bash-3.2# mkdir /mnt/tmp/tmp -bash-3.2# chmod 01777 /mnt/tmp/tmp -bash-3.2# swapon /dev/mmcblk0p3 </verbatim> * Get and install ="wget"= <verbatim> -bash-3.2# cd /mnt/tmp/tmp -bash-3.2# ftp ftp.gnu.org Connected to ftp.gnu.org (140.186.70.20). 220 GNU FTP server ready. Name (ftp.gnu.org:root): ftp ... Remote system type is UNIX. Using binary mode to transfer files. ftp> cd /gnu/wget/ 250 Directory successfully changed. ftp> bin 200 Switching to Binary mode. ftp> get wget-latest.tar.bz2 ... ftp> by 221 Goodbye. </verbatim> <verbatim> -bash-3.2# tar xf wget-latest.tar.bz2 -bash-3.2# cd wget-1.12/ -bash-3.2# ./configure -bash-3.2# make -bash-3.2# make install </verbatim> * Get and install ="debootstrap"= <verbatim> -bash-3.2# cd /mnt/tmp/tmp -bash-3.2# wget http://ftp.de.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.29_all.deb -bash-3.2# ar xv debootstrap_1.0.29_all.deb data.tar.gz -bash-3.2# ( cd / ; tar -zxvf - ) <data.tar.gz </verbatim> * Populate Debian root file system <verbatim> -bash-3.2# cd /mnt/tmp -bash-3.2# debootstrap --arch=armel squeeze /mnt/tmp http://ftp.de.debian.org/debian </verbatim> * ="chroot"= into Debian file system and prepare for bootstrap <verbatim> -bash-3.2# chroot /mnt/tmp /bin/bash root@twister:/# mount -t proc proc /proc </verbatim> Create console and other serial devices: <verbatim> root@twister:/# apt-get clean root@twister:/# mknod /dev/ttyS0 c 4 64 root@twister:/# mknod /dev/ttyS1 c 4 65 root@twister:/# mknod /dev/ttyS2 c 4 66 root@twister:/# mknod /dev/ttyS3 c 4 67 </verbatim> Set up file system table: <verbatim> root@twister:/# vi /etc/fstab root@twister:/# cat /etc/fstab /dev/mmcblk0p1 /boot vfat defaults 1 2 /dev/mmcblk0p2 / ext4 defaults 1 1 /dev/mmcblk0p3 swap swap defaults 0 0 proc /proc proc defaults 0 0 sysfs /sys sysfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 tmpfs /dev/shm tmpfs defaults 0 0 </verbatim> Configure network interfaces: <verbatim> root@twister:/# vi /etc/network/interfaces root@twister:/# cat /etc/network/interfaces # Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or # /usr/share/doc/ifupdown/examples for more information. # The loopback interface auto lo iface lo inet loopback # Wired interfaces auto eth1 iface eth0 inet dhcp iface eth1 inet dhcp </verbatim> Set up DNS: <verbatim> root@twister:/# vi /etc/resolv.conf root@twister:/# cat /etc/resolv.conf search denx.de nameserver 192.168.1.254 </verbatim> Adapt ="/etc/hosts"=: <verbatim> root@twister:/# vi /etc/hosts root@twister:/# cat /etc/hosts 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 192.168.20.29 twister.denx.de twister </verbatim> Fix settings for serial console port: <verbatim> root@twister:/# cp -vp /etc/inittab{,.ORIG} `/etc/inittab' -> `/etc/inittab.ORIG' root@twister:/# vi /etc/inittab root@twister:/# diff /etc/inittab{.ORIG,} 63c63 < #T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100 --- > T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt100 </verbatim> Enable initial login for =root= without password: <verbatim> root@twister:/# vi /etc/shadow < root:*:15090:0:99999:7::: --- > root::15090:0:99999:7::: </verbatim> Done. Unmount and reboot: <verbatim> root@twister:/# umount /proc root@twister:/# sync root@twister:/# exit exit root@twister:/mnt/tmp# root@twister:/mnt/tmp# reboot </verbatim> ---++ Finalize Debian Setup #UbootEnvDeb * Create or adjust the following environment settings in U-Boot: <verbatim> TAM3517 # setenv deb_root setenv bootargs root=/dev/mmcblk0p2 ro TAM3517 # setenv debian 'mmc init;fatload mmc 0 ${kernel_load} uImage;run def_disp_mode deb_root addtty addmisc fixup load_kernel;bootm ${kernel_load}' TAM3517 # saveenv </verbatim> Boot Debian for a test: <verbatim> TAM3517 # run debian mmc1 is available reading uImage 2992268 bytes read Using DaVinci EMAC device TFTP from server 192.168.1.1; our IP address is 192.168.20.29 Filename 'twister/uImage'. Load address: 0x81000000 Loading: ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# done Bytes transferred = 2992268 (2da88c hex) ## Booting kernel from Legacy Image at 81000000 ... Image Name: Linux-2.6.32 Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2992204 Bytes = 2.9 MiB Load Address: 80008000 Entry Point: 80008000 Verifying Checksum ... OK Loading Kernel Image ... OK OK Starting kernel ... Uncompressing Linux........................................................................................................................................................................................... done, booting the kernel. Linux version 2.6.32 (wd@pollux.denx.de) (gcc version 4.2.2) #1 Wed Apr 27 15:05:23 CEST 2011 CPU: ARMv7 Processor [411fc087] revision 7 (ARMv7), cr=10c53c7f CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache Machine: TAM3517 EVM ... Debian GNU/Linux 6.0 twister ttyS0 twister login: </verbatim> Log in as =root=; no password is needed here: <verbatim> twister login: root Linux twister 2.6.32 #2 Wed Apr 6 12:41:42 CEST 2011 armv7l The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. root@twister:~# </verbatim> Set system time and time zone: <verbatim> root@twister:~# apt-get clean root@twister:~# apt-get install ntpdate root@twister:~# ntpdate -b pool.ntp.org root@twister:~# hwclock --systohc --utc root@twister:~# cp /usr/share/zoneinfo/CET /etc/localtime root@twister:~# date Tue Apr 26 22:23:00 CEST 2011 </verbatim> Set up package database and make sure we are up to date: <verbatim> root@twister:~# apt-cache gencaches root@twister:~# apt-get update root@twister:~# apt-get upgrade </verbatim> Enable remote login through =ssh=: <verbatim> root@twister:~# apt-get install ssh </verbatim> Set root password and halt system. <verbatim> root@twister:~# passwd root root@twister:~# poweroff </verbatim> #MakeDebianDefault ---++ Make Debian default OS Enter the following commands in U-Boot to make Debian boot as default OS whenever you power on the "Twister" board: <verbatim> TAM3517 # setenv old_bootcmd $bootcmd TAM3517 # setenv bootcmd run debian TAM3517 # saveenv </verbatim> Reset the board to test this. ---++ Customizing Debian Environment * You may want to install a few additional packages that are needed for example for a software development environment: <verbatim> root@twister:~# apt-get install at bash binutils bzip2 cpio curl ethtool gawk gdb grep gzip lsof openssl perl perl-base postfix rsync sed strace sysstat tar tcpdump unzip vlan xdelta root@twister:~# apt-get install make procmail sasl2-bin resolvconf zip debhelper root@twister:~# apt-get install debian-keyring autoconf automake1.9 libtool flex bison git-arch git-cvs git-svn git-email git-gui gitk gitweb ed </verbatim> ---++ Take a Snapshot At this point it makes sense to take a snapshot of the installed system, so you don't have to go through all these steps again: <verbatim> root@twister:~# cd / root@twister:/# tar --one-file-system -cf - . | ssh wd@pollux 'gzip >/work/wd/Twister/twister-snapshot-1.tar.gz' </verbatim> A copy of the resulting tarball can be found [[ftp://ftp.denx.de/pub/os-images/debian-6.0/arm/twister-snapshot-1.tar.gz][here]]. ---++ Install a GUI Debian comes with a plethora of software you can pick from. For example, to install a graphical desktop environment, proceed as follows: * Install Xorg and basic XFCE environment <verbatim> root@twister:~# apt-get install xorg xfce4 xfce4-goodies xfce4-notifyd </verbatim> * Install Display Manager <verbatim> root@twister:~# apt-get install gdm3 </verbatim> * Install Web Browser <verbatim> root@twister:~# apt-get install iceweasel </verbatim> or <verbatim> root@twister:~# apt-get install midori </verbatim> * Take another snapshot: [[ftp://ftp.denx.de/pub/os-images/debian-6.0/arm/twister-snapshot-2.tar.gz][twister-snapshot-2.tar.gz]] #InstallSnapshot ---++ Installation from a Snapshot If you are just interested in getting Debian running on your "Twister" board, the fastest way to get there is installation from the snapshot tarballs on our [[ftp://ftp.denx.de/pub/os-images/debian-6.0/arm/][FTP server]]. Please proceed as follows: * Perform all the steps described in sections [[#PrepareSdCard]["Prepare a SDCard"]], [[#DownloadSources]["Download source files"]], [[#BuildLinuxKernel]["Configure and Build a Linux Kernel Image"]], and [[#InstallLinuxKernel]["Install Linux kernel image"]]. * Download a snapshot tarball: <verbatim> $ cd /tmp $ wget ftp://ftp.denx.de/pub/os-images/debian-6.0/arm/twister-snapshot-1.tar.gz </verbatim> * Mount root file system partition of SDCard and install tarball: <verbatim> $ sudo mount /dev/sdg2 /mnt/tmp/ $ cd /mnt/tmp/ $ sudo tar zxpf /tmp/twister-snapshot-1.tar.gz $ cd $ sudo umount /dev/sdg2 </verbatim> * Insert the SDCard into the board. * Power on the board, and interrupt the initial countdown by pressing any key. * Prepare environment settings as described [[#UbootEnvNfs][here]], [[#UbootEnvDeb][here]] and [[#MakeDebianDefault][here]] . * Reset (or power-cycle) the board and watch it booting into Debian. *Note:* the =root= password used in the snapshot images is ="root"=; in the XFCE environment you can login as normal user ="denx"= with password ="denx"=. Please make sure to change these psswords before putting the system into actual use. You should also make sure to generate new, unique SSH host keys for ="/etc/ssh/ssh_host_*"=.