Search This Blog

Configuring zRAM on the Sony Xperia Play with FreeXperia Zeus

If you have unlocked your Xperia Play and installed FreeXperia (+CyanogenMod  9.1) then you will quickly discover that enabling zRAM via the Performance settings has no effect whatsoever.





















I have reported this as a bug but the project team seem more interested in burying their head in the sand so you won't get any help at all from them. I even asked for help on the +FreeXperia +Google+ page but I gave up on asking for any help from anyone there a long time ago.

The provided Linux kernel definitely does have zRAM enabled.

# ll /dev/block/zram*
brw-------    1 root         root          253,   0 Sep 10 13:10 /dev/block/zram0

The problem lies within the UI to configure it. No scripts seem to be created or executed so either the option is a stub or it is simply broken.

Initially I decided to use SetXperia which, again, proves that the kernel part is fine, but SetXperia remains in RAM all the time, and even in the notification area. I just don't see the point in that.

It can't be that difficult to enable zRAM, right?

Using the Ubuntu zram-config package it was fairly easy to work out what was needed and hence create a script.

#!/system/bin/sh

SWAPPINESS="35"
TAG="zram-config"

log -p i -t $TAG "Setting vm.swappiness to $SWAPPINESS"
logwrapper sysctl -w vm.swappiness=$SWAPPINESS
log -p i -t $TAG "Done."

log -p i -t $TAG "Setting up zram"
echo 75497472 > /sys/block/zram0/disksize
logwrapper mkswap /dev/block/zram0
logwrapper swapon /dev/block/zram0
log -p i -t $TAG "Done."

log -p i -t $TAG "All done."

I dropped this script into /data/local/userinit.d/zram-config (remember to set +x on the script).

All the log and logwrapper stuff is obviously to send details to the log. It probably doesn't work as the script is run before Android is loaded. Indeed, I've never seen anything using logcat unless it's run manually. They are not needed for the script to work.

vm.swappiness is set to 60 by default. You shouldn't change that unless you know what you're doing. In my case sysctl -w vm.swappiness=35 does this. I could not find a config file for sysctl (such as /etc/sysctl.conf) as is the case for most Linux distributions.

The Ubuntu script sets up the amount of zRAM based on the amount of RAM and creates separate devices based on the number of cores, which makes sense because it's a generic script to be used on a vast array of machines including, recently, mobile platforms. There's no real need to do that unless you plan on dropping the script on a variety of different devices. You should decide for yourself how much zRAM you want to configure.

echo 75497472 > /sys/block/zram0/disksize sets my zRAM device to 75 MB.

mkswap /dev/block/zram0 sets up the device as a swap device, as you would with any normal swap.

swapon /dev/block/zram0 enables the swap.

This can, of course, be used with any device that has zRAM enabled in the kernel.

# uname -a
Linux localhost 2.6.32.9-FXP #1 PREEMPT Fri Apr 19 17:37:58 EEST 2013 armv7l GNU/Linux

I recommend installing ZRAM Status from the Play Store so that you can see that your zRAM is being used, along with some interesting, nerdy statistics.




Remember that you will need to reboot your device (or run the script manually) to enable zRAM the first time.

Start the Android media scanner from the command line

If you're like me, and let's hope for your sake that you're not, you find it much easier to run an SSH server on your Android device than using something like adb or USB Mass Storage or any of the other crap out there.

With SSH I can simply and easily check logcat, netstat, issue commands, copy files and generally bugger about.

Sometimes you have moved quite a lot of files around and you need your media scanner to launch to update its database. This can be done via the CLI.

Putting Windows XP to sleep remotely

Have you noticed that when connected to Windows XP via RDP that the Start Menu option for putting the machine to sleep vanishes? What the Hell is that all about?

It doesn't even make sense when you can wake the machine with Wake-on-LAN to reconnect if you need to. Saving energy not really a priority here.

To make things worse the Task Manager's menus have Standby and Hibernate disabled too.

You could mess about installing VNC, but why bother? Turns out the solution is incredibly easy!

Open a command prompt and enter:

 C:\> rundll32 powrprof.dll,SetSuspendState

That's it! The computer will enter Suspend.

If you're looking to hibernate the machine instead then:

 C:\> rundll32 powrprof.dll,SetSuspendState Hibernate

Job's a good un.

Now go install Linux.

.nomedia is recursive on Android devices

Just a small note but I thought I best mention it as not everyone realises this.

Your /sdcard can often have a lot of garbage in it that you do not necessarily want to appear in your Media Album.

A solution to this is to add .nomedia (a zero byte file) to the directories that you do not want the Media Scanner to scan. What you need to be aware of is that the Media Scanner will skip this whole directory and will not recurse into subfolders. The result being if you drop the file /sdcard/.nomedia then nothing on the SD card will be scanned nor added to the Media Library.

If you're one of those people who drops everything on /sdcard then you need to tidy it up a bit. /sdcard/downloads for example is nearly always the best place to drop your downloads, and you rarely want that stuff scanned. If you do then create new directories:

