Please enable JavaScript to view this site.

How this block appears in a Simulink model?

spiffs_block_1-

What can be configured?

SPIFFS Setup block

spiffs_block_2

Configuration Parameter

Selectable Option/Value

Description

Format if mount fail

True--False

If SPIFFS cannot be mounted, and this parameter is true, create the partition table and format the file system. Keep the value as 'True' when the partition size is changed.

Base path

Cannot be edited

SPIFFS registers with the '/spiffs' base path

Partition size

 

The partition size for SPIFFS. This partition size will be allocated from the Flash memory. Be aware of the Flash size of the ESP32 microcontroller. This size can be allocated in KB or in MB range.

Remaining Flash size

 

This will show the remaining Flash size. Allocate the required memory for SPIFFS partition considering the remaining Flash size.

Maximum number of files

 

maximum number of files which can be open at the same time

Include files/folders to SPIFFS

Check--Uncheck

If files or folders need to be attached 'Check' this parameter.

Folder path

 

Browse the root folder path which need to be included from the computer. Put all the required files and folder inside the root folder.

E.g: if the root folder path is set as 'C:\waijung2\include'. Assume that there is a  folder called 'text' inside the 'include' folder and inside the 'text' folder there is a text file called 'test.txt'. If this file needs to be read using a SPIFFS Read Data block, the file path should be '/spiffs/text/test.txt'.

SPIFFS Read Data block

spiffs_block_3

Configuration Parameter

Selectable Option/Value

Description

Data buffer size

32--64--128--256--512--1024--2048--4096

Select the expected number of characters to be read from the file.

File path

 

The file path should follow the following convention

/<Base path>/<file path>/<filename>.<extention>

Sample Time

-1 (inherited) or specify

Specify the sample time for the block

 

OUTPUT Port

Port Name

Port Type

Date Type

Description

Data

Vector

uint8

The port outputs a character vector with the data written in the requested file in the SD card.

SPIFFS Write Data block

spiffs_block_4

Configuration Parameter

Selectable Option/Value

Description

File path

 

The file path should follow the following convention

/<Folder path>/<filename>.<extention>

 

INPUT Port

Port Name

Port Type

Date Type

Description

Data

Vector

uint8

Feed in a character vector with the data to be written.

SPIFFS Append Data block

spiffs_block_5

Configuration Parameter

Selectable Option/Value

Description

File path

 

The file path should follow the following convention

/<folder path>/<filename>.<extention>

 

INPUT Port

Port Name

Port Type

Date Type

Description

Data

Vector

uint8

Feed in a character vector with the data to be appended.

When to use this block?

This block can be used to set up, read, write, append data to SPIFFS in ESP32 microcontroller. For convenience, the driver is implemented on four blocks. Namely,

SPIFFS Setup

SPIFFS Read Data

SPIFFS Write Data

SPIFFS Append Data

It is mandatory to have the SPIFFS Setup block present in the model whenever the other blocks are used.

How does this block work?

SPIFFS Setup: ESP-IDF uses the SPIFFS library to read/write data to the Flash memory.

SPIFFS Read Data: The block reads the content saved in the specified file up to the buffer size limit and outputs the data from the output port.

SPIFFS Write Data: The block search for the file name in the given path. If the filename already exists, it deletes that file and creates a new file with the same name, and writes the new data to that file. If the file name does not exist, it creates a new file and the data.

SPIFFS Append Data: The block search for the file name in the given path. If the file name already exists, it opens that file and adds the new data to the file. If the file name does not exist, it creates a new file and the data.

Demo

Demo file : esp32_spiffs_demo.slx

 

spiffs_block_6

Description

This demo shows how to use the SPIFFS block. In the model, the SENSORS subsystem is used to mimic two analog sensors. In first five seconds the acquired data is logged into a CSV file on the SPIFFS and after that period logged data will be shown in the serial monitor.

What should be happening?

Once the SPIFFS is initialized in the application, the data will be logged to the SPIFFS. After first five seconds the logged data will be printed in the serial monitor.

spiffs_block_7

Copyright 2022 Aimagin Co.,Ltd. Rev.507