RK30xx kernel source for custom modding...

Re: RK30xx kernel source for custom modding...

Postby eCCoMaNia » Fri Nov 23, 2012 10:52 am

AndrewDB wrote:Hi everybody,
Just a very short update post: Rockchip HDMI Analog Stereo ALSA device (a.k.a. sound) is finally working in Ubuntu Linux on the UG802, thanks to the "riko kernel".
Anybody wanting to compile the kernel: use the "hotdog" config file as a base configuration for all the PC stick format RK3066 devices.

EDIT: and also I retested the USB transfer rates reading/writing to a USB key and the issues I was having last week with slow transfer rates seem to be solved (I am getting the USB key's rated speed on reads and writes).

you really are amazing ! :D thank you for all your efford AndrewDB, when do you think you can post beta or alpha image for ug802 linux ? I'm just getting really excited about this !
eCCoMaNia
 
Posts: 111
Joined: Wed Sep 26, 2012 10:56 am

Re: RK30xx kernel source for custom modding...

Postby mitchb » Fri Nov 23, 2012 12:28 pm

Thanks Andrew for all the work you have done ! I just can't wait to try it on my MK808.

I am also ready to test ! Alpha, beta, bring it on ! :-)
mitchb
 
Posts: 4
Joined: Thu Oct 04, 2012 10:19 am

Re: RK30xx kernel source for custom modding...

Postby aloksinha2001 » Fri Nov 23, 2012 1:27 pm

AndrewDB wrote:Hi everybody,

Anybody wanting to compile the kernel: use the "hotdog" config file as a base configuration for all the PC stick format RK3066 devices.



Andrew: Cud u pls elaborate ?

Alok
aloksinha2001
 
Posts: 41
Joined: Thu Nov 08, 2012 11:11 pm

Re: RK30xx kernel source for custom modding...

Postby mosfet » Fri Nov 23, 2012 2:49 pm

Hi mosfet,
The MK808 is slightly more practical to flash because the USB otg port is not shared between the WiFi and the OTG functions (on the MK808 the WiFi uses SDIO, not USB).

Yes, please could you post some details on how you use the Linux tool rkflashtool? Do you have to short two pins on the MK808 to enter Flash mode, or is pressing the hidden button while connecting it to the PC enough?

Thanks!


Hi AndrewDB,

It's interesting that UG802 share the OTG port with WiFi over SDIO. I know the MK808 has a bootstrap ROM on the RK3066 chip that checks for the “recover” button to be pressed during power up and switches to a basic OTG device mode where it can be programmed using rkflashtool when plugged in a host PC.

In order to get rkflashtool to work with your given model (provided the OTG port works the same way as the MK808) you'll need to figure out what USB device ID UG802 has:


1. hold down the recovery button (using a paperclip) and power up the RK3066 device from only the OTG port using a standard usb cable (no special OTG cable required or shorting of the sense pins) plugged in to your PC running linux.
2. After 5 seconds release the button. No led will turn on at this point.
3. Run dmesg and you should see something like this:

Code: Select all
[  205.907467] usb 2-2: USB disconnect, device number 2
[  227.990348] usb 2-2: new high-speed USB device number 5 using ehci_hcd
[  228.122866] usb 2-2: unable to get BOS descriptor


4. Run lsusb and make note of the device id (in my case for the MK808 it is 2207:300a)
5. Next open up rkflashtool.c from the supplied archive and add a conditional if statement (Third if) for your device as follows (Note: place your device ID that you identified with lsusb):

Code: Select all
    if (!(h = libusb_open_device_with_vid_pid(c, 0x2207, 0x290a)))
        if (!(h = libusb_open_device_with_vid_pid(c, 0x2207, 0x281a)))
           if (!(h = libusb_open_device_with_vid_pid(c, 0x2207, 0x300a)))
                  fatal("cannot open device\n");


6. Save the file and run make (ensure you have libusb and liusb dev packages installed)
7. This should have built rkflashtool with your specific arm device id. (I have already added the device id for MK808 to the file)
8. Now you're ready to read the flash. As a first step I dumped the entire 8GB nand flash as a backup like so (it will take some time to backup the whole nand):
Code: Select all
rkflashtool r 0x00000000 0x01000000 > myflashbackup.bin


10. To quickly get an idea of where everything is in the flash you can run “hexdump -C myflashbackup.bin | more” to reveal the params which include the offsets for all images in nand including boot, system, user.
11. In my case, to grab the kernel I did the following:

