Monday, October 10, 2011

[TOOL] rkflashtool for Linux and rk2818 based tablets

0 comments

Hi,

I wasn't sure where to post this, but since the unofficial rk2818 port of CM7 thread is here, I thought this would be the best place.

Because I don't run Windows nor NetBSD, I rewrote rkflash from scratch with the use of libusb-1.0, so you can now read and write your rk2818-based tablet's flash memory under Linux (also w/o the need to root your tablet). Credit for reverse-engineering the protocol goes to the original author of rkflash (see source).

Small guide:

- unzip the file
- compile with
gcc -o rkflashtool rkflashtool.c -lusb-1.0 -O2 -W -Wall -s

- powerdown your tablet
- disconnect all cables

To get into flash mode differs for many tablets. Google around or use trial and error 
Here's what I do for my Arnova 10 tablet

- insert USB cable in computer (if it's not already there)
- hold vol+
- insert other end in tablet
- wait a few seconds
- release vol+

Now if you run lsusb, the following line should appear:

Bus 001 Device 044: ID 2207:281a

Bus and device number may be different. The screen of my tablet stays black.

The USB device must be readable and writable for the user running rkflashtool. If that's not the case, you'll see an error like this:
Code:
$ ./rkflashtool b
libusb couldn't open USB device /dev/bus/usb/001/048: Permission denied.
libusb requires write access to USB device nodes.
rkflashtool: fatal: cannot open device
This can be fixed in several ways (chmod, run as root, udev rules) but that's beyond the scope of this posting. For now, chmod 666 the device mentioned in the error message.

Usage of rkflashtool
Code:
$ ./rkflashtool
rkflashtool: fatal: usage:
rkflashtool b reboot device
rkflashtool r offset size >file read flash
rkflashtool w offset size <file write flash

offset and size are in units of 512 bytes
On my tablet, the boot partition starts at offset 0x8000 (in blocks of 512 bytes)
Its size is 0x2000 blocks
To backup the partition, issue:
Code:
$ ./rkflashtool r 0x8000 0x2000 >boot.img.backup
rkflashtool: info: interface claimed
rkflashtool: info: reading flash memory at offset 0x00008000
rkflashtool: info: reading flash memory at offset 0x00008020
.......
rkflashtool: info: reading flash memory at offset 0x00009fe0
To write a new boot.img or an old backup back to the device:
Code:
$ ./rkflashtool w 0x8000 0x2000 <boot.img.backup
rkflashtool: info: interface claimed
rkflashtool: info: writing flash memory at offset 0x00008000
rkflashtool: info: writing flash memory at offset 0x00008020
.......
rkflashtool: info: writing flash memory at offset 0x00009fe0
You can find a list of all partitions of your tablet in the HWDEF file.

After reading and writing at will, you can reboot your tablet by issuing
./rkflashtool b

If the file you are writing is smaller than the specified size, the rest is padded with zeroes. If it's bigger, it will be truncated. This is different from rkflash, which will overwrite blocks beyond the partition size.
rkflashtool does not support flashing a new bootloader directly.
If you have a different tablet, please try rkflashtool b and r first before flashing something new.
Standard DISCLAIMER with regard to bricking your tablet applies.

Enjoy! 

Leave a Reply

 
Mobile phone NEWS © 2011 DheTemplate.com & Main Blogger. Supported by Makeityourring Diamond Engagement Rings

You can add link or short description here