Building RePhone applications with Eclipse on Linux

There was some questions about developing RePhone application on Linux.
I have prepared the complete guide how to prepare Rephone, Linux distro and Eclipse for app development.
It was tested on Ubuntu 15.10 & 16.04 (64bit), but can be easily adapted for other releases/distributions.

You can use my GitHub repository which contains SDK, tools and configured Eclipse projects for https-demo, Lua and JS.
The projects builds in Eclipse without any problem and runs on Rephone.

Rephone mass storage is available in Ubuntu when rephone is booted in mass storage mode.
Serial interface to application is available on /dev/ttyACM0
Serial interface to MK2502 modem (AT Commands) is available on /dev/ttyACM1

You can download the installation guide for detailed instructions.

Still not clear how to debug the code. Do you have something instead of MTK Monitor? I see printf() in your code, does it print directly to serial USB port?
PS: Are yout sure the firmware you uploaded is correct? I still see MTK Monitor-related messages, the AT command port works, too. So I found no changes respect to original FW.

Yes, printf prints to serial usb port (/dev/ACM0).
For debuging you can use vm_log_*** functions, just redefine them in include/vmlog.h like this:

//#define vm_log_fatal(...) if(_vm_log_module(__FILE__, __LINE__)) _vm_log_fatal(__VA_ARGS__) #define vm_log_fatal(...) printf("[FATAL] %s:%d %s\n",__FILE__,__LINE__,__VA_ARGS__) //#define vm_log_error(...) if(_vm_log_module(__FILE__, __LINE__)) _vm_log_error(__VA_ARGS__) #define vm_log_error(...) printf("[ERROR] %s:%d %s\n",__FILE__,__LINE__,__VA_ARGS__) //#define vm_log_warn(...) if(_vm_log_module(__FILE__, __LINE__)) _vm_log_warn(__VA_ARGS__) #define vm_log_warn(...) printf("[WARNING] %s:%d %s\n",__FILE__,__LINE__,__VA_ARGS__) //#define vm_log_debug(...) if(_vm_log_module(__FILE__, __LINE__)) _vm_log_debug(__VA_ARGS__) #define vm_log_debug(...) printf("[DEBUG] %s:%d %s\n",__FILE__,__LINE__,__VA_ARGS__) You must also include stdio.h in include/vmlog.h

#include <stdio.h> For release version, you can disable logging defining LINKIT_RELEASE

#define __LINKIT_RELEASE__

I think there is not much need for MTK Monitor.

I think the uploaded firmware is the right one. (It is from Rephone Arduino package if I remember well).
AT Command port always work (on /dev/ACM1).
You shouldn’t get any output in MTK Monitor. Under Windows in MTK Monitor you should get something like this:

0 NA NA NA NA Get PS Frame failed (0x8) 1 NA NA NA NA Get PS Frame failed (0x8) 2 NA NA NA NA Get PS Frame failed (0x8) (MTK Monitor listens on what is now AT commands interface)

Thanks for you answer. Have you seen this project LinkIt_Assist_2502 ? (sorry cannot place URL, forum’s engine blocks it) I’m using it to start developing on Linux. Particulary, I found interesting Python scripts, like for captuirng data from debug serial port and to send vxp to board’s internal memory (and to reset it). The uploader works well for me, it uses AT-coomand and opens port /dev/ttyACM0, so I suppose this is what you called “AT Command port”. opens /dev/ttyACM1 and tryes to catch messages sent by vm_log_debug() and etc calls (often misses them and this is my main concern). But your manual states:
/dev/ttyACM0 the application usb serial port interface
/dev/ttyACM1 MT2502 modem interface (AT Commands)
Probably just port enumeration issue, so I moved forward, built and uploaded Https-demo, trying to catch something on /dev/ttyACM0 using “screen /dev/ttyACM0” but nothing, then opened /dev/ttyACM1 and got parmanently changing garbage.
Am I doing something wrong?

Probably I understood your idea, which resides in retarget.c. It opens usb serial port 1 and overrides get/put symbols. And it’s expeceted that port 1 is free and can be opened. According to the guide “The purpose of that flashing is to disable the MT2502 debug output”. That’s probably a reson why it doesn’t work: the debug port is not disabled even after flashing…

There are 2 versions of the firmware.

Both versions have one USB serial port dedicated to AT Command interface.

The 1st version has one USB serial port dedicated to debug output (for MTK monitor) and this port cannot be used in application. If you want the serial communication with application you have to use UART. It doesn’t make much sense to use it under Linux as we don’t have MTK monitor for Linux anyway.

The 2nd version has debug output disabled, and the USB serial port can be used for communicating with the application (initiated in retarget.c)

uart_handle = vm_dcl_open(VM_DCL_SIO_USB_PORT1, g_owner_id); .... vm_dcl_control(uart_handle, VM_DCL_SIO_COMMAND_SET_DCB_CONFIG, (void *)&settings);
I’m using the second version for couple of weeks, and it works as expected.

I’m not sure which version I’ve uploaded to GitHub, maybe it is the 1st one, I’ll check it tomorrow.

You can use serial uploader, but it is much more simpler to just mount internal Rephone drive and transfer the files to/from it …

Wow, I didn’t know about two different FW versions! Uploaded by you is definitely with enabled debug. I took another from Arduino for Windows distribution, programmed https application and got serial output as expected. Thank you, Boris!


I used your github repo to make the lua.vxp and it worked great. Oddly I noticed that the github repo mentioned in the rephone wiki doesn’t seem to work. I looked at the diff between the two and it seems pretty significant. Where did your Lua directory contents come from? Some version of Linkit Assist 2502 before there was Linkit One? I think so. Would be nice to know, track the changes, and push fixes upstream to the main seeed studio . That’s what I am going to try and do… FWIW.

Thanks for


All the changes and additions to Lua in my GitHub repository are mine.

Seed studio’s Lua implementation is very limited (more or less just enough to prove that it can work).
I’m working hard on making the Rephone Lua more complete. Many improvements and additions are made from the last GitHub commit, they will be committed soon.

os and debug modules and coroutines are supported, many improvements to gpio (support for all rephone gpio’s), tcp, https (full support for post method, including file transfer), sensor module (DS1820, DHT11/22,…), memory and heap management improvements, watchdog, shell on USB or UART, scheduled shut down/wake up, NTP support, struct module added, json module … and many more.

When ready, I’ll post the information and the complete documentation for added functions/functionality on this forum.

Very Cool. Thanks so much for all your work!

In addition to the packages mentioned in the instructions I needed to also install the packet libnewlib-arm-none-eabi (on Linux Mint)
Otherwise seems to work great, thank you