Page 1 of 1

Cache disabled but cached memory region accessed

Posted: Tue Feb 15, 2022 7:54 am
by MaxSydney
I am intermittently encountering this error when writing data to flash. This seems to be an interaction between the RMT driver and writing/reading from VFS. Specifically, I only encounter this crash when using the ESP_INTR_FLAG_IRAM in rmt_driver_install.

What is likely the cause for this error, and what are the implications of not using this flag when installing the RMT driver?

Discussion https://github.com/DavidAntliff/esp32-owb/issues/25

Re: Cache disabled but cached memory region accessed

Posted: Tue Feb 15, 2022 10:44 pm
by WiFive
Please always specify your sdk, branch/commit, chipset, module, board, and any other relevant details.

The implications are that the isr will not run during flash operations.

Re: Cache disabled but cached memory region accessed

Posted: Wed Feb 16, 2022 8:47 am
by MaxSydney
Fair enough WiFive. Please let me know if there are any other details I can provide.

Could you explain why this interrupt firing while writing to flahs is causing this error? How is this typically dealt with?

esp32 wrover-b
Idf ver: 4.3 (c9646ff0beffc86d2c6d1bfbad34da16e328e0e3)

I (30) boot: chip revision: 1
I (33) boot.esp32: SPI Speed : 40MHz
I (38) boot.esp32: SPI Mode : DIO
I (42) boot.esp32: SPI Flash Size : 16MB

Re: Cache disabled but cached memory region accessed

Posted: Wed Feb 16, 2022 4:10 pm
by WiFive
Rmt driver should support iram flag and psram. Suggest you post a decoded backtrace. It seems like there is no requirement to use iram flag with that particular driver based on its transactional design but I could be wrong.

Re: Cache disabled but cached memory region accessed

Posted: Thu Feb 17, 2022 8:56 am
by MaxSydney
Thanks WiFive. Here's a trace

Code: Select all

I (86856) Filesystem: Mounting filesystem
I (86863) Filesystem: Filesystem mounted
I (86935) Controller: Controller tuning successfully written to file
W (86936) Controller: PBData total: 7781 bytes, used: 753 bytes
Re-enable cpu cache.
Guru Meditation Error: Core  0 panic'ed (Cache disabled but cached memory region accessed). 

Core  0 register dump:
PC      : 0x4017e470  PS      : 0x00060034  A0      : 0x80085b3c  A1      : 0x3ffb0800  
0x4017e470: rmt_ll_get_tx_err_interrupt_status at /home/max/esp/esp-idf/components/hal/esp32/include/hal/rmt_ll.h:294

A2      : 0x3ffb11f0  A3      : 0x00000000  A4      : 0x00000000  A5      : 0x00000080  
A6      : 0x00000001  A7      : 0x00000001  A8      : 0x800860c1  A9      : 0x3ffb11f0  
A10     : 0x3ff56000  A11     : 0xfffffff7  A12     : 0x00000000  A13     : 0x3ffdb6b0  
A14     : 0x00060023  A15     : 0x00000000  SAR     : 0x0000001d  EXCCAUSE: 0x00000007  
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  

Backtrace:0x4017e46d:0x3ffb0800 0x40085b39:0x3ffb0840 0x40084259:0x3ffb0860 0x400847fa:0x3ffafa00 0x40084760:0x3ffafa20
0x4017e46d: rmt_ll_enable_tx_err_interrupt at /home/max/esp/esp-idf/components/hal/esp32/include/hal/rmt_ll.h:240

0x40085b39: shared_intr_isr at /home/max/esp/esp-idf/components/esp_system/intr_alloc.c:421

0x40084259: _xt_lowint1 at /home/max/esp/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1105

0x400847fa: spi_flash_op_block_func at /home/max/esp/esp-idf/components/spi_flash/cache_utils.c:114

0x40084760: ipc_task at /home/max/esp/esp-idf/components/esp_ipc/ipc.c:62



ELF file SHA256: 4935c03c7c4c20f5

