eCore Setup

To setup the eCore for the first time, you first have to check the Quick Start Guide section.

1) Serial Logs Configuration

By default, serial logs are configured to use UART1, which is the one connected to the RS232/RS485 port used by Modbus RTU protocol.

Note

It may be interesting to change the log output from UART1 to UART0 when a Modbus RTU device is connected.

1.1) Change Logs from UART1 to UART0

To do so, you must access Menuconfig using:

idf.py menuconfig

Important

You first need to upload the environmental variables using source ~/esp/esp-idf/export.sh.

A window will be opened, you must select:

Component config

Then, choose:

ESP System Settings

You should see a window as the one shown in the image below:

Menuconfig

Finally, you must select Channel for console output (Custom UART) and change Custom UART to Default: UART0.

Uart0

1.2) Change Logs from UART0 to UART1

If you want to change back the serial logs configuration, you must follow the same steps detailed above.

One you are in ESP System Settings you must select Channel for console output (Custom UART) and change Default: UART0 to Custom UART.

Then, you must change the UART peripherial to use for console output (0-1) from UART0 to UART1.

Finally, you must select the Tx and Rx GPIO for UART1:

UART TX on GPIO# must be set to 13.

UART RX on GPIO# must be set to 14.

Menuconfig uart1


2) Telnet Logs Configuration

To use Telnet logs, they must be configured in the application code. The following function must be called:

remoteLogInit()

This function initializes Telnet logs and blocks 30 seconds or until a client is connected using Telnet.

You can access Telnet logs as a Telnet client by using:

telnet <eCore_ip_address>

Note

If you do not know the IP of your eCore, you can access it as it is explained here.


3) User Partitions

We have based the design of our partitions on Linux design system, for this reason /etc and /data have been created. Both partitions can be used by the user to store different information.

Concretely, /etc partition can be used to store configuration files and it is 256KB in size. On the other size /data partition can be used to store all the data the user wants, and it is 3200KB in size.

3.1) /etc and /data Partitions

The /etc and /data partitions use LittleFS format, which is a small fail-safe filesystem for microcontrollers, instead of Spiffs format.

This high-integrity file system has the following advantages:

  • Low memory footprint: Memory efficient design for minimising RAM and FLASH usage. IoT devices are constrained by ROM and RAM. A small footprint saves money.
  • Power Loss Protection: It is designed to handle random power failures. All file operations have strong copy-on-write guarantees and if power is lost the filesystem will fall back to the last known good state. Embedded systems require strong guarantees that the file system remains consistent, and data is flushed to the underlying storage.
  • Dynamic wear Levelling: It is designed with flash in mind, and provides wear leveling over dynamic blocks. Typically storage supports a limited number of erases per block, so making use of the entire storage device is important for reliability.

The abstraction layer for the management of these partitions has already been designed and implemented and they can be used directly as a file system.

Below you have a code example:

    using namespace std;
    ofstream creatMyFile("/data/test.txt");
    creatMyFile << "Hello World!!!";
    creatMyFile.close();

    string myText;
    ifstream readMyFile("/data/test.txt");
    while (getline (readMyFile, myText)) {
        cout << myText;
    }
    readMyFile.close();

In this example, first of all a new file is written in /data partition, named test.txt. On the second part, the same file is read.

Important Information

It is recommended to use fsync periodically if you have to keep any files open.

3.2) NVS (Non-Volatile Storage) Partition

The /nvs (Non-Volatile Storage) partition is created by default in ESP-IDF, that the user can use for their purpose. Its main use is store key-value pairs.

There is a second nvs partition, which is reserved by the system. It is strongly recommended not to modify or format this partition.

4) Factory Reset

You can perform a factory reset in your eCore device by pressing the reset button during 3 seconds.