Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RMT Module - Guru Meditation Error: Core / panic'ed (Cache disabled but cached memory region accessed). (IDFGH-14868) #15588

Open
3 tasks done
Dawid-Wawrzynczyk opened this issue Mar 17, 2025 · 5 comments
Labels
Status: Opened Issue is new Type: Bug bugs in IDF

Comments

@Dawid-Wawrzynczyk
Copy link

Dawid-Wawrzynczyk commented Mar 17, 2025

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

ESP-IDF 5.4.0-dirty

Espressif SoC revision.

ESP32-S3

Operating System used.

Windows

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

PowerShell

Development Kit.

ESP32-S3-WROOM-1

Power Supply used.

USB

What is the expected behavior?

When I click a button the motor should start rotating at the expected speed using the RMT Module - When I click the button again the motor should come to a stop.

What is the actual behavior?

The motor does indeed start and stop accordingly. The issue is; sometimes, if the timing is right, during quick ON / OFF switch, I get the:

Guru Meditation Error: Core / panic'ed (Cache disabled but cached memory region accessed).
MMU entry fault error occurred while accessing the address 0x3ceb7c2c (invalid mmu entry)

There is no clear pattern to when it happens, sometimes after few clicks, sometimes after many clicks.

Steps to reproduce.

It's really hard to clearly point out where this bug resides. The final stack line error is always at 'rmt_encoder.c:210' with few lines following below it present in the debug log.

I'll present the chain of functions that have anything to do with the error.

Here is the main task that receives a command and performs the RMT communication:

rmt_encoder_handle_t accel_encoder = NULL;
rmt_encoder_handle_t uniform_encoder = NULL;
rmt_encoder_handle_t decel_encoder = NULL;

void IRAM_ATTR motor_move_task(void *pvParameters)
{
    void **data = (void**)pvParameters;
    motor_handle_t *motor_handle = (motor_handle_t*)data[0];
    SemaphoreHandle_t semaphore = *((SemaphoreHandle_t*)data[1]);
    bool *new_command_flag = ((bool*)data[2]);

    while (1)
    {
        if (xSemaphoreTake(semaphore, portMAX_DELAY) == pdTRUE)
        {
            uint32_t base_frequency = calculate_frequency(motor_handle->steps_per_rev, 1);

            if ((motor_handle->command == STOP || motor_handle->command == INSTANTSTOP) && motor_handle->motor_state == STATIONARY) continue;

            if (motor_handle->motor_state == MOVING)
            {
                if (motor_handle->command == STOP)
                {
                    rmt_disable(motor_handle->motor_chan);
                    rmt_enable(motor_handle->motor_chan);
                    continue;
                }
            }
            else if (motor_handle->motor_state == ACCELERATING)
            {
                if (motor_handle->command == STOP)
                {
                    rmt_encoder_handle_t decel_encoder = NULL;
                    uint32_t ramp_steps = motor_handle->current_freq_hz - base_frequency;
                    if (ramp_steps > 2) ramp_steps = ramp_steps / 3; 
                    uint32_t decel_samples = create_decel_move_data(ramp_steps, base_frequency, motor_handle->current_freq_hz, &decel_encoder, motor_handle);

                    if (decel_samples > 0)
                    {
                        motor_decelerate(motor_handle, (rmt_transmit_config_t) { .loop_count = 0 }, decel_encoder, decel_samples);
                    }

                    //Accelerating Phase
                    rmt_disable(motor_handle->motor_chan);
                    rmt_enable(motor_handle->motor_chan);

                    //Moving Phase
                    rmt_disable(motor_handle->motor_chan);
                    rmt_enable(motor_handle->motor_chan);

                    //Decelerating Phase
                    rmt_disable(motor_handle->motor_chan);
                    rmt_enable(motor_handle->motor_chan);

                    continue;
                }
            }
            else if (motor_handle->motor_state == DECELERATING)
            {
                if (motor_handle->command == STOP)
                {
                    continue;
                }
            }

            uint32_t target_max_frequency = calculate_frequency(motor_handle->steps_per_rev, motor_handle->target_rps);

            if (base_frequency > target_max_frequency) base_frequency = target_max_frequency;

            int steps = motor_handle->target_steps;

            unsigned int ramp_steps;
            unsigned int max_frequency;

            if (steps < target_max_frequency)
            {
                ramp_steps = steps;
                max_frequency = steps * 3;
                if (max_frequency > target_max_frequency) max_frequency = target_max_frequency;
            }
            else
            {
                ramp_steps = target_max_frequency - base_frequency;
                if (ramp_steps > 2) ramp_steps = ramp_steps / 3;
                else { ramp_steps = 0; }
                max_frequency = target_max_frequency;
            }

            if (accel_encoder != NULL) rmt_del_encoder(accel_encoder);
            if (uniform_encoder != NULL) rmt_del_encoder(uniform_encoder);
            if (decel_encoder != NULL) rmt_del_encoder(decel_encoder);

            accel_encoder = NULL;
            uniform_encoder = NULL;
            decel_encoder = NULL;

            uint32_t accel_samples;
            uint32_t uniform_speed_hz = max_frequency;
            uint32_t decel_samples;

            rmt_transmit_config_t tx_config = {
                .loop_count = 0
            };

            create_uniform_move_data(&uniform_encoder, motor_handle);

            rmt_tx_wait_all_done(motor_handle->motor_chan, portMAX_DELAY);

            if (motor_handle->command != STOP && motor_handle->command != INSTANTSTOP)
            {       
                accel_samples = create_accel_move_data(ramp_steps, base_frequency, max_frequency, &accel_encoder, motor_handle);

                // acceleration phase
                if (accel_samples > 0)
                {
                    motor_accelerate(motor_handle, tx_config, accel_encoder, accel_samples);
                }

                // uniform phase
                if (ramp_steps != steps){
                    motor_continuemaxspeed(motor_handle, tx_config, uniform_encoder, uniform_speed_hz, steps - ramp_steps);
                }
            }

            decel_samples = create_decel_move_data(ramp_steps, base_frequency, max_frequency, &decel_encoder, motor_handle);
            // deceleration phase
            if (decel_samples > 0)
            {
                motor_decelerate(motor_handle, tx_config, decel_encoder, decel_samples);
            }
        }
    }
}