Rebooting...
ets Jun  8 2016 00:22:57

Re: Cache disabled but cached memory region accessed

Posted: Thu May 26, 2022 4:30 am
by Alemarius Nexus
I am getting the exact same error, under pretty much the exact same circumstances: A "Cache disabled but ..." Guru error in the RMT driver (using the same esp32-owb library as OP) while reading from the SPI flash. I'm using ESP-IDF v4.4.1. Here's the backtrace:

Code: Select all

Guru Meditation Error: Core  0 panic'ed (Cache disabled but cached memory region accessed).

Core  0 register dump:
PC      : 0x4016189c  PS      : 0x00060034  A0      : 0x80081f70  A1      : 0x3ffb0ba0
0x4016189c: rmt_ll_get_tx_err_interrupt_status at C:/esp/esp-idf/components/hal/esp32/include/hal/rmt_ll.h:307

A2      : 0x3ffb14fc  A3      : 0x00000000  A4      : 0x00000080  A5      : 0x00000001
A6      : 0x00000001  A7      : 0x00000000  A8      : 0x80084643  A9      : 0x000e0f20
A10     : 0x3ff56000  A11     : 0x3ffb0ba4  A12     : 0x00000000  A13     : 0x3ffd7ee8
A14     : 0x00060023  A15     : 0x00000000  SAR     : 0x00000020  EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000


Backtrace:0x40161899:0x3ffb0ba00x40081f6d:0x3ffb0be0 0x40083935:0x3ffb0c00 0x4008578c:0x3ffafbd0 0x40083dbc:0x3ffafbf0
0x40161899: rmt_ll_enable_tx_err_interrupt at C:/esp/esp-idf/components/hal/esp32/include/hal/rmt_ll.h:252

0x40081f6d: shared_intr_isr at C:/esp/esp-idf/components/esp_hw_support/intr_alloc.c:407

0x40083935: _xt_lowint1 at C:/esp/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1111

0x4008578c: spi_flash_op_block_func at C:/esp/esp-idf/components/spi_flash/cache_utils.c:123 (discriminator 1)

0x40083dbc: ipc_task at C:/esp/esp-idf/components/esp_ipc/src/esp_ipc.c:74

With some random modifications to my application code, I can also coax another, similar trace out of it:

Code: Select all

Guru Meditation Error: Core  0 panic'ed (Cache disabled but cached memory region accessed).

Core  0 register dump:
PC      : 0x4015831c  PS      : 0x00060034  A0      : 0x80081e98  A1      : 0x3ffb0ba0
0x4015831c: rmt_ll_get_tx_err_interrupt_status at C:/esp/esp-idf/components/hal/esp32/include/hal/rmt_ll.h:307

A2      : 0x3ffb14f8  A3      : 0x00000000  A4      : 0x00000080  A5      : 0x00000001
A6      : 0x00000001  A7      : 0x00000000  A8      : 0x8008456b  A9      : 0x000e0f20
A10     : 0x3ff56000  A11     : 0x3ffb0ba4  A12     : 0x00000001  A13     : 0x3ffddf30
A14     : 0x00060023  A15     : 0x00000000  SAR     : 0x00000020  EXCCAUSE: 0x00000007
EXCVADDR: 0x00000000  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0x00000000


Backtrace:0x40158319:0x3ffb0ba00x40081e95:0x3ffb0be0 0x4008385d:0x3ffb0c00 0x4000c2df:0x3ffbfef0 0x400934f1:0x3ffbff00 0x40085752:0x3ffbff80 0x400f5d79:0x3ffbffc0 0x400ebc8d:0x3ffbfff0 0x400ebf69:0x3ffc0020 0x400ebfdb:0x3ffc0060 0x400ec09b:0x3ffc00c0 0x400ec93a:0x3ffc00f0 0x400ee526:0x3ffc0150 0x400eedbb:0x3ffc01a0 0x400eb133:0x3ffc01c0 0x400d3aab:0x3ffc01f0 0x4014771c:0x3ffc0210 0x401477c5:0x3ffc0240 0x400dc15d:0x3ffc0260 0x400d86a5:0x3ffc0310
0x40158319: rmt_ll_enable_tx_err_interrupt at C:/esp/esp-idf/components/hal/esp32/include/hal/rmt_ll.h:252

