lunedì 26 agosto 2013

LG L9 Unbrick script

Here is a script I make to unbrick LG L9. This uses some custom firmware downloaded from random web sites so YMMV. This should automatically unbrick your LG L9.

This script is to be used ONLY when phone can't be booted in sw upgrade mode and everything else fails. Screen MUST be always black, otherwise other methods may give better results. When nothing else works, proceed at your own risk.

When screen is black with all possible key combos, connect your phone to a linux box using an USB data cable, without battery. Then run "lsusb". If you see a texas instrument device in the list, then proceed.

Before running the tool, you need to install the android-tools-fastboot package (read the comments in the script to know more).

Unzip the archive, cd to the obtained directory  and run "./lgL9FixBoot.sh".

You will first be asked to connect the phone without battery, then to insert the battery in a second step.

https://dl.dropboxusercontent.com/u/8112691/unbrick-LG-Optimus-L9.zip



venerdì 23 agosto 2013

Today I evolved the "hello world" example from the fuse library (http://fuse.sourceforge.net) in order to have a minimal read-write file system. The result is the following:


#define FUSE_USE_VERSION 26

#include <fuse.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>

static char *file_str;
static size_t len = 0;
static size_t maxlen = 1024 * 1024;
static const char *file_path = "/file";

static int file_getattr(const char *path, struct stat *stbuf)
{
int res = 0;

memset(stbuf, 0, sizeof(struct stat));
if (strcmp(path, "/") == 0) {
stbuf->st_mode = S_IFDIR | 0755;
stbuf->st_nlink = 2;
} else if (strcmp(path, file_path) == 0) {
stbuf->st_mode = S_IFREG | 0644;
stbuf->st_nlink = 1;
stbuf->st_size = len;
} else
res = -ENOENT;

return res;
}

static int file_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
if (strcmp(path, "/") != 0)
return -ENOENT;

filler(buf, ".", NULL, 0);
filler(buf, "..", NULL, 0);
filler(buf, file_path + 1, NULL, 0);

return 0;
}

static int file_open(const char *path, struct fuse_file_info *fi)
{
if (strcmp(path, file_path) != 0)
return -ENOENT;

return 0;
}

static int file_read(const char *path, char *buf, size_t size, off_t offset,
     struct fuse_file_info *fi)
{
if(strcmp(path, file_path) != 0)
return -ENOENT;

if (offset < len) {
if (offset + size > len)
size = len - offset;
memcpy(buf, file_str + offset, size);
} else
size = 0;

return size;
}

static int file_write(const char *path, const char *buf, size_t size,
    off_t offset, struct fuse_file_info *fi)
{
if(strcmp(path, file_path) != 0)
return -ENOENT;

if (offset < maxlen) {
if (offset + size > maxlen)
size = maxlen - offset;
memcpy(file_str + offset, buf, size);
len = fmax(offset + size,len);
} else
size = 0;

return size;
}

static int file_truncate(const char *path, off_t size)
{
if(strcmp(path, file_path) != 0)
return -ENOENT;

len = size;
return 0;
}

static struct fuse_operations file_oper = {
.getattr = file_getattr,
.readdir = file_readdir,
.open = file_open,
.read = file_read,
.write = file_write,
.truncate = file_truncate
};

int main(int argc, char *argv[])
{
file_str = malloc(maxlen);
return fuse_main(argc, argv, &file_oper, NULL);
}

venerdì 26 luglio 2013

Using external SDCard as /data on cyanogenmod 10.1 (android jellybean)

Quick explanation on how I got my external SD to be the data partition in CyanogenMod 10.1. YOU NEED TO UNDERSTAND EVERY STEP YOURSELF OTHERWISE DON'T DO THIS.

Note: I managed to brick my LG Optimus L9 P760 the first time I erased partitions, so YMMV. Be prepared to unbrick.

*) we need to operate as root on the device; an easy way is to install ssh server, which is available in the app store. Install and configure it. When you are logged in on the phone, type "su" to become root; allow operation on the phone.

*) identify what is your sdcard. Mine is /dev/block/mmcblk1

*) umount any mounted partitions.

*) use fdisk to wipe all partitions and create an ext2 partition. Assign to it type 83 (linux)  # maybe brick in progress...

*) reboot if needed

*) mke2fs /dev/block/mmcblk1p1  # use your device! careful here, brick is coming!

*) mkdir /mnt/fuse/real_sdcard1  # from now on, especially if you rebooted fine before, no brick anymore I think

*) mount -t ext2 /dev/block/mmcblk1p1 /mnt/fuse/real_sdcard1   # use your device

*) cp -a /data /mnt/fuse/real_sdcard1

*) mount -o remount,rw /     # not sure if really needed, let me know

*) nano /data/local/userinit.sh  # this is called by /etc/init.d/90userinit

*) therein, we put:

    mkdir -p /mnt/fuse/real_sdcard1
    mount -t ext2 /dev/block/mmcblk1p1 /mnt/fuse/real_sdcard1
    mount -o bind /mnt/fuse/real_sdcard1/data /data

reboot, enjoy

vincenzoml