/sdcard/Music
/sdcard/Movies
/sdcard/Porn

for example.

This way you can simply touch /sdcard/Porn/.nomedia so that it doesn't appear in your Media Album.

Installing gcc on OpenIndiana

This shouldn't have been such a difficult task, but it has taken me four days (on and off) to work it out.

Problem: Install gcc on OpenIndiana
Pain level: 8/10
Solution: Simple!

I Googled around a huge amount and all the articles I found were utterly useless. They suggested that once gcc is installed that is should be in /usr/sfw/bin, and the reason a configure script cannot find it is because /usr/sfw/bin is not in the $PATH by default.

Well, doing a pkg search gcc reveals a load of different packages, which is quite nice - it's always nice to have a choice, but after installing a bunch of them it didn't seem to make any difference. To be honest I have no idea what files have actually been added to my system, and I haven't yet worked out how to get the file list (yes, I'm a Solaris n00b).

Anyway: easy, really: pkg install SUNWgcc

And that's it! Solved! You don't even need to update your path. Marvellousfish.

$ uname -a
SunOS openindianaVM 5.11 oi_151a7 i86pc i386 i86pc Solaris

Thanks: http://hashbang0.com/2008/05/19/installing-gcc-on-opensolaris/

It should be noted that SUNWgcc has problems with .visible, but the gcc package cannot find it's own dependencies! (Binaries in /opt/gcc/4.4.4/bin). Buyer beware!

YouTube does NOT listen to copyright claims

Last year I wrote about how YouTube does listen to copyright claims.

After writing that I realised that YouTube, in fact, don't even get involved. Their Content ID system finds a match, and a copyright claim is automatically triggered by the system on behalf of whoever claims to own the copyright, even when they don't.

The result being that they then start receiving revenue for your video.

Now, if you're idiotic enough to steal another person's copyrighted material then that's your tough luck, but if the person making the claim in the first place has no claim at all then they're effectively stealing from you, and that is a criminal offence.

BT SmartTalk

I have previously written about how impressed I am by BT's roll out of their 21CN network. I never thought for a second they could impress me even further but they have! I do believe this now makes me a BT fanboi, but I'm cool with that because I'll be an adult soon.

Whilst messing around on the Internet and checking my telephone usage I stumbled across BT SmartTalk. SmartTalk is not new technology. It is basically a VoIP service operated by BT where your calls are routed over the Internet and you are billed to your BT bill. This means you can bill your landline at landline rates, and not have to pay the ridiculous charges mobile operators get away with (such as charging for 0800, higher charges for 0844, 0845, etc.) and even call back to the UK at UK standard call rates so long as you have an Internet connection. And it's free!

In Australia and want to call home? Got a plan that gives you free calls to landlines? It won't cost a penny!

Dropbear SSH server on Android

It's safe to say that if you're reading this then you know why one would want an SSH server running on your Android device. Personally I have SSH running on all my Linux boxes because it makes life so much easier, and I'm sure I do not need to explain why. Having an SSH server start on boot is simply a lot more convenient!

There are a number of apps on the Android market but most of them are utterly useless with one exception: SSHDroid.

If you are likely to use SSH once in a while then it may be easier for you to just install SSHDroid on your device and start it when needed, and I have been happy with it for a while.

However:
  1. It's an ugly app that sits in your notification tray once it has been started and uses up RAM and CPU. I want a background app.
  2. SSHDroid refuses to run if it cannot access adverts unless you pay for it. I block all adverts because they get on my nerves.
  3. All it does is drop a copy of Dropbear anyway, so you may as well do that yourself.
  4. Dropbear will happily run in the background and uses tiny amounts of CPU when active, so you can imagine how little it does when idle.
  5. If you can compile Dropbear yourself you can choose the options that you want.
As I'm sure you are aware there is no package delivery system for this kind of application in Android, but Android runs on a modified Linux kernel - this makes things so much easier! The result being that the following process is ridiculously easy assuming that your OS has:
  • su or sudo (root)
  • init.d support (or another way to run scripts at startup)
The only problem, really, is that the filesystem and methods used in Android aren't exactly standard compared to other *nix systems, but its not massively different. The result being that there are a number of ways that you can get things to work, so I'll simply show you what I have done. If I was doing this to a number of devices or in a corporate environment then I would use a bit more planning.

YouTube is utterly broken

Google have recently made a whole bunch of changes across most of their platforms to, apparently, integrate more easily with Google+. One of the platforms affected is YouTube. But YouTube also decided to introduce a new video format at the same time, namely 140p (around 32kbps, presumably for dial-up users).

At the exact same time my ISP, O2, sold their broadband network to Sky, more's the pity. I have been informed that there should have been no changes to my ISP in any way... yet.

If that is the case then YouTube is definitely broken.

Nuisance 1
Connection: Ethernet --> ADSL2+

