Tuesday, April 16, 2013

3D HW acceleration on Picuntu Linux (Mali400)



I have ported olegk0's kernel (https://github.com/olegk0/rk3066-kernel) updates and Mali driver to Picuntu on my Picuntu kernel branch (https://github.com/Galland/picuntu-3.0.8-alok https://github.com/Galland/rk3x_kernel_3.0.36).

I'm testing and it seems very stable. glxgears reports now 85fps 3D, whereas before I was getting 5fps (3D in software), if I remember well. (glxgears is OpenGL, not OpenGL-ES, which is the HW accelerated one by Mali! thanks to Jean-Luc Aufranc for pointing it out) glmark2-es2 reports a glmark2 score of 80, and es2gears reports some 150fps.

Please note that Mali is the GPU on the RK3066, responsible for 2D/3D acceleration, not for HW video en/decoding! That's done by the VPU core, which is still unsupported.

Please note that, afaik, all of this is work done by olegk0 (see [1]) and I have just checked it does work on our Picuntu, so all cheers go to him, thanks for the great work, olegk0!

If you would like to test this too, grab my github kernel and follow the instructions on [1] or these Picuntu-targeted instructions here:

1) Get xorg.conf and place it on your Picuntu MicroSD's folder /etc/X11/

2) Get rk30fb_drv.so (or compile it yourself) and place it on your Picuntu MicroSD's folder /usr/lib/xorg/modules/drivers/

3) Modify /etc/rc.local by commenting (precede with #) existing lines that use "fbset" and adding the following new lines:
 fbset -rgba 8/16,8/8,8/0,8/24 -a
chmod 666 /dev/mali /dev/ump

4) Modify /etc/modules to add the following lines:
rk29-ipp
ump

disp_ump
mali
drm
mali_drm

5) Get the mali package, uncompress and install this file: mali400_2.1-13_armhf.deb

6) Run the following commands:


sudo mv /usr/lib/arm-linux-gnueabihf/mesa-egl/ /usr/lib/arm-linux-gnueabihf/.mesa-egl/ 
sudo ln -s /usr/lib/libMali.so /usr/lib/libEGL.so
sudo ln -s /usr/lib/libMali.so /usr/lib/libEGL.so.1.4
sudo ln -s /usr/lib/libMali.so /usr/lib/libGLESv1_CM.so
sudo ln -s /usr/lib/libMali.so /usr/lib/libGLESv1_CM.so.1.1
sudo ln -s /usr/lib/libMali.so /usr/lib/libGLESv2.so
sudo ln -s /usr/lib/libMali.so /usr/lib/libGLESv2.so.2.0



Then if you enter:        ll /usr/lib | grep libMali

The output should look something like this:
lrwxrwxrwx 1 root root 19 abr 16 17:58 libEGL.so -> /usr/lib/libMali.so
lrwxrwxrwx 1 root root 10 feb 22 02:06 libEGL.so.1.4 -> libMali.so
lrwxrwxrwx 1 root root 19 abr 16 17:58 libGLESv1_CM.so -> /usr/lib/libMali.so
lrwxrwxrwx 1 root root 10 feb 22 02:06 libGLESv1_CM.so.1.1 -> libMali.so
lrwxrwxrwx 1 root root 19 abr 16 17:58 libGLESv2.so -> /usr/lib/libMali.so
lrwxrwxrwx 1 root root 10 feb 22 02:06 libGLESv2.so.2.0 -> libMali.so
-rw-r--r-- 1 root root 731492 feb 22 02:06 libMali.so





LAST STEP : ONLY IF YOU ARE NOT USING KERNEL 3.0.36+
Get my github kernel code (3.0.36+) and compile it, just make sure that you do this too:

- I'm using the Measy U2C stick, which has DDR3 1333 9-9-9 capable memory, but this may not be your case and may cause your system to not boot. So just before compiling ("make -j 4") do "make menuconfig" and get inside "System Type" and there set "DDR Memory Type" to "DDR3 (Type default)" and "DDR SDRAM frequence (in MHz)" [sic] to "333".

- Also please note that my kernel is set to Maximum CPU frequency of 1.6 GHz (instead of 1.2 GHz in stock Picuntu), so use at your own risk!!!!! For added safety you can make your CPU run cooler by setting (in above menuconfig) into "CPU Power Management" --> "CPU Frequency scaling" --> "Default CPUfreq governor" to "conservative" or "powersave", so it will rarely go to high frequencies (but it'll be slower). My CPU does fine with 1.6 GHz without any heatsink, and usually runs at 60-70 ÂșC, with 80+ spikes :S however voltage scaling is known to work on my stick (not on others I fear). I fixed this in current github kernel, so CPU automatically scales down frequency when temperature rises.

- You may also want to check on "Device Drivers" -> "Network device support" -> "Wireless LAN" that your Wifi chip/stick is selected there, for its driver to be compiled. My kernel is, currently, more up to date than others, and as you will see, there is a driver for the RK903 Wifi. However, since I don't own a stick that has it, I haven't been able to test. Please let me know if it works for you :)

- After compiling, you have to do "make modules" too, this is very important!

- Then do "make modules_install" and go to your PC's /lib/modules to grab the full "3.0.8+alok" "3.0.36+" folder and copy it to your Picuntu MicroSD's /lib/modules folder (or just do all this on your Picuntu Linux!!:), then boot up your Picuntu stick and type in a terminal "depmod -a" so it will parse the new modules and restart Picuntu.

- After doing that you can flash the recovery partition with the compiled kernel

This could sound complicated but kernel tinkering is actually pretty straightforward and works! :)  Hope it helps and check your temperature with: cat /sys/module/tsadc/parameters/temp*

END OF LAST STEP (only for non 3.0.36+)



Testing 3D acceleration:

Run as a normal user:     es2gears   
It should report >120 fps (I usually get from 120 to 170 fps) with a CPU usage of around 30% for Xorg and just <15% for es2gears.
If that's not the case then double-check above steps and if it still doesn't work, you can, for example, post your questions at Miniand's Picuntu forum, where I try to be of help.



Disclaimer: Use at your own risk!!

If you run into an "Illegal instruction" error or a sudden reboot... your stick needs a heatsink... I spent the whole glmark2-es2 test blowing air to mine!
This is due to my overclocking the GPU from 266 MHz to its limit of 400 MHz, I've undone this in the github kernel too :)


MK808 note: If you have a MK808 you may want to compile olegk0's kernel instead of mine, because MK808 uses a different "LCDC video port" for HDMI output (1 instead of 0), which requires some minor code changes. However my kernel is more up to date (less bugs, less power consumption, etc.) than his, so I must recommend it for other sticks.



Reference
http://www.slatedroid.com/topic/55626-my-version-of-the-linux-kernel-for-mk808/
http://linux-sunxi.org/Binary_drivers
https://www.miniand.com/forums/forums/picuntu-linux/topics/new-kernel-3-0-36-for-picuntu-linux-on-rk3066-released

8 comments:

  1. Congratulations for the sucess

    ReplyDelete
  2. amazing just what we need in this small pc

    ReplyDelete
  3. So your code use the lcdc0 for HDMI , how can you do that ?
    I want to learn , can you show me how to do . Thanks

    ReplyDelete
  4. I cant find the xorg.conf!
    Under the Link is nothing (no Dokument)
    Can You post the xorg.conf normal.?

    Thanks!

    ReplyDelete
  5. hi great work. i see you have 1.6ghz. i was wondering if you can make a kernel of 1.7ghz and 1.8ghz like omegamoon's kernel. i have a mk802iii with heatsink and fan i would like to test this on. i want to try but i dont know how to compile the modifications.

    ReplyDelete
  6. Really nice. One suggested change in step 3:
    in rc.local:
    chmod 666 /dev/mali /dev/ump /dev/dri/card0
    Otherwise only superusers are able to access the driver. At least in my case.

    ReplyDelete
  7. Hi again this is my last post here don't worry because you ae maybe the only one who can find the solution :-) but i'm struggling to make 3d hardware acceleration work on our device with ubuntu 14.04 (using sgjava work)

    i tried everything i can but without successs (all kernels and mod files found )
    i'm using your kernel 3.0.36+

    and i first tried to use files provided by your tutorial http://hwswbits.blogspot.fr/2013/04/...ntu-linux.html

    but it has some incompatibility with ubuntu 14.04 xorg
    so i recompiled the mali driver (RK30FB)
    but also mali.ko, ump.ko, drm.ko ,mali_drm.ko libMALI.so and libUMP.so in order to get everything compatible with my system using the same version of mali drivers r3p2-01rel2!
    but when i try to run an opengl ES app i get this

    root@ubuntu:/home/test# glmark2-es2
    Error: eglInitialize() failed with error: 12291
    Error: Error: Could not get a valid XVisualInfo!
    Error: Error: Couldn't create X Window!
    Error: main: Could not initialize canvas

    is someone have an idea of what to do ? i'm about to give up XD

    thanks by advance for your answers !

    information you could need :

    root@ubuntu:/home/test# dmesg | grep -i mali
    [ 18.777305] Mali: init_mali_clock mali_clock c0e259c0
    [ 18.784194] Mali: Mali device driver loaded
    [ 18.824661] DRM: mali_platform_drm_probe()
    [ 18.824676] mali_drm_init(), driver name: mali_drm, version 0.1
    [ 18.825569] DRM: mali_driver_load()
    [ 18.825622] [drm] Initialized mali_drm 0.1.0 20100520 on minor 0
    root@ubuntu:/home/test# dmesg | grep -i UMP
    [ 18.744755] UMP: UMP device driver loaded

    Xorg.0.log
    [ 2262.425] (II) RK30FB: driver for framebuffer: rk30fb
    [ 2262.427] (WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
    [ 2262.427] (II) RK30FB(0): RK30: Try setup nonstd mode for dev:/dev/fb0
    [ 2262.428] (II) RK30FB(0): RK30: Setup for bpp:32
    [ 2262.430] (II) RK30FB(0): RK30: Setup nonstd mode completed
    [ 2262.430] (**) RK30FB(0): Depth 24, (--) framebuffer bpp 32
    [ 2262.430] (==) RK30FB(0): RGB weight 888
    [ 2262.430] (==) RK30FB(0): Default visual is TrueColor
    [ 2262.430] (==) RK30FB(0): Using gamma correction (1.0, 1.0, 1.0)
    [ 2262.430] (II) RK30FB(0): hardware: fb0 (video memory: 32768kB)
    [ 2262.431] (**) RK30FB(0): Option "HWCursor" "false"
    [ 2262.431] (**) RK30FB(0): Option "WaitForSync" "true"
    [ 2262.431] (II) RK30FB(0): checking modes against framebuffer device...
    [ 2262.431] (II) RK30FB(0): mode "1280x720" ok
    [ 2262.431] (EE) RK30FB(0): FBIOPUT_VSCREENINFO: Invalid argument
    [ 2262.431] (II) RK30FB(0): mode "1920x1080" test failed
    [ 2262.431] (II) RK30FB(0): mode "1920x1080" not found
    [ 2262.432] (II) RK30FB(0): checking modes against monitor...
    [ 2262.432] (--) RK30FB(0): Virtual size is 1280x720 (pitch 1280)
    [ 2262.432] (**) RK30FB(0): Mode "1280x720": 74.2 MHz (scaled from 0.0 MHz), 45.0 kHz, 60.0 Hz
    [ 2262.432] (II) RK30FB(0): Modeline "1280x720"x0.0 74.25 1280 1390 1430 1650 720 725 730 750 +hsync +vsync (45.0 kHz)
    [ 2262.432] (==) RK30FB(0): DPI set to (96, 96)
    [ 2262.447] (II) RK30FB(0): Init mode: 1280x720
    [ 2262.464] (==) RK30FB(0): Backing store enabled
    [ 2262.465] (**) RK30FB(0): DPMS enabled
    [ 2262.465] (II) RK30FB(0): HW:Main setup ovl
    [ 2262.465] (II) RK30FB(0): Overlay memory pages
    [ 2262.465] (II) RK30FB(0): --------------------
    [ 2262.465] (EE) RK30FB(0): HW:Error overlay mem block size:0
    [ 2262.465] (EE) RK30FB(0): HW:Error init ovl
    [ 2262.465] (II) RK30FB(0): XV:Init begin
    [ 2262.465] (II) RK30FB(0): XV:Init complete



    Module Size Used by
    mali_drm 5284 0
    drm 133568 1 mali_drm
    mali 105154 0
    disp_ump 807 0
    ump 26264 4 disp_ump,mali
    rk29_ipp 5253 0
    rfcomm 29888 0
    bnep 8848 2
    bluetooth 129935 10 bnep,rfcomm
    sr9700 6407 0
    dm9601 5416 0
    gc2035 16753 0

    ReplyDelete

Note: Only a member of this blog may post a comment.