Code: Select all
rkflashtool r 0x00004000 0x00004000 > mk808kernel.img


12. To upload a new kernel do the following:

Code: Select all
rkflashtool e 0x00004000 0x00004000
rkflashtool w 0x00004000 0x00004000 < mynewkernel.img


13. After the flash tool is done its operation, simply unplug and plug in the RK3066 devices to reboot it or run rkflashtool b to reboot the device.
14. To recover from a kernel firmware load do the following run:

Code: Select all
rkflashtool e 0x00000000 0x00008000
rkflashtool w 0x00000000 0x00008000 < myflashbackup.bin



Your mileage may vary in terms of success. The above steps worked for me using the MK808 using Ubuntu 12.04 LTS 64bit on the host pc. I have also tried using VirtualBox under Windows 7 64 but the OTG device is not properly translated in windows and rkflashtool cannot “claim the device.”

I've attached an archive that also includes a precompiled version of rkflashtool for Ubuntu 12.04 LTS 64 for MK808.

Here it is:
rkflashtool.tar.bz2


Good luck and let me know how it goes.
You do not have the required permissions to view the files attached to this post.
mosfet
 
Posts: 17
Joined: Thu Nov 22, 2012 1:04 pm

Re: RK30xx kernel source for custom modding...

Postby AndrewDB » Fri Nov 23, 2012 4:05 pm

Thank you mosfet for the great write up and detailed explanations, great post!
I am going to try it ASAP! :geek:
AndrewDB
 
Posts: 144
Joined: Sun Oct 28, 2012 5:53 pm

Re: RK30xx kernel source for custom modding...

Postby llewelld » Fri Nov 23, 2012 9:48 pm

Hi Guys,

Can anyone tell me, is the work being done here only for Ubuntu for RK-3066, or will it also be for android?

I have an MK808 and have been searching hi & low for a rom with true 1080p desktop, not the scaled 1280x672.

Many of the existing Android roms for me would be near perfect, except for the screen resolution issue.

Cheers for any feedback and cant wait to test out Ubuntu.
llewelld
 
Posts: 24
Joined: Thu Nov 15, 2012 1:57 am

Re: RK30xx kernel source for custom modding...

Postby vampirex » Fri Nov 23, 2012 10:24 pm

mosfet wrote:
...... I have also tried using VirtualBox under Windows 7 64 but the OTG device is not properly translated in windows and rkflashtool cannot “claim the device.....


What about VMware player?
http://www.vmware.com/products/player/

You can find some precompiled Linux vm images for VM player here:
http://www.thoughtpolice.co.uk/vmware/
vampirex
 
Posts: 28
Joined: Wed Oct 31, 2012 10:32 pm

Re: RK30xx kernel source for custom modding...

Postby fun » Fri Nov 23, 2012 11:30 pm

AndrewDB wrote:Yes, please could you post some details on how you use the Linux tool rkflashtool? Do you have to short two pins on the MK808 to enter Flash mode, or is pressing the hidden button while connecting it to the PC enough?


just FYI,

there are 2 kind of special boot mode on RK device.

1. read initial boot code from USB, then enter NAND read/write mode
2. read initial boot code from NAND, then enter NAND read/write mode

if you short 2 pins on NAND which disables NAND, or press equivalent button which is available on some(few?) devices, "1" will be started.

if you press a button for "upgrade", "restore", or something else, or run "reboot bootloader" from shell/adb, "2" will be started. for "2", proper boot code need to be flashed in NAND.

rkflash/rkflashtool can work with "2" only, and only MTD partitions which can be accessed from Android/recovery are supported. rkflash/rkflashtool can't read/write initial boot code area in NAND.

official tools from Rockchip can work with both "1" and "2". they can send initial boot code via USB for "1", and they can access initial boot code area in NAND.

--
if you bricked your device by e.g. flashing invalid boot code into NAND, you need to do "1" with official tools to unbrick.

to support "1" in rkflash/rkflashtool, at least, unknown "extra 2 bytes" need to be solved.
viewtopic.php?f=66&t=212&start=160#p2519
fun
 
Posts: 124
Joined: Wed Nov 07, 2012 11:09 am

Re: RK30xx kernel source for custom modding...

Postby fun » Fri Nov 23, 2012 11:47 pm

AndrewDB wrote:3) I have started investigating the NAND driver.


by the way, I think Rockchip's NAND/MTD driver is very strange. standard MTD tools such as flash_image/erase_image don't work correctly. probably ERASE ioctl doesn't work.

