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

IntegerDividByZero in i2s_std_set_clock (IDFGH-14952) #15659

Open
3 tasks done
floitsch opened this issue Mar 26, 2025 · 0 comments
Open
3 tasks done

IntegerDividByZero in i2s_std_set_clock (IDFGH-14952) #15659

floitsch opened this issue Mar 26, 2025 · 0 comments
Assignees
Labels
Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@floitsch
Copy link
Contributor

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.5-dev-2657-g23c73cdc37

Espressif SoC revision.

ESP32-D0WDQ6 (revision v1.0)

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.

ESP32S

Power Supply used.

USB

What is the expected behavior?

  • No panic.
  • Documentation which frequencies are acceptable for i2s.

What is the actual behavior?

Guru Meditation Error: Core 0 panic'ed (IntegerDivideByZero). Exception was unhandled.

Steps to reproduce.

Do an i2s_channel_init_std_mode with a frequency below 4000?.

#define BCLK -1
#define WS -1
#define DATA 32

#define BUFF_SIZE 1024
#define DATA_SIZE 12

#define SAMPLE_RATE 2000
#define BITS_PER_SAMPLE 16

static void init(void)
{
    i2s_chan_config_t tx_chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_MASTER);
    ESP_ERROR_CHECK(i2s_new_channel(&tx_chan_cfg, &tx_chan, NULL));

    i2s_std_config_t tx_std_cfg = {
        .clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(SAMPLE_RATE),
        .slot_cfg = I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG(BITS_PER_SAMPLE, I2S_SLOT_MODE_STEREO),
        .gpio_cfg = {
            .mclk = I2S_GPIO_UNUSED,
            .bclk = BCLK,
            .ws = WS,
            .dout = DATA,
            .din = I2S_GPIO_UNUSED,
            .invert_flags = {
                .mclk_inv = false,
                .bclk_inv = false,
                .ws_inv = false,
            },
        },
    };
    ESP_ERROR_CHECK(i2s_channel_init_std_mode(tx_chan, &tx_std_cfg));
}

Debug Logs.

I (312) main_task: Calling app_main()
Guru Meditation Error: Core  0 panic'ed (IntegerDivideByZero). Exception was unhandled.

Core  0 register dump:
PC      : 0x4000d099  PS      : 0x00060730  A0      : 0x800d9eed  A1      : 0x3ffb4290  
--- 0x4000d099: __udivdi3 in ROM

A2      : 0x00000000  A3      : 0x00000000  A4      : 0x00000000  A5      : 0x00000000  
A6      : 0x00000100  A7      : 0x00000006  A8      : 0x00000001  A9      : 0x00000000  
A10     : 0x00000000  A11     : 0x00000000  A12     : 0x00000008  A13     : 0x3f4075d5  
A14     : 0x00000001  A15     : 0x3ffb4150  SAR     : 0x0000001c  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff  
--- 0x4000c2e0: memcpy in ROM
0x4000c2f6: memcpy in ROM



Backtrace: 0x4000d096:0x3ffb4290 0x400d9eea:0x3ffb42b0 0x400da21d:0x3ffb4300 0x400d6ad9:0x3ffb4330 0x400d6bd0:0x3ffb43b0 0x400e5e75:0x3ffb43d0 0x40086455:0x3ffb4400
--- 0x4000d096: __udivdi3 in ROM
0x400d9eea: i2s_std_set_clock at /home/flo/NOSAVE/playground/esp-idf/components/esp_driver_i2s/i2s_std.c:99
0x400da21d: i2s_channel_init_std_mode at /home/flo/NOSAVE/playground/esp-idf/components/esp_driver_i2s/i2s_std.c:241
0x400d6ad9: init at /home/flo/NOSAVE/tmp/2025-04/i2s-native/main/i2s-native.c:106

Diagnostic report archive.

idf-diag-aa07af15-ebc9-4071-aac4-52f5ff4eb252.zip

More Information.

I have tracked it down to i2s_std_set_clock where the call to i2s_hal_set_tx_clock sets ret_mclk_div's fields denominator and numerator to 0.
The subsequent division by (ret_mclk_div.integer * ret_mclk_div.denominator + ret_mclk_div.numerator) then leads to a panic.

@floitsch floitsch added the Type: Bug bugs in IDF label Mar 26, 2025
@github-actions github-actions bot changed the title IntegerDividByZero in i2s_std_set_clock IntegerDividByZero in i2s_std_set_clock (IDFGH-14952) Mar 26, 2025
@espressif-bot espressif-bot added the Status: Opened Issue is new label Mar 26, 2025
@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: Opened Issue is new Status: Reviewing Issue is being reviewed labels Mar 28, 2025
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

3 participants