Tuesday, November 19, 2013

Linux on UG008 TV Box (RK3066)

I was looking for the cheapest Rockchip device with external Wifi antenna and/or Ethernet connection, just to find both capabilities in the UG008 TV Box, a RK3066 (dual core) device at just 55 USD (shipping included).

After purchasing it and a quick delivery of 2 weeks to Europe, I set out to test it, since I worried it may be lagging behind the newer 4 core experience with the RK3188 CPUs.

The TV box surprised me being very small, at 7.5cm x 7.5cm and looking really slick and solid. I was glad to see Android feels zippy.


Small and cheap UG008 TV Box (wifi antenna is also just 7 cm)


So, hacking started:

1) Backup internal flash: The recovery button is at a tiny hole in one side, near the front. The only quirk here is that you insert a clip there and stay pressing the recovery button, plug the MicroUSB from the PC to the TV box and then: you also have to press a couple of seconds the power button, before you can release the recovery.

A red light appears around the MicroUSB slot, and on your [Linux] PC you can type "lsusb" and find a nameless device (for my PC's buses/devices, it is: "Bus 002 Device 004: ID 2207:300a  "), the 2207:300a ID is what matters, that is our UG008.

First's first, the "partition table", extracted with:
sudo ./rkflashtool r 0 1 | head -n 11
looks like:
CMDLINE: console=ttyFIQ0 androidboot.console=ttyFIQ0 init=/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00002000@0x00002000(misc),0x00006000@0x00004000(kernel),0x00006000@0x0000A000(boot),0x00008000@0x00010000(recovery),0x00120000@0x00018000(backup),0x00040000@0x00138000(cache),0x00300000@0x00178000(userdata),0x00002000@0x00478000(kpanic),0x00120000@0x0047A000(system),-@0x0059A000(user)
We go one by one backing them up into our PC (you can safely leave out some, like user, cache, kpanic), just remember for the rkflashtool command you have to swap the hex numbers above.

For example to backup recovery (to flash our Linux kernel on it), which is listed above as "0x00008000@0x00010000(recovery)", you'd do:

sudo ./rkflashtool r 0x10000 0x8000 > UG008_recovery.img

2) Rooting UG008: Once we are done with that, we should root the device (even if just for the sake of being able to dual boot Android or Linux), the rooting procedure is fairly standard and described here. If you only want Linux on the box, you don't need to root it, keep reading,


3) Flash Linux kernel: You have two options depending on what you want:

a) Dual Boot Android/Linux: This is the usual way, you want to flash the recovery partition. I've found this box to be a close relative of the Measy U2C, for which I published several recovery kernels that are compatible with UG008, you'd be missing Wifi (RK901) and Ethernet. Flashing being just:

sudo ./rkflashtool w 0x10000 0x8000 < recovery.img
sudo ./rkflashtool b 

      If you're into working your way around, it should be easy to add the connectivity. Wifi with RK901 has been supported in Linux sticks for some time already (though I never bothered to check myself, being used to wired LAN), and Ethernet should require only to enable this .config options before building your kernel: CONFIG_NET_ETHERNET and CONFIG_RK29_VMAC.

Generic Linux Kernel building for RK devices is described here. Just remember this is a RK3066 device, so don't compile it for RK3188! The audio codec is the well known RK1000.

Now, in order to boot to Linux from Android you can use this excellent "Autorun Linux" app, or install "Android Terminal Emulator" get inside type "su" and then "reboot recovery" every time.


b) Only Linux (remove Android): Very legitimate. Using the same recovery kernel as above, the flashing procedure is all explained here (but follow the instructions for flashing "boot" partition, instead of "kernel" partition, since you are using a recovery kernel). The boot writing (after you back up that partition!!) can be done with this command:

sudo ./rkflashtool w 0xA000 0x6000 < recovery.img
sudo ./rkflashtool b 

Note: I haven't tested the "Only Linux" approach on my UG008, though it should work, or else you can always flash again your backed up stock partition and be back where you started.



4) Booting Linux: Insert your usual MicroSD card with Linux root file system (rfs) and you're good to go.


Any questions, and polite criticism is welcome in the comments below. I hope this post helps!




9 comments:

  1. Hi, this is not a comment for this post. I wanted to appologize for misleading you. Allwinner A20 doesn't have support for SATA Port Multipliers. I said it has.

    ReplyDelete
    Replies
    1. Thanks very much for the updated info! :-)

      Delete
  2. Hi, first thanks for all the work, it saves so many so much time, while advancing computing for everyone.

    I was successful in getting the system running, except for the internal ethernet adapter. I compiled the kernel with CONFIG_NET_ETHERNET and CONFIG_RK29_VMAC. options, and the ethernet adapter gets recognized. But it does not pickup DHCP address and with static IP address it encounters so many errors that it doesn't transmit nor is it able to negotiate the speed link.

    I haven't looked any further (it was 3AM), but was wondering whether you had any suggestions or could try the internal adapter.

    ReplyDelete
    Replies
    1. That's not normal. If you can open a thread about it on miniand.com's forum:
      https://www.miniand.com/forums/forums/picuntu-linux

      Specifying which Linux distro are you using, and its version, the kernel repo source that you compiled and the errors you're getting, I may be able to help over there.

      Delete
  3. cheapest? what's is your plan on this "common" box?

    ReplyDelete
  4. So great so see some attention for the UG008 -- with wireless as a weak link in this space, a wired interface is important, and now to have a real OS too... Let's say Christmas came early! Thanks!

    ReplyDelete
  5. Bricked my UG008... I get "rkflashtool: fatal: premature end-of-file reached." and device is unbootable. Attempts to restore from backup fail. Any ideas how this happened?

    ReplyDelete
  6. http://www.wax-berry.com/bbs/forum.php?mod=forumdisplay&fid=44

    Ug008 contains waxberry PI2 board and there are several distributions of Linux for the link above.
    But you can do even if you download account on that forum. Try to download from there.

    ReplyDelete