Overclocking a MK808B plus (Amlogic S805) to run LAKKA.

Hello blog. It was many years sins I made a post on this blog, but I guess now its the time again.

I bought a MK808B plus with thserveimagee Amlogic S805 chip onboard a while ago, I really like this SOC. Its efficient and quite powerful for its size.

Sins my sister requested a NES Classic Mini for the kids for Christmas, I thought that it was better to create a Emulator-console instead. And I think that they have a hard time to appreciate a 8 bit console now days 😛

Sins they already got a MK808B plus with android ( Yes I installed it a year a go so they could stream Youtube and watch movies with Kodi) I saw the perfect plan to pimp this computer a little bit.

I noticed that this computer has support for LAKKA. A lightwight Distro with Retroarch on top. And it worked out great. Check it out here:  http://www.lakka.tv/lakka-retrogaming-linux

I bought a couple of cheap china ps3 wireless gamepads on ebay witch had support in the distro.

I took a while until I figured out Retroarch worked. The first thing was that I could not add my games to the library. Seems like they where not from the correct release. Looking at the retroarch page, they refer to support the No-Intro releases, and after some googling I found a torrent with all the No-Intro releases packed into a big bundle.

I also wanted the boxcovers for the games. I manually installed them in the thumbnails folder because I had some problem to download this directly in retroarch. It was just to extract them in the folder with the correct name. you find them here.

 

Said and done. Everything seems to work out quite well. Snes, Nes, SegaMS and Sega IMG_20181225_104148Genesis. and even PS1 seems to work. But I didn’t got the N64 to work, which was my main console that I wanted to work. Mainly because they have many games for kids, likplaying, seems to work okay for about 5 minutes and after that it was thermal throttling. The day before Christmas I bought a 50mm fan  and solder it to a USB cable. It was working. The SOC did not throttle anymore and the N64 games worked out, a bit laggy thought with some slowdowns running Mario Kart.

The Kids loved the christmas gift, and we where playing Mario Kart the whole evening, and they did not care about the slowdowns. But I did. 🙂

So long story short. I wanted to overclock this SOC and see if I could get a more smooth gameplay in the N64 console. I thought it was wierd that it was thermal throttling because its not hot at all. All my other SOM computers have been much warmer.

Said and done. At first I cloned the src from github.

git clone https://github.com/libretro/Lakka-LibreELEC

And after that run the magical make command.

PROJECT=S805 SYSTEM=MK808B-Plus ARCH=arm make image -j4

The Lakka/LibreELEC should have super cred for the amazing build scripts. Every thing worked out without any breaks which often happens in big project like this. 🙂

6 hours later the build-process was complete and we got a nice image to deploy to the target. It worked out perfect. Now was the time to experiment and see if we could get some more performance out of the Amlogic SOC.

After some researching i found out 4 files that I had to modify to overclock the S805 in the Linux kernel.

/arch/arm/boot/dts/amlogic/meson8b_mk808bplus.dtd

The device tree file contains all board specific data. Here I found the voltage regulation depending on which frequency we are using. I needed to bump the voltage a little bit to get it stable… by writing 1f instead of 1c, I get 1,17 volt instead of 1,14v. This made the trick.

	0x050017        1090000
	0x040018        1100000
	0x030019        1110000			
	0x02001a        1120000			
	0x01001b        1130000
	0x00001f        1140000

Thermal throttling values are also at this file. Before it was thermal throttling @ 70C, Sins we are going to push it, it will get warmer. So I set the the thermal barrier @ 85C.

	thermal{
		compatible = "amlogic-thermal";
		#thermal-cells=<7>;
		dev_name = "aml_thermal";
        trip_point=<85 1488001 1488001 511 511 3 2 87 1200001 1200001 435 435 2 2 90 800001 800001 328 328 1 1 260 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff 0xffffffff>;

Next file we had to edit is the arch/arm/mach-meson8b/clock.c

This file holds the PLL table so we get corresponding clock values. Here we change the max frequency limit 2088Mhz.

#define CPU_FREQ_LIMIT 2088000000

Perfect, next up is to edit the frequency scaling table. We find it here: /arch/arm/mach-meson8b/include/mach/cpufreq_table.h

Here I edited the cpufreq_frequency_table meson_freq_table so it matches the overclock I wanted.

static struct cpufreq_frequency_table meson_freq_table_fix_syspll[]=
{
    {0	,   96000   },
    {1	,  192000   },
    {2  ,  384000   },
    {3  ,  768000   },
#if 1
    {4  , 1250000   },
    {5  , 1536000   },
    {6  , 1632000   },
    {7  , 1728000   },
    {8	, 1824000   },
    {9	, 1920000   },
    {10	, 2016000   },
    {11	, 2088000   },
    {12	, CPUFREQ_TABLE_END},
#else
    {4  , 2088000   },
    {5	, CPUFREQ_TABLE_END},
...

I tried several different frequencies, but ended up running the CPU @ 2088Mhz, Pretty nice overclock if you ask me, from 1536 which was the original clock.

At last I managed to overclock the Mali GPU by editing platform_m8b.c adding support for 850Mhz mode.
@ /drivers/amlogic/gpu/mali/platform/meson_m450

struct mali_gpu_clk_item  meson_gpu_clk[]  = {
    {255,  1150},   /* 182.1 Mhz, 1150mV */
    {364,  1150},   /* 318.7 Mhz */
    {425,  1150},   /* 425 Mhz */
    {510,  1150},   /* 510 Mhz */
    {637,  1150},   /* 637.5 Mhz */
    {850,  1250},   /* 850 Mhz */

I created a script so I could monitor the frequency and the temperature.

Lakka:~ # ./monitor.sh 
Sun Jan  6 14:19:08 UTC 2019
cpu_freq: 2088000
cpu temp: 72000
gpu_freq: 637
Sun Jan  6 14:19:09 UTC 2019
cpu_freq: 2088000
cpu temp: 72000
gpu_freq: 637
Sun Jan  6 14:19:10 UTC 2019
cpu_freq: 2088000
cpu temp: 72000
gpu_freq: 637

And the script:

#!/bin/sh
while [ 1 ]; do 
date
echo "cpu_freq: `cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq`"
echo "cpu temp: `cat /sys/class/thermal/thermal_zone0/temp`"
echo "gpu_freq: `cat /sys/class/mpgpu/cur_freq`" 
sleep 1
done

After some tuning, It worked out perfectly. Mario Kart are now runnning smooth. Without slow-downs, and Super Mario 64 also works great. So the overclock made a big difference here. With the fan 50mm fan connected to 5v its running @ max 75C, stable.

If you want to try the modded kernel you can download it here including the modified source-code. Just replace your current kernel.img and kernel.img.md5 on your lakka partition. Disclamer: Your device will overheat if you dont use a fan.

Take care friends. Hope my overclock comes in handy. 😉

9 thoughts on “Overclocking a MK808B plus (Amlogic S805) to run LAKKA.

    • Yep, but the dtb is for mk808b+ so if you have a different board you will have to migrate the changes to your target.

  1. Hi, would it be possible to provide a link to your Lakka build for the MK808B?

    It seems like the latest version of Lakka 3 does not support our device and the links to the older builds no longer work.

    • Same here, it would be great Xmas gift if you could share that.
      Thanks!

  2. Hi there, I was looking for meson8b_mk808bplus.dtd and looks like it disappeared. Could you please share it on github or somewhere else?
    Many thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *