Friday 17 June 2016

Ubuntu Precise 12.04 on Pandaboard - Configuration

This guide describes how to install and configure Ubuntu Precise on OMAP4 Pandaboard with working HDMI out (ES should be similar)

(I have put code below)

What do you need:

- Panda-board + power supply
- Linux host (You can use Windows with Cygwin as an alternative: https://www.cygwin.com)
- Host computer with SD card reader (or separate)
- SD card: 8BG+ ( MIN = 4GB), Class 10 preferably (fastest)
- Wifi / Ethernet connection
- Minicom
- HDMI / DVI supported TV / monitor
- Serial cable (optional, I am not a developer)

SD Card:

First, make sure you have >4GB SD card to make your life easier. If you use 4GB card for e.g., there is very high chance resizing will fail .. And you will have to do it manually. Thus, ideally you should use SD card 8 GB or bigger. Also, I recommend faster class.

Prepare SD card:

Download pre-built image (OMAP4 ARMv7 hardfloat)
http://cdimage.ubuntu.com/releases/12.04/release/ubuntu-12.04-preinstalled-desktop-armhf+omap4.img.gz
Uncompress gzip archive
Make sure you know which device your SD card stands for, in most cases it would be sdc or sdd (sda is definitely wrong ... don't wipe your hard drive !) Use sudo fdisk -l to check !
Transfer the image with dd command - takes some time and sync
Now your card is ready !
sudo fdisk -l
cd $HOME
wget http://cdimage.ubuntu.com/releases/12.04/release/ubuntu-12.04-preinstalled-desktop-armhf+omap4.img.gz
gunzip ubuntu-12.04-preinstalled-desktop-armhf+omap4.img.gz
sudo dd bs=4M if=ubuntu-12.04-preinstalled-desktop-armhf+omap4.img of=/dev/sdX
sudo sync


Boot up your board:

You should get HDMI image immediately more or less. LEDs should be lit and working.
You should be informed that the filesystem is being re-sized - if it fails, you would need to do it manually on your host computer (e.g. with GParted).
Then, it should reboot and commence installation - follow on-screen instructions (input your router details to make use of Wifi).


Install add-ons and do basic configuration:

Follow step-by-step - otherwise you will run into problems:
1) A) (Update) Before anything else, update your repos in: /etc/apt/sources.list
and uncomment any unused repositories, including precise-backports, but make sure there are no duplicates.
-   B) Alternatively, you can use Software Properties application:
software-properties-gtk
(If you run into duplicate warnings: http://askubuntu.com/questions/120621/how-to-fix-duplicate-sources-list-entry)
2) Add OMAP PPA (Guide for installation of add-ons: https://groups.google.com/forum/#!topic/pandaboard/vKunvhMNV8k
3) Update sources and upgrade software.
4) Install drivers.
5) Change bootargs ! Follow this link for more info: https://groups.google.com/forum/#!msg/pandaboard/7DLabw7amBg/ofeX-SOsdw4J
Change this:
vram=40M mem=456M@0x80000000 mem=512M@0xA0000000
to this:
 mem=1G@0x80000000

in your /boot/boot.script
ro elevator=noop console=ttyO2,115200n8 mem=1G@0x80000000 root=<UUID or LABEL root> fixrtc splash
(Recommended bootargs according to Xavier)
6) Force bootloader update.
7) Tweak ALSA as advised (not sure why).
8) Disable hardware cursor option ! It cause GUI crashes if not disabled. Edit  /usr/share/X11/xorg.conf.d/99-omap.conf and add this line to Device section:
Option "HWcursor" "false"
9) Re-boot.
10) Re-install pvr-omap4-dkms (it causes constant error messages otherwise). You can check if the GPU module is loaded with lsmod.
If the board doesn't boot the first 10 times, press Enter for e.g. to end this.
sudo nano /etc/apt/sources.list

sudo add-apt-repository ppa:tiomap-dev/release
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install ubuntu-omap4-extras
sudo nano /boot/boot.script
sudo /usr/sbin/flash-kernel --update-bootloader
sudo /usr/bin/alsaucm -c Panda set _verb HiFi
sudo nano /usr/share/X11/xorg.conf.d/99-omap.conf
sudo reboot
sudo apt-get install --reinstall pvr-omap4-dkms && sudo reboot
Optional:
Use GParted to change your SD card label - this will make it much easier to make sure the rootfs are always found, even after backing up / restoring image. For example, if you change the label to PANDA, add this bootarg:
root=LABEL="PANDA"

Optional:
Disable SWAP, if you are using a SD card. This is strongly advised, as you will be trashing your SD card, not to mention slowing down your system (I/O of Pandaboard SD card is quite slow). Follow these commands to disable it completely (you can confirm that SWAP is not being used with top):
sudo swapoff -a
sudo nano /etc/fstab
sudo rm /SWAP.swap
(Remove SWAP entry from fstab)



(Update) Optional: Update TI PPA software

You can update some of OMAP stuff by getting packages from TI Trunk PPA, which is more up to date. It includes updated GPU drivers, among other things.
(You don't need to remove Release PPA)

1) Add ppa:tiomap-dev/omap-trunk repository
2) Run apt-get update, followed by dist-upgrade
3) Again, make sure xorg configuration has Hardware Cursor disabled !
4) Force boot-loader update !
 
sudo add-apt-repository ppa:tiomap-dev/omap-trunk
sudo apt-get update
sudo apt-get dist-upgrade
sudo nano /usr/share/X11/xorg.conf.d/99-omap.conf
sudo /usr/sbin/flash-kernel --update-bootloader


(Update) Optional: Disable ondemand CPU frequency scaling:

(Thanks to Trevor Robinson)

Note: Doesn't seem to solve the issue for me, but quoted to be successful by some users. Also, setting performance governor will surely increase the incidence of overheating by logic. If the freeze is due to overheating, this may make the problem worse ... 
sudo update-rc.d ondemand disable
sudo apt-get -y install cpufrequtils
sudo echo 'ENABLE="true"
GOVERNOR="performance"
MAX_SPEED="0"
MIN_SPEED="0"' > /etc/default/cpufrequtils
sudo cpufreq-set -r -g performance
This disables ondemand and forces Ubuntu to switch to performance mode

Install a light Desktop Environment:

This can be LXDE or XFCE4 for example:
sudo apt-get install lxde
or
sudo apt-get install xfce4
Both are quite light. LXDE is probably lighter, but XFCE has nice customization of panels and workspace, which can help offset over-scan issue you might have on TV screen for e.g.
If you want full desktop version with all the features, you can install xubuntu-desktop or lubuntu-desktop respectively.
Important: Do not use XFCE4 Settings / Display !! You will end up with no image if you switch resolution. Instead, install ARandr.
There is also Enlightenment.
For those interested in GLES2 accelerated window manager, have a look here:
https://userbase.kde.org/KWin
Its a KDE Window Manager, but can be bundled with any DE with some tweaks. Here is a nice guide by Will Foster about using KWin with XFCE4:
https://hobo.house/2015/08/14/using-kwin-with-xfce/
Now, I have tried that by adding: kwin_gles --replace to auto-sessions in XFCE, which does the trick. However, I haven't noticed any difference ...

Problems after update

1) HDMI blanking

There is a weird issue of HDMI screen going black on some hardware ... Well, I have the symptoms. It happens in particular stages:
After splash screen and before login
When login crashes
When I move mouse (!)
When going from Shell console back to GUI
To recover:
Disconnect and reconnect your HDMI cable - you should get back to login screen
We need to turn-off hardware cursor (how can such small thing as mouse pointer have an effect ??): create xorg.conf and edit it turning off hardware cursor.
After reboot, everything works fine ! Unity 2D is advised

2) Freezes / lock-ups / turn-offs

Strange random boot-up freezes: sometimes it gets stuck on splash loading screen, sometimes after ... LEDs may or may not blink, may stop blinking after splash ... Well, really weird. So I have to to do a full reset - disconnecting power supply and pressing reset button.
Apparently, odemand governor is a culprit: http://askubuntu.com/questions/201981/pandaboard-crash-on-startup-or-freeze-after-minutes and https://bugs.launchpad.net/ubuntu/+source/linux-ti-omap4/+bug/971091. I don't think it has anything to do with overheating, at least not for Panda at 1GHz.
The solution should be to disable odemand. But that didn't solve the problem completely... Freezes happen during installation of software or browsing, as well as watching movies.
This may be related to overheating.
Make sure you fully disconnect the board: remove power supply and eject SD card, only then re-insert and boot up. Otherwise, it can continue to freeze each few minutes.
Update: Nice topic discussing the issue on Pandaboard ES: https://groups.google.com/forum/#!topic/pandaboard/sZtIzLs1LaM

3) Limited resolutions on HDMI

It seems not all TV resolutions are available in Xrandr. After trying Ubuntu 12.10, I have noticed that I have much more resolutions there than on 12.04 (it was not very useful system though). I couldn't find any solution so far, apart from accepting ... Oh, Xrandr --newmode doesn't work, at least for me. I have followed this Ubuntu guide: https://wiki.ubuntu.com/X/Config/Resolution#Adding_undetected_resolutions


How to back up the system to host computer:

Insert your SD card and don't mount it.
Use dd to write an image from it and compress with gzip, for e.g. (sudo fdisk -l to confirm your card just in case):
sudo fdisk -l
cd $HOME
sudo dd bs=4M if=/dev/sdX of=Pandaboard-8GB.img
gzip Pandaboard-8GB.img
This allows us to create our own image of Ubuntu on Panda and restore if we mess up ...
(Be warned that dd and gzip can take a long time to finish)


Status:

- GPU 2d / 3d acceleration is working, video scaling, etc; use es2gears to check (Unity 2d or and other desktop environment is preferred)
- Hardware video acceleration is working via Gstreamer (Totem and XBMC are supported and work quite well), however:
* Not all formats are supported in Totem - MKVs are sideshow :( ... Use MP4s preferably
* XBMC supports more containers ! :) At least MKVs. 720p works like a charm, 1080p is a little bit sluggish. Sometimes shattering occurs in some videos and supplied XBMC doesn't seem to support subtitles ...
- Audio over HDMI / speakers works fine
- Wifi works fine
- SD card speed is somewhat slow (known issue)
- Bluetooth doesn't work (will never work, not with stock kernel)
- System is not stable (see above)

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)

Saturday 1 September 2012

Debian on Pandaboard: Graphics

NOTE: Not finished !!! 3d doesn't work !!!

What is the choice ?

In relation to PandaBoard, we have a choice of 4 drivers:

---> FBDev (Linux framebuffer) - xserver-xorg-video-fbdev - a generic, hardware independent, primitive driver for Xserver
     * It is very easy to install
     * It is a framebuffer driver :P - no 2d acceleration, no 3d acceleration, no Xorg video (xv) output acceleration, etc
     * But, it will work, when everything else fails. You may need it initially to have at least GUI, or you may need it when the other two drivers crash.

---> OMAPFB - xf86-video-omapfb - open-source Xorg driver for OMAP boards, which uses DSS (display sub-system)
http://git.pingu.fi/xf86-video-omapfb/
http://gitweb.pingu.fi/?p=xf86-video-omapfb.git;a=summary
     * It is better than fbdev, as it is optimized for OMAP boards, specifically for DSS
     * It is a framebuffer driver; with support for overlays, XV video output, etc; but it doesn't provide 2d or 3d acceleration
     * It is open-source, so it shouldn't be too hard to install

---> x86-video-omap - open-source Xorg driver for OMAP boards, but which uses closed-source submodule for EXA acceleration.
https://github.com/robclark/xf86-video-omap
http://cgit.freedesktop.org/xorg/driver/xf86-video-omap/
     * It requires omapdrm support in kernel and (as I understood) SGX binaries.

---> PVR OMAP4 - pvr-omap4 - closed source driver for OMAP4 SGX GPU, which has the best performance and provides all the features
https://launchpad.net/~tiomap-dev/+archive/release 
https://launchpad.net/~tiomap-dev/+archive/omap-trunk
     * It is what we want the most - overlays, XV, GLES, GLES2, EGL, etc
     * It is closed source + depends on particular kernel version + depends on Xorg ABI major version + depends on armel / armhf arch. Thus, it can be a pain to install this driver. It will be ... for Debian


fbdev driver - xserver-xorg-video-fbdev

To install this driver, simply do:
sudo apt-get install xserver-xorg-video-fbdev
or just install your desktop environment straight away, e.g. LXDE
sudo apt-get install lxde
That's all. You have your driver. No need to configure anything. The default resolution I got on my HDMI TV was 640 x 480.

omapfb driver - xf86-video-omapfb

(This is not complete yet.)
Getting xf86-video-ompafb driver to work shouldn't be too hard (in theory), however the driver is old now and is no longer updated. Newest kernels seem to cause issues for this driver.
The driver can be installed as a package or built from source:

a) Installing via apt:
Two packages are provided:
--- xserver-xorg-video-omap3, which was built with -mfpu=neon flag and is thus optimized for NEON extension (which we have - gives performance boost)
--- xserver-xorg-video-omapfb, which is the same as -omap3, but is not optimized for NEON
To install the driver, simply run:
sudo apt-get install xserver-xorg-video-omap3
or, if you want the one without NEON optimizations:
sudo apt-get install xserver-xorg-video-omapfb
and set up the Xorg (will be described further).

b) Building and installing from source:
0) Install all the necessary tools and developmental packages:
sudo apt-get install build-essential autoconf libtool gettext xutils-dev x11proto-render-dev xorg-dev
(Some of them you might already have.)
1) Clone any of the following git repos:
http://git.pingu.fi/xf86-video-omapfb/
git://anonscm.debian.org/collab-maint/xf86-video-omapfb.git
(They give same results anyway)
git clone http://git.pingu.fi/xf86-video-omapfb.git
OR
git clone git://anonscm.debian.org/collab-maint/xf86-video-omapfb.git
2) Configure the driver:
cd xf86-video-omapfb
./autogen.sh
./configure --prefix=/usr --with-xorg-module-dir=/usr/lib/xorg/modules --enable-neon CFLAGS="-O2 -mtune=cortex-a9 -mfpu=neon"
3) Check makefiles (in xf86-video-omapfb and xf86-video-omapfb/src dirs) for CFLAGS variable, which should have "-mfpu=neon" flag. If this flag is missing, add it. Otherwise, the build will fail.
4) Compile and install the driver:
make
sudo make install
5) Configure Xorg

Configuring Xorg for xf86-video-omapfb:
We will create new configuration file in /usr/share/X11/xorg.conf.d directory. I have looked at Xorg configuration file for pvr-omap4 drivers, so I named the file "99-omapfb.conf" (you can give it any other name). So:
sudo nano /usr/share/X11/xorg.conf.d/99-omapfb.conf
and add the following configuration (true for HDMI certainly), or something similar:
Section "Device"
    Identifier    "OMAPFB Video Device"
    Driver        "omapfb"
    Option        "fb"    "/dev/fb0"
EndSection

Section "Monitor"
    Identifier "hdmi"
EndSection

Section "Screen"
    Identifier    "Screen0"
    Monitor        "hdmi"
    Device        "OMAPFB Video Device"
    DefaultDepth     16
EndSection
Save and exit. Reboot:
sudo reboot
Xorg should start.

Current result:
It did start. Resolution is still the same though - 640x480. XRandr doesn't give any choices. XVideo is still useless - "No adaptors present." The following is my Xorg.0.log output, in relation to omapfb:
anton@arm:~$ cat /var/log/Xorg.0.log | grep omapfb
[    20.313] Kernel command line: console=ttyO2,115200n8 console=tty0 vram=16MB omapfb.mode=hdmi:1280x720MR-16@60 omapdss.def_disp=hdmi root=/dev/mmcblk0p2 ro rootfstype=ext4 rootwait fixrtc buddy= buddy2=
[    20.427] (II) LoadModule: "omapfb"
[    20.432] (II) Loading /usr/lib/xorg/modules/drivers/omapfb_drv.so
[    20.436] (II) Module omapfb: vendor="X.Org Foundation"
[    20.437] (II) omapfb: Driver for OMAP framebuffer (omapfb) and external LCD controllers:
[    20.437] (WW) Error opening /sys/devices/platform/omapfb/ctrl/name: No such file or directory
[    20.438] (II) omapfb(0): Base plane capabilities:
[    20.438] (II) omapfb(0): Base plane supports the following image formats:
[    20.438] (II) omapfb(0): VideoRAM: 600KiB (SDRAM)
[    20.438] (II) omapfb(0): Creating default Display subsection in Screen section
[    20.438] (--) omapfb(0): Depth 16, (==) framebuffer bpp 16
[    20.438] (==) omapfb(0): RGB weight 565
[    20.438] (==) omapfb(0): Default visual is TrueColor
[    20.438] (II) omapfb(0): Detecting outputs
[    20.438] (II) omapfb(0): Output dvi using monitor section hdmi
[    20.438] (II) omapfb(0): Output hdmi using monitor section hdmi
[    20.439] (II) omapfb(0): overlayPoolInit: Found 3 framebuffers, 4 overlays and 3 managers
[    20.440] (II) omapfb(0): Printing probed modes for output dvi
[    20.440] (II) omapfb(0): Modeline "640x480"x59.5   23.50  640 688 720 800  480 483 487 494 (29.4 kHz P)
[    20.440] (II) omapfb(0): Printing probed modes for output hdmi
[    20.440] (II) omapfb(0): Modeline "640x480"x60.1   25.18  640 656 688 800  480 491 511 524 (31.5 kHz P)
[    20.440] (II) omapfb(0): Output dvi connected
[    20.440] (II) omapfb(0): Output hdmi connected
[    20.440] (II) omapfb(0): Using exact sizes for initial modes
[    20.440] (II) omapfb(0): Output dvi using initial mode 640x480
[    20.440] (II) omapfb(0): Output hdmi using initial mode 640x480
[    20.440] (II) omapfb(0): Using default gamma of (1.0, 1.0, 1.0) unless otherwise stated.
[    20.440] (II) omapfb(0): XRandR extension initialized
[    20.440] (--) omapfb(0): Virtual size is 640x480 (pitch 640)
[    20.440] (**) omapfb(0):  Mode "640x480": 25.2 MHz, 31.5 kHz, 60.1 Hz
[    20.440] (II) omapfb(0): Modeline "640x480"x60.1   25.18  640 656 688 800  480 491 511 524 (31.5 kHz P)
[    20.440] (==) omapfb(0): DPI set to (96, 96)
[    20.458] (EE) omapfb(0): FBIOBLANK: Invalid argument
[    20.458] (==) omapfb(0): DPMS enabled
[    20.458] (II) omapfb(0): RandR 1.2 enabled, ignore the following RandR disabled message.
[    20.640] (II) omapfb(0): Setting screen physical size to 169 x 127
[    20.922] (WW) omapfb(0): overlayPoolApplyConnections: Disconnecting overlay 0
[    20.922] (WW) omapfb(0): overlayPoolApplyConnections: Connecting 0 -> 0 -> 1
anton@arm:~$
I played a lot with options in Xorg configurations. I will try to build custom kernel and test this driver. Also I will try omapfb optimized mplayer. This driver should be useful, at least better than fbdev.

omap driver - xf86-video-omap

Will test later ...

pvr-omap4 driver

The problem:
Debian Wheezy currently provides Xserver 1.12.xxx version, which is not supported and ,most likely, will not be supported by OMAP PPA team:
https://groups.google.com/forum/?fromgroups#!topic/pandaboard/BYFaLYzCniQ
(Thanks to ndec for letting me know.)
So, what does it mean ? Well, the pvr-omap4 driver depends on Xorg server version. Ubuntu OMAP ppa trunk provides drivers for Xserver version 13 (for Ubuntu 12.10 ), which is not yet out. Ubuntu OMAP ppa release provides drivers for Xserver version 11 (for Ubuntu 12.04), which is older than what we have. If you try to install these drivers without upgrading / downgrading your Xorg, the Xorg will crash and you will get:
"module ABI major version (11) doesn't match the server's version (12)"
or

"module ABI major version (13) doesn't match the server's version (12)"
Thus we have only 2 choices in this situation:
---- a) Downgrade Xorg from 1.12.xx to 1.11.xx and install drivers for Xserver version 11
OR
---- b) Wait when Xorg 1.13.xx becomes available, upgrade Xorg from 1.12.xx to 1.13.xx and install the drivers for Xserver version 13
Upgrade is much safer than downgrade, usually. But I hate to wait.

Option A - Xorg downgrade, using the drivers for Xserver ABI 11:

1) Build and install Ubuntu kernel, if you haven't done it already:
http://alastordmcblog.blogspot.ie/2012/05/debian-on-pandaboard-building-ubuntu.html
2) Uninstall Xorg (1.12.xx), if you have it:
sudo apt-get remove xserver-xorg-core xserver-xephyr
(don't worry about other packages, which will be removed).
3) Download specific .debs, which will give us Xserver ABI 11, keyboard / mouse support and fbdev:
(Source page: http://snapshot.debian.org/package/xorg-server/2%3A1.11.4-1/ )
wget http://snapshot.debian.org/archive/debian/20120305T093701Z/pool/main/x/xorg-server/xserver-xephyr_1.11.4-1_armhf.deb
wget http://snapshot.debian.org/archive/debian/20120305T052015Z/pool/main/x/xorg-server/xserver-common_1.11.4-1_all.deb
wget http://snapshot.debian.org/archive/debian/20120305T093701Z/pool/main/x/xorg-server/xserver-xorg-core_1.11.4-1_armhf.deb
wget http://snapshot.debian.org/archive/debian/20120305T224435Z/pool/main/x/xserver-xorg-input-evdev/xserver-xorg-input-evdev_2.6.0-2_armhf.deb
wget http://snapshot.debian.org/archive/debian/20120305T224435Z/pool/main/x/xserver-xorg-video-fbdev/xserver-xorg-video-fbdev_0.4.2-4_armhf.deb
4) In the same directory (where your downloaded packages are), run the following to install the packages:
sudo dpkg -i xserver-xephyr_1.11.4-1_armhf.deb xserver-common_1.11.4-1_all.deb xserver-xorg-core_1.11.4-1_armhf.deb xserver-xorg-input-evdev_2.6.0-2_armhf.deb xserver-xorg-video-fbdev_0.4.2-4_armhf.deb
OR run this, if you are lazy and have nothing else in that directory:
sudo dpkg -i *
5) If you have got NO errors, reboot to test your downgraded Xserver:
sudo reboot
 and verify that you mouse / keyboard still work.
(If you have errors during installation, remove the problematic packages, reinstall the working Xserver and try again. If you fail to install fbdev - you will have no video, if you fail to install evdev - your keyboard + mouse will be unresponsive.)

Building and installing the omapdrm_pvr module (from pvr-omap4-dkms source):

0) Install dos2unix (needed for building), if you don't have it:
sudo apt-get install dos2unix
1) Download the right version of pvr-omap4-dkms:
    a) For Xorg 1.11.xx
DKMS="1.7.10.0.1.20"
wget https://launchpad.net/~tiomap-dev/+archive/release/+files/pvr-omap4-dkms_$DKMS.orig.tar.gz
2) Extract the source:
tar xzf pvr-omap4-dkms_$DKMS.orig.tar.gz
3) Set some variables (DISCIMAGE variable is probably useless...):
export KERNELDIR=$HOME/ubuntu-precise
export DISCIMAGE=/
This, of course, assumes that your kernel source is ubuntu-precise folder in your home directory. Change the value of the variable if it is not the case. (The module needs kernel sources to be built.)
4) Cd into driver directory and build the module:
cd git-import-orig/sgx/eurasiacon/build/linux2/omap4430_linux
make
5) Install the module (uname -r extracts the release number of the kernel - it is needed to make a correct directory for modules):
KERNELRELEASE=$(uname -r)
sudo mkdir /lib/modules/$KERNELRELEASE
sudo mkdir /lib/modules/$KERNELRELEASE/kernel
sudo mkdir /lib/modules/$KERNELRELEASE/kernel/extra
sudo cp $HOME/git-import-orig/sgx/eurasiacon/binary2_omap4430_linux_release/target/omapdrm_pvr.ko /lib/modules/$KERNELRELEASE/kernel/extra

Loading omapdrm_pvr module:

Now that we have installed the module, we need to load it. To check that your module is not loaded indeed, run:
lsmod
and you will get nothing, i.e. this:
Module                  Size  Used by
which means that no modules are currently loaded.

If you want to check that your module can be loaded, run the following:
KERNELRELEASE=$(uname -r)
sudo insmod /lib/modules/$KERNELRELEASE/kernel/extra/omapdrm_pvr.ko
lsmod
and you should get this:
Module                  Size  Used by
omapdrm_pvr           157683  0
which means that the module is loadable. But this is not exactly what we want ... We need auto-loading, at boot time

To load the omapdrm_pvr module at boot, proceed as follows:
0) Gain root privileges and set a variable
su
KERNELRELEASE=$(uname -r)
1) Create modules.builtin and modules.order files in your kernel modules directory
touch /lib/modules/$KERNELRELEASE/modules.builtin
touch /lib/modules/$KERNELRELEASE/modules.order
2) Add "kernel/extra/omapdrm_pvr.ko" as the contents for both of them
echo "kernel/extra/omapdrm_pvr.ko" > /lib/modules/$KERNELRELEASE/modules.builtin
echo "kernel/extra/omapdrm_pvr.ko" > /lib/modules/$KERNELRELEASE/modules.order
3) Run depmod (this will create all the necessary files for automatic loading of the module)
depmod -a
4) Edit /etc/modules file, which will load the module for us at boot
nano /etc/modules
and add the following line
omapdrm_pvr
to the end, save and exit.
5) Reboot your system to test the module
reboot
and at the next boot, use lsmod again. You should have the module loaded at each boot.

Installing pvr-omap4 libraries, binaries and configuration files:

1) Download, extract the correct version of the pvr-omap4 drivers to your home directory, gain root privileges and set a variable:
    a) For Xorg 1.11.xx:
cd

wget https://launchpad.net/~tiomap-dev/+archive/release/+files/pvr-omap4_1.7.10.0.1.21.orig.tar.gz
tar xzf pvr-omap4_1.7.10.0.1.21.orig.tar.gz
su
PVRVERS="1.7.10.0"
2) Copy all the necessary files (including headers, but without debug data and documents):
cp -f usr/lib/libusc.so.$PVRVERS usr/lib/libTIPVR2DBLT.so.$PVRVERS usr/lib/libpvrPVR2D_DRIWSEGL.so.1.7.10.0 usr/lib/libpvr2d.so.$PVRVERS usr/lib/libsrv_um.so.$PVRVERS usr/lib/libOpenVG.so.$PVRVERS usr/lib/libEGL.so.$PVRVERS usr/lib/libGLESv2.so.$PVRVERS usr/lib/libOpenVGU.so.$PVRVERS usr/lib/libPVRScopeServices.so.$PVRVERS usr/lib/libIMGegl.so.$PVRVERS usr/lib/libsrv_init.so.$PVRVERS usr/lib/libGLESv1_CM.so.$PVRVERS usr/lib/libglslcompiler.so.$PVRVERS /usr/lib
cp -f usr/lib/pkgconfig/* /usr/lib/pkgconfig
cp -f usr/lib/xorg/modules/drivers/pvr_drv.so /usr/lib/xorg/modules/drivers
cp -f usr/share/X11/xorg.conf.d/99-pvr.conf.panda /usr/share/X11/xorg.conf.d
cp -r -f usr/share/sgx-lib /usr/share
cp -f usr/bin/* /usr/bin
cp -r -f usr/include/KHR /usr/include
cp -r -f usr/include/GLES /usr/include
cp -r -f usr/include/VG /usr/include
cp -r -f usr/include/EGL /usr/include
cp -r -f usr/include/GLES2 /usr/include
3) Make all the necessary symbolic links:
ln -s /usr/lib/libusc.so.$PVRVERS /usr/lib/libusc.so
ln -s /usr/lib/libTIPVR2DBLT.so.$PVRVERS /usr/lib/libTIPVR2DBLT.so
ln -s /usr/lib/libpvrPVR2D_DRIWSEGL.so.$PVRVERS /usr/lib/libpvrPVR2D_DRIWSEGL.so
ln -s /usr/lib/libpvr2d.so.$PVRVERS /usr/lib/libpvr2d.so
ln -s /usr/lib/libsrv_um.so.$PVRVERS /usr/lib/libsrv_um.so
ln -s /usr/lib/libOpenVG.so.$PVRVERS /usr/lib/libOpenVG.so.1
ln -s /usr/lib/libOpenVG.so.1 /usr/lib/libOpenVG.so
ln -s /usr/lib/libEGL.so.$PVRVERS /usr/lib/libEGL.so.1
ln -s /usr/lib/libEGL.so.1 /usr/lib/libEGL.so
ln -s /usr/lib/libGLESv2.so.$PVRVERS /usr/lib/libGLESv2.so.2
ln -s /usr/lib/libGLESv2.so.2 /usr/lib/libGLESv2.so
ln -s /usr/lib/libOpenVGU.so.$PVRVERS /usr/lib/libOpenVGU.so
ln -s /usr/lib/libPVRScopeServices.so.$PVRVERS /usr/lib/libPVRScopeServices.so
ln -s /usr/lib/libIMGegl.so.$PVRVERS /usr/lib/libIMGegl.so
ln -s /usr/lib/libsrv_init.so.$PVRVERS /usr/lib/libsrv_init.so
ln -s /usr/lib/libGLESv1_CM.so.$PVRVERS /usr/lib/libGLESv1_CM.so.1
ln -s /usr/lib/libGLESv1_CM.so.1 /usr/lib/libGLESv1_CM.so
ln -s /usr/lib/libglslcompiler.so.$PVRVERS /usr/lib/libglslcompiler.so
 4) Warning: The next command will apply changes to your Xorg configuration ! Up to this point your Xorg was untouched. Now, you have a potential to crash your Xorg at the next boot ! You have been warned.
Run this to use PVR driver at the next boot:
mv /usr/share/X11/xorg.conf.d/99-pvr.conf.panda /usr/share/X11/xorg.conf.d/99-pvr.conf
5) Reboot your system:
reboot

And, this is as far as I can get. What are the results you ask ? Well:
- Xorg starts
- From the logs, I can state that pvr driver is being used indeed
- Mouse pointer freezes from time to time and I can assume that there is a massive SD card I/O activity
- Xrandr works and I can switch between resolutions
- Rendering doesn't work !!! All tests fail. Xeglinfo fails.
- Details are here:
https://groups.google.com/forum/?fromgroups=#!topic/pandaboard/FLegeDRqzzQ

So, pvr driver works, but 3d doesn't. I would love to finish the guide and get the 3d to work, but I run out of time (I am a dental student - my term starts from the 3d of Sept).

Thus, I would be very happy if someone could finish this thing off and get the rendering to work :) But please, let me know !

Additional details:
- All versions of sources have been used as stated in the guide
- libdrm was installed (most likely when I have installed lxde)
- libdri was not installed (well, apt-get stated that it could not locate the package: libdr, libdri2, etc - but if DRM is installed, DRI must also be installed, or, at least, installable ???)
- I tried to install libdrm from source from OMAP PPA Release. Succeeded. But no effect - no 3d :(
- Tried to apply OMAP patch to libdrm (for OMAP support - but I don't think it is needed - armin76 didn't tell anything about it ?). Failed, couldn't successfully run autoconf and configure (i have installed autoconf beforehand ).
- Tried to install libdri2 from source from OMAP PPA Release. Asked for xorg-macros. Tried to install it from source (1.10, debian unstable) - failed. Configure failed.
- Made extensive changes to kernel configuration - changed all things that are related / could be related to GPU, DRM, Power Saving, DMA, etc to be the same as in Ubuntu configuration - didn't help in any way - same results.
- Used modprobe - no effect
- Installed Modules.symvers from built pvr-omap4-dkms - no effect ...
- Tried passing BUILD=debug for pvr-omap4-dkms. Failed to compile ...
- Tried BUILD=timing ... Succeeded, but no effect ...
- Tried passing W=1 for pvr-omap4-dkms - lots of warning ! No effect
- Tried to install kernel with modules (Ubuntu configuration, modules as modules). Failed ! make modules install gives me errors and doesn't work no matter what I do ! This is why I make them all built-in (if I can) ....
- Tried 3.2.0-1412.16 kernel ... Changed some commands to download, extract ... The procedure didn't work. Armin76's config didn't work after using sed commands. And I can't install kernel with modules ...
- Tried 3.2.0-1412.16 kernel with omap4_defconfig + all odules built-in ... Failed - didn't boot successfully.
- Tried the newest 3.4 kernel (from OMAP release ppa) with omap4plus_defconfig + all modules built-in. Failed again - didn't boot successfully
- I run out of ideas :(




Monday 28 May 2012

Debian on Pandaboard: Building Ubuntu kernel

Setting up basic build environment:

There is a nice package, called "build-essential", by installing which you should have all the tools needed to compile and packed applications/kernels from their respective sources:
sudo apt-get install build-essential libncurses5-dev
(You would want to have libncurses5-dev - without it, you would be unable to run "menuconfig".)
If that didn't work, use this:
sudo apt-get install gcc g++ make libncurses5-dev

Building your kernel: (with enabled WiFi, Bluetooth, etc)

In this tutorial, we are going to use Ubuntu kernel source. Why ? Because Ubuntu kernels are officially supported by TI devs - we will get all the fixes Ubuntu has and all nice features. But the most important point is: GPU driver binaries are built for specific versions of Ubuntu kernels. (If I am correct, the only binary blobs provided are for Ubuntu and Android. Source.) We want GPU drivers, right ?
There are very nice tutorials provided by armin76 about installing and configuring Gentoo Linux on Pandaboard. (http://dev.gentoo.org/~armin76/arm/pandaboard/) They had really helped me.
We will use the kernel source of Ubuntu Precise (we obviously want hard float).
(Run everything in this paragraph as a normal user - non-root. Don't use su.)

Step-by-step process: (Skip it, if you just want to build the kernel, without running menuconfig.)

1) Download the kernel source:
KERNELVERSION="3.2.0-1416.22"
cd
wget --no-check-certificate wget --no-check-certificate https://launchpad.net/ubuntu/precise/+source/linux-ti-omap4/$KERNELVERSION/+files/linux-ti-omap4_$KERNELVERSION.tar.gz
2) Extract:
tar zxvf linux-ti-omap4_$KERNELVERSION.tar.gz
3) Change to ubuntu-precise directory:
cd ubuntu-precise
4) Download a nice .config, provided again by armin76.
wget http://dev.gentoo.org/~armin76/arm/pandaboard/kconfig -O .config
5) Solve annoying CONFIG_SCSI_WAIT_SCAN=m "damn persistent module" problem (will set it as built-in - will explain why we want this):
sed -i 's/default m/default y/g' drivers/scsi/Kconfig
6) Force the kernel to built no modules (not even that scsi_wait_scan.ko module):
sed -i 's/=m/=y/g' .config
So, why do we need this ? Well, having no modules around makes the installation process hell like easy. More importantly, however, as reported by a number of users, is that you need to have modules built into your kernel or use initrd to have a normal booting procedure. (http://groups.google.com/group/pandaboard/browse_thread/thread/236f7df1572fc6d5 - post by Pavol Cupka)
(By the way, the kernel that armin76 provides didn't boot for me on Debian - waited 15 mins - no login, no read/write activity. In fact it happened on Angstrom also. The reason, I think, is that it fails to find a number of modules and stops booting. My usb keyboard + mouse were completely unresponsive. But then it works just fine on Gentoo ... I don't get it.)
7) Edit your kernel configuration (optional):
make menuconfig
(Make sure NOT to disable debug in display section. My picture was a mess after I disabled it.)
8) Build you kernel:
make -j2 ARCH=arm uImage
This will take a while. Find something to do for an hour or so. (Depends on your card speed.) After that you will get your uImage file (this is our new kernel).

Single-step process: (No menuconfig - will just build the kernel.)

Run this:
KERNELVERSION="3.2.0-1416.22"
wget --no-check-certificate https://launchpad.net/ubuntu/precise/+source/linux-ti-omap4/$KERNELVERSION/+files/linux-ti-omap4_$KERNELVERSION.tar.gz && tar zxvf linux-ti-omap4_$KERNELVERSION.tar.gz && cd ubuntu-precise && wget http://dev.gentoo.org/~armin76/arm/pandaboard/kconfig -O .config && sed -i 's/default m/default y/g' drivers/scsi/Kconfig && sed -i 's/=m/=y/g' .config && make -j2 ARCH=arm uImage
and you should get your uImage.

Installing your kernel:

1) Make a backup of your boot files to "backup" folder on "boot" volume and clean "boot" volume:
sudo mv -f /boot/uboot/MLO /boot/uboot/u-boot.img /boot/uboot/zImage /boot/uboot/initrd.img /boot/uboot/uEnv.txt /boot/uboot/SOC.sh /boot/uboot/backup
2) Restore MLO and u-boot.img:
sudo cp -f /boot/uboot/backup/MLO /boot/uboot/backup/u-boot.img /boot/uboot
3) Install your new kernel (make sure you are in ubuntu-precise directory):
sudo cp -f arch/arm/boot/uImage /boot/uboot
4) Just reboot the system:
sudo reboot
NOTE: It could take 2 - 4 minutes before you get to the login screen with the new kernel. During this time, you may or may not have video signal. If you have a signal, you will most likely see only 2 penguins on a black background, with no other output.

My comments about my new kernel:

- Version: 3.2.0-1416.22
- Boot time with this kernel (from cold to login screen): 2 - 4 minutes
- HDMI out: yes, 1080p - default, but can change if you disconnect and then reconnect the cable or change the source from your TV (tested with fbdev video driver). Ony one resolution is available.
- DVI out: not tested
- Bluetooth: not tested
- Wifi: Works
- Ethernet: Not tested, should work
- SGX drivers:  Work, but with issues, more to come ...
- Audio: Not tested
- CPU frequency scaling: Not tested

Thanks to: armin76 for awesome tutorials.

Saturday 26 May 2012

How to install Debian on Pandaboard + do basic configuration.


Installing Debian - very easy and fast:

EDIT: Updated for the latest version of rootfs. Some minor changes.
(Thanks to Dr. Ace Jeangle for providing those instructions: http://www.chalk-elec.com/?p=1478 )
(And thanks to Robert Nelson, for creating and providing ARM hard float Debian rootfs. You can visit his site by following this link: http://www.rcn-ee.com .)

Insert your SD card into a card reader of your host PC and run the commands below on your host system, preferably Ubuntu or Debian. (We are using apt-get here.)

WARNING !!! PLEASE ENSURE THAT THE "sdb" DEVICE IS THE ONE OF YOUR SD CARD ! "sda" IS MOST CERTAINLY WRONG ONE TO USE ! IF YOU ARE NOT CAREFUL, YOU CAN WIPE OUT YOUR HARD DRIVE ! PLEASE READ BELOW ABOUT EASY WAYS TO CHECK WHICH ONE IS YOUR CARD

To check the latest rootfs available, visit:
http://rcn-ee.net/deb/rootfs/wheezy/
and update the VERSION variable to that of the newest rootfs
VERSION="2012-11-29"
sudo apt-get install uboot-mkimage wget pv dosfstools btrfs-tools parted
wget http://rcn-ee.net/deb/rootfs/wheezy/debian-wheezy-minimal-armhf-$VERSION.tar.xz
tar xJf debian-wheezy-minimal-armhf-$VERSION.tar.xz
cd debian-wheezy-minimal-armhf-$VERSION/
sudo ./setup_sdcard.sh --mmc /dev/sdb --uboot panda

Use "panda" for PandaBoard Ax (non-ES). Use "panda_es" for PandaBoard ES.
(http://elinux.org/BeagleBoardDebian#Demo_Image)
In my case, the name of my card is "sdc", because I have external USB HDD, which is "sdb". But usually, the card would be "sdb". I use:
sudo ./setup_sdcard.sh --mmc /dev/sdc --uboot panda
You can use the following command to see what is mounted:
df -h
Or you can use:
dmesg
just after you have plugged-in your SD card.
Take a notice of "sdb" or "sdc". Estimate which is your card.

Another OS is installed on the card:

If your card has already got some OS installed on it, we can remove it using "fdisk":
sudo fdisk /dev/sdc
(Change "sdc" to what you have !!!) NOTE: Use "d" option to delete a partition. Each partition has a number (1, 2, etc). Use option "w" to save your changes. (Otherwise your changes will not be saved.)

Video output:

a) If you want to use DVI video output:
Open file uEnv.txt on "boot" partition of the card:
(for e.g.)
nano /media/boot/uEnv.txt
uncomment the line "defaultdisplay=dvi", uncomment "vram=16MB" (if it is commented), uncomment "dvimode=1280x720MR-16@60" and (if you want) change it to suit your display. Some examples (as I don't use DVI) can be found here, by Dr. Ace Jeangle:
http://www.chalk-elec.com/?p=1478

b) If you want to use HDMI video output:
Same as above, except that you leave "dvimode=1280x720MR-16@60" commented in and change "defaultdisplay=dvi" to "defaultdisplay=hdmi".
More to come, when I do a little bit of testing with custom kernel, as with stock kernel, I have stubborn 640x480 60Hz output on my 1080i TV, via HDMI.

Booting process:

Insert your Debian populated SD card into Pandaboard and boot-up the board.
Ok, if your new Debian system is working, on boot you should see the video output being displayed on your monitor or TV. The booting process progresses much faster than on Ubuntu. After a minute or so you should see the login prompt (in Command Line Interface - no GUI).
(From here onwards, all the commands will be executed on our board.)

Login:

So, how do I login ? Well, the default user is "debian" and "temppwd" is its password. The root password is "root". (http://elinux.org/BeagleBoardDebian#Debian_Wheezy_snapshot)

Important security measures:

1 - Change root password ! (IMPORTANT !!!)
Login as root and run:
passwd
then enter and verify your new root password.
2 - Create new user.
Login as root (temporary) OR login as debian and use:
su
(sudo might not work), then run:
adduser YOUR NEW USER NAME
and answer all questions (password, full name, etc).
3 - Add the user to sudoers file. 
(Optional. Will grant the user the ability to use "sudo" command.)
Run:
su
visudo
This will open the /etc/sudoers file. (Visudo is made for this ! Don't think about using nano, vim, etc.)
Look for the following line:
root ALL=(ALL) ALL
and add this line just underneath:
user ALL=(ALL) ALL
changing "user" to your username. Save and exit: Ctrl + o, ENTER, Ctrl + x. Now you can use the "sudo" command. (Btw, "sudo" uses user password, not root password.
4 - Change debian password.
Login as debian or (your username) and run:
 sudo passwd debian
and type in + verify your new debian password. (This is strongly advised, as the default debian password is known and public.)

Set-up Internet connection:

Now, to download packages and etc we need to have an Internet connection. For Panda we have 2 options: Ethernet or WiFi - both work in our Debian Linux !
a) Ethernet: Just connect the cable between your router and the board. It should work straight away - no configurations are needed. Reboot is not necessary.
b) WiFi: Here a little bit of work is needed. But it will work: (This site has really helped me: http://www.howtoforge.com/how-to-connect-to-a-wpa-wifi-using-command-lines-on-debian)
1 - Run "ifconfig -a" if you want to. We do have our WiFi adapter working though. Its name is: wlan0 (We also have wpasupplicant installed - no need to search or install it.)
2 - Create and edit the following file:
su
nano /etc/wpa_supplicant.conf 
Type in the following:
network={
                 ssid="TYPE IN THE NAME OF THE ROUTER HERE"
                 psk="TYPE IN ITS KEY/PASSWORD HERE"
}
Complete the entries. Save and exit: Ctrl + o, ENTER and Ctrl + x .
3 - Run the following command:
wpa_supplicant -B -iwlan0 -c/etc/wpa_supplicant.conf -Dwext
Then, when you see its output, hit ENTER.
4 - Run this last command:
dhclient wlan0
and now you should be connected.
5 - Following the next boot, you will be disconnected. To reconnect, you just repeat step 3 and 4.

Before installing anything:

Update your system. This is required, as you will run into problems if you don't do this:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
Depending on how old is your rootfs, this might take few minutes.

Installing Graphical User Interface:

The easiest way is by using the minimal_lxde_desktop.sh script, provided by Robert Nelson.
(This will give you a working LXDE environment, which I think is the best choice for us.)
cd /boot/uboot/tools/ubuntu
sudo sh minimal_lxde_desktop.sh
Or you can install LXDE with one command line:
sudo apt-get install lxde
If your choice is XFCE, then do:
sudo apt-get install xfce4
LXDE is the easiest option and is the guaranteed one. XFCE didn't work for me last time. GNOME / KDE would take a lot of time to install and are quite heavy (for fbdev in particular).
Installing any of these desktop environments will also cause installation of Xorg (1.12 currently), as well as xserver-xorg-video-fbdev driver, which we will use initially.

Achieving auto-connection (with Wifi):

We have a number of options here. The following are those, which I have tried:
(Choose option "c" if you want boot-up speed-up, but don't want Ethernet.)

a) Install Wicd client:
sudo apt-get install wicd
and answer one configuration question (which users will run wicd). Run the client, find your router, provide your password (in Advanced Settings), click "Automatically connect to this network" box and that's all ! (I don't know for sure, but in my case I had to reboot to get connection. Works perfectly.)

OR

b) Debian has a rc.local start-up script, which we can edit. Open the /etc/rc.local file:
sudo nano /etc/rc.local
and just add the following commands:
wpa_supplicant -B -iwlan0 -c/etc/wpa_supplicant.conf -Dwext
dhclient wlan0
to the end of the script (after all comments), BUT before "exit 0" command. Save and exit. You will be connected each time you boot.

OR

c) This one is the best so far. Edit /etc/network/interfaces file:
sudo nano /etc/network/interfaces
,look for the following:
# WiFi Example
#auto wlan0
#iface wlan0 inet dhcp
#    wpa-ssid "essid"
#    wpa-psk  "password"
,comment out  the last 4 lines quoted here and substitute "essid" with (your router ssid), "password" with (your router password). Now look for:
# The primary network interface
auto eth0
iface eth0 inet dhcp
and comment in the last 2 lines quoted. In the end, the file should look like this:
auto lo
iface lo inet loopback

# The primary network interface
#auto eth0
#iface eth0 inet dhcp
# Example to keep MAC address between reboots
#hwaddress ether DE:AD:BE:EF:CA:FE

# WiFi Example
auto wlan0
iface wlan0 inet dhcp
    wpa-ssid "**********"
    wpa-psk  "**********"
Save and exit. Done.
This actually has a double value for us. 1st - you have a working Wifi, which will be connected at each boot. 2nd - your boot-up time is reduced significantly, as Ethernet is disabled at boot and there is no DHCPDISCOVER loop (which takes about a minute of time). Being in this section means that you don't need Ethernet anyway.

Clock skew and its solution (Important !):

The most annoying problem ... EDIT: Seems to me there are still problems with this, ugh ...
The initial time we have in Debian is .... ugh ... quite far from being accurate - 1st of January, 1970 ! This indicates that the clock was completely reset ... No wonder - Panda, by itself, doesn't have a battery to supply hardware clock.
First, we need to make sure that the timezone is correct. To edit the timezone, we use:
tzselect
and follow the steps. In the end, you will get:
Therefore TZ='TIMEZONE YOU HAVE' will be used.
with you timezone. This is what we need. For example, I got:
Therefore TZ='Europe/Dublin' will be used.
Now, like stated, we will make this change permanent:
cd
nano .profile
Scroll to the bottom of the file, leave an empty space after the last line and add the timezone line:
TZ='TIMEZONE YOU HAVE'; export TZ
Save the file (Ctrl + o, ENTER, Ctrl + x), log out and log in again. Your timezone is set.
Next, we will set the correct time and date. For this task, we will use "date" command:
(Example)
sudo date -s "Jun 1 20:27:00 2012"
The usage is obvious enough. The "-s" flag is used to set the date. Use first 3 characters of each month.
To see the date, use:
sudo date
Now, we wouldn't be able to maintain the correct time via hardware clock. (Unless you have modded your board.) So, we are going to rely on the Internet to sync the clock. Lets use NTP service.1) Install the package:
sudo apt-get install ntp
2) Edit the configuration file (if you want better accuracy):
sudo nano /etc/ntp.conf
Look for the following section:
server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.debian.pool.ntp.org iburst
Replace this section by a relevant section of the NTP server you want to use. For e.g. I live in Ireland - so I want a local NTP pool. I have added:
server 0.ie.pool.ntp.org
server 1.europe.pool.ntp.org
server 0.europe.pool.ntp.org
and saved the file.
Look here about which pools to use and how to add them:
http://www.pool.ntp.org/use.html
3) Restart the NTP service:
sudo service ntp restart
Or, if the above command gives you a warning, you can use the combination:
sudo service ntp stop
sudo service ntp start
4) Your NTP service should be set up now and should sync the clock from time to time. Now, if you want to test whether it actually works, run:
sudo ntpq -pn
and you should see something like that:

Note the asterisk (*) (you will probably notice it only after reboot). If you have it, it means that this IP address is being currently used to provide the time for syncing the clock. Initially after reboot, you might notice that the time is set wrong again, but it is only temporally. After few minutes, the clock will be synced. That's all in relation to time.
If your desktop clock (clock applet) shows wrong time, run "sudo date" command to update it.
Note: I know, this paragraph might not sound important, but please, don't skip it. The reason being is that a clock skew will be a source of many annoying problems; such as those warnings you get during "tar" extraction, warnings during kernel configuration, potential errors during compiling, loads of other problems... We don't want them, right ?

Some tweaks:

Turn off SWAP:
SWAP is a form of virtual memory, which is:
- Completely useless for Pandaboard, as SD I/O is hellishly slow !!!
So, check if you have it disabled:
free -m
which should give you this line:
Swap:            0          0          0
meaning swap is disabled. This is how it should be.
If it is not disabled, run this to switch it off:
sudo swapoff -a
which should do the job. That's all.

Disable Ethernet at boot (if it is not needed):
(Skip this section, if you have used option "c" in "Achiving auto-connection (with Wifi)" section)
With Ethernet enabled, what you get is a couple of "DHCPDISCOVER...." lines and about 0.5 - 1 minute of wasted time during boot. If you don't use Ethernet, why wasting time because of it ?
To disable it, edit /etc/network/interfaces file:
sudo nano /etc/network/interfaces
and comment in the following:
auto eth0
iface eth0 inet dhcp
so it will look like:
#auto eth0
#iface eth0 inet dhcp
save and exit. Done !

Disable screensaver in LXDE:
Screensaver is useless in our case. It is an extra load for CPU, as we do not have OpenGL drivers (and will probably never have). We would be able to install GLES / GLES2 drivers, but they are most likely not used by screensaver. So, lets disable it.
For LXDE:
Open /etc/xdg/lxsession/LXDE/autostart file:
sudo nano /etc/xdg/lxsession/LXDE/autostart
and remove "screensaver" line. Save and exit.

My comments about what I have so far: 

- The system is fast. Certainly much faster than Ubuntu. It boots quicker (edit: at least with original kernel) and is much more responsive.
- EDIT: But SD I/O is still slow :(
- The rootfs partition is Ext4 !
- Both USB keyboard and USB mouse work normally.
- Ethernet is working fine.
- WiFi is working. Firmware is installed.
- HDMI out works. With GUI, I get 640 x 480 picture at 60 Hz on my 720p HDMI TV (with default kernel). Fbdev driver is being used by default. Primitive, I know. But this is only temporary. Later, I will try to install GPU drivers. But first, I need to choose the right version of kernel and install it. (GPU drivers are heavily dependent on the version of the kernel you use.) Of course, you should be able to somehow change you resolution, by modifying your uEnv.txt file. Also, you can install the omapfb driver, which is for OMAP DSS (also uses NEON extension) - it doesn't use SGX though. The omapfb driver will be faster than fbdev driver.
- Sound doesn't work - no soundcard is found. We should be able to solve this ...
- I don't know whether Bluetooth works or not. However, according to some comments on http://www.chalk-elec.com/?p=1478 , it should work.
- Obviously no 2d/3d hardware acceleration yet. I will try to install the drivers ...EDIT: 2d/3d in progress ...
- No hardware video decoding yet. This will probably take a lot of time to set up ...
- Edit: Clock skew problem solved. Took a lot of time !
- A lot more to come. I will try to get as much working staff as I can on this awesome board !

Why did I choose Debian in the first place:

1 - Heard it was much faster than Ubuntu.
2 - Debian uses .deb packages, like Ubuntu, and also shares a lot in common with it. Installing packaged drivers should work ... Of course some changes will be needed.
Actually, after I have done a little bit of reading, I understood that: INSTALLING UBUNTU PACKAGES ON DEBIAN IS NOT A GOOD IDEA AND CAN CAUSE A LOT OF PROBLEMS LATER ON. So, I am going to build everything from source.
3 - I just wanted to see what is Debian like ! (I have already tried Ubuntu, Angstrom, YDL and Fedora.)

What's next ?

Lets build Ubuntu kernel ! This way, we would be able to install SGX drivers and hardware decoders/encoders.
http://alastordmcblog.blogspot.com/2012/05/debian-on-pandaboard-building-ubuntu.html





Tuesday 22 May 2012

Installing Ubuntu on Toshiba Satellite L755G

Intro:
- This is just my method - modify it as you like !

Purpose:
- To quickly install Ubuntu/Lubuntu/Kubuntu/etc on Toshiba Satellite L755G laptop

What do you need (or may need):
- Toshiba Satellite L755G laptop (I know - obvious)
- Ubuntu ISOs (Download links below.)
- Already installed OS + burning software. (My laptop had Windows 7 64-bit pre-installed and had, I think, 3 burning applications.)
- Blank CDs (A USB storage device may be used instead of optical disk, but I have never used such method - not going to explain. )
- Wired or wireless Internet connection is NOT necessary during installation, but is HIGHLY recommended.
- Maybe an hour or 2 of free time ?

Downloading Ubuntu ISOs:
- Ubuntu (the one with Unity desktop environment):
http://www.ubuntu.com/download/desktop
- Lubuntu (LXDE desktop):
http://lubuntu.net/
- Kubuntu (KDE)
http://www.kubuntu.org/getkubuntu/download
- Xubuntu (XFCE) (Didn't try this. Desktop - LiveCD.)
http://xubuntu.org/getxubuntu/
- Other flavors can be found here: http://www.ubuntu.com/project/about-ubuntu/derivatives
* I have used LiveCD ISOs. They are very good to show that your PC will actually run Ubuntu. Excellent way to test your Wifi also. The Wireless chip set is supported, by the way.
* Choose 64-bit, as we are using 64-bit AMD processor in our machine and we want to take advantage of 64-bit processing and more than 4 GB of RAM. (Of course, PAE - Physical Address Extension allows you to use up to 64 GB on 32-bit system. It is not the same as running on 64-bit though - https://help.ubuntu.com/community/EnablingPAE .)
* Choose 32-bit only if you have a reason for it. What is the point of missing 64-bit features otherwise ? One reason would be if 64-bit doesn't work for some reason. (Than again you can just switch ISOs.) A good reason is if you want to run some 32-bit applications which are linked to 32-bit libraries. (There are other ways to have 32-bit applications - https://help.ubuntu.com/community/32bit_and_64bit , but, honestly, this one is the easiest.) I wanted to have at least one 32-bit system to be able to run ePSXe without any problems. (ePSXe depends on some old 32-bit libraries.)
* Download with torrent client when possible

Making LiveCDs:
- Look here: https://help.ubuntu.com/community/BurningIsoHowto
- We just need to burn the ISO onto a blank CD in a specific way. Easy. One thing to remember though: You are burning the ISO using a special burning software. So, you DO NOT extract the ISO file and you DO NOT burn the ISO directly, like you burn movies.
- Windows 7 should have some burning applications pre-installed. You just need to: insert a blank CD, right-click the ISO and choose the burning application. The application should burn the ISO and verify the disk.
- On Win 7 you can use this guide: http://windows.microsoft.com/en-us/windows7/burn-a-cd-or-dvd-from-an-iso-file

So, how do we start our Ubuntu CD ?
- It is straightforward enough.
1) Boot into your default system (most likely Win 7), if you are not there already.
2) Insert the CD, if it is not inserted already. No need to run anything.
3) Restart - now, pay attention to what you see on the screen.
4) When you see TOSHIBA splash screen - press F12 button quickly. This will open the Boot Menu.
5) Most likely, the first option will be "HDD/SSD". We need the "ODD" (Optical Disk Drive) option. Using up/down keys choose this option and press ENTER:
(This is my Boot Menu. As you can see, I have put "ODD" as the 1st choice - makes more sense. If you use USB storage devices to install OSs - use USB. Later I will show how you can change the boot priority/sequence, i.e. what is booted first. But this is BIOS staff, not Linux.)
6) Then you will see black screen with some white characters, or something like that. After a while a Ubuntu splash image should appear (at least for LiveCD), showing that Ubuntu is loading ...

LiveCD has loaded - what is next ?

Ubuntu (with Unity)
1) You will be greeted with this screen in Ubuntu:

2) Choose "Try Ubuntu". (Why not "Install Ubuntu" you might ask ? Well, this way we can first connect to a wireless router for example and have connection. This will than allow us to download staff during installation.)
3) Wait while the system loads. This will take some time. After that you will see the Unity desktop. There should be a "Install Ubuntu XX.XX" icon.
4) You should first make sure that you are connected to the net. If not - connect now. Then, when you are ready, double-click the installation icon.
5) A window pops-up and you can choose your system language ... Well, the rest is more or less straightforward.Visit this page for instructions:
http://www.ubuntu.com/download/help/install-ubuntu-desktop

NOTE: For Ubuntu 12.04 LTS I didn't have to do anything extra to get it working. GUI (Graphical User Interface) started perfectly, which means either:
- The GPU (Radeon HD) was detected correctly and a certain open-source graphics driver started successfully, or
- the VESA (very simple driver - no 2d, 3d staff) loaded automatically.
6) After the system has been installed, it will ask you to restart. Press restart, remove the disk when it is ejected, close the tray and press ENTER to continue.
7) The system should boot up without any surprises.
8) Now, lets install the property ATI Catalyst driver to get 3d and 2d acceleration. Go to: System -> Administration -> Additional Drivers
9) Install the "ATI/AMD proprietary FGLRX graphics driver". (NOT the one with "post-release updates" !) The updated one will most likely fail to install/work. (Failed for me.)
10) Restart again. Now you should have 3d acceleration. To test that it is actually working, lets run "glxgears" command from the terminal. (Install it by running: "sudo apt-get install mesa-utils"). This is what I get:
11) Enjoy !


Lubuntu
1) In Lubuntu, you are will see the following:
2) Choose your language and press ENTER. You will see the following:

3) Don't press any of these yet ! Instead, press F6:
4) Now we can see some boot options. Press Esc. You will see the string of options. Remove the last 2 characters "--", change "splash" to "nosplash", change "quit" to "noquit" and, after that, add: "radeon.modeset=0 xforcevesa". So, the last 4 options will be:
noquit nosplash radeon.modeset=0 xforcevesa
5) "Try Lubuntu without installing" should be highlighted and the code should be shown as in the picture above. Press ENTER.
6) After a while a Lubuntu splash screen will be shown. Then, the LXDE desktop will appear. You will see the installation icon:
7) Double-click and the window will greet you. Choose language, etc ... Visit this page if you need help: https://help.ubuntu.com/community/Lubuntu/InstallingLubuntu
8) After the installation has finished, you will be prompted to restart the computer. The CD will be ejected, take it out, close the tray, press ENTER to continue the restart process.
9) As the system boots up, you will something you do not expect - black screen with white characters - no GUI (at least I got it with Lubuntu 12.04 LiveCD). Check whether you can type - if you can, follow next step. If you can not type, press the Ctrl + Alt + F1 combination. This will take you to Command Prompt.
10) At the command prompt, type your username, press ENTER, your password, ENTER. You must be connected to the Internet at the point. We need to download GPU drivers. Now we are ready to run some commands.
11) Type:
sudo apt-get install fglrx
press ENTER, type your password again, ENTER. The Apt program will then install the fglrx (Catalyst) driver for our ATI Radeon HD GPU. This will take few minutes or so:

12) After the fglrx driver has been installed, type and run the following code:
 sudo aticonfig --initial -f
This will provide the basic configuration for our video card.
13) Reboot:
sudo reboot
After the system has booted, you should be able to login normally (with GUI). Now you also have 3d acceleration !
14) To test that you have you 3d staff, just install "mesa-utils" package and run "glxgears" in the terminal window.
15) Enjoy !

Kubuntu
- Should work the same way as Lubuntu
- Didn't work fully for me, as it could not download fglrx drivers for some reason :(