Author Archives: vonger

VoCore2: Port mt7628.ko to LuCI

This will be a long journey…
LuCI should be the most easy way to setting router.

I will study from start, try to learn how uci system works and how LuCI works with current openwrt system.

I know something about C/C++, maybe RF, PCB layout or even physics, but I am absolutely a noob of script especially bash.

Lucky me, 50% UCI system is based on shell script. 🙂 So I have a chance to learn it.

For wifi turn on or turn off, all I know is the magic command “wifi”, so what is it?

I find it actually a script, its path can be found by call “which wifi”

interface code of /sbin/wifi

case "$1" in
	down) wifi_updown "disable" "$2";;
	detect) wifi_detect_notice ;;
	config) wifi_config ;;
	status) ubus_wifi_cmd "status" "$2";;
	reload) wifi_reload "$2";;
	reload_legacy) wifi_reload_legacy "$2";;
	--help|help) usage;;
	*) ubus call network reload; wifi_updown "enable" "$2";;

After couple of hours painful decode wifi script, looks like once we call wifi, it will goto ‘*) ubus call network reload; wifi_updown “enable” “$2”;;

I reach a dead end at the beginning. What is this “ubus call network reload”? Is it an important part of uci system? I directly run it in command line, nothing happens…OK, ignore it.

PS: That’s why I hate script, you will be very hard to find what it is exactly doing.

Next it is “wifi_updown enable”. Good name, from its name I know it is able to control enable/disable wifi.