0x40081e95: shared_intr_isr at C:/esp/esp-idf/components/esp_hw_support/intr_alloc.c:407

0x4008385d: _xt_lowint1 at C:/esp/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1111

0x400934f1: spi_flash_chip_generic_read at C:/esp/esp-idf/components/spi_flash/spi_flash_chip_generic.c:220

0x40085752: esp_flash_read at C:/esp/esp-idf/components/spi_flash/esp_flash_api.c:832

0x400f5d79: esp_partition_read at C:/esp/esp-idf/components/spi_flash/partition.c:424

0x400ebc8d: littlefs_api_read at C:/Users/alemariusnexus/workspace/vustoy/master/esp32-vustoy/externals/components/esp_littlefs/src/littlefs_api.c:22

0x400ebf69: lfs_bd_read at C:/Users/alemariusnexus/workspace/vustoy/master/esp32-vustoy/externals/components/esp_littlefs/src/littlefs/lfs.c:99
 (inlined by) lfs_bd_read at C:/Users/alemariusnexus/workspace/vustoy/master/esp32-vustoy/externals/components/esp_littlefs/src/littlefs/lfs.c:27

0x400ebfdb: lfs_dir_getslice at C:/Users/alemariusnexus/workspace/vustoy/master/esp32-vustoy/externals/components/esp_littlefs/src/littlefs/lfs.c:600

0x400ec09b: lfs_dir_get at C:/Users/alemariusnexus/workspace/vustoy/master/esp32-vustoy/externals/components/esp_littlefs/src/littlefs/lfs.c:646

0x400ec93a: lfs_dir_find at C:/Users/alemariusnexus/workspace/vustoy/master/esp32-vustoy/externals/components/esp_littlefs/src/littlefs/lfs.c:1230

0x400ee526: lfs_file_rawopencfg at C:/Users/alemariusnexus/workspace/vustoy/master/esp32-vustoy/externals/components/esp_littlefs/src/littlefs/lfs.c:2483

0x400eedbb: lfs_file_rawopen at C:/Users/alemariusnexus/workspace/vustoy/master/esp32-vustoy/externals/components/esp_littlefs/src/littlefs/lfs.c:2625
 (inlined by) lfs_file_open at C:/Users/alemariusnexus/workspace/vustoy/master/esp32-vustoy/externals/components/esp_littlefs/src/littlefs/lfs.c:5094

0x400eb133: vfs_littlefs_open at C:/Users/alemariusnexus/workspace/vustoy/master/esp32-vustoy/externals/components/esp_littlefs/src/esp_littlefs.c:939

0x400d3aab: esp_vfs_open at C:/esp/esp-idf/components/vfs/vfs.c:399 (discriminator 3)

0x4014771c: _fopen_r at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/fopen.c:129

0x401477c5: fopen at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/fopen.c:168

For me, this only happens when compiling with size optimizations (-Os). It does not happen with -O2. I have searched around a bit and found a discussion about similar errors that seemed to have something to do with function inlining:

https://github.com/espressif/esp-idf/is ... -669172977
https://github.com/espressif/esp-idf/is ... -823995356

I have not really looked into how all of this relates, so I might be way off here, but I do notice that the offending function is declared inline but not forced inline like this, which seemed to be the problem in that discussion:

Code: Select all

static inline uint32_t rmt_ll_get_tx_err_interrupt_status(rmt_dev_t *dev)
{
    uint32_t status =  dev->int_st.val;
    return ((status & 0x04) >> 2) | ((status & 0x20) >> 4) | ((status & 0x100) >> 6) | ((status & 0x800) >> 8) |
           ((status & 0x4000) >> 10) | ((status & 0x20000) >> 12) | ((status & 0x100000) >> 14) | ((status & 0x800000) >> 16);
}