block device(/dev/block/mtdblock*) is also strange. writing some amount of data to mtdblock from userland(cat, dd, etc) will lead oops/data corruption. I guess erasesize of 0xff need to be written before writing data, and/or some special handling is needed even for block device.
(read/write thru kernel, i.e. read/write files on mounted file system works fine, of course)

I'm not sure standard Linux mkfs/fsck can run properly on RK's mtdblock.
Last edited by fun on Sat Nov 24, 2012 12:45 am, edited 3 times in total.
fun
 
Posts: 124
Joined: Wed Nov 07, 2012 11:09 am

Re: RK30xx kernel source for custom modding...

Postby mosfet » Sat Nov 24, 2012 12:06 am

Lots of great activity on this thread!

AndrewDB: If you need any help with testing let me know.

llewelld: I've been playing with the kernel AndrewDB uploaded to github and have successfully enabled 1080p on the MK808 using Android 4.1.1. Unfortunately, at this time the RK901 WiFi driver isn't working and I have some errors showing up relating to dynamic voltage and frequency management. Also, I noticed that when running in 1080p the graphics are a bit more sluggish but not bad.

vampirex: thanks for the vmware image resource. I haven't yet tried rkflashtool under vmware.

fun: Interesting info about the nand flash loading. It seems like it is a multistage boot loader. Can you explain which two bytes you're refering to for mode 1?

cheers
mosfet
 
Posts: 17
Joined: Thu Nov 22, 2012 1:04 pm

Re: RK30xx kernel source for custom modding...

Postby fun » Sat Nov 24, 2012 12:40 am

mosfet wrote:fun: Interesting info about the nand flash loading. It seems like it is a multistage boot loader. Can you explain which two bytes you're refering to for mode 1?


modern CPUs have similar functionality. there is a small code in on-chip ROM, it runs just after power-on/reset, it can use only small memory such as on-chip cache/SRAM. DRAM initialization and much more complicated functions need to be loaded from NAND/SD/USB/etc. I'm not sure this behavior can be called as "multistage boot loader".

currently I understand there is a "bootloader" in (e.g.) "RK30xxLoader(L)_V1.14.bin". some parts of this file are flashed into NAND, and it reads kernel/boot/recovery image from partitions. I don't have any information about detail implementation of this bootloader.

it's possible to make "dual boot" system by using boot and recovery partition. and probably it's possible to make "multi boot" system by making some kind of 2nd boot loader and flash it as boot or recovery image.


about extra 2 bytes, please read olin's post.
viewtopic.php?f=66&t=212&start=160#p2519
I also confirmed myself that surely "extra 2 bytes" are appended. currently I have no information about it. more investigation need to be done.
fun
 
Posts: 124
Joined: Wed Nov 07, 2012 11:09 am

Re: RK30xx kernel source for custom modding...

Postby AndrewDB » Sat Nov 24, 2012 3:28 am

llewelld wrote:Hi Guys,

Can anyone tell me, is the work being done here only for Ubuntu for RK-3066, or will it also be for android?

I have an MK808 and have been searching hi & low for a rom with true 1080p desktop, not the scaled 1280x672.

Many of the existing Android roms for me would be near perfect, except for the screen resolution issue.

Cheers for any feedback and cant wait to test out Ubuntu.


Hi,
The 1080P HDMI resolution issue is actually solved (see my posts a few days back), so if anyone wants to compile an Android kernel with the "hotdog" defconfig file that I mentioned above, using the riko kernel source that I posted on Github, that should work right out-of-the-box.
There is just a single line in a single file to edit: rk30_hdmi.h, change the default resolution from 720p to 1080p.
I can also compile a flashable test Android kernel with default 1080p for the MK808 and post it in my dropbox, but right now I don't have the time to compile a ROM and test it.
For the Android ROM itself, apart from the kernel, I suggest the latest Finless JB ROM based on the Rikomagic MK802 III official ROM
AndrewDB
 
Posts: 144
Joined: Sun Oct 28, 2012 5:53 pm

Re: RK30xx kernel source for custom modding...

Postby AndrewDB » Sat Nov 24, 2012 4:01 am

Hi fun,
fun wrote:
AndrewDB wrote:3) I have started investigating the NAND driver.


by the way, I think Rockchip's NAND/MTD driver is very strange.


What follows is an educated guess, I am not 100% sure about this:

In Android ROMs for all these RK3066 devices you can find a rk30xxnand_ko.ko kernel module that is a proper driver NAND, configured and compiled for the NAND chips that each individual device (UG802, MK808, etc) uses. Unfortunately, the exact source code for this driver is not available in either the edison or the riko kernel source trees. :(

I have tested this module in the modified CWM recovery that I posted about in this thread initially, and it worked, I could read and write to NAND flash using dd. When the module is loaded, it reports various NAND chip parameters, among other things the erasesize.

I believe that using the wrong module (i.e. a module compiled and configured for a different device, with different brand/model of NAND chips) can result in corrupt NAND.

There is also another Rockchip mtd "driver" in the kernel, here we have the source, but as far as I can tell this is just some glue logic for the rk30xxnand_ko.ko module.

fun wrote:standard MTD tools such as flash_image/erase_image don't work correctly. probably ERASE ioctl doesn't work.

block device(/dev/block/mtdblock*) is also strange. writing some amount of data to mtdblock from userland(cat, dd, etc) will lead oops/data corruption. I guess erasesize of 0xff need to be written before writing data, and/or some special handling is needed even for block device.
(read/write thru kernel, i.e. read/write files on mounted file system works fine, of course)

I'm not sure standard Linux mkfs/fsck can run properly on RK's mtdblock.


Indeed, I think we (developers) have a problem here. Right now I have no idea how to proceed on investigating this.
AndrewDB
 
Posts: 144
Joined: Sun Oct 28, 2012 5:53 pm

Re: RK30xx kernel source for custom modding...

Postby wangan » Sat Nov 24, 2012 4:55 am

hey guys,

sorry to interupt here, but I jusr received my mk802 III and would like to test this on that device. Maybe you could upload your linux image somewhere online?
wangan
 
Posts: 3
Joined: Sat Nov 17, 2012 7:36 am

Re: RK30xx kernel source for custom modding...

Postby mosfet » Sat Nov 24, 2012 11:50 am

fun wrote:
mosfet wrote:fun: Interesting info about the nand flash loading. It seems like it is a multistage boot loader. Can you explain which two bytes you're refering to for mode 1?


modern CPUs have similar functionality. there is a small code in on-chip ROM, it runs just after power-on/reset, it can use only small memory such as on-chip cache/SRAM. DRAM initialization and much more complicated functions need to be loaded from NAND/SD/USB/etc. I'm not sure this behavior can be called as "multistage boot loader".

currently I understand there is a "bootloader" in (e.g.) "RK30xxLoader(L)_V1.14.bin". some parts of this file are flashed into NAND, and it reads kernel/boot/recovery image from partitions. I don't have any information about detail implementation of this bootloader.

it's possible to make "dual boot" system by using boot and recovery partition. and probably it's possible to make "multi boot" system by making some kind of 2nd boot loader and flash it as boot or recovery image.


about extra 2 bytes, please read olin's post.
viewtopic.php?f=66&t=212&start=160#p2519
I also confirmed myself that surely "extra 2 bytes" are appended. currently I have no information about it. more investigation need to be done.


Thanks fun for the great info. I'll look through the linked discussion you posted. I'll also take a closer look at rkflashtool to see what it is doing.
mosfet
 
Posts: 17
Joined: Thu Nov 22, 2012 1:04 pm

Re: RK30xx kernel source for custom modding...

Postby deadhp1 » Sat Nov 24, 2012 3:51 pm

AndrewDB wrote:Hi fun,
fun wrote:
AndrewDB wrote:3) I have started investigating the NAND driver.


by the way, I think Rockchip's NAND/MTD driver is very strange.


What follows is an educated guess, I am not 100% sure about this:

