STORAGE_ERROR Handling When SD Card is Full in MP4 Loop Mode

Hi all,

I am running an MP4 recording example on the Ameba platform with the following configuration

static mp4_params_t mp4_v1_params = {
.sample_rate = 8000,
.channel = 1,
.record_length = 30, // seconds
.record_type = STORAGE_ALL,
.record_file_num = 1500,
.record_file_name= “NuraEye_recording”,
.fatfs_buf_size = 224 * 1024, /* 32 KB multiple */
};

Loop mode is enabled using:

mm_module_ctrl(mp4_ctx, CMD_MP4_LOOP_MODE, 1);

I am using a 2 GB SD card. Everything works fine until the SD card becomes full. After that, the system prints:

STORAGE_ERROR → STORAGE_IDLE

It seems that the storage module is not properly handling the full SD card scenario in loop mode. I would like to understand:

  1. Is this the expected behavior when SD card space is exhausted?

  2. Are there recommended settings to prevent STORAGE_ERROR when the card is full, e.g., automatically deleting old files in loop mode?

  3. Any best practices for handling SD card full scenarios in continuous MP4 recording on this platform?

Thanks in advance for any guidance

Hi @ravinder

Suggest that you can use the following functions to check the remaining SD card storage space at the application level and perform deletion operations accordingly:

long long int fatfs_get_free_space_byte(void);
long long int fatfs_get_used_space_byte(void);

You can refer to the following files for reference:

A similar example can also be found in the Arduino SDK, which you may refer to for additional guidance.

Example Guide: Display Free and Use space of SD card — Ameba Arduino AIoT Documentation v1.1 documentation