Here are the helper methods for the speed phases and the encoder creation:

void callback_test(motor_state_update_data_t *data)
{
    motor_handle_t * motor_handle = (motor_handle_t*)(data->user_args);
    motor_handle->current_freq_hz = data->current_freq_hz;
    motor_handle->motor_state = data->motor_state;
}

uint32_t create_accel_move_data(unsigned int ramp_steps, unsigned int base_frequency, unsigned int max_frequency, rmt_encoder_handle_t * encoder_handle, motor_handle_t * motor_handle)
{
    stepper_motor_curve_encoder_config_t accel_encoder_config = {
        .resolution = STEP_RESOLUTION_HZ,
        .sample_points = ramp_steps > 0 ? floor(ramp_steps / 2) : 0,
        .start_freq_hz = base_frequency,
        .end_freq_hz = max_frequency,
        .motor_state_update_callback = {
            .callback = callback_test,
            .user_args = motor_handle
        }
    };
    *encoder_handle = NULL;
    if (accel_encoder_config.sample_points > 0) ESP_ERROR_CHECK(rmt_new_stepper_motor_curve_encoder(&accel_encoder_config, encoder_handle));

    return accel_encoder_config.sample_points;
}

void create_uniform_move_data(rmt_encoder_handle_t * encoder_handle, motor_handle_t * motor_handle)
{
    stepper_motor_uniform_encoder_config_t uniform_encoder_config = {
        .resolution = STEP_RESOLUTION_HZ,
        .motor_start_uniform_speed_callback = {
            .callback = callback_test,
            .user_args = motor_handle
        }
    };
    *encoder_handle = NULL;
    ESP_ERROR_CHECK(rmt_new_stepper_motor_uniform_encoder(&uniform_encoder_config, encoder_handle));
}

uint32_t create_decel_move_data(unsigned int ramp_steps, unsigned int base_frequency, unsigned int max_frequency, rmt_encoder_handle_t * encoder_handle, motor_handle_t * motor_handle)
{
    stepper_motor_curve_encoder_config_t decel_encoder_config = {
        .resolution = STEP_RESOLUTION_HZ,
        .sample_points = ramp_steps > 0 ? ceil(ramp_steps / 2) : 0,
        .start_freq_hz = max_frequency,
        .end_freq_hz = base_frequency,
        .motor_state_update_callback = {
            .callback = callback_test,
            .user_args = motor_handle
        }
    };
    *encoder_handle = NULL;
    if (decel_encoder_config.sample_points > 0) ESP_ERROR_CHECK(rmt_new_stepper_motor_curve_encoder(&decel_encoder_config, encoder_handle));

    return decel_encoder_config.sample_points;
}

void motor_accelerate(motor_handle_t * motor_handle, rmt_transmit_config_t tx_config, rmt_encoder_handle_t accel_encoder, uint32_t accel_samples)
{
    tx_config.loop_count = 0;
    rmt_transmit(motor_handle->motor_chan, accel_encoder, &accel_samples, sizeof(accel_samples), &tx_config);
}

void motor_continuemaxspeed(motor_handle_t * motor_handle, rmt_transmit_config_t tx_config, rmt_encoder_handle_t uniform_encoder, uint32_t uniform_speed_hz, uint32_t steps)
{
    tx_config.loop_count = steps;

    uint32_t *speed_hz = (uint32_t *)malloc(sizeof(uint32_t)); //Will be freed inside the rmt_transmit.
    *speed_hz = uniform_speed_hz; 

    rmt_transmit(motor_handle->motor_chan, uniform_encoder, speed_hz, sizeof(*speed_hz), &tx_config);
}

void motor_decelerate(motor_handle_t * motor_handle, rmt_transmit_config_t tx_config, rmt_encoder_handle_t decel_encoder, uint32_t decel_samples)
{
    tx_config.loop_count = 0;
    rmt_transmit(motor_handle->motor_chan, decel_encoder, &decel_samples, sizeof(decel_samples), &tx_config);
}

I am using the ESP-IDF Stepper Motor RMT sample (in my code it's 'stepper_motor_encoder.c'):
https://github.com/espressif/esp-idf/tree/v5.2.5/examples/peripherals/rmt/stepper_motor

The only change I've made is the methods now give some kind of response to what state the motor is currently at:

static size_t rmt_encode_stepper_motor_curve(rmt_encoder_t *encoder, rmt_channel_handle_t channel, const void *primary_data, size_t data_size, rmt_encode_state_t *ret_state)
{
    rmt_stepper_curve_encoder_t *motor_encoder = __containerof(encoder, rmt_stepper_curve_encoder_t, base);
    rmt_encoder_handle_t copy_encoder = motor_encoder->copy_encoder;
    rmt_encode_state_t session_state = RMT_ENCODING_RESET;
    motor_state_t motor_state;
    uint32_t points_num = *(uint32_t *)primary_data;
    size_t encoded_symbols = 0;
    if (motor_encoder->flags.is_accel_curve) {
        encoded_symbols = copy_encoder->encode(copy_encoder, channel, &motor_encoder->curve_table[0],
                                               points_num * sizeof(rmt_symbol_word_t), &session_state);
        motor_state = ACCELERATING;
    } else {
        encoded_symbols = copy_encoder->encode(copy_encoder, channel, &motor_encoder->curve_table[0] + motor_encoder->sample_points - points_num,
                                               points_num * sizeof(rmt_symbol_word_t), &session_state);
        motor_state = DECELERATING;
    }
    *ret_state = session_state;

    motor_encoder->total_encoded += encoded_symbols;
    try_send_callback(motor_encoder->motor_state_update_callback.callback, motor_encoder->total_encoded, encoded_symbols, motor_state, convert_to_freq_from_duration(motor_encoder->resolution, motor_encoder->curve_table[motor_encoder->total_encoded].duration0), motor_encoder->motor_state_update_callback.user_args);

    return encoded_symbols;
}
esp_err_t rmt_new_stepper_motor_curve_encoder(const stepper_motor_curve_encoder_config_t *config, rmt_encoder_handle_t *ret_encoder)
{
    esp_err_t ret = ESP_OK;
    rmt_stepper_curve_encoder_t *step_encoder = NULL;
    float smooth_freq;
    uint32_t symbol_duration;
    ESP_GOTO_ON_FALSE(config && ret_encoder, ESP_ERR_INVALID_ARG, err, TAG, "invalid arguments");
    ESP_GOTO_ON_FALSE(config->sample_points, ESP_ERR_INVALID_ARG, err, TAG, "sample points number can't be zero");
    ESP_GOTO_ON_FALSE(config->start_freq_hz != config->end_freq_hz, ESP_ERR_INVALID_ARG, err, TAG, "start freq can't equal to end freq");
    step_encoder = rmt_alloc_encoder_mem(sizeof(rmt_stepper_curve_encoder_t) + config->sample_points * sizeof(rmt_symbol_word_t));
    ESP_GOTO_ON_FALSE(step_encoder, ESP_ERR_NO_MEM, err, TAG, "no mem for stepper curve encoder");
    rmt_copy_encoder_config_t copy_encoder_config = {};
    ESP_GOTO_ON_ERROR(rmt_new_copy_encoder(&copy_encoder_config, &step_encoder->copy_encoder), err, TAG, "create copy encoder failed");
    bool is_accel_curve = config->start_freq_hz < config->end_freq_hz;

    // prepare the curve table, in RMT symbol format
    uint32_t curve_step = 0;
    if (is_accel_curve) {
        curve_step = (config->end_freq_hz - config->start_freq_hz) / (config->sample_points - 1);
        for (uint32_t i = 0; i < config->sample_points; i++) {
            smooth_freq = convert_to_smooth_freq(config->start_freq_hz, config->end_freq_hz, config->start_freq_hz + curve_step * i);
            symbol_duration = config->resolution / smooth_freq / 2;
            step_encoder->curve_table[i].level0 = 0;
            step_encoder->curve_table[i].duration0 = symbol_duration;
            step_encoder->curve_table[i].level1 = 1;
            step_encoder->curve_table[i].duration1 = symbol_duration;
        }
    } else {
        curve_step = (config->start_freq_hz - config->end_freq_hz) / (config->sample_points - 1);
        for (uint32_t i = 0; i < config->sample_points; i++) {
            smooth_freq = convert_to_smooth_freq(config->end_freq_hz, config->start_freq_hz, config->end_freq_hz + curve_step * i);
            symbol_duration = config->resolution / smooth_freq / 2;
            step_encoder->curve_table[config->sample_points - i - 1].level0 = 0;
            step_encoder->curve_table[config->sample_points - i - 1].duration0 = symbol_duration;
            step_encoder->curve_table[config->sample_points - i - 1].level1 = 1;
            step_encoder->curve_table[config->sample_points - i - 1].duration1 = symbol_duration;
        }
    }
    ESP_GOTO_ON_FALSE(curve_step > 0, ESP_ERR_INVALID_ARG, err, TAG, "|end_freq_hz - start_freq_hz| can't be smaller than sample_points");

    step_encoder->sample_points = config->sample_points;
    step_encoder->flags.is_accel_curve = is_accel_curve;
    step_encoder->base.del = rmt_del_stepper_motor_curve_encoder;
    step_encoder->base.encode = rmt_encode_stepper_motor_curve;
    step_encoder->base.reset = rmt_reset_stepper_motor_curve_encoder;
    step_encoder->motor_state_update_callback.callback = config->motor_state_update_callback.callback;
    step_encoder->motor_state_update_callback.user_args = config->motor_state_update_callback.user_args;
    step_encoder->resolution = config->resolution;
    step_encoder->total_encoded = 0;
    *ret_encoder = &(step_encoder->base);
    return ESP_OK;
err:
    if (step_encoder) {
        if (step_encoder->copy_encoder) {
            rmt_del_encoder(step_encoder->copy_encoder);
        }
        free(step_encoder);
    }
    return ret;
}

And the try send callback method:

static void try_send_callback(motor_state_update_callback_t motor_state_update_callback, size_t total_steps, size_t steps_this_update, motor_state_t motor_state, uint32_t current_freq_hz, void * user_args)
{
    if (motor_state_update_callback) 
    {
        motor_state_update_callback(&(motor_state_update_data_t)
        { 
            .steps_this_update = steps_this_update,
            .total_steps = total_steps,
            .motor_state = motor_state,
            .current_freq_hz = current_freq_hz,
            .user_args = user_args
        });
    }
}

Debug Logs.

Guru Meditation Error: Core  / panic'ed (Cache disabled but cached memory region accessed). 
MMU entry fault error occurred while accessing the address 0x3d132bd4 (invalid mmu entry)


Core  0 register dump:
PC      : 0x40378eca  PS      : 0x00060034  A0      : 0x8200b1bc  A1      : 0x3fc974a0
--- 0x40378eca: rmt_encode_copy at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/esp_driver_rmt/src/rmt_encoder.c:210

A2      : 0x00000030  A3      : 0x3c0b7f70  A4      : 0x3d131314  A5      : 0x00000031
A6      : 0x3fc974c0  A7      : 0x00000030  A8      : 0x600168c0  A9      : 0x0000002f
A10     : 0x00000631  A11     : 0x00000000  A12     : 0x60016800  A13     : 0x3fc99718
A14     : 0x3c398888  A15     : 0x00000000  SAR     : 0x00000014  EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000  LBEG    : 0x40056f5c  LEND    : 0x40056f72  LCOUNT  : 0x00000000
--- 0x40056f5c: memcpy in ROM
0x40056f72: memcpy in ROM



Backtrace: 0x40378ec7:0x3fc974a0 0x4200b1b9:0x3fc974c0 0x40379041:0x3fc974f0 0x403790ac:0x3fc97520 0x403796a6:0x3fc97540 0x403769d5:0x3fc97560 0x40377815:0x3fc97580 0x4201d653:0x3fcbf770 0x4201d6b2:0x3fcbf790 0x4201d6fd:0x3fcbf7b0 0x4201b651:0x3fcbf7d0 0x4201b67c:0x3fcbf7f0 0x4201b6fe:0x3fcbf810 0x4201ceb2:0x3fcbf830 0x42013d79:0x3fcbf8b0 0x42014546:0x3fcbf950 0x4206a389:0x3fcbf990 0x420151ae:0x3fcbf9b0 0x4201523e:0x3fcbf9d0 0x42019c28:0x3fcbfa10 0x42019f21:0x3fcbfb40 0x42019cd8:0x3fcbfc20 0x42019f21:0x3fcbfd50 0x4201a1c0:0x3fcbfe30 0x4201a33a:0x3fcbfe50 0x4201a4e4:0x3fcbfe80 0x4201a5ed:0x3fcbfec0 0x4201a7b7:0x3fcbfee0 0x42027981:0x3fcbff00 0x42027a31:0x3fcbff20 0x42012e94:0x3fcbff40 0x4037d3cd:0x3fcbff60
--- 0x40378ec7: rmt_encode_copy at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/esp_driver_rmt/src/rmt_encoder.c:212
0x4200b1b9: rmt_encode_stepper_motor_curve at C:/ESP-IDF Projects/EasyCut-v2/main/motor_controller/stepper_motor_encoder.c:72
0x40379041: rmt_encode_check_result at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/esp_driver_rmt/src/rmt_tx.c:668
0x403790ac: rmt_isr_handle_tx_threshold at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/esp_driver_rmt/src/rmt_tx.c:934
0x403796a6: rmt_tx_default_isr at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/esp_driver_rmt/src/rmt_tx.c:1088
0x403769d5: shared_intr_isr at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/esp_hw_support/intr_alloc.c:445
0x40377815: _xt_lowint1 at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/xtensa/xtensa_vectors.S:1240
0x4201d653: execute_drawing at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw.c:512
0x4201d6b2: execute_drawing_unit at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw.c:383
0x4201d6fd: dispatch at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/draw/sw/lv_draw_sw.c:463
0x4201b651: lv_draw_dispatch_layer at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/draw/lv_draw.c:276
0x4201b67c: lv_draw_dispatch at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/draw/lv_draw.c:182
0x4201b6fe: lv_draw_finalize_task_creation at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/draw/lv_draw.c:147
0x4201ceb2: lv_draw_rect at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/draw/lv_draw_rect.c:165
0x42013d79: lv_obj_draw at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/core/lv_obj.c:619
0x42014546: lv_obj_event at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/core/lv_obj.c:872
0x4206a389: lv_obj_event_base at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/core/lv_obj_event.c:89
0x420151ae: event_send_core at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/core/lv_obj_event.c:364
0x4201523e: lv_obj_send_event at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/core/lv_obj_event.c:67
0x42019c28: lv_obj_redraw at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/core/lv_refr.c:116
0x42019f21: refr_obj at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/core/lv_refr.c:1032
0x42019cd8: lv_obj_redraw at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/core/lv_refr.c:167
0x42019f21: refr_obj at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/core/lv_refr.c:1032
0x4201a1c0: refr_obj_and_children at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/core/lv_refr.c:820
0x4201a33a: refr_area_part at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/core/lv_refr.c:753
0x4201a4e4: refr_area at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/core/lv_refr.c:679
0x4201a5ed: refr_invalid_areas at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/core/lv_refr.c:586
0x4201a7b7: lv_display_refr_timer at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/core/lv_refr.c:398
0x42027981: lv_timer_exec at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/misc/lv_timer.c:326 (discriminator 2)
0x42027a31: lv_timer_handler at C:/ESP-IDF Projects/EasyCut-v2/managed_components/lvgl__lvgl/src/misc/lv_timer.c:107
0x42012e94: lvgl_port_task at C:/ESP-IDF Projects/EasyCut-v2/managed_components/espressif__esp_lvgl_port/src/lvgl9/esp_lvgl_port.c:262
0x4037d3cd: vPortTaskWrapper at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:139



Core  1 register dump:
PC      : 0x403799be  PS      : 0x00060834  A0      : 0x82002ecd  A1      : 0x3fcaeb90
--- 0x403799be: esp_cpu_wait_for_intr at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/esp_hw_support/cpu.c:64

A2      : 0x00000000  A3      : 0x0000abab  A4      : 0x8037d769  A5      : 0x3fcaf490
A6      : 0x00060023  A7      : 0x00000000  A8      : 0x8204aaba  A9      : 0x3fcaeb50
A10     : 0x00000000  A11     : 0x00000001  A12     : 0x03c96b7c  A13     : 0x01ffffff
A14     : 0x3fc96b7c  A15     : 0x3fcaed64  SAR     : 0x00000000  EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000


Backtrace: 0x403799bb:0x3fcaeb90 0x42002eca:0x3fcaebb0 0x4037e9d1:0x3fcaebd0 0x4037d3cd:0x3fcaebf0
--- 0x403799bb: xt_utils_wait_for_intr at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/xtensa/include/xt_utils.h:82
 (inlined by) esp_cpu_wait_for_intr at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/esp_hw_support/cpu.c:55
0x42002eca: esp_vApplicationIdleHook at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/esp_system/freertos_hooks.c:58
0x4037e9d1: prvIdleTask at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/freertos/FreeRTOS-Kernel/tasks.c:4353 (discriminator 1)
0x4037d3cd: vPortTaskWrapper at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:139





ELF file SHA256: 9fc83fdd0

Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40375d59
--- 0x40375d59: esp_restart_noos at C:/Users/Dawid Wawrzynczyk/esp/v5.4/esp-idf/components/esp_system/port/soc/esp32s3/system_internal.c:160

SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce2820,len:0x170c
load:0x403c8700,len:0x4
load:0x403c8704,len:0xec4
load:0x403cb700,len:0x3170
entry 0x403c8950

Also the boot log if it's important at all:
I (26) boot: ESP-IDF v5.4-dirty 2nd stage bootloader
I (26) boot: compile time Mar 17 2025 11:42:52
I (26) boot: Multicore bootloader
I (27) boot: chip revision: v0.2
I (29) boot: efuse block revision: v1.3
I (33) qio_mode: Enabling default flash chip QIO
I (37) boot.esp32s3: Boot SPI Speed : 80MHz
I (41) boot.esp32s3: SPI Mode       : QIO
I (45) boot.esp32s3: SPI Flash Size : 16MB
I (49) boot: Enabling RNG early entropy source...
I (53) boot: Partition Table:
I (56) boot: ## Label            Usage          Type ST Offset   Length
I (62) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (69) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (75) boot:  2 factory          factory app      00 00 00010000 00100000
I (82) boot: End of partition table
I (85) esp_image: segment 0: paddr=00010020 vaddr=3c080020 size=2a484h (173188) map
I (118) esp_image: segment 1: paddr=0003a4ac vaddr=3fc96200 size=0336ch ( 13164) load
I (121) esp_image: segment 2: paddr=0003d820 vaddr=40374000 size=027f8h ( 10232) load
I (124) esp_image: segment 3: paddr=00040020 vaddr=42000020 size=703e4h (459748) map
I (198) esp_image: segment 4: paddr=000b040c vaddr=403767f8 size=0f9b0h ( 63920) load
I (210) esp_image: segment 5: paddr=000bfdc4 vaddr=600fe100 size=0001ch (    28) load
I (218) boot: Loaded app from partition at offset 0x10000
I (218) boot: Disabling RNG early entropy source...
I (228) octal_psram: vendor id    : 0x0d (AP)
I (228) octal_psram: dev id       : 0x02 (generation 3)
I (229) octal_psram: density      : 0x03 (64 Mbit)
I (231) octal_psram: good-die     : 0x01 (Pass)
I (235) octal_psram: Latency      : 0x01 (Fixed)
I (239) octal_psram: VCC          : 0x01 (3V)
I (243) octal_psram: SRF          : 0x01 (Fast Refresh)
I (248) octal_psram: BurstType    : 0x01 (Hybrid Wrap)
I (253) octal_psram: BurstLen     : 0x01 (32 Byte)
I (258) octal_psram: Readlatency  : 0x02 (10 cycles@Fixed)
I (263) octal_psram: DriveStrength: 0x00 (1/1)
I (268) MSPI Timing: PSRAM timing tuning index: 5
I (271) esp_psram: Found 8MB PSRAM device
I (275) esp_psram: Speed: 80MHz
I (278) cpu_start: Multicore app
I (714) esp_psram: SPI SRAM memory test OK
I (722) cpu_start: Pro cpu start user code
I (722) cpu_start: cpu freq: 240000000 Hz
I (722) app_init: Application information:
I (723) app_init: Project name:     EasyCut-v2
I (727) app_init: App version:      4abd6bb-dirty
I (731) app_init: Compile time:     Mar 17 2025 12:17:27
I (736) app_init: ELF file SHA256:  9fc83fdd0...
I (740) app_init: ESP-IDF:          v5.4
I (744) efuse_init: Min chip rev:     v0.0
I (748) efuse_init: Max chip rev:     v0.99
I (752) efuse_init: Chip rev:         v0.2
I (756) heap_init: Initializing. RAM available for dynamic allocation:
I (762) heap_init: At 3FCAA630 len 0003F0E0 (252 KiB): RAM
I (767) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
I (772) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (777) heap_init: At 600FE11C len 00001ECC (7 KiB): RTCRAM
I (783) esp_psram: Adding pool of 8192K of PSRAM memory to heap allocator
I (790) spi_flash: detected chip: boya
I (793) spi_flash: flash io: qio
I (796) sleep_gpio: Configure to isolate all GPIO pins in sleep state
I (802) sleep_gpio: Enable automatic switching of GPIO sleep configuration
I (809) main_task: Started on CPU0
I (819) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (819) main_task: Calling app_main()
I (819) SPIC: Initializing SPI bus...
I (829) SPIC: Initializing SPI bus...
I (829) SDC: Adding SD card to SPI bus...
I (829) gpio: GPIO[10]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (879) sdspi_transaction: cmd=52, R1 response: command not supported
I (919) sdspi_transaction: cmd=5, R1 response: command not supported
I (949) SDC: SD card mounted successfully
I (949) gpio: GPIO[42]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:3
I (949) gpio: GPIO[41]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:3
I (959) gpio: GPIO[40]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:3
I (959) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (969) gpio: GPIO[38]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (979) gpio: GPIO[39]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
D (989) rmt: new group(0) at 0x3c0b81d4, occupy=ffffff00
D (999) rmt: group clock resolution:80000000
D (999) rmt: new tx channel(0,0) at 0x3c0b7f70, gpio=21, res=10000000Hz, hw_mem_base=0x60016800, dma_mem_base=0x0, dma_nodes=0x0, ping_pong_size=48, queue_depth=5
I (1009) MC: Initialised Motor using MC
I (1019) LVGL: Starting LVGL task
I (1019) gpio: GPIO[7]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1029) ST7796: Installed panel IO
I (1029) st7796: version: 1.3.1
I (1029) gpio: GPIO[9]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1039) st7796_general: LCD panel create success, version: 1.3.1
I (1279) ST7796: Successfully Installed Display Driver
I (1309) ST7796: Added LVGL Display Instance
I (1309) gpio: GPIO[14]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:2
E (1309) gpio: gpio_install_isr_service(502): GPIO isr service already installed
I (1319) ST7796: Initialised touch controller XPT2046
I (1319) ST7796: Successfully Finished GUI Initialisation

