All posts by admin

Libreelec Image for Amlogic socs

In the market there are several TV boxes equipped with Android. Among the most common there are those based on soc Amlogic. For devices with this module there is the way to run, even in parallel without removing the Android image, a media center system based on Linux and Kodi, which is Libreelec. It is a fork of the mediacenter OpenELEC system

Libreelec

The supported platforms are similar to those already available for OpenELEC, but the community is carrying out the development of other images besides the official ones; this is the case for the Amlogic platform.

In Libreelec forum developers have developed unofficial images for tv boxes with soc Amlogic S802 / S905 / S905X

Amlogic Libreelec Forum

We’ll install a Libreelec image for an Amlogic S905 box, in our case the box is Android Beelink MiniMX III. The box comes with on board an Android firmware on the internal flash. The next steps allow to keep the Android firmware of the internal flash and Libreelec on the micro sd card. These instructions can be repeated at least in part with other boxes with soc Amlogic. Refer to Libreelec forum for more insights.

The first operation is to download the image from the link given on Libreelec forum

Amlogic S905 Libreelec Images

We download the version 7.0.2.007

Libreelec S905 7.0.2.007

At the link above there also the dtb files, device tree file, file containing the specifications of the hardware system, for different boxes already  tested.

We unzip the file and load it on a micro sd card in a similar way to what was done for the creation of OpenELEC image for the Orange IP PC

Openelec installation on Orange PI PC

Again we launch Win32DiskImager and after unpacking the LibreELEC-S905.aarch64-7.0.2.007.img.gz file we proceed to the writing on the micro sd card.

At this point,we insert the micro sd card into the box  that we start holding down, in the case of this model, the reset button on the bottom of the box. This is a one-time process; to subsequent reboots the system starts Libreelec, if there is the Micro SD card, or Android system, present on the internal flash, in the absence of micro sd card.

The image automatically uses the remote.conf file for the remote control  from the Android image intalled in the internal flash.

The configuration steps are quite similar to what was done for OpenELEC Orange PI PC, such as to enable the ssh daemon, etc; in this case the remote control, being a box supported by the image, is already working.

libreelec

 WARNING: The image installation on the device is at your own risk. We accept no responsibility if the installation leads to  malfunction or block of the device. Before performing any operation, make sure that you have the original image of the box so you can recover the Android system in case of issues.

In the next article we will see how to configure an infrared remote control with NEC protocol on a system based on soc Amlogic

Remote control configuration for Libreelec on Amlogic socs

Nodemcu Enduser_setup module lua sample(part2)

After the firmware build and its upload to the nodemcu dev kit, we connected a switch to pin D5, as shown in the previous article

Nodemcu Enduser_setup module lua sample(part1)

We finally can upload some sample code in which we use the enduser_setup module

Open ESPlorer and load the following sample code

  • webserver.lua

  • riasserawifi.lua

  • init.lua

 It is possible to download the above samples at the following link

 Sample code

Here is the documentation about the enduser_setup module

enduser_setup module documentation

The example consists of three files:

  1. init.lua:  It is executed at the startup of the esp8266.
  2. riazzerawifi.lua: It starts the portal to connect and save the configuration to your Access Point.
  3. webserver.lua:  It starts the webserver sample on the nodemcu.

As you can see from the code in init.lua, when the pin D5 is in the state HIGH, we start the portal using enduser_setup module. In the case in which the pin D5 is in the state LOW the  esp8266 acquires the IP from an Access Point defined previously after which the test webserver starts.

To save the access point confguration to which we want to connect we place the switch in order to have the HIGH input on pin D5 and reboot the card.

From a PC we can observe the presence of another access point, defined in the file riazzerawifi.lua

composed by Mynode string + ChipID module

nodemcu portal wifiWe can connect to this access point and  via browser we  access to the portal at the ip address 192.168.4.1

Login portal wifi nodemcuSelect or enter the SSID of an access point providing the correct   password. After the connection reposition the switch to have  the LOW state  for pin D5 and reboot the nodemcu dev kit.

Now the system will automatically connect to the SSID defined previously and starts the example of the web server.

Please refer to the Lua documentation nodemcu for further study and usable modules

LUA Nodemcu Documentation

Nodemcu Enduser_setup module lua sample(part1)

In the previous article we showed a sample LUA code for ESP8266

Lua sample code for esp8266

Let us now see an example in which we’ll use the enduser_setup Lua module.

As a first step we compile the nodemcu firmware by including the enduser_setup module. We have to apply the same steps discussed in the build process article

Nodemcu firmware build

editing the app/include/user_modules.h file and uncommenting the line

After the building and firmware upload to the device, we use a switch connected to nodemcu dev kit as shown in the picture

reset access point nodemcu

The pin D5 can be connected to a low or high input voltage. Based on the input voltage we can change the behavior of the system.

Note: The Pin D5 in this specific example has been used as Input Pin; in the case of use as Output Pin, you must insert a resistor to limit the output current, as specified in the link

GPIO Pin Allocations

In the next article we’lll upload a LUA sample code with enduser_setup module enabled and we’ll utilize it to manage the wifi connections

Nodemcu Enduser_setup module lua sample(part2)

Lua sample code for esp8266

As mentioned in the previous article

how to upload nodemcu firmware with esptool

we are now ready to upload some example code on ESP8266 system.

We follow the LUA Nodemcu documentation

Nodemcu LUA Documentation

and upload a simple http server on the system.

Using ESPlorer  we  upload the following code, a modified version of the code available on the github. Modify the fields “SSID” and “password” with the the values of your Wi-fi Router.

webserver pin

Save the file as ipstatico.lua. With ESPlorer upload the file to nodemcu devkit with “Save to ESP” button .
Create a second file named init.lua

Save this file on the device.

Reboot the device with the reset command on ESPlorer tool and from the ESPlorer  command bar execute

ESPlorerThis command  provides us the ip acquired by the device. We are able now to access with a browser to the assigned ip address, discovered above, and interact with a small interface that allows us to activate or not the PIN1 output

webserverlua

With this method, however, we need to know the Access Point to which you must connect. To overcome this limitation, we can use the enduser_sertup module

Enduser_setup module

With this module we start the ESP8266 device as an access point with a portal on which we can enter the credentials of the access point which we  want to connect.

In the next article we’ll build the nodemcu firmware by adding the  enduser setup module, not available in the standard firmware, and we will do the same example using this  module

Enduser_setup module sample

How to upload nodemcu firmware with esptool

In the article about the Nodemcu firmware building

Nodemcu firmware building

we created in the bin folder the  0x0000.bin and 0x100000.bin files and copied the  blank.bin and esp_init_data_default.bin files from the Espressif SDK.

According to the esptool tool documentation

esptool

the generic  command to load the firmware is the following

In our case, as we have a development kit with 4M of flash and an 9600 USB bps we have to specify the following parameters

  • mode=dio
  • size=32m

 Always according to the esptool documention, not generating the firmware with docker, we merged the two files, 0x0000.bin and 0x100000.bin,  into the nodemcu_float.bin file

 For our development kit we need to use the other two files

  • esp_init_data_default.bin: default init data.
  • blank.bin: to reset the configuration.

according to the mapping available at the following link

ESP8266 Guide

In our case we have to use (4M flash)

  • 0x3FC000 address for  esp_init_data_default.bin.
  • 0x3FE000 address for blank.bin

In the shell command window move into nodemcu-firmware and set the PATH variable

Then execute the following commands, with /dev/ttyUSB0 as COM port of the nodemcu dev kit

  • Flash erase

  • Firmware upload

In the next article we’ll upload our custom LUA code on the nodemcu dev kit.

Lua sample code

Nodemcu compilation on Linux

We’ll cover the steps to follow to create your own Nodemcu image with cross compiling on Linux.

We always start from the Debian envinronment described in the previous article

Debian Envinronment

 According the following link

Cross Compilation

as first step we prepare the cross compiling envinronment.

Log on Debian with our development user (sviluppo in our case) and create an esp8266 folder in  a terminal window

We install the prerequisites

We download the open-esp-sdk repository

to proceed to its compilation

At the end of the compilation we have the following messages

So we have to include in the PATH variable the following

We can clone at this point the Nodemcu firmware github. Always from the previous terminal window run

Once placed in the esp8266 folder execute

At the end go into the nodemcu-firmware folder

Before proceeding to the creation of our first firmware we have to make  changes in the app / include / user_config.h file configuration:

  • We enable the directive for our devkit 0.9 (our devkit)

#define DEVKIT_VERSION_0_9 1     // define this only if you use NodeMCU devkit v0.9

  • We change the USB communication speed (speed for our devkit)

//#define BIT_RATE_DEFAULT BIT_RATE_115200
#define BIT_RATE_DEFAULT BIT_RATE_9600

  • We change the flash size to 4M (flash of our nodemcu devkit)

#define FLASH_4M
// #define FLASH_8M
// #define FLASH_16M
//#define FLASH_AUTOSIZE

We save the file and proceed to the creation of the firmware with the command

At the end under the bin folder

we’ll find two files: 0x00000.bin and 0x100000.bin. We generate a single file nodemcu_float.bin with the command

At this point we have to enable the sviluppo user to use the usb port with the command

Debian has no need for additional USB drivers. In the presence of virtual machine enable the USB device.

Access to the SDK downloaded and compiled previously; in the bin folder copy the files

  • blank.bin
  • esp_init_data_default.bin

into the folder we generated the 0x00000.bin and 0x100000.bin files

binDefaultAt this point we are able to flash the firmware on the device using the esptool. In the next article we’ll descrive how to load the firmware

Nodemcu firmware upload with esptool

Uploading LUA code on ESP8266

After flashing the nodemcu firmware

Flashing the firmware

you can upload your own LUA script code on your device. To do this there are several tools

Uploading LUA code

In this article we’ll treat  ESPlorer

ESPlorer

It ‘a java application available for Windows, Linux and OSX. As a prerequisite requires the presence of Java SE ver. 7 or higher.

Download the tool from the link listed below to a folder

ESPlorer Download

To run it excecute from command prompt

or we can use a script in dos or unix (ESPlorer.bat or ESPlorer.sh).

At this point we plug the Nodemcu devkit to the PC and set the communication parameters and the speed of the COM port.

In Windows we have the following screen

ESPlorer

You can press Open, which allows access to the device.

ESPlorerConnesso

You can proceed at this point to the creation of your own code in LUA script and upload it on the ESP8266; you can use the various modules available in the  firmware according to the documentation

Nodemcu API

In the next article we’ll describe how to compile your personalized firmware in Linux

Nodemcu compilation

Flashing the firmware using Nodemcu Flasher

In the previous article we examined the different ways to flash the firmware

Flashing Nodemcu firmware

Now we describe how to proceed in Windows.

Looking at the Nodemcu firmware github

Nodemcu github

we find the followng application for Windows

 Nodemcu flasher

 We download the version compatible with our Windows operating system (32 or 64 bit)

First operation is to install the USB-Serial chip drivers of our Nodemcu Devkit, as specified in previous article. We have a devkit Nodemcu ver. 0.9, so we have to install the CH340G drivers

CH340G Drivers

After the drivers installation we can download the Nodemcu flasher in a folder and plug the  USB-Micro Usb cable between the pc and the devkit. Our COM port should be visible in the Windows device manager in the COM  devices list

PortaCom

In our case it is available on the COM port 5.

The steps to follow are the following:

  • Run Nodemcu Flasher and choose the COM5 port.

NodemcuProg

  • In Config select  INTERNAL://NODEMCU  with address 0x00000.

NodemcuProgConfig

  •  In Advanced we have the following parameters
    • Baudate: 9600 as specified in our devkit.
    • Flash size: 4MByte. Flash size of our devkit.
    • Flash Speed: 40MHz. The default speed.
    • SPI Mode: DIO is the default for 4Mb flash size.

NodemcuProgAdvanced

  • Proceed with the flash of the firmware pressing the FLASH button

NodemcuProgFlash

  • The application shows a progress bar of the operation

NodemcuProgProgress

At the end you can close the window and make sure everything is working properly using a LUA script uploader program, which we’ll see in the next article

Uploading LUA code

 

How to flash the Nodemcu firmware

In previous article we described the ESP8266 wifi module integrate into the Nodemcu development kit

ESP8266 WiFi Module

Here we look at how to load the firmware on the device.

First step is to assess the nodemcu development kit model we are working with. In our case we’ll perform the various operations with a development board Nodemcu V0.9. The USB-Serial chipset in this case is the CH340G

The drivers for this chipset can be downloaded directly from github of nodemcu

USB-Serial Drivers

To load the firmware, you can use the methods described in the Nodemcu site

Flashing Firmware

Basically there are two main methods:

  • Flash through the Windows Nodemcu Flasher tool

Nodemcu Flasher

  • Flash via a utility in Python to use in Linux, OSX or Windows

esptool

The Nodemcu flasher tool allows you to load a default firmware on the card  intuitively and quickly.

As can be seen from the above documentation of the  devkit you do not need to take any action on the pin GPI0 ESP to put the devive in flash mode; the flash operation and execution start automatically.

In the next article we’ll flash the firmware using the Nodemcu Flasher tool

Flashing the firmware with Nodemcu Flasher

Nodemcu Firmware

As discussed in previous article

ESP8266 WiFi Module

we’ll work on the ESP8266 SOC using the Nodemcu firmware

Firmware Nodemcu

Nodemcu is, to date at rev.  1.5.4.1, based on LUA 5.1.4. It is based upon Expressif SDK NONOS

Expressif SDK NONOS

It uses the spiffs filesystem

spiffs filesystem

We can get the firmware, as specified at the link

Nodemcu building

with different methods

  • Using a cloud service, specifying the additional modules if required

Nodemcu Custom Build

  • Using a Docker system

Docker Nodemcu Build

  •  Using cross compilation under a Linux system

We’ll descrive how to install the cross compilation envinronment under our Debian machine described in previous post.

The easiest way to get a default firmware is to use the Nodemcu Flasher tool.

In the next article we’ll treat how to load the firmware using various tools, among which the Nodemcu Flasher tool

How to flash the Nodemcu firmware