Thursday 16 July 2015

Debian on Pandaboard Project - Installation and configuration

Hi there !
Here is the first tutorial of how to get a fully working Debian linux on Pandaboard (development board). In this part, we are going to: prepare a SD card, install boot files, transfer Debian rootfs, install the system and do a little bit of tweaking.
 
Acknowledgments:
Thanks to Robert Nelson for providing install script / rootfs / etc. Made working with Pandaboard so much easier !
Home address

1) Prepare host environment

We need some tools on our host system in order to install Debian on Pandaboard. These packages are required by Robert Nelson's netinstall script. In my setup, I am using Ubuntu 14.04.2 as a host:
sudo apt-get install wget dosfstools u-boot-tools parted
If you are using Fedora or Gentoo, install git as well as:
Fedora: as root: yum install wget dosfstools dpkg patch uboot-tools parted
 Gentoo: emerge wget dosfstools dpkg u-boot-tools parted

2) Get the install script ready

This script will do all the steps up to online Debian installation. We are going to download the script to our home directory.
 git clone https://github.com/RobertCNelson/netinstall.git
 cd netinstall

3) Prepare the SD card

Find out what is the name of your SD card on the host system. The easiest method would be using fdisk:
sudo fdisk -l
I just look at the size of the storage medium, to find out my /dev/sdX. In my case it was /dev/sdd. Please make sure the device you choose is the right one. Your hard disk would probably be: /dev/sda

Unmount SD card, if it is mounted:
sudo umount /dev/(sdX)
I am not sure if it matters (the script most likely takes care of that), but if you have your SD card partitioned already, it would be better to delete all partitions. Run fdisk:
sudo fdisk /dev/(sdX)
d - request to delete partition
1, 2, etc - partition number
w - write changes
(q - quit, if your card is empty)

Now your SD card is ready. Note your: /dev/(sdX)


4) Run the script with root privileges

sudo ./mk_mmc.sh --mmc /dev/(sdX) --dtb omap4-panda --distro jessie --firmware
The following are the options to the script:
Required Options:
--mmc </dev/sdX>
--dtb <dev board>
        A10-OLinuXino-Lime
        A20-OLinuXino-Lime
        A20-OLinuXino-Lime2
        am335x-boneblack
        am335x-bone-serial
        am335x-bone-video
        imx51-babbage
        imx53-qsb
        imx53-qsrb
        imx6dl-udoo
        imx6q-sabrelite
        imx6q-sabresd
        imx6q-udoo
        omap3-beagle
        omap3-beagle-xm
        omap4-panda
        omap4-panda-a4
        omap4-panda-es
        omap4-panda-es-b3

        omap5-uevm
        tegra124-jetson-tk1
        wandboard
Optional:
--distro <distro>
        Debian:
                wheezy-armhf (Debian 7)
                jessie (Debian 8) <default>
        Ubuntu:
                trusty (14.04) (EOL: April 2019)
                vivid (15.04) (EOL: January 2016)
--firmware
    Add distro firmware
--serial-mode
    <DVI Mode is default, this overrides it for Serial Mode>
Additional Options:
-h --help
    this help
--probe-mmc
    List all partitions: sudo ./mk_mmc.sh --probe-mmc
I am choosing Jessie as it is the newest stable Debian release. If you have Panda ES or Panda A4 revision, change your --dtb as required. I am not sure what --firmware option does - there is no rootfs partition present after the script is run. Firmware is not installed in this way.


5) Boot up your system and start installation

Your board should boot up. Now proceed with the installation, following on-screen instructions. In particular, we are interested in the following stages:

Configure the network:

As we can see, only Ethernet and USB devices are available for connection. Wlan is absent.
We are going to connect using Ethernet, so we can:
a) Connect to your router / network - you might need quite long cable for this
b) Connect to your host computer, sharing connection - this option requires a bit of tweaking, but we can use the shortest cable possible, have a look at these guides:
--- For Windows
--- For Ubuntu

Partition disks:

By default, partition manager wants to create swap ... Which we really do not want. Write / read speed of a SD card is horrible on Pandaboard and we certainly do not need extra trashing. Disable SWAP:

Now delete the rootfs partition as well and re-create a larger version of it. Your rootfs partition should look like this:

Once you have done your changes, this is the result you should have. Note the SD card portion:
What's important is that we have two partitions: small FAT16 - boot, and large EXT4 - rootfs

Additional software:

At this stage we can install some additional components. I am interested in a desktop environment, so I have installed LXDE (lightweight, easy to use). Beware, the installation step can take a lot of time - have a cup of coffee or 10 cups ... If your card is slow like mine :(


6) Check the system

Now its time to see what we have. In short, here is the summary

Summary - For kernel 4.1.2 (sorry, have to verify)


WORKING:
--- OS - Boots fine and fast
--- HDMI Video Out + a number of supported resolutions (yey ! see the list below)
--- HDMI Audio Out ! (tested with LXMusic -  both channels work in Stereo)
--- Audio Out (jack) - not working !
--- USB Input (keyboard, mice work fine)
--- USB Storage - works fine
--- Ethernet connection (otherwise we would not install our system in the first place)
--- CPU Frequency Scaling !! (conservative, ondemand, etc modes supported)

NOT WORKING:
--- WiFi - it doesn't matter if the newest firmware drivers are installed or not - wlan0 device does not even show up ... I have looked at kernel config - it is certainly enabled. Broken in the newest kernel ?
--- Overlays / Scaler / 2d / 3d - no driver installed
--- Video acceleration - no driver installed

NOT TESTED:
--- DVI Out - no DVI cable ... can I test with HDMI cable, but insert into DVI port of Panda ?
--- Audio In - should be able to test ...
--- Bluetooth - I assume its not working ... And WiFi is more important

Additional configuration:


a) Setting up sudo

I am used to "sudo" command. So here is how you can set it up:
Run
su
visudo
This will open the /etc/sudoers file. Now we need to edit it. Look for the following line:
root    ALL=(ALL:ALL) ALL
and add this line just under it:
user   ALL=(ALL:ALL) ALL
where "user" is your username (not root). Save and exit: Ctrl + o, ENTER, Ctrl + x

b) Setting up Cpu Frequency Scaling:

Install cpufrequtils and sysfsuitils
sudo apt-get install cpufrequtils sysfsutils
Edit your cpufrequtils (will probably be empty)
(Reference: https://wiki.debian.org/HowTo/CpuFrequencyScaling )
sudo nano /etc/default/cpufrequtils
and add this line:
GOVERNOR="conservative"
or:
GOVERNOR="conservative"
Save the file. The effects can show up immediately or after reboot. We do not need to do any additional configuration.


Some tests I have run:


Xvinfo


anton@debian-panda:~$ xvinfo
X-Video Extension version 2.2
screen #0
 no adaptors present

Xorg info - Fbdev is being used (well, better than no driver)

anton@debian-panda:~$ cat /var/log/Xorg.0.log | grep fbdev
[    17.860] (==) Matched fbdev as autoconfigured driver 1
[    17.864] (II) LoadModule: "fbdev"
[    17.865] (II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so
[    17.866] (II) Module fbdev: vendor="X.Org Foundation"
[    17.867] (II) FBDEV: driver for framebuffer: fbdev
[    17.889] (WW) Falling back to old probe method for fbdev
[    17.889] (II) Loading sub module "fbdevhw"
[    17.889] (II) LoadModule: "fbdevhw"
[    17.890] (II) Loading /usr/lib/xorg/modules/libfbdevhw.so
[    17.891] (II) Module fbdevhw: vendor="X.Org Foundation"
[    17.972] (II) UnloadModule: "fbdev"
[    17.972] (II) Unloading fbdev
[    17.972] (II) UnloadSubModule: "fbdevhw"
[    17.972] (II) Unloading fbdevhw

Xrandr (run xrandr - to check resolutions)

Screen 0: minimum 320 x 200, current 1280 x 720, maximum 2048 x 2048
HDMI-0 connected 1280x720+0+0 (normal left inverted right x axis y axis) 735mm x 420mm
   1920x1080     50.00 +  60.00    59.94
   1920x1080i    60.00    50.00    59.94
   1280x720      60.00*   50.00    59.94
   720x576       50.00
   720x576i      50.00
   720x480       60.00    59.94
   720x480i      60.00    59.94
   640x480       60.00    59.94
DVI-0 disconnected

Cpuinfo - before changing cpufrequency governor ("performance" is default)

anton@debian-panda:~$ cat /proc/cpuinfo
processor    : 0
model name    : ARMv7 Processor rev 2 (v7l)
BogoMIPS    : 2010.71
Features    : half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpd32
CPU implementer    : 0x41
CPU architecture: 7
CPU variant    : 0x1
CPU part    : 0xc09
CPU revision    : 2
processor    : 1
model name    : ARMv7 Processor rev 2 (v7l)
BogoMIPS    : 2010.71
Features    : half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpd32
CPU implementer    : 0x41
CPU architecture: 7
CPU variant    : 0x1
CPU part    : 0xc09
CPU revision    : 2
Hardware    : Generic OMAP4 (Flattened Device Tree)
Revision    : 0000
Serial        : 0000000000000000
anton@debian-panda:~$

Cpuinfo - after setting "conservative" or "ondemand" governor 

anton@debian-panda:~$ cat /proc/cpuinfo
processor    : 0
model name    : ARMv7 Processor rev 2 (v7l)
BogoMIPS    : 598.42
Features    : half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpd32
CPU implementer    : 0x41
CPU architecture: 7
CPU variant    : 0x1
CPU part    : 0xc09
CPU revision    : 2
processor    : 1
model name    : ARMv7 Processor rev 2 (v7l)
BogoMIPS    : 598.42
Features    : half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpd32
CPU implementer    : 0x41
CPU architecture: 7
CPU variant    : 0x1
CPU part    : 0xc09
CPU revision    : 2
Hardware    : Generic OMAP4 (Flattened Device Tree)
Revision    : 0000
Serial        : 0000000000000000

Ifconfig:

root@debian-panda:/home/anton# sudo ifconfig -a
eth0      Link encap:Ethernet  HWaddr aa:94:53:36:0e:b1
          inet addr:192.168.137.191  Bcast:192.168.137.255  Mask:255.255.255.0
          inet6 addr: fe80::a894:53ff:fe36:eb1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12350 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9359 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:11476659 (10.9 MiB)  TX bytes:1559729 (1.4 MiB)
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:480 (480.0 B)  TX bytes:480 (480.0 B)
usb0      Link encap:Ethernet  HWaddr 5a:f7:de:c4:dc:25
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)