Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

"install interrupt handler Failed=261" when initializing two I2C buses #1869

Copy link
Copy link
Closed
@zecodeur

Description

@zecodeur
Issue body actions

Hardware:

Board: Custom board
Core Installation/update date: Release 1.0.0
IDE name: Arduino IDE
Flash Frequency: 80Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Windows 10

Description:

Hello,

I have a custom board with two I2C buses and have been happily using Stickbreaker’s fork (ie. release v.0.2.0 of https://github.com/stickbreaker/arduino-esp32 ) for quite a while. Things have been working great on this fork. Now I’d like to start using Release 1.0.0, since Stickbreaker’s work seems to have been integrated back into the main repo. However, I am hitting lots of error “install interrupt handler Failed=261” when initializing the second I2C bus, followed by a crash when setting an hw timer in my application code (cf traces below).

Would anybody have any idea of what I could be doing wrong? Is there something I need to change in my application code for it to work on Release 1.0.0?

From what I can tell, code 261 (0x105 ESP_ERR_NOT_FOUND I think) means “No free interrupt found with the specified flags”. Looking into the code where this error originates from (cores/esp32/esp32-hal-i2c.c, function i2cProcQueue) I think I see some differences between Release 1.0.0 (that gives me some trouble) and Stickbreaker’s fork (that works). Basically, the flags argument in the call to esp_intr_alloc_intrstatus() is now a combination of EPS_INTR_FLAG_xxx instead of just 0 in Stickbreaker’s fork. Now the crazy part: if I modify the 1.0.0 code to pass 0 as flags again (hum… yes, I tried that…), then everything seems to work (no more error, no more crash when setting up HW timer…).

References:

cores/esp32/esp32-hal-i2c.c

if(!i2c->intr_handle) { // create ISR for either peripheral
        // log_i("create ISR %d",i2c->num);
        uint32_t ret = 0;
        uint32_t flags = ESP_INTR_FLAG_EDGE |  //< Edge-triggered interrupt
          ESP_INTR_FLAG_IRAM |  //< ISR can be called if cache is disabled
          ESP_INTR_FLAG_LOWMED;   //< Low and medium prio interrupts. These can be handled in C.

        log_w("MY TRACE: i2c->num=%d", i2c->num); // Trace I added….
         if(i2c->num) {
            ret = esp_intr_alloc_intrstatus(ETS_I2C_EXT1_INTR_SOURCE, flags, (uint32_t)&i2c->dev->int_status.val, 0x7FF, &i2c_isr_handler_default,i2c, &i2c->intr_handle);
        } else {
            ret = esp_intr_alloc_intrstatus(ETS_I2C_EXT0_INTR_SOURCE, flags, (uint32_t)&i2c->dev->int_status.val, 0x7FF, &i2c_isr_handler_default,i2c, &i2c->intr_handle);
        }

        if(ret!=ESP_OK) {
            log_e("install interrupt handler Failed=%d",ret);
            I2C_MUTEX_UNLOCK();
            return I2C_ERROR_MEMORY;
        }
    }

https://github.com/espressif/esp-idf/blob/master/components/esp32/include/esp_err.h

#define ESP_ERR_NOT_FOUND           0x105   /*!< Requested resource not found */

https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/system/intr_alloc.html

/*
...
* @return ESP_ERR_INVALID_ARG if the combination of arguments is invalid.
*         ESP_ERR_NOT_FOUND No free interrupt found with the specified flags
*         ESP_OK otherwise
*/
esp_err_t esp_intr_alloc_intrstatus(int source, int flags, uint32_t intrstatusreg, uint32_t intrstatusmask, intr_handler_t handler, void *arg, intr_handle_t *ret_handle);

https://github.com/espressif/esp-idf/blob/3276a13/components/esp32/include/esp_intr_alloc.h

* @param flags An ORred mask of the ESP_INTR_FLAG_* defines. These restrict the
*               choice of interrupts that this routine can choose from. If this value
*               is 0, it will default to allocating a non-shared interrupt of level
*               1, 2 or 3. If this is ESP_INTR_FLAG_SHARED, it will allocate a shared
*               interrupt of level 1. Setting ESP_INTR_FLAG_INTRDISABLED will return 
*               from this function with the interrupt disabled.

Traces (esp32 + app):

[D>][    0.03][ZSER][ZSeries.h:540] setup BEGIN 0
[D_][    0.03][ZSER][ZSeries.h:394] screenPower() True
[I_][    0.04][SYST][System.h:267] scan()
[D>][    0.04][I2C][System.h:89] scan BEGIN 0
[W][esp32-hal-i2c.c:974] i2cProcQueue(): MY TRACE: i2c->num=0
[IV][    0.06][I2C] Name = I2CA
[IV][    0.06][I2C] Expected = 0x19 0x34 0x76
[IV][    0.06][I2C] Found = 0x19 0x34 0x76
[IV][    0.06][I2C] Missing =
[IV][    0.06][I2C] hasError = False
[D<][    0.07][I2C][System.h:89] scan END   29
[D>][    0.07][I2C][System.h:89] scan BEGIN 0
[W][esp32-hal-i2c.c:974] i2cProcQueue(): MY TRACE: i2c->num=1
[E][esp32-hal-i2c.c:982] i2cProcQueue(): install interrupt handler Failed=261
[W][esp32-hal-i2c.c:974] i2cProcQueue(): MY TRACE: i2c->num=1
[E][esp32-hal-i2c.c:982] i2cProcQueue(): install interrupt handler Failed=261

// … LOTS of errors 

[W][esp32-hal-i2c.c:974] i2cProcQueue(): MY TRACE: i2c->num=1
[E][esp32-hal-i2c.c:982] i2cProcQueue(): install interrupt handler Failed=261
[IV][    1.65][I2C] Name = I2CB
[IV][    1.66][I2C] Expected = 0x40
[IV][    1.66][I2C] Found =
[IV][    1.66][I2C] Missing = 0x40
[IV][    1.67][I2C] hasError = True
[D<][    1.67][I2C][System.h:89] scan END   1597
[E_][    1.67][SENS][SystemState.h:70] setError I2CB
[D>][    1.68][BSL][Msp.h:457] setup BEGIN 0
[IV][    1.70][MSPA] CRC_result = 57411
[W][esp32-hal-i2c.c:974] i2cProcQueue(): MY TRACE: i2c->num=1
[E][esp32-hal-i2c.c:982] i2cProcQueue(): install interrupt handler Failed=261
[W][esp32-hal-i2c.c:974] i2cProcQueue(): MY TRACE: i2c->num=1
[E][esp32-hal-i2c.c:982] i2cProcQueue(): install interrupt handler Failed=261
[IV][    1.72][MSP] bootRunning = False
[IV][    1.72][MSP] appRunning = False
[E_][    1.72][MSP][Msp.h:488] Could not figure out what MSP is currently running
[IV][    1.73][MSP] TRANSITION = Unknown -> Error
[D<][    1.74][BSL][Msp.h:457] setup END   59
[I_][    1.74][EPRM][Eeprom.h:138] save()
[D>][    1.78][MAX11613][MAX11613.h:265] setup BEGIN 0
[D<][    1.79][MAX11613][MAX11613.h:265] setup END   9
[D>][    1.79][HEAD][Head.h:645] setup BEGIN 0
[D>][    1.79][DSP][Display.h:253] setup BEGIN 0
[D<][    1.79][DSP][Display.h:253] setup END   1
[D<][    1.79][HEAD][Head.h:645] setup END   4
Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x40180f03  PS      : 0x00060e30  A0      : 0x800f6c06  A1      : 0x3ffb3ed0
A2      : 0x00000000  A3      : 0x0000060e  A4      : 0x40081df4  A5      : 0x00000001
A6      : 0x3ffd2730  A7      : 0x00000000  A8      : 0x800feea0  A9      : 0x3ffb3e80
A10     : 0x00000105  A11     : 0x0000060e  A12     : 0x00000000  A13     : 0x00000000
A14     : 0x40081df4  A15     : 0x00000000  SAR     : 0x00000020  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0x00000000

Backtrace: 0x40180f03:0x3ffb3ed0 0x400f6c03:0x3ffb3ef0 0x400eab45:0x3ffb3f10 0x400eabb2:0x3ffb3f80 0x400f026b:0x3ffb3fa0

Rebooting...

0x40180f03: esp_intr_get_cpu at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/esp32/intr_alloc.c line 772
0x40081df4: __timerISR at C:\Users\adrien\Documents\Arduino\hardware\espressif\esp32\cores\esp32/esp32-hal-timer.c line 173
0x40081df4: __timerISR at C:\Users\adrien\Documents\Arduino\hardware\espressif\esp32\cores\esp32/esp32-hal-timer.c line 173
0x40180f03: esp_intr_get_cpu at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/esp32/intr_alloc.c line 772
0x400f6c03: timerAttachInterrupt at C:\Users\adrien\Documents\Arduino\hardware\espressif\esp32\cores\esp32/esp32-hal-timer.c line 173

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.