More Information.

I am using the LVGL 9.3 for the user interface with ST7796 LCD Display over SPI.

The log output has a stack from LVGL for some unknown reason, it doesn't connect to my code anywhere and to be honest I don't even know why it's started appearing there, It didn't use to, but now I can't really get rid of it, so I'm including it just in case.

I've disabled the 'CONFIG_SPI_MASTER_ISR_IN_IRAM' in case it's the problem with the LCD, I have also tried decorating every single method that I showcased here in this report with the 'IRAM_ATTR', the stack might change a little at the entry point, but the rest is the same.

I've spent days trying to fix this bug and anyone here willing to help is my last resort.

@Dawid-Wawrzynczyk Dawid-Wawrzynczyk added the Type: Bug bugs in IDF label Mar 17, 2025
@github-actions github-actions bot changed the title RMT Module - Guru Meditation Error: Core / panic'ed (Cache disabled but cached memory region accessed). RMT Module - Guru Meditation Error: Core / panic'ed (Cache disabled but cached memory region accessed). (IDFGH-14868) Mar 17, 2025
@espressif-bot espressif-bot added the Status: Opened Issue is new label Mar 17, 2025
@suda-morris
Copy link
Collaborator

So you enabled RMT_ISR_IRAM_SAFE Kconfig? If so, all RMT ISR callbacks must be placed in the IRAM, including your customized encoder function. Have you placed the rmt_encode_stepper_motor_curve into the IRAM?

