Friday, October 4, 2013

Radxa Rock board Linux development starts!

So, finally the Radxa Rock board (early developer sample) arrived.

First of all a big thanks to Tom Cubie and his team at Radxa for kindly donating it to further Linux development!



Overview


This tiny board looks fantastic, first and foremost because it has EXPANSION HEADERS, apart from this varied assortment of ports and peripherals:

- CPU RK3188 quad-core @ 1.6 GHz
- 2 GB DDR3 RAM
- 8 GB Flash
- Wifi + BT
- 10/100 Eth
- Audio I/O + integrated microphone + SPDIF Out
- IR RX
- 2 full size USB ports
- 1 OTG USB port
- Power connector (doesn't take up a USB port)

Very nice specs but, to me, what makes this board unique is the expansion headers (along with openly available schematics!) where you can directly plug and access devices through I2C, SPI, UART, ... there is even an LCD output as well as another USB port at those pins!


First boot


After screwing in the protective top/bottom methacrylate plastics you will need a power adapter and an HDMI cable (normal size connector, not mini/micro) to attach it to a display and be ready to boot.

When you power the board for the first time it boots into Android, scaled 720p and in English, version 4.2.2 with kernel 3.0.36+ based on RK3188 R-BOX Android 4.2.2 SDK v1.0.0-130514.
However, beware, there is no Google Play, so you're on your own to install apps.


Hack it!


If you want to tinker with it, nothing easier, turn it off, unplug power and then: while keeping pressed the Recovery push-button nearby the USB ports, plug the OTG USB port to your PC.

A board red LED will light immediately, give it 2 seconds (or it'll boot Android) and, then, you can release the pushbutton and go to your PC.

I'm supposing you're on Linux, so if you go to a Terminal and write "lsusb" you'll see a new nameless device with ID: 2207:310b which corresponds to a RK3188 SoC awaiting flashing instructions.


IMPORTANT TIMEOUT: This recovery mode for flashing powers off after 2 minutes from last flash operation  or from being plugged in (if you do no operations). So it will issue a "power off" command through the serial console and just disappear from "lsusb" output. You'll have to re-plug it again to access it.

Then, through the usual Windows RK-provided tool or with the Linux rkflashtool that you can download and compile with ease from: https://github.com/Galland/rkflashtool_rk3066   (I know, worst name ever, it does handle RK29* and RK31* too).

So download and compile the Linux USB flashing tool:

git clone https://github.com/Galland/rkflashtool_rk3066 rkflashtool
cd rkflashtool
sudo apt-get install libusb-1.0-0-dev
gcc -o rkflashtool rkflashtool.c -lusb-1.0 -O2 -W -Wall -s


Ask the Radxa board about its partition sizes and offsets:

sudo ./rkflashtool r 0x0 0x1 | head -n 11

the result should be:

FIRMWARE_VER:4.1.1
MACHINE_MODEL:rk31sdk
MACHINE_ID:007
MANUFACTURER:RK31SDK
MAGIC: 0x5041524B
ATAG: 0x60000800
MACHINE: 3066
CHECK_MASK: 0x80
KERNEL_IMG: 0x60408000
#RECOVER_KEY: 1,1,0,20,0
CMDLINE:console=ttyFIQ0 androidboot.console=ttyFIQ0 init=/init initrd=0x62000000,0x00800000 mtdparts=rk29xxnand:0x00002000@0x00002000(misc),0x00005000@0x00004000(kernel),0x00007000@0x00009000(boot),0x00010000@0x00010000(recovery),0x00020000@0x00020000(backup),0x00040000@0x00040000(cache),0x00200000@0x00080000(userdata),0x00002000@0x00280000(kpanic),0x00100000@0x00282000(system),-@0x00382000(user)

What does this tell us?

Well, for us Linux developers, used to sharing sticks' space with Android (unless you decide to wipe it and make your Linux take over the flash...) we are bound to flashing our kernels into the "recovery" partition so that we can dual boot Android or Linux by having the latter's filesystem in a MicroSD (also called uSD) card.

And then, from above parameters, where each partition is described as:
        partition_size@partition_offset(partition_name)
we infer that our "recovery" partition is at 0x10000 and has a size of 0x10000
Please remember that the flashing tool requires these numbers in reversed position (first the offset, then the size), like   sudo ./rkflashtool r (offset) (size)


Hence, once you have downloaded/compiled your Linux kernel and have a Ubuntu rfs (root file system) in your uSD, you can go ahead and flash your Linux kernel with these simple commands:

sudo ./rkflashtool w 0x10000 0x10000  <   my_kernel_recovery.img
sudo ./rkflashtool b

The "b" command safely reboots the RK device when the flash is written.

I'll initially be using my most up to date kernel for booting Linux, so you may see some activity there:
https://github.com/Galland/Linux3188

Have fun hacking!

2 comments:

  1. Radxa Rock now available at Miniand: https://www.miniand.com/products/Radxa%20Rock%20Dev%20Board

    ReplyDelete