sábado, 19 de mayo de 2012

Rooting my Android device for the first time

I'm getting ready for the next cyanogenmod stable release, so today I started by rooting my device (a ZTE Blade Gen 2) and then installing clockmod recovery, being a newbie on this made me notice a few items missing on the docs, let's go over them...
First thing was to install the Android SDK to be able to run adb, I only had to install openjdk-6-jdk for this, I followed Cyanogenmod's guide and what it didn't say there is that adb doesn't come on the starter package anymore, you have to run android on the tools directory and there select to install the android sdk platform-tools, that way you'll end up with adb on the platform-tools directory.
Of course that to be able to run adb's ELF 32-bit LSB executable on my Debian 64 bits installation I had to do a few things but luckily being running Debian Wheezy with its multiarch superpowers it took me just a dpkg --add-architecture i386 ; apt-get update ; apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
Once I had the adb installed and running (Debian's multiarch rules) I found that adb was giving this message: "error: device not found". It turned out that I had to turn on "USB Debugging" on my device (Settings > Applications > Development > enable USB debugging) and then give plugdev group permisions to write to the device using this udev rule:
SUBSYSTEM=="usb", ATTR{idVendor}=="19d2", MODE="0660", GROUP="plugdev"
Then I just followed Cyanogenmod's root and recovery howto and it went like a charm.
I know have the blade ready for the last step, where I plan to follow Cyanogenmod's flashing instructions to be able to install the new stable version (which should be out when it is ready, in a Debian style).
Just one more thing, to boot into the ClockworkMod Recovery you have to hold for some time volume down while you power the phone on.
/me feels much like the good old days starting with Linux following other guy's howtos with just a little knowledge of what one was doing.

martes, 24 de abril de 2012

La Fonera definitive cable

One of my old mobile phones (a Grundig) had a usb cable which has been around for a long time without much use, some time ago when plugging it into Linux I realised that it seemed like a standard usb to serial adaptor.

Bus 003 Device 002: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port

[54027.595634] USB Serial support registered for pl2303
[54027.595855] pl2303 3-1:1.0: pl2303 converter detected
[54027.607264] usb 3-1: pl2303 converter now attached to ttyUSB0

So I analyzed it and found that it seemed like a 3.3V serial adaptor, so I had to start using it to access routers, mobiles, ... having also a broken Fonera power supply around (one of this typical Fonera problems where the power supply outputs the correct voltage but not enough intensity) I thought... if I put all this together I'll have a USB cable capable of powering La Fonera and also accessing it's serial port all in one and using just one USB slot.

And so... here is what I think is the definitive Fonera cable:

Recovering my fonera's filesystem files after f*cking it

Once upon a time I was cleaning up the jffs2 filesystem of my OpenWrt Backfire 10.03.1 based Fonera by removing "unused" packages and I thought... what is this hotplug2 package doing here, the fonera doesn't have anything hotplugable, so I can safely remove it... WRONG!

Never remove your hotplug2 package from your OpenWrt router, it won't complain, but once you reboot... at least on a Fonera with Backfire you are f*cked!

Hotplug2 is so needed that today, after finishing my definitive cable for La Fonera (I'll write about this later) when I saw it booting on the serial console, I watched my Fonera say on boot...

VFS: Mounted root (jffs2 filesystem) readonly on device 31:1.
Freeing unused kernel memory: 136k freed
Please be patient, while OpenWrt loads ...
Kernel panic - not syncing: Attempted to kill init!

and that was before getting to failsafe mode or anything, so... how could I gain access to the files I had inside if it was not booting?

It seems I went through the hard way, cause it resulted on a long way, that's why I'm writing it here...

I had access to the console and it has redboot on it (/me doesn't know anything about redboot), so I stopped redboot (I did this on the serial console but I have just realised that this can be done over telnet as well) and typed help, and then looking at my previous notes on how to flash OpenWrt I tried to enable capture on minicom (if you do this on telnet try to pipe it to tee) and dump the contents of the jffs2 filesystem using:

RedBoot> baudrate -b 115200
Baud rate will be changed to 115200 - update your settings
Baud rate changed to 115200 - continue (y/n)? y
Update RedBoot non-volatile configuration - continue (y/n)? n
RedBoot> fis list
Name FLASH addr Mem addr Length Entry point
RedBoot 0xA8000000 0xA8000000 0x00030000 0x00000000
rootfs 0xA8030000 0xA8030000 0x006D0000 0x00000000
vmlinux.bin.l7 0xA8700000 0x80041000 0x000E0000 0x80041000
FIS directory 0xA87E0000 0xA87E0000 0x0000F000 0x00000000
RedBoot config 0xA87EF000 0xA87EF000 0x00001000 0x00000000
RedBoot> fis load -b 0x80041000 rootfs
** Warning - checksum failure. stored: 0x136086ec, computed: 0x5571b53b
RedBoot> dump -b 0x80041000 -l 0x006D0000
80041000: 19 85 20 03 00 00 00 0C F0 60 DC 98 19 85 E0 01 |.. ......`......|
...

So, after some minutes I had all this hexa dump of the memory on my HD. Deavid kindly contributed this 90 secs python script to extract the hexa into binary (many thanks to him):

#! /usr/bin/python

from binascii import unhexlify
import sys

for line in sys.stdin:
colon = line.find(":")
end = line.find("|")
if colon < 0 or end <0:
sys.stderr.write(line)
else:
newline = line[colon+1:end].replace(" ","")
sys.stdout.write(unhexlify(newline))

And I had my jffs2 filesystem dumped on a file, yeah, so I thought I could simple mount -o loop it but... nope, jffs2 isn't that easy. Looking on the net I found that I should:

modprobe mtdram total_size=24576 erase_size=128
modprobe mtdblock
dd if=jffs2.img of=/dev/mtdblock0
mount -t jffs2 /dev/mtdblock0 /mnt

But that resulted on a mount: /dev/mtdblock0: can't read superblock error.

At that time I thought it could be an endianness problem, as I also wasn't able to mount an OpenWrt original jffs2 filesystem. So... a little more search on the net confirmed this and showed that:

apt-get install mtd-utils
jffs2dump -b -c -e dest_file.little src_file.big

should fix it, and so it did, after doing that and copying the new data converted from big endian to little endian to the mtdblock0 I was able to mount it and finally access all that I had on my Fonera.

That's it!

viernes, 24 de febrero de 2012

livebox2 reset internet connection

Being with Orange for some years means that I used to have a livebox 1 and now have a livebox 2. With the new one however it seems that from time to time my connection is stuck, if you look at the web page everything seems fine, but packets don't get passed the livebox, resetting the Internet connection is the quickest way to solve this. Here is a script to reset the connection from the command line:
wget --post-data="page=home&authaction=login&authlogin=admin&authpasswd=YOURPASSWORD" http://192.168.0.1/index.cgi -O - 2>/dev/null|(URL=$(sed -n 's|.*index.cgi?page=internet\(&sessionid[^"]*\)".*|http://192.168.0.1/index.cgi?page=internet\&action=reset\1|p');wget "$URL" -O - >/dev/null 2>&1)
One warning, here we have the password on the command line, you can use --post-file instead of --post-data to be safer, but anyway, please note that we are sending the password in the clear without any ciphering, while the livebox web page sends it as a hash, so it should be somewhat safer if they do things right.

viernes, 27 de enero de 2012

Pepephone vuelve a ofrecer la del pulpo

Pues eso, que los de Pepephone vuelven a ofrecer la tarifa del pulpo (que es la que tengo yo), ahora se paga el primer minuto a 0 y va aumentando de precio hasta los 4.9¢/minuto de máximo, eso sí, siempre con establecimiento de 15¢, si a alguien le interesa podéis pillarla en la web promocional del pulpo pepe

domingo, 1 de enero de 2012

Feliz 2012

Como algunos de mis amigos parecen leer este blog he pensado que estaba bien felicitar el año por este medio, y además se me ha ocurrido utilizar unas fotos que a algunos les traerán recuerdos de los good old times...


en esa foto se puede observar parte del hardware con que fueron tomadas las fotos: una capturadora de video y una cámara VHS, por aquel entonces no crecían las cámaras digitales por todos lados :-) He fechado esto en el año 1998, a ver si alguien me lo puede confirmar, es en la Taboada's Party y estábamos pasando mucho frío, digo... preparando la Arroutada de ese mismo año. Una de las atracciones de la party (al menos para los linuxeros) fue:


un PC (Pentium 166 a 200) que llevaba 12 tarjetas de red, 4 PCI y 8 ISA configuradas en modo bridge (haciendo switching) y que sería el "core" de la red de la Arroutada de ese año, esta es una vista del equipo:


Y aquí tenéis un detalle del expansor de bus que habíamos utilizado para poder meter 5 tarjetas ISA más en la máquina:


La verdad, todavía conservo esta cacharrería por aquí, algún año de estos en una Dudes o algo así me gustaría intentar volverla a poner a funcionar :-)
Mientras tanto... unas imágenes más del engendro, una del interior con las 12 tarjetas numeradas:


Una de la parte trasera con todas las tarjetas con sus BNCs conectados en la que me veo yo con las pintas de aquella época y sin dormir :-)


Y una última en la que se el interior sin los papelotes de numeración de las tarjetas:


Que tiempos aquellos :'-)
Nada más, feliz año a todos y que sigamos pudiendo disfrutar de la informática como siempre lo hemos hecho.

miércoles, 21 de diciembre de 2011

Camiseta de GPUL para Artai

Últimamente a mi mujer se le da por coser, y se le ocurrió hacerle unas camisetas a Artai reciclando camisetas nuestras, esta salió de una antigua camiseta de GPUL mía :-)


Por cierto, también se le ha dado por hacer un blog sobre lo que anda cosiendo, está empezando, se llama Agulla e fio para quien pueda interesar.