====== 2013.11.26 - taming panda ====== {{ :blog:2013:11:26:im_with_panda.jpg?300|i'm with panda}} recently i bought [[http://www.pandaboard.org|pandaboard]]. pretty old, yet still quite nicely featured dual core 1.2GHz ARM A-9 with 1GB ram and SD card as a hard drive. since i spent quite some time running this thing i'd like to share my findings. note that this manual can also be used as an howto on installation [[wp>debian]] on pandaboard. ===== sanity checks ===== after unpacking and connecting the board it is worth while to check if it is working as expected. there is ready to go [[https://gforge.ti.com/gf/download/frsrelease/643/5076/validation-19102011.img|validation image]] prepared on the [[http://pandaboard.org/content/resources/troubleshooting|troubleshooting]] page. get it and write to SD card directly: wget https://gforge.ti.com/gf/download/frsrelease/643/5076/validation-19102011.img dd if=validation-19102011.img of=/dev/XXX (/dev/XXX is your SD card) panda's terminal is setup to 115200-8-N-1. to connect use gtkterm (or similar): gtkterm -p /dev/ttyUSB0 -s 115200 connect RS-232 (regular -- panda uses max232 to do level converting for you) to usb adapter (directly), insert SD card and apply power. if everything works as expected, it should boot and on your terminal linux prompt should appear. this image allows testing of a board, but for the purposes of this manual it is enough to see the prompt. ===== use ready images ===== if it's possible, just use what's there. there are pre-built [[http://pandaboard.org/content/resources/development-environment|ubuntu and android images]] available. you can download them and write to SD card the same way you did with validation image. it given distribution works for you, you're home! ===== own (debian) installation ===== i was unlucky and my SD (SDHC, to be precise) card did not work properly with pre-shipped ubuntu kernel. kernel delivered with debian did not worked as well. the only option i was left with, was to go the hard way and compile everything from scratch. pandaboard es, which i have, uses OMAP4460 (OMAP4). general boot sequence on OMAP4 is starting with the first partition of the SD card (needs to be a fat partition -- sorry) and goes like this: - start x-loader ("MLO" file) -- this is a first boot stage, that initializes basic hardware. - start u-boot ("u-boot.img" file) -- this is a second boot stage, that loads and starts kernel, passes arguments, etc... - boot kernel ("zImage" file) following sections describe how to obtain, compile and install required elements on an SD card. ==== formatting card ==== since you already have written validation image on the card, first (fat) partition is fine. you only need to change the second one, to use full card space, and have no content. the shortest way is simply to re-create it and format. run: fdisk /dev/XXX and delete second partition, create new one in its place, taking whole disk space and quit while saving changes. now format both partitions: mkdosfs /dev/XXX1 mkfs.ext3 /dev/XXX2 having them all in place, mount them for further processing: mount /dev/XXX1 /media/usb1 mount /dev/XXX2 /media/usb2 ==== installing debian ==== thanks to //debootstap// and qemu emulation in rootfs, installation of debian is dead simple! :D first install this wunderwaffe-set: apt-get install debootstrap qemu-user-static and then prepare filesystem. root privileges are required here. debootstrap --foreign --arch=armhf testing /media/usb2 http://ftp.pl.debian.org/debian/ cp -v /usr/bin/qemu-arm-static /media/usb2/usr/bin/ DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGUAGE=C LANG=C chroot /media/usb2 /debootstrap/debootstrap --second-stage this finishes the basic installation, there are however few steps worth doing. set root password to 'root': sed -i 's#^root:.*#root:$6$D4IAlHGx$VyuhjuulSFUbc6DjehKZPw9Cn1ZyaNBJl9jOsuAeCY75LoodSNnSdK7DjImqBR6lk3WAalDYAm3oRCO3yILqV.:16030:0:99999:7:::#g' /media/usb2/etc/shadow enable serial console: cat >> "$D/etc/inittab" <> /media/usb2/etc/network/interfaces <> /etc/apt/sources.list <Das U-Boot]] [[ftp://ftp.denx.de/pub/u-boot/|release package]] and build it, for panda board: wget ftp://ftp.denx.de/pub/u-boot/u-boot-2013.10.tar.bz2 tar xjvf u-boot-2013.10.tar.bz2 cd u-boot-2013.10 make CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm omap4_panda_config make CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm you should now have the following files: - MLO - u-boot.bin - u-boot.img copy them to boot partition: cp -v MLO u-boot.bin u-boot.img /media/usb1 ==== kernel ==== this was the most tricky part for me and here exactly i've spent the most time. the problem is that most mainline kernels do NOT work properly with this device. this is very bad news and there is no easy way to fix that manually. in short -- a proper set of kernel patches need to be applied to make it all work. otherwise you'll stuck with "Starting kernel..." message on the screen, and nothing will happen. fortunately [[http://github.com/RobertCNelson|Robert Nelson]] prepared set of scripts that automate this all. the fast procedure to build reasonably-new-and-yet-known-to-be-working kernel, with all the required patches, follows: git clone git://github.com/RobertCNelson/stable-kernel.git cd stable-kernel ./build_kernel.sh # you'll be asked to checkout kernel branch - choose the one you like ./build_kernel.sh now in the //deploy// directory there will be a set of files, that you'll need to install to rootfs (modules and firmwares) and boot partition (kernel and DTBs). for start save absolute path to the deploy directory into a variable: S=`pwd`/deploy first rootfs: cd /media/usb2 tar xzf $S/*-modules.tar.gz cd lib/formware tar xzf $S/*-firmware.tar.gz note that some of the firmwares will override firmware delivered with modules. that's ok, since the files are binary identical. now boot partition preparation: cd /media/usb1 cp $S/*.zImage zImage mkdir dtbs cd dtbs tar xzf $S/*-dtbs.tar.gz having all binaries in place the time has come to create a boot script for u-boot: cd /media/usb1 cat > boot_mmc.txt <