Skip to content

Setup

Please check the Quick Start Guide section if you setup the eCore for the first time.

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.

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, select Component config. Then, choose ESP System Settings

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

Menuconfig

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

Uart0

Change logs from UART0 to UART1

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

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

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

Finally, 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


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 logs as a Telnet client by using:

telnet <eCore_ip_address>

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

For more information, please check here.


User partitions

Info

nvs_internal partition name valid from v1.2.6. For previous images, partition is named nvs_user_store. You can check your eCore version as explained here.

The eCore has three partitions reserved for user storage:

  • /etc partition should be used to store configuration files. It is a small partition of 256KB.
  • /data partition should be used to store any other data. It is a larger partition of 3200KB.
  • /nvs_internal partition can be used to store key-value pairs. It is a small partition of 16KB.

/etc and /data partitions

The /etc and /data partitions use LittleFS format, which is a small fail-safe filesystem for microcontrollers, safer than 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.

Example

Here we show how to write and read files.

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

// Reading file /data/test.txt
string myText;
ifstream readMyFile("/data/test.txt");
while (getline (readMyFile, myText)) {
    cout << myText;
}
readMyFile.close();
See the oficial documentation to learn more about ofstream and ifstream

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

NVS (Non-Volatile Storage) partition

The /nvs_internal (Non-Volatile Storage) partition is created by default in ESP-IDF and can be used to 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 it.

Factory reset

You can perform three different types of factory reset in your eCore device by pressing the reset button. Factory reset types are the following:

  • Soft reset: The reset button needs to be pressed during 3 seconds. It sets all network configurations (Ethernet, Wi-Fi) by the ones defined by default. Also, it sets the users credentials to the default ones.

  • Hard reset: The reset button needs to be pressed during 10 or more seconds. It performs a soft reset and enables a flag that can be used from an eCore application to restore the desired values to the default ones.

  • Recovery reset: The reset button needs to be pressed while powering the device. It recovers all the device to the default configurations.