Tuesday, April 9, 2013

Mele as a media server

Perfect media server

Your media (and general purpose) server should have:
  1. Torrent daemon
  2. samba share
  3. mysql + php + nginx
  4. software to queue, rename and organize your downloads (I'm using sickbeard+ couchpotato) 
  5. misc

Operative system

I'm choosing debian armhf, but feel free to try ubuntu arm or arch arm.
Follow either Guillaume's or Roman's instructions on how to install.


Torrent daemon

I chose to use transmission-daemon over deluge (and didn't try any other) because deluged + deluge-web was eating up to 30MB of ram, where as transmission-daemon uses 2MB of ram, and the Mele has only 512MB.


# apt-get install transmission-daemon
# service transmission-daemon stop
# vi /etc/transmission-daemon/settings.json

set rpc-whitelist-enabled to false
   "watch-dir": "/home/storage/torrentfiles",
   "watch-dir-enabled": true
at the end of the file if you want transmission to pick up the torrents placed in that folder (both couchpotato and sickbeard can do that)

# service transmission-daemon start

Log in to the default port The default password is transmission.
On the webui I set up a watch directory because sickbeard stores the torrent files there, and transmission loads them.

Samba share


#apt-get install samba-common-bin samba-common samba

Each samba share configuration is unique to the user, but I've set a share with read-write, anonymous access.
At the end of the /etc/samba/smb.cnf file add
  path = /path/to/share
  read only = no
  writeable = yes
  guest ok = yes

Mysql + php + nginx

#apt-get install nginx php5 php5-mysql php5-fpm mysql-server-5.5 mysql-client-5.5 php5-mysql

Mysql configuration

Remote access
I'm assuming  you used 'root' for your username.

mysql -u root
If you didn't set up a password
mysql> SET PASSWORD FOR 'ROOT'@'LOCALHOST' = PASSWORD('your_new_password');

To gain remote access with the username

mysql> exit

#vi /etc/mysql/my.cnf
comment out the line that says 
bind-address =
#service mysql restart

Optimize the ram usage of mysql


I chose nginx because of it's small memory footprint and high performance. Check benchmarks vs apache to see the difference.
#vi /etc/nginx/sites-available/default

A webserver's config changes totally, depending the needs of the host. Here's an example link

Couchpotato, SickBeard

#apt-get install git-core python2.7 python-cheetah
$ git clone git://github.com/RuudBurger/CouchPotato.git
$ git clone git://github.com/midgetspy/Sick-Beard.git

Follow on-screen intructions for both.


Here's the server running all the processes (no couchpotato)

Mount ntfs with write permission
#apt-get install ntfs-3g
#mount /dev/sd# /path/you/want


#echo '1110000' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq


use "1" to turn them on, you might need to run #insmod sun4i-gpio
power off blue led
echo "0" > /sys/devices/virtual/misc/sun4i-gpio/pin/ph20
power off red led

echo "0" > /sys/devices/virtual/misc/sun4i-gpio/pin/ph10

Thursday, February 21, 2013

Ubuntu and XBMC on the MELE

Been trying to set up the MELE as a media/home server and found guillaume's blog (http://guillaumeplayground.net)

Get the ubuntu 12.10 armhf image with the patched kernel from here  (MD5: 32e181589ac4232fdaac3e9f86546e87)

Decompress the image and dd it to your SD card.
Put it in the MELE, connect VGA/Ethernet and turn it on.
Default user/password is: root/root

To modify the video output, led flashing and MAC address, run PIMP_MY_MELE as root.
It's a perl script located on /usr/local/pimpmymele/

Sata module is not loaded by default.
To load it until reboot, run
modprobe sw_ahci_platform
or load it on boot with
echo "sw_ahci_platform" >> /etc/modules; reboot
Check your MELE speed
# grep BogoMIPS /proc/cpuinfo
BogoMIPS : 1001.88

If not:
rm -f /etc/rc2.d/*ondemand
echo "cpufreq-set -g performance" >> /etc/rc.local
cpufreq-set -g performance

This is dangerous. You've been warned. This will set your frequency at 1.15GHz and it will be off when you reboot (stress test to see if your MELE is stable; glxgears is useful)
echo '1152000' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
If you want to make this permanent run
echo "echo '1152000' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq" >> /etc/rc.local

Available frequencies are at /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequenciesConsider that you'll need overvoltage to pass 1.2GHz, and if you plug in an external HDD / sata HDD, the current might not be enough for the processor

This got me from 35.785 to 39.447 fps on GLXGears (~10% performance increase with a 15% OC)

Download the files (compiled from 
git://github.com/empatzero/xbmca10) and decompress them to / (yes, to root)

You can run these from X
or this from a TTY

Considering it runs on framebuffer, if you run it from SSH you'll see the cursor where it was; if you run it locally the cursor will go to the last row and it'll be unnoticeable

Before setting up XBMC on boot you should test audio and video; as well as automounting if you plan on using external disks or pendrives.

If you have dependecy problems launching xbmc 
apt-get install xbmc
You won't run the repo version, but some libraries/dependencies are not in the tar

Thursday, September 6, 2012

XBMC as launcher

Now that XBMC is useful as a media player for my MELE (see HW acceleration thread), I also use it as a launcher.

Basic instructions

Download the APK from here.
And if you want to use an external player, check the previous post.

Advanced instructions

Important: There's already a modified manifset file uploaded here

To make xbmc work as launcher and make it persistent (this means it doesn't close when you watch a movie,and it doesn't need to load everything again when you finish a movie) you have to modify the file: "$XBMC_FOLDER/tools/android/packaging/xbmc/bin/AndroidManifest.xml".

Inside the file you can find the "intent-filter" node, we need to add an Intent for the home action.
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.HOME" />

If you want to xbmc appear in the default launcher as an application, don't replace the line:
<category android:name="android.intent.category.LAUNCHER" />

If you replace LAUNCHER with DEFAULT the application won't be listed anywhere but in the "All" section of the Android application manager.

To make it persistent:
(WARNING this will make XBMC constantly consume resources, so if you have low memory everything will be slower, this doesn't seem to be the case with MELE, but if you are using emulators or other applications with high memory usage this may impact on the performance).

You need to modify the "Application" Node:
"<application android:icon="@drawable/ic_launcher" android:debuggable="true" android:label="@string/app_name" android:hasCode="true">"

add the option:

When this file was modified, the following file got modified also 
I believe you should also modify this file with the desired options.

After modifying the xml, you have to build the apk, and install it normally.

XBMC with external player [temporary solution for lack of HW acceleration]

You may know the XBMC project ("XBMC is an award-winning free and open source (GPL) software media player and entertainment hub for digital media."), it's awesome, open source and works very well.

But, for now, in android the hardware acceleration is not working.

inRivalz came up with a workaround to use an external player, which has working hardware acceleration, instead of the internal player.

This means using a closed-source alternative, for now.

Basic instructions

Download this apk.

Install it on your device, and modify the playercorefactory.xml (which, according to XBMC Wiki is in Android/data/org.xbmc.xbmc/files/.xbmc/userdata/)

<player name="MPC-HC" type="ExternalPlayer" audio="false" video="true">
<rules action="prepend">
<rule video="true" player="MPC-HC"/>

Replace the bold part with either for the corresponding version of the MXPlayer you have installed.
com.mxtech.videoplayer.pro - Pro Edition.
com.mxtech.videoplayer.ad - Free Edition.

Advanced instructions:

Download the source from XBMC Git: Instructions
Apply this patch Link, but replace "StartActivityWithExtra" with this
// External Player
bool CXBMCApp::StartActivityWithExtra(const string &package,const string &path)
if (!m_activity || !package.size())
return false;
jthrowable exc;
JNIEnv *env = NULL;
jobject oActivity = m_activity->clazz;
jclass cActivity = env->GetObjectClass(oActivity);

// Intent oIntent = new Intent(Intent.ACTION_VIEW);
jclass cIntent = env->FindClass("android/content/Intent");
jmethodID midIntentCtor = env->GetMethodID(cIntent, "<init>", "(Ljava/lang/String;)V");
jstring sIntentView = env->NewStringUTF("android.intent.action.VIEW"); // Intent.ACTION_VIEW
jobject oIntent = env->NewObject(cIntent, midIntentCtor, sIntentView);
// Uri oUri = Uri.parse(sPath);
jclass cUri = env->FindClass("android/net/Uri");
jmethodID midUriParse = env->GetStaticMethodID(cUri, "parse", "(Ljava/lang/String;)Landroid/net/Uri;");
jstring sPath = env->NewStringUTF(path.c_str());
jobject oUri = env->CallStaticObjectMethod(cUri, midUriParse, sPath);
// oIntent.setDataAndType(oUri, "video/*");
jmethodID midIntentSetDataAndType = env->GetMethodID(cIntent, "setDataAndType", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;");
jstring sMimeType = NULL;
sMimeType = env->NewStringUTF("video/*");
oIntent = env->CallObjectMethod(oIntent, midIntentSetDataAndType, oUri, sMimeType);
// oIntent.setPackage(sPackage);
jstring sPackage = env->NewStringUTF(package.c_str());
jmethodID mSetPackage = env->GetMethodID(cIntent, "setPackage", "(Ljava/lang/String;)Landroid/content/Intent;");
oIntent = env->CallObjectMethod(oIntent, mSetPackage, sPackage);

// startActivity(oIntent);
jmethodID mStartActivity = env->GetMethodID(cActivity, "startActivity", "(Landroid/content/Intent;)V");
env->CallVoidMethod(oActivity, mStartActivity, oIntent);
exc = env->ExceptionOccurred();
if (exc)
CLog::Log(LOGERROR, "CXBMCApp::StartActivity Failed to load %s. Exception follows:", package.c_str());
return false;
return true;
// End External Player
The issue with the original code was the method "getLaunchIntentForPackage". This finds the first intent action for the package. The MX Player has both, MAIN and VIEW, but "getLaunchIntentForPackage" only finds the MAIN intent, and for this reason it doesn't work.

Build the source and install it on your device, and modify the playercorefactory.xml (which, according to XBMC Wiki is in Android/data/org.xbmc.xbmc/files/.xbmc/userdata/)

<player name="MPC-HC" type="ExternalPlayer" audio="false" video="true">
<rules action="prepend">
<rule video="true" player="MPC-HC"/>

Replace the bold part with either for the corresponding version of the MXPlayer you have installed.

com.mxtech.videoplayer.pro - Pro Edition.
com.mxtech.videoplayer.ad - Free Edition.

Wednesday, August 22, 2012

Random MELE Tweaks

Set FileSystem writable
mount -o rw,remount /system

Set FileSystem readable-only
mount -o r,remount /system

Remove infrared capabilities
rmmod sun4i_ir

Power off blue led
echo '0' > /sys/devices/platform/gpio_sw.1/gpio_sw/PH20/data

Power On blue led
echo '1' > /sys/devices/platform/gpio_sw.1/gpio_sw/PH20/data

Power On red led
echo '1' > /sys/devices/platform/gpio_sw.0/gpio_sw/PH10/data

Power off red led
echo '0' > /sys/devices/platform/gpio_sw.0/gpio_sw/PH10/data

This has to be done every time you reboot.

Disable most System apps
  1. Place sh on MELE [link].
  2. navigate to folder.
  3. sh systemapps.sh
  4. follow instructions
Enable adb via TCP:
setprop service.adb.tcp.port 5555
stop adbd
start adbd
ifconfig eth0

Download SuperCharger V6 Script

Tuesday, August 21, 2012

ICS [Stock] and CM9/AOKP ICS for MELE A1000


  1. Official MELE files:
    1. Official 4.0 V1
    2. Official 4.0 V1.1
    3. Phoenix card software for Windows 7
    4. Phoenix card software for Windows XP
  2. CM9/AOKP files
    1. Recovery file
    2. Mele 1.0.8 Legacy file
    3. Gapps signed
    4. AOKP
    5. CM9
    6. ADB Recovery files

Installation process for MELE Files:
  1. Flash the desired image with the corresponding PhoenixCard version to an SD card.
  2. Turn off MELE
  3. Place SD inside of MELE
  4. Turn on MELE
  5. Wait for it to stop flashing red and blue lights
  6. Remove SD card
  7. Turn on MELE
The problem is that the xpad module is not supported with the original ICS files, which means no Xbox controller but CM9 and AOKP support xpad.

In order to flash CM9 or AOKP:
  1. Turn on MELE
  2. Connect to Ethernet.
  3. In the ADB Recovery files
    1. Run HDMI or VGA scripts according to your setup(CWM will use this output).
    2. Edit the script.fex MAC address for yours.
    3. Run edit bootload.bat
  4. Copy the following files to the SD
    1. Recovery.img
    2. CM9 or AOKP, your choice
    3. Google apps
    4. Mele legacy file
  5. Execute install-recovery.bat <mele ip address>, this will make MELE reboot in recovery mode.
  6. During recovery mode
    1. Wipe cache
    2. Wipe data
    3. Flash CM9/AOKP
    4. Flash Google Apps
    5. Flash Legacy File
    6. Go to advanced -> Fix permissions
    7. Reboot.
If something goes wrong during the flash process, MELE won't give video at all or it will get stuck in a bootloop. Just flash original 4.0 image and proceed to flash CM9/AOKP again.

CM9/AOKP won't work if you flash 4.0 V1.1, you have to be on 4.0 V1.0
The boot image comes pre-rooted.

Based on Naismith's (Slatedroid) tutorial

Friday, August 17, 2012

XBOX 360 controller support in 3.0.8 kernel

The XBOX 360 controller doesn't work in my MELE (Kernel 3.0.8) because the kernel modules needed to support it [ ff-memless, xpad ] , are disabled by default in our kernel.

Download the ARM kernel
git clone git://github.com/amery/linux-allwinner/tree/lichee-3.0.8-sun4i
Install the necessary libraries / binaries
apt-get install gcc-4.4-arm-linux-gnueabi build-essential u-boot-tools (if u-boot-tools not found, try uboot-mkimage)

# make clean
# make -j4 ARCH=arm CROSS_COMPILE=/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi- xconfig

Check(Press 'M') the following modules:
Input device support -> Support for memoryless force-feedback device
Input device support -> Joystick / gamepad
Input device support -> Joystick / gamepad -> X-box gamepad

Compile the modules
# make -j4 ARCH=arm CROSS_COMPILE=/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-

If you get "arm-linux-gnueabi-gcc" not found, run:
sudo ln -s /usr/bin/arm-linux-gnueabi-gcc-*version* /usr/bin/arm-linux-gnueabi-gcc

That should give you the xpad.ko in the drivers/input/joystick file.

Move it to the MELE, then run

insmod xpad.ko

Alternatively, if you don't want to compile the kernel use this module.
xpad.ko module
download it, copy it to the MELE and then run

insmod xpad.ko