The first problem which became apparent was that the Wii client couldn't play videos any more, or not for more than a few seconds anyway. When it did play it would randomly stop to buffer only a few seconds at a time, and sometimes give up altogether and exit the video. I am not alone:
YouTube on Wii keeps buffering. It won't load more than 30 seconds of video.

Nuisance 2
Connection: Any

The second problem was on the trusty browser. In my case Chromium on Ubuntu 12.04.

I seem to have been volunteered to join the HTML5 trial, which I really didn't mind except that it doesn't bloody work.



The video above is Big Buck Bunny downloaded in H264 format at 1080p. It refuses to play in the HTML5 player. To be fair this has only been uploaded a few hours ago and may need time to prepare/transcode/whatever, but as a general rule the HTML5 player fails on videos a LOT.

Switching back to Flash for affected videos can still give the same message, but continually hitting refresh tends to get the damned thing working.

Nuisance 3
Connection: Any

Another problem is that the video will play for a few seconds, usually the magic number of 19 seconds, and then stop, never to continue. Hitting refresh a number of times is required for this to start working too. See the video in Nuisance 4 for an example of this.

Nuisance 4
Connection: Wi-Fi --> ADSL2+

With my 3Mbps down connection I have been able to play 720p YouTube videos for quite a while. If someone else is on the network then it would happily drop down to 480p and play nicely. Not any more!

For reasons unknown the quality jumps up and down, preferentially towards the new 144p format. This is simply ridiculous! At 144p some videos are nothing more than a jumble of pixels. I have deliberately chosen a picture slideshow to show this as quality should be easy to maintain (very little motion). The video is 1080p.



This video shows a typical example of what happens (approximate times):

0:00 "An error occurred, please try again".
0:27 480p
0:37 Video stops altogether as the download stream fails and there is not enough video buffered.
0:45 144p
0:55 480p
1:13 240p
1:45 360p
2:20 144p

Perhaps the ISP or the connection to the router is the problem? Well, I tested this by downloading Big Buck Bunny. This was over Wi-Fi. Caution: this is a very dull video.



tldw; The video basically shows a number of drops in download speed. If I was sensible I would compare this to a wired connection but I don't feel there is any point: the drop-outs are minimal and very short lived. The download (of Big Buck Bunny) is not affected. I also have no other problems with connection on this computer ever. I feel fairly safe to conclude that the signal is not the problem and given that YouTube is supposed to buffer to avoid these problems, that this is not the cause. Uploading is a very similar story. In this instance it's an upload to YouTube of Big Buck Bunny. An equally dull video.

Reported.

Nuisance 5
Connection: Wi-Fi --> Any

On mobile, the video usually plays quite well, but recently has decided to simply pause for no reason. Hitting play will start it up again but... Nuisance 6.

Not tested over a mobile network yet but I cannot imagine it makes a difference.

Reported.

Nuisance 6
Connection: Any

On both mobile and web the video should buffer. It doesn't really matter if it does, however. Once paused, either intentionally or because the mobile just felt like it, the video continues to buffer. When clicking play the entire buffer is lost and the video starts downloading again. What the Hell is the point in the video buffering if it's just going to dump the buffer anyway? A wonderful waste of bandwidth.

Pausing used to be useful if I wanted to buffer a whole video in 1080p and watch it in this higher quality. Now it is simply impossible!

The Android app has a solution: pre-loading. Add the video to "Watch later" and it will download the whole video. Annoyingly if you don't watch every video you have pre-loaded immediately then there is a notification on the phone "reminding" you that you have pre-loading enabled and you're not watching the videos. P.I.T.A.

Nuisance 7
Connection: Ethernet --> Powerline --> Ethernet --> ADSL2+

This has never worked. I have a Philips Blu-ray player which comes with a YouTube app (probably Java).

The problem being that the bloody stupid thing makes no attempt to discover the maximum download speed. This means that it will play at the highest quality, no matter what it is. At 3 Mbps my connection cannot handle 1080p (or in some cases 720p) and so continually stops, buffers a BIT (pausing is no use) and then goes through the process again. There is no solution. Even using the Android app the quality cannot be amended.



I thought this app may be maintained by Philips, but it has the same layout as other T.V. apps for YouTube so I don't know who maintains the code. Either way it's cack.

Reported.

Nuisance 8
Connection: Ethernet --> Powerline --> Ethernet --> ADSL2+

Same equipment as above. The Wii works fine using the Android app as a remote control. On the Blu-ray player it often does whatever the Hell it likes. It nearly always starts the video twice, sometimes three times, and often randomly switches the video. Sometimes it plays a video I played a while ago because it seems to have created a play list and decides to play that from the beginning. The whole thing is just garbage! The responsiveness is generally poor on the YouTube app on this Blu-ray player anyway. The Blu-ray player itself seems underpowered but it plays all kinds of HD files without any problem.

(The Picasa app cannot handle video at all, but makes no attempt to filter them.)

I'm sure there are more but I think I've said enough for now.

YouTube is utterly broken!
VigLink badge My profile on StackExchange