_wifi_updown() {
	for device in ${2:-$DEVICES}; do (
		config_get disabled "$device" disabled
		[ "$disabled" = "1" ] && {
			echo "'$device' is disabled"
			set disable
		config_get iftype "$device" type
		if eval "type ${1}_$iftype" 2>/dev/null >/dev/null; then
			eval "scan_$iftype '$device'"
			eval "${1}_$iftype '$device'" || echo "$device($iftype): ${1} failed"
		elif [ ! -f /lib/netifd/wireless/$ ]; then
			echo "$device($iftype): Interface type not supported"
	); done

wifi_updown() {
	[ enable = "$1" ] && {
		_wifi_updown disable "$2"
		ubus_wifi_cmd "$cmd" "$2"
	ubus_wifi_cmd "$cmd" "$2"
	_wifi_updown "$@"

$DEVICE, this should come from scan_wifi.

wifi script it will read /lib/wifi/, and once we run wifi, it will call function in, scan_mt7628/enable_mt7628/disable_mt7628 and all the parameters are from /etc/config/wireless.

To Be Continue…

VoCore2: Port mt7628.ko for Linux 4.14 Part2

I have upload source code of uictx to github:, and also mt7628 driver.
So you can make your own latest version of openwrt now.

PS: please help me do a homework 🙂

1. use it as a OpenWRT feeds, so people do not have to manually do the compile.

2. combine the api to UCI, so we can use UCI and /etc/config/wireless to control the wifi.

Feel free to submit patch.

Note: my last firmware 20180419.bin have some log like this:

[  108.175895] mmc0: error -22 whilst initialising MMC card
[  108.263953] mtk-sd 10130000.sdhci: no support for card's volts

This is because you do not have SD card hardware. We have two ways, one call “rmmod mtk_sd” in console.

Another, use this firmware :p

md5: 41fc7dfb02bd183de8a520ad146a65b8

I added shellinabox to this firmware, so you can directly access to console without using ssh or putty. Open

Or third way, compile your own firmware without mtk_sd.

Happy hacking!!

VoCore2: Port mt7628.ko to Linux4.14

Yes, I have successfully port mt7628.ko to latest openwrt based on Linux 4.14.

Here is the firmware:

md5: 547fba4379e61fefb145cef2e1c30609

This firmware can not working with uci system yet…

PS: I am still study UCI…

But I write a simple replace.
It is a cgi-bin app, can run in /www/cgi-bin or directly run in console command line.

if you want to use it as webserver, just run in your browser.

if you want to use it as command, just run uictx “f=sta_disconnect” in command line.


### ap_set_ssid

– used to set current ap ssid name.
– usage: ap_set_ssid [ssid]
– example:

### ap_set_password

– used to set current ap ssid password.
– usage: ap_set_password [password]
– example:

## Scan API

### ap_scan

– get nearby ssid, bssid, and signal strength.
– usage: ap_scan
– example:
– return: {“status”:”success”, “message”:””, “ssid1″:”KB86”, “bssid1″:”30:b4:9e:a6:99:bb”, “signal1″:”99”, “ssid2″:””, “bssid2″:”28:6c:07:cc:e7:46”, “signal2″:”18”, “ssid3″:”CX-8888”, “bssid3″:”30:c8:9e:aa:e6:2f”, “signal3″:”57”}

## Station Mode API

### sta_connect

– connect to nearby access point as client device. if everything is correct, it will alloc a ip for apcli0. MUST call ap_scan before sta_connect.
– usage:
– normal ap: sta_connect [ssid] [password]
– hidden ap: sta_connect “” [password] [bssid]
– example1:

note: in the example, “MY ROUTE” has a space, it needs to convert into url format.

– example2:

### sta_disconnect

– disconnect from connected access point, you will immediatily disconnect from your router and vocore will back to ap mode.
– usage: sta_disconnect
– example:

Source code I will upload to github soon.


PS: do not forget setting up the network first.

uci add_list firewall.@zone[1].network="wwan"
uci set network.wan=interface
uci set network.wan.ifname=eth0.2
uci set network.wan.force_link=1
uci set network.wan.proto=dhcp
uci set network.wwan=interface
uci set network.wwan.ifname=apcli0
uci set network.wwan.proto=dhcp
uci commit

VoCore2 + DOOM Port

I spend around 10 hours finish this, looks like it is pretty easy to port exists project to using VoCore2 display.

First checkout source code from, thanks for its contributor jeffdoggett, other DOOM source code I can not even compile 🙂

Only need to change one file /Doom/Source/i_video.c

//	DOOM graphics stuff for VoCore2 Display, OpenWrt.
//  based on i_video.c.

#include "includes.h"
#include "libvodisp.h"

unsigned int SCREENWIDTH = 320;
unsigned int SCREENHEIGHT = 200;
unsigned int ORIGSCREENWIDTH = 320;
unsigned int ORIGSCREENHEIGHT = 200;

union pixel {
    struct _rgb {
        unsigned char red;
        unsigned char green;
        unsigned char blue;
    unsigned int full:24;
static union pixel palette_table[256];
static byte *framebuffer;

void I_InitGraphics (void)
    framebuffer = malloc(800 * 480 * 3);
    memset(framebuffer, 0, 800 * 480 * 3);


void I_ShutdownGraphics(void)

void I_SetPalette (byte* palette)
    unsigned int colour = 0;
    do {
        palette_table[colour]   = gammatable[usegamma][*palette++];
        palette_table[colour] = gammatable[usegamma][*palette++];
        palette_table[colour]  = gammatable[usegamma][*palette++];
    } while (++colour < 256);

void I_FinishUpdate (void)
    byte *src = screens[0], *dst = framebuffer;
    int i, j, pos;

    for (j = 0; j < SCREENHEIGHT; j++) {
        pos = j * 480 * 3;
        for (i = 0; i < SCREENWIDTH; i++)
            *(unsigned int *)(dst + pos + i * 3) = palette_table[*src++].full;


void I_ReadScreen (byte* scr)
    memcpy(scr, screens[0], SCREENWIDTH * SCREENHEIGHT);

void I_InitKeyboard (void)

void I_UpdateNoBlit (void)

void I_SetScreenSize (void)

void I_SetWindowName (const char * title)

void I_StartFrame (void)

void I_StartTic (void)

Here is necessary library and Makefile, you might need to modify.

Download:, uncompress and put it in /Doom/Source then compile.

VoCore2: UI Library 4

I want to make the display support SDL so we can play a lot of games and make app based on SDL2.

PS: I love DOS games 🙂

SDL2 supports directFB which is not maintained anymore.
So I am consider to write a video driver for my display.

In SDL source code, SDL_DirectFB_video.c, we can get every interface:

    /* Set the function pointers */
    device->VideoInit = DirectFB_VideoInit;
    device->VideoQuit = DirectFB_VideoQuit;
    device->GetDisplayModes = DirectFB_GetDisplayModes;
    device->SetDisplayMode = DirectFB_SetDisplayMode;
    device->PumpEvents = DirectFB_PumpEventsWindow;
    device->CreateSDLWindow = DirectFB_CreateWindow;
    device->CreateSDLWindowFrom = DirectFB_CreateWindowFrom;
    device->SetWindowTitle = DirectFB_SetWindowTitle;
    device->SetWindowIcon = DirectFB_SetWindowIcon;
    device->SetWindowPosition = DirectFB_SetWindowPosition;
    device->SetWindowSize = DirectFB_SetWindowSize;
    device->SetWindowOpacity = DirectFB_SetWindowOpacity;
    device->ShowWindow = DirectFB_ShowWindow;
    device->HideWindow = DirectFB_HideWindow;
    device->RaiseWindow = DirectFB_RaiseWindow;
    device->MaximizeWindow = DirectFB_MaximizeWindow;
    device->MinimizeWindow = DirectFB_MinimizeWindow;
    device->RestoreWindow = DirectFB_RestoreWindow;
    device->SetWindowGrab = DirectFB_SetWindowGrab;
    device->DestroyWindow = DirectFB_DestroyWindow;
    device->GetWindowWMInfo = DirectFB_GetWindowWMInfo;

    /* !!! FIXME: implement SetWindowBordered */

    device->GL_LoadLibrary = DirectFB_GL_LoadLibrary;
    device->GL_GetProcAddress = DirectFB_GL_GetProcAddress;
    device->GL_MakeCurrent = DirectFB_GL_MakeCurrent;

    device->GL_CreateContext = DirectFB_GL_CreateContext;
    device->GL_SetSwapInterval = DirectFB_GL_SetSwapInterval;
    device->GL_GetSwapInterval = DirectFB_GL_GetSwapInterval;
    device->GL_SwapWindow = DirectFB_GL_SwapWindow;
    device->GL_DeleteContext = DirectFB_GL_DeleteContext;


    /* Shaped window support */
    device->shape_driver.CreateShaper = DirectFB_CreateShaper;
    device->shape_driver.SetWindowShape = DirectFB_SetWindowShape;
    device->shape_driver.ResizeWindowShape = DirectFB_ResizeWindowShape;

    device->free = DirectFB_DeleteDevice;

Of course, I do not think VoCore2 can run OpenGL, because it do not have any video hardware, ignore that.

PS: mesa3d has a software mode but it must be very slow. 🙂

To be simple, we do not need shaped window support either…

OK, rest interfaces for windows look like necessary, every video driver has them.
So they are VideoInit/Quit, Get/SetDisplayModes, CreateSDLWindow/From, SetWindowTitle/Icon/Position/Size, Show/Hide/Raise/Maximize/Minimize/Restore/DestroyWindow.

But it still need to code a lot…
I find most of the interfaces are empty in its psp video driver, maybe there is a way to make everything simple.

Any good idea?


VoCore2: 5 ethernet + SD card

Currently default pinmux is one ethernet port + sdcard + i2s + i2c + refclk + many gpio.
Actually there is a hidden pinmux in mt7628 chip, we can use ethernet x 5 + sdcard without i2c/i2s.

Very interesting, this pinmux works well on VoCore2 but do not have any clue in datasheet.
We need to remove i2c pull up resistor to make it work normal.

Its pin order:


but also need to update driver to make it work. 🙂

VoCore2: Production Lifetime

Today, support get an interesting question, how long is the VoCore lifetime?
I think this is an important question for the people want to use VoCore2 as part of their production.

As we promised, VoCore2 life is not end until the chip stop production. Mainly VoCore2 have three chips, one DDR2, one CPU, one NOR flash, DDR2 and NOR flash are widely used in many area, so we can think it will keep production forever. The only problem is CPU.

VoCore first version is using RT5350F which is almost stop production by mediatek/ralink. I said ‘almost’, because we still able to buy it from MTK(not recycle chip, the new one). The only problem is its price is increased a lot, almost double of MT7628.

Chip companies such as mediatek will not allow their chips suddenly death, that is not good for themselves and not good for their loyal clients. Normally mediatek will increase the chip price month by month if they decide to end one production. One day, the old chip price will be higher than the new one, so why pay much to use old slow one but not the new fast low power consume one? At that time people will start to upgrade their production. For RT5350, this process is over three years.

Actually VoCore old version is still in production, but price is much higher than the one based on MT7628. When RT5350F price is same as MT7628, I removed VoCore from site, because MTK is giving a clear signal: we are going to stop, do not use it anymore.

MT7628 is coming around four years, it still have over 10 years lifetime, so no need to worry about VoCore2 🙂
note: MTK is not stupid, why stop a cash cow? unless nobody use it already.:)

VoCore2: UI library 2…

I find many good library.

Actually directFB is an good choose but currently it can not compile at all.

First is the one from China, named GuiLite, it has everything I need and its code is really simple, performance is good.

Second is littlevgl, very good interface and light weight.

Third is uGFX, also light weight but not totally free, for test and study it is free.

4th, μGUI, it is too light weight for VoCore2 🙂

I like C better than C++, so I’d like to choose one from littlevgl & uGFX if no better find.