2014-05-10

Let's run (chrooted) Debian Wheezy on LG Optimus Prime 4X HD (P880)

I have been struggling quite a bit to find a lightweight ROM for my phone, but now that I have finally settled down I believe it's time to start playing for real with this smartphone.

This is one of the official pictures provided by vendor, probably photoshopped. Gotta love those glares! Imagine this: you are going to pay extra $$$ to have good photos made for your nice shiny new product, and then you photoshop them to add glare. Wonderful times we live in :)

My experiment will be to have a running Debian Wheezy 7 inside my Android, and I will use this article as basis; I had some issues with those instructions, thus I created this updated post. I know there is the nice Lil'Debi out there, but that would spoil most of the fun :)

In order to build this Debian I am giving up a 4GB external microSD card that is plugged in my phone already, so first thing unmount it by going to Settings -> Storage:


Make a backup before continuing because we are going to completely replace its content.

So, let's recap the needed ingredients:
- a rooted Android phone, I am using LG Optimus Prime 4x HD
- an external microSD card, minimum 2GB
- debootstrap command on your Linux system (it's available almost everywhere)
- adb & your phone's USB configured to receive adb commands

Ready to go!
Let's build a tarball of the base Debian system for our target architecture. I have added my scripts (from this gist) to ease setup, but I advise you go through each of them at least for learning purposes.

debootstrap --arch armel --foreign wheezy wheezy http://http.debian.net/debian/
cd wheezy
wget https://gist.github.com/neagix/bbfed4f91f8821bed7e7/download -O gist.tgz
tar xf gist.tgz
mv gist*/* root/
rm -r gist.tgz gist*
chmod +x root/*.sh
sudo tar cf ../debian-wheezy-armel.tgz .
cd ..

At this point upload the archive to your P880 and let's start hacking our way through Android.
We will individuate our external SD by excluding the internal block device marked for boot. This is a hack, so always double-check results before wiping out the block device.

sudo adb push debian-wheezy-armel.tgz /data/local/
sudo adb shell
su
cd /dev/block/vold/
for D in `ls`; do fdisk -l $D | grep ^`echo $D | awk '{ print substr($1, 1, 3) }'`; done | grep '*' | awk '{ print substr($1, 1, length($1)-2) }' > /data/local/boot-device.txt
clear && echo -e "**********************\nThe individuated device of your external SD is: $PWD/`ls | grep -v $(</data/local/boot-device.txt )`\nPlease double check with output of fdisk -l before proceeding!!!\n**********************\n" && rm /data/local/boot-device.txt

(commands in blue are run in the adb shell, available also as gist here)
Example output you will see:
**********************
The individuated device of your external SD is: /dev/block/vold/179:49
Please double check with output of fdisk -l before proceeding!!!
**********************
Remember to double-check for correctness with fdisk, then take note of the individuated device. On my P880 it is:
/dev/block/vold/179:49
Now we will format the external SD, use the default mountpoint /storage/sdcard1 and extract the Debian base system on the external SD. The mount command will allow mounting the SD with dev and exec permissions, which are necessary for our Debian chroot to work.

NOTE: do not copy/paste these commands but run them one by one, so that you can take action in case of errors.

On the adb shell (replace device in bold with what you got from above, and remember to escape the ':'):

mkfs.ext2 -L AndyWheezy /dev/block/vold/179\:XXX
mount -o rw,noatime,nodiratime,user_xattr,acl,barrier=0,data=ordered,noauto_da_alloc -t ext4 /dev/block/vold/179\:XXX /storage/sdcard1/
cd /storage/sdcard1

mkdir rootfs && cd rootfs && tar xf /data/local/debian-wheezy-armel.tgz

Once this operation is complete successfully, you are half-way :) Feel free to remove the archive with:
rm /data/local/debian-wheezy-armel.tgz

Now let's enter the chroot environment with:
busybox chroot /storage/sdcard1/rootfs /bin/bash

Thanks to the correct permissions on our external SD, you now have the wonderful and powerful bash prompt available at your fingers' range.
I have no name!@localhost:/#
In our new chroot, run these commands (these are safer to copy/paste):
export PATH=/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
export USER=root
mkdir /dev/pts
mount -t devpts devpts /dev/pts
mount -t proc proc /proc
mount -t sysfs sysfs /sys
/debootstrap/debootstrap --second-stage 

The last one will complete the debootstrap process, and will take some time (about 10 minutes for me).

Once it's complete you are basically done with the preparation of the Debian chroot :)

Now let's put the mount/umount scripts outside the chroot, so that you can easily call them in an Android shell:

mkdir /data/local/debian
mv /storage/sdcard1/rootfs/root/*.sh /data/local/debian/

From now on you can mount/umount your Debian chroot by calling one of these:

/data/local/debian/mount.sh # OR
/data/local/debian/umount.sh

Tips:
- set hostname in chroot: hostname AndyWheezy && hostname > /etc/hostname
- set APT sources in /etc/apt/sources.list (in chroot: mv /root/sources.list /etc/apt/)
- install an SSH server
- set your root password or better use certificates for remote login
- automate chroot setup/teardown with some scripts and use gscript to start them, for example: su -c '/data/local/debian/run.sh /storage/sdcard1 /etc/init.d/ssh start'


Here you see Debian Wheezy on all its glory, running from within a P880 Android device


Enjoy experimenting!

2013-10-13

odroid-wheezy-retro 0.8.2 released: kernel 3.8 and updates

With this release I am proud to announce that 3.8.11 is stable enough for our retro-gaming purposes, thus it has been integrated in my retro image.


 
  • now using hardkernel official 3.8.13.10 linux kernel
  • fixed support of Hardkernel upgrade script
  • added MFC firmware (s5p-mfc.fw)
  • supports XBMC (not included)
  • most recent Debian 7.1 packages
  • default partition size is now 2G
  • most recent RetroArch + cores
  • fixed bug with network at 1st boot

2013-09-08

Let's play X-COM on the ODROID U2

One of the classic games I always dreamt to play again (on bigger screens, with huge blocky pixels) is the original X-COM: Enemy Unknown (a.k.a. Ufo Defense).


Not many of them survived every time I played this game


Spoiler: Enemy Unknown works fine on our beloved U2s thanks to OpenXcom :)

I will explain here how to get it running in a few steps. You will need some patience and the original X-COM 1 game. See also OpenXcom's README.

Installing yaml 0.5 packages


You will need slightly more recent yaml packages than those provided with Debian Wheezy.

wget http://ftp.debian.org/debian/pool/main/y/yaml-cpp/libyaml-cpp-dev_0.5.1-1_armhf.deb
wget http://ftp.debian.org/debian/pool/main/y/yaml-cpp/libyaml-cpp0.5_0.5.1-1_armhf.deb

sudo dpkg -i libyaml*.deb

Compiling the sources


git clone https://github.com/SupSuper/OpenXcom.git --depth=0 
cd OpenXcom
mkdir -p buildcd build
cmake ..
CFLAGS="-marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard" \
CXXFLAGS="-marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard" \
ASFLAGS="-marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard" \
make -j5

mv bin/data ~/.local/share/openxcom/data
## customize target of link with your favourite binaries location
ln -s $PWD/bin/openxcom /usr/local/bin/openxcom


At this point, if everything went fine, you have almost finished.


Using the original game


Run the game by providing the original game's directory:

SDL_AUDIODRIVER=alsa /usr/local/bin/openxcom -data /path/to/XcomEnemyUnknown/


NOTE: The prefixed SDL_AUDIODRIVER variable is needed to force usage of ALSA, since I get garbled sound with pulse. If you don't have pulse installed then it's safe to assume that you won't need this environment variable

Game options

From options, select full screen and change resolution to 1280x720 for best gaming experience.

Enjoy it! :)

2013-09-07

Postfix, virtual mailboxes and aliases: priority matters

Sometimes - either for work or leisure - I need to configure Linux servers, and also mail servers.

The '90s lovely logo of Postfix

postfix is a great software that I like to use for mailservers; in this post I want to describe you one feature that works in a counter-intuitive way.

In postfix you can define mailboxes by specifying in your /etc/postfix/main.cf:

virtual_mailbox_maps = hash:/etc/postfix/virtual_mailbox_maps

Official virtual MAILBOX example here

You can also specify aliases, e.g. mailboxes that directly forward to other mailboxes, by specifying:

virtual_alias_maps = hash:/etc/postfix/virtual_alias_maps

Official virtual ALIAS example here
Aliases are useful for example when you want to define a catch-all alias forwarding all mail to the postmaster address.

Priority matters!

However, what I dislike is the priority applied to both: aliases have higher priority than mailbox maps (yes, you've read right).

The first time I configured an alias I got all mail delivered to the catch-all address because I thought that - being less catchy - the catch-all addresses would have less priority.

What you need to do is instead add identity definitions to the aliases map, this way:

john@example.com   john@example.com
mary@example.com   mary@example.com
berry@example.com  berry@example.com
@example.com       postmaster@example.com

In above example of virtual_alias_maps, the last line is the catch-all line, while the other lines are inherent to mailbox maps defined in virtual_mailbox_maps.

Now tell me if that's not counter-intuitive, error-prone (because of the duplication) and less easy to mantain.

2013-09-01

The state of hardware acceleration on ODROID U2: 3rd round

There has been fermentation and progress regarding the ongoing 3.8 issues (performance degradation, FIMC/FMC), today I have tested the 3.8 hardkernel linux tree, added some missing patches and could finally complete my benchmarks.

Kernel X11 Driver Resolution glxgears es2gears glmark2-es2 glmark2-es2 --fullscreen
3.0.90 ARM mali 720p ~ 140 fps ~ 599 fps 142 81
3.0.90 ssvb sunxi 720p ~ 144 fps ~ 620 fps 156 91
3.8.13.7 ARM mali 720p ~ 139 fps ~ 659 fps 143 81
3.8.13.7 ssvb sunxi 720p ~ 144 fps ~ 447 fps 87 48

You can compare these tests with the 2nd round of my benchmarks: did you notice the difference? :)




Yes, the performance degradation bug is fixed. Many thanks to ovversun, memeka and mdrjr for all their work and tests!

2013-07-28

Why eBay should disappear tomorrow

I have been using (or better: being affected by...) eBay for almost a decade now. What is my opinion?

It's the worst corporate-blind company in the world, not caring a dime about its customers and enjoying a de facto monopoly as much as they can.
Image courtesy of http://whyebaysucks.info/

This is the list of complaints I have for eBay:
  • crappy user interface that didn't change in the last years, no improvement, no nothing. If the cash cow is milking well, why change anything, right?
  • you cannot change the user interface language and it must be the same language of the nation you have a living address in. Microsoft has the same habit. The message I perceive is: we don't care about you people moving across country borders. How you dare!
  • The HTML editor is...horrible
  • if you save your item as a draft, and then save another item as a draft..*puff!* your previous item is gone. No warning, no nothing.
  • where are our well paid government officials when it's about antitrust? By buying PayPal they created the best monopoly ever, and basically you are forced to use it when using eBay. There are little to zero alternatives, and using others you loose all the "protected customer" rights
  • account verification is a joke. It has a lot of glitches, it keeps looping in a stupid sequence of 3 forms if you haven't yet verified your account from PayPal. So cheap for such a big company, and the problem has been there at least 5 years already!
  • it doesn't matter if your item is conform to description. If the buyer complains, he will get the money back. You are on the weak side by selling on eBay.
  • if you want to sell abroad, eBay will show you that you need 10 feedback comments and 90 days must have elapsed after last sale. But only after you completed the insertion, just to make it more fun for you.
 There are no sound alternatives that I know of, but I seriously hope that they will come to light...this online "service" already smells very bad these days.

2013-07-16

odroid-wheezy-retro 0.8.1 released: ALL RetroArch cores & fixes

A new release!

  • compiled RetroArch with NEON-optimized sound resampler (thanks to Squarepusher)
  • enabled page flipping (DRI2_PAGE_FLIP) for smoother RetroArch experience
  • added vim and missing packages for eduke32 and RetroArch-Phoenix
  • removed modelviewer core, added all RetroArch cores
  • added ~/libretro-super
  • enabled all joystick drivers in kernel