Crash on initialization of nvs

banjoluck
Posts: 25
Joined: Fri Jul 29, 2022 5:11 pm

Crash on initialization of nvs

Postby banjoluck » Tue Apr 25, 2023 9:01 pm

When I invoke nvs_flash_init(), the program crashes. Without this call, it doesn't. I don't think this call, specifically, is the problem, but I can see that adding just this one call is enough to make the program crash.

The stack backtrace shows that these is the problem instructions:

Code: Select all

401019bc <adc_hal_get_desc_addr>:
{
401019bc:       004136          entry   a1, 32
    return adc_dma_ll_get_in_suc_eof_desc_addr(hal->dev, hal->dma_chan);
401019bf:       5228            l32i.n  a2, a2, 20
    *eof_addr = hw->in_eof_des_addr;
401019c1:       0020c0          memw
401019c4:       f228            l32i.n  a2, a2, 60
}
401019c6:       f01d            retw.n

401019c8 <adc_hal_check_event>:
{
401019c8:       004136          entry   a1, 32
    return adc_dma_ll_rx_get_intr(hal->dev, mask);
401019cb:       5228            l32i.n  a2, a2, 20
    return hw->int_st.val;
401019cd:       0020c0          memw
401019d0:       4228            l32i.n  a2, a2, 16
401019d2:       103320          and     a3, a3, a2
401019d5:       120c            movi.n  a2, 1
401019d7:       080c            movi.n  a8, 0
401019d9:       832830          moveqz  a2, a8, a3
}
401019dc:       f01d            retw.n

And here is the backtrace and registers:
Guru Meditation Error: Core 0 panic'ed (Cache disabled but cached memory region accessed).

Core 0 register dump:
PC : 0x401019c8 PS : 0x00060034 A0 : 0x400832b4 A1 : 0x3ffb1dc0
A2 : 0x3ffc1d68 A3 : 0x3ffc1d6c A4 : 0x00040000 A5 : 0x4008f1ea
A6 : 0x3ffc6184 A7 : 0x3ff420c0 A8 : 0x80088c5e A9 : 0x3ffc61c4
A10 : 0x3ffc1d6c A11 : 0x00000200 A12 : 0x00000000 A13 : 0x00002000
A14 : 0x00000006 A15 : 0x3ffb5218 SAR : 0x00000018 EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000 LBEG : 0x40089ac2 LEND : 0x40089acd LCOUNT : 0x00000000


Backtrace: 0x401019c5:0x3ffb1dc0 0x400832b1:0x3ffb1de0 0x400907cf:0x3ffc6140 0x400905d2:0x3ffc6160 0x40093294:0x3ffc6180 0x40088273:0x3ffc6200 0x400eee39:0x3ffc6240 0x400ec7be:0x3ffc6260 0x400ed7cc:0x3ffc6280 0x400ed9fb:0x3ffc62c0 0x400ec67b:0x3ffc6330 0x400ec9dc:0x3ffc6390 0x400eca41:0x3ffc63b0 0x400ec246:0x3ffc63e0 0x400ec25a:0x3ffc6410 0x400ddc03:0x3ffc6430 0x400ddc75:0x3ffc6490 0x400daa2d:0x3ffc64b0 0x400daa49:0x3ffc64d0 0x4008ee39:0x3ffc64f0
A couple of steps back in the stack, I can see that the program is catching an interrupt with function _xt_medint2.

Documentation states that this kind of thing could happen if the ISR is invoked from flash when flash access is disabled. We would need to put the handlers into IRAM. But, we don't explicitly setup our handlers with ESP_INTR_FLAG_IRAM. The ADC is running and the callback is declared with the IRAM_ATTR attribute, but we don't set this INTR option.

Is there some other place where we should be looking?

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: Crash on initialization of nvs

Postby ESP_Sprite » Wed Apr 26, 2023 1:02 am

Suggest you decode that backtrace (idf.py monitor will do it automatically when you trigger the error), that should point you into the right direction.

Who is online

Users browsing this forum: MicroController and 131 guests