In Android ROMs for all these RK3066 devices you can find a rk30xxnand_ko.ko kernel module that is a proper driver NAND, configured and compiled for the NAND chips that each individual device (UG802, MK808, etc) uses. Unfortunately, the exact source code for this driver is not available in either the edison or the riko kernel source trees. :(

I have tested this module in the modified CWM recovery that I posted about in this thread initially, and it worked, I could read and write to NAND flash using dd. When the module is loaded, it reports various NAND chip parameters, among other things the erasesize.

I believe that using the wrong module (i.e. a module compiled and configured for a different device, with different brand/model of NAND chips) can result in corrupt NAND.

There is also another Rockchip mtd "driver" in the kernel, here we have the source, but as far as I can tell this is just some glue logic for the rk30xxnand_ko.ko module.

fun wrote:standard MTD tools such as flash_image/erase_image don't work correctly. probably ERASE ioctl doesn't work.

block device(/dev/block/mtdblock*) is also strange. writing some amount of data to mtdblock from userland(cat, dd, etc) will lead oops/data corruption. I guess erasesize of 0xff need to be written before writing data, and/or some special handling is needed even for block device.
(read/write thru kernel, i.e. read/write files on mounted file system works fine, of course)

I'm not sure standard Linux mkfs/fsck can run properly on RK's mtdblock.


Indeed, I think we (developers) have a problem here. Right now I have no idea how to proceed on investigating this.



I don't know if this helps at all, but I have run ALL the different rk3066 firmwares available from the Google Drive mirror on both the MK808 and UG802.
I've also run many different rk3066 tablet firmwares on the mk808 and ug802. I've yet to run into any data corruption other than the micro sd card.
deadhp1
 
Posts: 656
Joined: Thu Sep 20, 2012 5:22 pm

Re: RK30xx kernel source for custom modding...

Postby mosfet » Sat Nov 24, 2012 4:01 pm

Hi All,

I've just successfully built the the 3.0.8 kernel from github.org/AndrewDB/rk3066-kernel with WiFi support for the RK901 using external kernel modules. I believe this can be also applied to the RK903 chipset with some minor kernel config tweaks and the right kernel modules. This nicely allows us to get around the problem of not having source for the rkwifi driver.

Currently, I'm using Android 4.1.1 on my MK808 and have solved the issue of missing symbols in the kernel during wifi module loading. In the case of Ubuntu, I think we can easily specify an alternate path for the firmware and nvram RK901/903 files too.

WiFi seems to be stable and without issue for the past hour or so using this build.
Last edited by mosfet on Sat Nov 24, 2012 7:55 pm, edited 1 time in total.
mosfet
 
Posts: 17
Joined: Thu Nov 22, 2012 1:04 pm

Re: RK30xx kernel source for custom modding...

Postby llewelld » Sat Nov 24, 2012 6:08 pm

Hi Andrew, re the 1080P Kernel..

It is beyond my skillset to compile my own kernel, but if you are willing to post a test Kernel for MK808 with 1080p to your dropbox, I would love to test it.

Or if anyone else is able to compile a Kernel with Andrews instructions above I would love to test.

Thanks!
llewelld
 
Posts: 24
Joined: Thu Nov 15, 2012 1:57 am

Re: RK30xx kernel source for custom modding...

Postby perpe » Sat Nov 24, 2012 6:54 pm

Hello guys,
A month ago I wrote to some German rk3066 Android tablet vendors and asked for the kernel source code. None of them answered :evil:
One of them is easypix, I went to their homepage again and saw that they have released it in the meantime. Unfortunately, it's incomplete like the source for edison and the riko, missing the same parts like rk30xxnand. It's also a 3.0.8 tree, but slightly different in the rk specific parts, hdmi and snd.
I uploaded it to github, https://github.com/perpe/EasyPad_971_Dual_Core
Feel free to use it :)

The original download can be found on http://easypix.eu/download_easypad.html, it's the EasyPad 971 DualCore.
perpe
 
Posts: 1
Joined: Sat Oct 27, 2012 4:10 pm

Re: RK30xx kernel source for custom modding...

Postby fun » Sat Nov 24, 2012 8:53 pm

deadhp1 wrote:
AndrewDB wrote:Indeed, I think we (developers) have a problem here. Right now I have no idea how to proceed on investigating this.



I don't know if this helps at all, but I have run ALL the different rk3066 firmwares available from the Google Drive mirror on both the MK808 and UG802.
I've also run many different rk3066 tablet firmwares on the mk808 and ug802. I've yet to run into any data corruption other than the micro sd card.


well, my information is also contain some amount of my guess. and I still don't get RK3066 device yet. for now I'm talking my memory with old RK devices.

data corruption on NAND(what I said) will not happen on normal use. but it may happen on other environment such as Linux userland, so I posted about it.
I'm not sure "rknand.ko from different device" causes this issue. I think I saw data corruption with proper rknand.ko, so I guessed "special handling is needed". anyway, I'm not 100% sure.

what I wanted to say is, RK's NAND driver is something strange. and probably it's same on RK3066.
some times ago, I checked CWM for RK3066. CWM can handle normal mtd device. but CWM for RK3066 uses mtdblock instead of raw mtd. I guessed same thing happened on raw mtd on RK3066.
(just mounting mtdblock as file system, which is needed for normal use, should be safe)

currently there is no source code for RK's NAND driver, so no way to investigate it. I just did trial & error, and guess.
fun
 
Posts: 124
Joined: Wed Nov 07, 2012 11:09 am

PreviousNext

Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest