Posts Tagged ‘tutorial’

How to Write ESP8266 Firmware from Scratch (using ESP Bare Metal SDK and C Language)

October 7th, 2016 8 comments

CNXSoft: This is a guest post by Alexander Alashkin, software engineer in Cesanta, working on Mongoose Embedded Web Server.

Espressif’s ESP8266 had quite an evolution. Some may even call it controversial. It all started with ESP8266 being a WiFi module with a basic UART interface. But later it became clear that it’s powerful enough for embedded system. It’s essentially a module that can be used for running full-fledged applications.


Espressif realized this as well and released an SDK. As first versions go, it was full of bugs but since has become significantly better. Another SDK was released which offered FreeRTOS ported to ESP. Here, I want to talk about the non-OS version. Of course, there are third-party firmwares which offer support for script language to simplify development (just Google for these), but ESP8266 is still a microchip (emphasis on MICRO) and using script language might be overkill. So what we are going to come back to is the ESP SDK and bare C. You’ll be surprised, it’s easier than it looks!

First steps

To develop firmware you’ll need:

  1. ESP8266 connected to your computer via USB.
    There are a lot of articles how to connect an ESP to a computer. You will need several Dupont cables and a UART-to-USB adapter. If you have a Arduino board you can use it as UART-to-USB. Google “connect esp8266 to computer” – there are a lot of articles about this.
  1. SDK.  I suggest using this one:

Download it and follow its readme to build. There is nothing extraordinary in this process, all you need is to install prerequisites and invoke “make”.

In general, this SDK is intended for *nix systems, but there is a port for Windows as well.

In short, to start development you should have an ESP device available as /dev/ttyUSB0 (/dev/ttyACM0 if you use Arduino or COMn in Windows) and the SDK installed in a certain path.


In C int main() is an entry point to a program. But, in the case of ESP the entry point is void user_init(). This function must be used only for initialization, not for long-running logic.

Here an example:

Note, that all we do in user_init is calling the system_init_done_cb API function. This function accepts one parameter, which is a pointer to function which will be called once all system modules will be properly initialized. You can put your initialization code in user_init too, but you can face problems with some system function (like WiFi), just because appropriate modules aren’t initialized yet. Thus, it is better to use system_init_done_cb and perform initialization in the callback function.

Beware of the dog

ESP8266 has a watchdog functionality. And there is NO documented API to control it (there is some undocumented stuff, but out of scope for this tutorial). Its timeout is 1 second.

What does that mean? It means, that you have to return the control flow to system every second, otherwise the device will be rebooted. This code leads to the device reboot:

In general, watchdog is not evil, it helps if the program hangs. And, 1 second is not so small as it sounds. Just keep this fact in mind.

Doing something

Taking what we learned about the watchdog into account, we face an obvious question: where can I run my tasks?

The simplest answer is in timers. The timer API is very simple in ESP.

If the last parameter of the os_time_arm function is 0, the timer callback will be invoked only once. If it’s 1, it will be called repeatedly until the os_timer_disarm is called.

And, finally, we have a place to put our code: The start_timer_cb function.

Our task here is to make an LED blink. Some ESP boards have an LED attached to GPIO16, if your board doesn’t have it, you can attach an LED to any free GPIO.

As you remember start_timer_cb is a timer callback function, and it is called every 5 seconds. On first call on variable is 0 and we set GPIO16 to high – as result LED will be turned on. On second call we set GPIO16 to low – and LED is turned off. And so on and so on.

Building the project

Now it is time to build our project. Let’s say, we have only one source file – main.c. I cannot recommend using makefiles which are used for building examples. They are too complicated and a bit weird. So, I’d suggest to write your own (simple!) makefile.

Here are steps:

  1. Compile main.c to main.o.
    Use xtensa-lx106-elf-gcc compiler which is a part of esp-open-sdk.
  2. Link project.
    Linker to use – the same xtensa-lx106-elf-gcc. Libraries to link with are: c gcc hal m pp phy net80211 wpa main

Also, you need to supply the linker script (.ld file). Choose one from esp-open-sdk that matches the flash size of your device. After this step you’ll have .elf file.

  1. Convert .elf file to .bin

For this, use script from esp-open-sdk. Run it like this:

If everything is ok, you should have 3 files in <output dir> with names like 0x00000.bin, 0x11000.bin 0x66000.bin.


The final step is to put our firmware onto the device. For this we will use the esptool again, but now we should use write_flash option. Like this:

You should use real filenames from the previous step. And, if everything is still OK, the LED attached to the device will start to blink every 5 seconds.

Next steps

Writing the firmware for any device is a huge topic. Working with ESP8266 is no exception. So, the purpose of this article is only to highlight the direction. There are a lot of different APIs in the ESP8266 SDK: WiFi, GPIO, TCP/UDP and more. Make sure to check out the documentation fully here. It’s also good to check out the examples by firmware providers and esp-open-sdk. If you want to start with an example, check out this one which goes through running Mongoose Embedded Web Server on ESP8266.

Xtream Codes IPTV Panel Review – Part 2: Movie Data Editing, Security, Resellers, Users and Pricing Management

October 4th, 2016 1 comment

Dear readers, after part 1 of Xtream Codes Panel v.2.2.0 EVO review, here is part 2. I tried hard to get all in two parts, but “to be exhaustive” there will also have to be a part 3…

Movie Editing Section


As we can see, it’s only possible to assign a movie into a single category, a SELECT BOUQUET Option under the Category would be more then useful. So while Movie Editor Section is useful right now, it still needs improvement.

Also taking each movie by hand for editing, after, for example, a Main server crash or changing the Main, is really something, a waste of time. Some of the issues / possible improvements include:

  • No mass edit of movies to bouquets
  • If changing the category of a movie, I found no working method to change in a bulk.. Even if I tried to delete the “content” of a bouquet, it was denied.
  • Left Hand Section, Mass Edit Streams allows only live streams to be edited.
  • Stream Tools! To be able to delete the falsely assigned movies. With the result of the complete addition process later on, and the transcoding process has to be repeated all over again…
  • I strongly advice customers/user’s of the Xtream Codes Panel to name their movies in a kind of unique, retrievable way later on. If not, and if you try to sort them later by assigning them in to a bouquets, you stand in front of all the movies, the way you loaded them up. No kind of Movie editing (re-naming) possible, before you load them to transcode. The mass edit movie section is simply missing.
  • This great piece of Software NEEDS A MOVIE EDITING SECTOR

The options available right now:xtream-codes-movie-editing-options


  • Manage Categories has to be more specific to meet the needs of the customer.
  • Right now I was not able to really sort the categories to my preferred sequences. Did I miss here options? I couldn’t find it.
  • Edit Category function is limited to change the name only.


  • Again, if you have already tons of movies assigned to a category there’s no other way to assign them in a bulk right now. A time waster.

General Warnings

To be on the safe side, do not fill your HDD up to the limit. Max 70% should give more stability.

Attention: If you rent a dedicated server, seeing the offer for example, let’s say 2x 2TB, you should know that after a normal install, you’ll only get 2TB. That is because one is mirrored, in case you loose the first partition, it would be fatal, right?

So, better let it this way, do not use the whole size. Agreed?

Having issues with reconnecting interrupted streams, I filled Xtream Codes panel with over 200 streams, and around 500 movies. I checked the stopped streams, and most connected again after manually pressing the “start/restart stream” button. But these are rare cases only, overall I must say the platform is absolutely stable.

I found a few times the ‘Guilty-ONE” for this: It was not Xtream Codes Panel, it was the miserable Streams I got from a friend for testing purposes.

Security settings (Fight the Intruders by blocking them)

Handle this setting carefully! Especially if you give a trial List to a customer, he will zapp through the channels quickly, or VLC crash often, how we all know..

Wrong or too hard settings will block him immediately.

A good setting should be as follows:

  1. General Settings->Security Settings->Flood Limit to 6 or 8
  2. Request Frequency in Seconds to 1.

Security Settings Section

Back to the Security “plugins”

xtream-codes-security-pluginsBLOCK IP/CIDR


We see the IP’s or better, the intruders (hint: After you set-up the Flood Limits in General-Security/Settings)

Here we go, nice to look at… but why not show directly the “customer by name with IP”?. In the end, we have to make the decision whether to unlock the IP or keep him locked. It’s only working if a server with a fixed IP started the attack, dynamic IP’s appear soon then if the IP changed.

And in case no internal customer, let’s say a simple “from outside” or no customer would be a great help. Going through the log files  to find out if it us a customer or instead a competitor trying to slow down your server (we are all nosy, aren’t we?) makes no sense and no fun. Reason: time extensive if dozens or hundreds of logs!

Live Streams-Video on Demand Section

Manage Stream/Add New Stream

xtream-codes-live-streams-vodThere is also one relatively “unique” function; you should handle with care, or best ask the seller of the LEGITIMATE streams, if he allows that you use the “Use Direct Source & don’t restream it”. This means all coming traffics are not on your side, the connected server takes it all. You should be able to see the other side. But I guess you know already.

You can also redirect the Stream to the Original Source, so that your customers connect through your own DNS. Doing so, setting to yes, your URL will show up in the Bouquet List later. But again, be aware, choosing NO, your user will not connect to your server in any case. I tested it by letting the user connect over my DNS. I thought, I would see any client connecting through my DNS, but you will not, in both cases. No matter Client Connection Logs or in Manage Lines, he is simply invisible to you. I guess, after all not the smartest idea.


Security Section

General settings->Security Settings


Useful if you find the “right” setting. The Flood Limit shows the number of requests specified in “Request Frequency”. I started with 5 requests within 3 seconds, result: I got blocked myself and no idea why. I just watched one channel, no fast channel switching, no nothing. This seems to getting interesting, I thought.

Switched to 8 requests in 3 seconds range. Activated my test users… Result: 2 Android boxes getting blocked.

Mhhhh, I go deeper in this then after, and because of English is not my native language, haha, we “none-english” have sometimes a problem to understand the language. And…I found it! My mistake! Definitely to 90% only, haha! And 10% I give to Xtream Codes back, because they should really be more specific about this classy feature, which is highly useful!

Advice: Give 3 options, or 4, the ordinary customer can use! Like: LOW-Standard-HIGH-HYPER Settings, pre-configured! (Also the option for manual settings).

I know I know…but remember this: Many customers are not common with these terms; they simply do mistakes resulting in blocking customers who do nothing wrong at all, which could lead to losing customers.

Standard should be: 10:1, or 20:1 ((flood limit:request frequency), but hard to say for sure in my opinion. And even this could maybe cause some troubles, if a nervous user zapping the channel’s in a lightspeed and the playlist is huge…

For example: Each zapping under 1 second is 1 evil request, collected and memorized by the panel! 10:1  means, 10 times under 1 second is OK, but then… the 11th try would blocked them! This is a hard decision to make for each panel user, if he has a huge playlist with many customers. Some customers could complain, if they get blocked, and I don’t want to talk about the non-stop checking the Security Settings, and look for blocked IPs.

Recommendation: Invest in a DDOS Protection with your server, every hosting provider is offering this. Also let this setting to OFF (0) in the beginning, and get used to everything first. You can then implement the settings you are comfortable with lateron.

Resellers – Registered Users Section


Reseller Section

Registered Users and Reseller

When I started to work with the panel and getting used to it, this was the first category I started with. I expected something like: REGISTER RESELLER, or similar. Registered means already already registered, right?

Let’s start with “Register New User”. This feature is mainly used, to create a new RESELLER of yours, a now you want to give him access to a reseller panel. Let’s create one!


As we can see, you have to provide the follwing details for the new user (reseller in this case):

  • Username (Whatever you want to call the reseller)
  • Password (Please 6 digits minimum, out of security reasons, phrases are also useful)
  • E-Mail (Email address of your reseller, without one you can not create a new reseller)
  • Default Language (right now only English is possible)
  • Group Members (see the next Section, Group Members)
  • Reseller DNS (Reseller Only) – Here you can specify the reseller’s own DNSs
  • Credits (reseller Only) – The amount of money the Reseller payed you, usual is 1 credit = 1 UK pound or other currencies)

Section Manage Group Members

First of all, a little explanation here on this important part. As we’ve already seen above, we can “register” a new user, reseller in this case with “REGISTER NEW USER” option (I would rather see a “Create new Reseller” button). But here is the point: If you register a new future reseller, you have to assign the payment formalities later (ex: 300 Euro = 300Credits), but also how much for 1 month, 3 months or any other kind of subscription (time frame), and the reseller can create lines for his own customers later, and see his own costs each time.

Assigning them (the resellers) all in one category, named reseller, let you later no choice to give different kind of subscription prices. (ex: Reseller A 1 month =6 Euro, Reseller B 1 month 8 Euro), so that’s why Xtream Codes has a great feature in creating groups.

You can simply create a new “group”, let’s say Group elcap in my case, and assign reseller A to it. Now your Reseller A is a Group Member of “elcap” group. Next step, you want to give him prices and time frames of each line he creates.


As you can see, I created the trials , 1 month, 3 months, 6 months and 12 months, and also a VOD package for the reseller part of group elcap.

You start with Resellers -> New Package (Adds a new Package)

xtream-codes-resellersWe see the following options after clicking on New Package:xtream-codes-resellers-new-package-1


You first need to name the package, mark it as Trial or Official Package (1-12 month or else later, you are free in your decision), you can even pair the line with the ISP provider of your client by first connection. (Attn.: need additional plugin to buy).

Useful only if you create a Package for a RESTREAMER (Restreamers are able to put your bouquets/packages on their server(s) and use them as there own streams), as they have a fixed IP in any case.

In this example we give 20 connections to a Restreamer


Meaning: You can give your whole LEGITIMATE stream list, or assorted ones, like a bouquet you filled with specific streams before. In any case, your Restreamer you are selling to, is only able to open 20 connections on his server. The amount of connections you assign to him is what he pays for.

Settings Prices with Manage Packages


Edit a packagextream-codes-resellers-edit-package


A complete option to edit your before assigned package (Manage Package->Edit Package).

Here’s the output of my own created packages Create them for your own needs, everything is possible!


Manage ROOT (Registered Users)


By clicking on Manage Root you get the following options:


Here you can change your ROOT username/password given by Xtream Codes for your panel.

You can change both passwords here later, if you do not wish to use the old ones once given from Xtream Codes after you ordered and paid for your panel. Handle this carefully, write it down and copy it to safe locations, just in case of a crash of the main server (see upcoming part 3, with simulated crash of the Main server)

I initially planned to finish this review into two parts, but there are so many options, I have to do at least one more part.

I also have to repeat Options and Features for better understanding later on. See you guys on Part 3 soon, which should include:

  1. Changing the Main Server (through my extended kind of tests, I worked a couple of days on this, and the results should benefit all of us who are using this software and working with it.)
  2. Finishing the features for good, I promise
  3. The “Have’s” and the “Have Not’s
  4. Enumerations of the Top 5 settings to use
  5. Results after a new installation (Simulated Crash of the Main Server)
  6. The Pro’s & the contra’s
  7. The Competitors of Xtreme-Codes Panel
  8. Be aware of some kind of hosting services (Strange experiences with 2 “Big Ones”! Troubleshootings)
  9. The Conclusion
  10. Preparing a little Manual (PDF format, to help you guys)

[Update: During finishing my work on the huge Part 3 of the Review Xtream Codes Panel Version.2.2.0 EVO, there was yesterday, 08th October, an update to Version 2.3.0 EV0, with a lot of new Features and Improvements!

So, I will need a little longer to finish the Part 3, please stay tuned.]

How to check HTTP Header and Connection Stats from the Command Line

October 3rd, 2016 1 comment

A few days ago, I discussed with somebody whether a file was cached by Cloudflare or not, and this involved getting the HTTP header, and checking for CF-RAY field to see if data is going through one of Cloudflare data centers. This can be done with curl:

In the command above, -s stands for silent so that curl does not show the progress meter, -v stands for verbose to show the header, and -o /dev/null is used to discard the packet load.

You can also use -I option (fetch the HTTP-header only) with curl, which – if all you need is the HTTP header – provides a cleaner output:

I also came across httpstat Python script recently via n0where, doing much of the same thing, except it also adds transfer statistics.
It can be installed by downloading, or better using pip:

Let’s try it with this very blog:

The header is the same as with Curl -I, and for good reason, since httpstat relies on curl, and all curl options (except for -w, -D, -o, -s, -S) can be used with the command line. This script can be useful if you are trying to benchmark and lower TTFB (Time To First Byte), or decrease overall download times from your server.


How to Download YouTube 4K Videos with Youtube-dl Script

September 20th, 2016 7 comments

Many Android devices can now support 4K VP9 and/or H.264 video decoding, but for some reasons, Google only serves 4K videos to devices running Android TV OS, as opposed to just Android, with the latter limited to 1080p videos. If for some reasons you want to watch a YouTube 4K video on a capable device, you could download it with youtube-dl script written in Python, and available for Linux, Windows, and Mac OS.

youtube-4k-video-downloadI’ve been using the script for a while to download various video or audio files from YouTube, and other website, but for the purpose of this post, I made sure to update it to the latest version:

If you have already installed the script, it can also be updated with:

I’ll use one of the most popular 4K videos on YouTube as example, namely: COSTA RICA IN 4K 60fps (ULTRA HD) w/ Freefly Movi.

The first task is to list the video’s supported formats:

So we can see there are lots of different formats for a given video with different resolution, container formats, and bitrates. You have to find the lines you want and select the corresponding “format code” in the first column to download the video and audio. I’ll select 313 for video and let the script select the best audio format:

The “+” sign is used to merge video and audio. If you don’t add an option for audio, only the video without audio will be downloaded. You can also run “youtube-dl URL” without options, and it should download the video with both “best audio and video”, but you don’t have full control over the exact format of the video.

Youtube-hd script has many others options, include support for YouTube playlist downloads so it’s a very useful script.

Categories: Linux, Testing Tags: 4k, how-to, tutorial, youtube

Receive Android SMS & Call Notifications in Ubuntu 16.04 with KDE Connect (or Not?)

September 15th, 2016 11 comments

I often miss calls, and I may be slow to answer SMS on my Android phone, but I’m often in front of my computer, so I decided to look for solutions to show SMS and call notifications on my computer running Ubuntu 16.04. I first found LinConnect, but it does not seem to be developed anymore, and after some more research I discovered that KDE Connect should do the job. The developer just released KDE Connect 1.0 a few weeks ago with add encryption, the ability to reply to SMS from your computer and more… One person posted instructions for Kubuntu 16.04. There’s just a problem it won’t work with Unity desktop, only KDE Plasma, due to a lack of support for Qt 5.6.

You can still use the older version without encryption and other new features by “simply” running:

However the installation failed for me:

An “apt install -f” did not help, so I uninstalled kde-l10n-th package:

Ran “sudo apt install -f”, and the installation went through. It’s possible it’s an error specific to Thai language only. I’m unclear whether the bug is due to that package, or KDE Connect.

Now you can install KDE Connect Android app on your phone, and start KDE Connect Settings on your computer and enable the server in order to pair your phone.

Click to Enlarge

KDE Connect Settings (Ubuntu) – Click to Enlarge


I could connect to the server, and set notifications for apps. You can also set several options in KDE Connect in Ubuntu 16.04, and the program seems quite powerful.

Click to Enlarge

Click to Enlarge

Sadly, I only manage to get a notification once in the top right corner for an upcoming call (I was not fast enough for a screenshot), and after it I did work anymore. You can also open KDE Connect Monitor to have a look at notifications, but in the case of calls it will only show you the missed called, not when the call starts. The Blue button on the top right is used to make your phone ring in case you can’t find it.

android-smartphone-notifications-ubuntu-computerIt’s not really ideal, so I decided to go ahead and install the latest version.

The first step is to install the Kubuntu backport.

Sadly I canceled it, because I went through many dependencies errors during installation, maybe I did something wrong.

In case it works, you can use the PPA for Kubuntu 16.04 / 16.10, and install KDE Connect 1.0:

Overall, this was a time consuming experience, and KDE Connect did not work reliably for me. Any tips are welcomed.

Explore M3 Board based on NXP LPC1768 Cortex M3 MCU Comes with Lots of Tutorials (Crowdfunding)

September 12th, 2016 No comments

Explore M3 is an ARM Cortex M3 development board powered by a micro USB port, with plenty of I/Os, Arduino compatible, and the developers have also written many tutorials to help people getting started as fast and easily as possible. A starter kit with cables and sensors is also available with the board.



  • MCU – NXP LPC1768 ARM Cortex M3 @ up to 100MHz with 512KB flash, 64KB RAM,
  • USB – 1x micro USB 2.0 OTG port for programming and power
  • Expansion Headers – 2x 20-pin male headers + 8-pin unpopulated header with 38x GPIOs, 4x UARTs, 2x CAN, 2x SPI, 2x I2C, 6x PWM, 5x ADC, 1x DAC, 2x interrupt pins, I2S audio, and power signal
  • Debugging – JTAG/SWD Debug connector
  • Misc – USB boot and reset buttons
  • Dimensions – 55mm x 25mm

The hardware is somewhat similar to mbed LPC1768 board but with a few more I/Os. The breadboard friendly board can be programmed with the Arduino IDE, but you can also go “bare metal” using ARM-GCC and Ellipse, or other tool chains like Keil or Co-IDE. Alternatively, the board also support FreeRTOS real-time OS. You can find close to 50 tutorials for all three programming options on ExplorerEmbedded Wiki, and some source code is also available on Github.

explore-m3-pinoutExplorer M3 developers are now raising funds via CrowdSupply to help reducing price for mass production. A $19 pledge should get your the board, but for bare metal programming you may want to add $20 for SODA SWD debug adapter, if you don’t already have your own programmer, and the starter kit goes for $49 with various other accessories. Shipping is free, and delivery is planned for mid November.

Getting Started with B&T RTL-00 RTL8710 Module – Serial Console, AT Commands, and ESP8266 Pin-to-Pin Compatibility

August 18th, 2016 13 comments

The announcement of the ultra-low cost ARM based Realtek RTL8710 WiFi modules for IoT applications generated quite a lot of buzz since they can potentially compete with the popular ESP8266 modules. The main problem at the time was documentation and software support, but after some searches we could find that RTL8710 was part of Realtek Ameba family, and found some documents and an SDK for RTL8710/RTL8711/RTL8195. ICStation also kindly provided one B&T RTL-00 module for review, which costs $3.55 shipped per unit, and as low as $2.85 if you purchase 10 or more.

Click to Enlarge

Click to Enlarge

Click to Enlarge

Click to Enlarge

The question here is how to get started? The answer can be found in page 8 of the Chinese datasheet for the module with GB0 and GB1 pins used for Tx and Rx to access the serial console. Time for some soldering…


For the first test, we’ll just need Tx (GB1), Rx (GB0), GND and 3.3V, and cut breadboard wires to give me the flexibility to use it with a breadboard just in case.


Now you need to connect the module to a USB to TTL debug board with all four pins connected since it will also provide power.

Click to Enlarge

Click to Enlarge

Insert the debug board into a USB port of your computer, and setup a serial connection @ 38400 8N1 using minicom, screen, putty, or other serial capable app. I struggled to get the full boot, until I found ATSR command would reboot the board:

If you type help you’ll see some AT commands:

You can find the full AT command set in RTL8710 forums, and somehow it differs from the AT command set found in AN0025 Realtek at command.pdf application note available in Ameba Standard SDK.

Time to have some fun by trying to connect the board to my WiFi router:

Success, and that was easy. Now AP mode….

ATPA needs four arguments with ESSID,password (8 to 64 characters), channel, and hidden or not (1 or 0). I could not find the new access point with my phone, connected to it and typed the password. The serial console outputted it.

The command ATW? will return lots of info about WiFi status:

I’ll complete those little tests by enabling the web server in the board:

You can now connect to the web interface to configure the access point.

Click to Enlarge

Click to Enlarge

AT commands are all good, and you can configure WiFi, UDP/TCP servers, and even OTA firmware update, but there’s nothing about controlling GPIOs there… So that will be something to look into. [Update: ATSG is the command for GPIOs. See comment]

Dpape on RTL8710 forums discovered something very interesting: B&T RTL-00 module is pin-to-pin compatible with ESP12E module based on ESP8266, so if you already own a board with such module including NodeMCU board, you could unsolder the ESP8266 module, and replace it with RTL8710 and get going.

NodeMCU_RTL8710That’s exactly what he’s done and shown to work, with the module bought from Aliexpress, which appears to come pre-loaded with the exact same firmware. You’d normally not need the red USB debug board as shown above, but he removed the USB to TTL chip on NodeMCU previously, so that’s why…


The modules are actually only mostly pin-to-pin compatible, as for example GC5, corresponding to ADC on ESP12E, does not seem to support ADC, but only I2C1 SCL, SPI0 CS2, and GPIO_INT signals. But the power signals, Tx and TX, and most GPIO signal will match.

Realtek RTL8710 is still nowhere near ESP8266 in terms of community and software support however. However an ARM development board company – previously featured in this blog and many news outlets – is involved in the project, and I’ve been informed more details will be provided in 2 to 3 weeks. The current modules sold are for the Chinese market, and an international version is planned with a slightly different radio.

How-to Setup a DLNA/UPnP Server in Linux for Smoother Video Streaming with Kodi and Other Media Players

August 16th, 2016 8 comments

I’m normally playing videos from a SAMBA share installed in a Ubuntu PC to play files from Kodi in Android TV box reviews, but sometimes when I use 10/100 Ethernet, or worse WiFi local “streaming” may not be as smooth as possible. SAMBA is convenient because of access control and read write operations, but if you want to get a bit more performance, you may switch to NFS instead, or like I’ve going to show you here to a DLNA / UPnP server to stream videos locally from Kodi 16.1.

There are several options, but MiniDLNA is lightweight compared to MediaTomb, so it will also run on lower end hardware like cheap ARM Linux development boards like Raspberry Pi, Orange Pi, or NanoPi NEO without taking too many resources.

Installation is very easy in Debian / Ubuntu distributions, and I supposed this should also work with Windows Subsystem for Linux in Windows 10:

MiniDLNA can be configured with the same settings for all users, or different settings for specific users. In both case you’ll need to edit /etc/minidlna.conf configuration file. In my case, I only changed or uncommented the following lines for global settings:

You can add as many media_dir lines as you want, and also add A, V or P letter to separate Audio, Video, and Photo media type. For example:

Please note that minidlna daemon (minidlnad) will automatically scan subdirectories, so they don’t need to be specified.

Now that we have modifed the configuration, let’s restart it:

The Wiki on Ubuntu linked in the introduction also mentions to run the following command to rebuild the database:

However, while I could find my new UPnP server in Kodi, there were no files at all, and the log shows the same error message over and over:

eventually the command:

fixed the issue. But that’s not exactly the right way to fix it as it assumes root is running the daemon.

A better way if you’re going to have a decidated server is probably to set the ownership of media files to minidlna with a command like:

So how do you play videos from your DLNA/UPnP server in Kodi 16.1? Go to Videos->Files, and select Add videos…

Kodi_UPnP_devicesNow select UPnP devices

Kodi_miniDLNA_serverKodi should like your UPnP / DLNA servers. In my case FX8350:root, which correspond to the hostname or friendly_name in the hostname, and to the user, normally minidlna. Select the server, than Browser Folder, or Videos, and click OK.

I’ve shot a short video showing how to setup UPnP devices in Kodi, and compare SAMBA and DLNA performance by playing the same video file in Kodi 16.1 Android through SAMBA and UPnP/DLNA.

You’ll notice the video played from the SAMBA server starts much faster, but buffers several time during playback, while the video played from MiniDLNA server on the same PC will buffer data longer at start, and always fill the buffer fast enough to avoid bufferring.

I took Conky screenshots for another video showing the traffic shape for both SAMBA with relatively constant speed (6600 KB/s to 7400 KB/s) and DLNA which shows very high bitrate (>10000 KB/s) to fill the buffer the first time, and then play consistently around 6400 to 6800 KB/s.


Of course switching from SAMBA to DLNA won’t do miracles, but if you notice a few buffering while playing videos in SAMBA, switching to DLNA/UPnP may resolve the issue. You can also keep the best of both world, for example using SAMBA to download/copy files, and DLNA to play them back.