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

ESP32-C6 crashes in adc_oneshot_read() after bootloader_random_enable() (IDFGH-13368) #14280

Closed
3 tasks done
pelya opened this issue Jul 31, 2024 · 2 comments
Closed
3 tasks done
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@pelya
Copy link

pelya commented Jul 31, 2024

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.

v5.3

Espressif SoC revision.

ESP32-C6

Operating System used.

Linux

How did you build your project?

Command line with idf.py

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

None

Development Kit.

ESP32-C6

Power Supply used.

USB

What is the expected behavior?

Not crash.

What is the actual behavior?

The crash only happens on ESP32-C6. The same code works fine on ESP32-C3.

Steps to reproduce.

Please see the attached code sample to reproduce the crash. Removind bootloader_random_enable() and bootloader_random_disable() will stop the crashing. ADC is freed before calling bootloader_random_enable() and re-initialized after calling bootloader_random_disable(), so there should be no issue with concurrent usage of ADC.

#include <freertos/FreeRTOS.h>
#include "esp_log.h"
#include "esp_adc/adc_oneshot.h"
#include "esp_random.h"
#include "bootloader_random.h"

const static char *TAG = "EXAMPLE";

#define EXAMPLE_ADC1_CHAN0          ADC_CHANNEL_0
#define EXAMPLE_ADC_ATTEN           ADC_ATTEN_DB_12

void app_main(void)
{

    adc_oneshot_unit_handle_t adc1_handle;
    adc_oneshot_unit_init_cfg_t init_config1 = {
        .unit_id = ADC_UNIT_1,
    };
    ESP_ERROR_CHECK(adc_oneshot_new_unit(&init_config1, &adc1_handle));

    adc_oneshot_chan_cfg_t config = {
        .bitwidth = ADC_BITWIDTH_DEFAULT,
        .atten = EXAMPLE_ADC_ATTEN,
    };
    ESP_ERROR_CHECK(adc_oneshot_config_channel(adc1_handle, EXAMPLE_ADC1_CHAN0, &config));

    while (1) {
        int adc_raw = 0;
        ESP_ERROR_CHECK(adc_oneshot_read(adc1_handle, EXAMPLE_ADC1_CHAN0, &adc_raw));
        ESP_LOGI(TAG, "ADC%d Channel[%d] Raw Data: %d", ADC_UNIT_1 + 1, EXAMPLE_ADC1_CHAN0, adc_raw);
        vTaskDelay(pdMS_TO_TICKS(1000));

        ESP_ERROR_CHECK(adc_oneshot_del_unit(adc1_handle));
        bootloader_random_enable();
        uint32_t value = esp_random();
        ESP_LOGI(TAG, "Generated true random value: 0x%08lx", value);
        bootloader_random_disable();
        ESP_ERROR_CHECK(adc_oneshot_new_unit(&init_config1, &adc1_handle));
        ESP_ERROR_CHECK(adc_oneshot_config_channel(adc1_handle, EXAMPLE_ADC1_CHAN0, &config));
    }
}

Debug Logs.

I (321) main_task: Calling app_main()
I (321) gpio: GPIO[0]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (331) EXAMPLE: calibration scheme version is Curve Fitting
I (341) EXAMPLE: Calibration Success
I (341) EXAMPLE: ADC1 Channel[0] Raw Data: 2465
I (351) EXAMPLE: ADC1 Channel[0] Cali Voltage: 2367 mV
I (1351) EXAMPLE: Generated true random value: 0xb467407f
I (1351) gpio: GPIO[0]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
Guru Meditation Error: Core  0 panic'ed (Interrupt wdt timeout on CPU0). 

Core  0 register dump:
...

More Information.

Reproducibility 100%

@pelya pelya added the Type: Bug bugs in IDF label Jul 31, 2024
@github-actions github-actions bot changed the title ESP32-C6 crashes in adc_oneshot_read() after bootloader_random_enable() ESP32-C6 crashes in adc_oneshot_read() after bootloader_random_enable() (IDFGH-13368) Jul 31, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jul 31, 2024
@Bruce297
Copy link
Collaborator

Bruce297 commented Aug 1, 2024

bootloader_random_disable should not be called after ADC initialize, that's a known conflict.
You can see on

* bootloader_random_enable() and before RF subsystem features, ADC, or

We will consider to fix it if possible in future.

@playfulFence
Copy link

I think this bug is already being worked on in a similar #14124 issue

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: Opened Issue is new labels Aug 12, 2024
espressif-bot pushed a commit that referenced this issue Aug 12, 2024
…or C6

This configuration bit is required for ADC operation as well and hence
should not be cleared in the RNG API sequence.

Ideally, the ADC driver should take care of initializing this bit but
still the RNG layer change is required because of interleaved API usage
scenario described in following linked issue.

Closes #14124
Closes #14280
espressif-bot pushed a commit that referenced this issue Aug 21, 2024
…or C6

This configuration bit is required for ADC operation as well and hence
should not be cleared in the RNG API sequence.

Ideally, the ADC driver should take care of initializing this bit but
still the RNG layer change is required because of interleaved API usage
scenario described in following linked issue.

Closes #14124
Closes #14280
espressif-bot pushed a commit that referenced this issue Aug 22, 2024
…or C6

This configuration bit is required for ADC operation as well and hence
should not be cleared in the RNG API sequence.

Ideally, the ADC driver should take care of initializing this bit but
still the RNG layer change is required because of interleaved API usage
scenario described in following linked issue.

Closes #14124
Closes #14280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

4 participants