@Dawid-Wawrzynczyk
Copy link
Author

Dawid-Wawrzynczyk commented Mar 17, 2025

So you enabled RMT_ISR_IRAM_SAFE Kconfig? If so, all RMT ISR callbacks must be placed in the IRAM, including your customized encoder function. Have you placed the rmt_encode_stepper_motor_curve into the IRAM?

So I've tried enabling the CONFIG_RMT_ISR_IRAM_SAFE but I disabled it because I started having memory problems when it's enabled, basically it seemed like I don't have enough memory anymore and I wasn't sure why, and yes I've tried putting the rmt_encode_stepper_motor_curve into IRAM using the IRAM_ATTR pretty much the same thing still happens.

@Dawid-Wawrzynczyk
Copy link
Author

So you enabled RMT_ISR_IRAM_SAFE Kconfig? If so, all RMT ISR callbacks must be placed in the IRAM, including your customized encoder function. Have you placed the rmt_encode_stepper_motor_curve into the IRAM?

So I've tried enabling the CONFIG_RMT_ISR_IRAM_SAFE but I disabled it because I started having memory problems when it's enabled, basically it seemed like I don't have enough memory anymore and I wasn't sure why, and yes I've tried putting the rmt_encode_stepper_motor_curve into IRAM using the IRAM_ATTR pretty much the same thing still happens.

Actually, update on the CONFIG_RMT_ISR_IRAM_SAFE, I played around with it, a little and the out of memory was only to do with a memory leak. I have fixed this now but the main issue still persists.

@suda-morris
Copy link
Collaborator

I would suggest you to strip your project to only contain the RMT + stepper motor driver and get rid of the LVGL layer.

@Dawid-Wawrzynczyk
Copy link
Author

I would suggest you to strip your project to only contain the RMT + stepper motor driver and get rid of the LVGL layer.

I'll try that, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

3 participants