Page 1 of 1

Custom build works, except i2c.readfrom_mem

Posted: Tue Oct 26, 2021 11:31 am
by wbdsgnr
I'm using esp-idf v4.4-dev (latest commit before 5.0-dev) and micropython v1.17(also tested master branch) and am testing on a esp32-devkit-v4 module. I added some code to micropython use WiFi Enterprise from python. After building for GENERIC, wifi works, bluetooth works, standard things work. So far I've walked against one bug and that's when I use i2c.readfrom_mem() function, it crashes the freertos kernel and reboots. Weird thing is it does work with the dirty general binairies available on the website. This is the error:

Code: Select all

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

Core  0 register dump:
PC      : 0x4008c788  PS      : 0x00060031  A0      : 0x8008c91d  A1      : 0x3ffbe8d0
0x4008c788: i2c_master_cmd_begin_static at /opt/esp-idf-sdk/components/driver/i2c.c:1345

A2      : 0x3ffb6f70  A3      : 0x00000000  A4      : 0x00000000  A5      : 0x6002701c
A6      : 0x00000001  A7      : 0x00000000  A8      : 0x3ffb717c  A9      : 0x00000901
A10     : 0x000000a5  A11     : 0x00000001  A12     : 0x00000001  A13     : 0x3ffb7180
A14     : 0x00000000  A15     : 0x3ff67000  SAR     : 0x0000001d  EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000008  LBEG    : 0x4008c73a  LEND    : 0x4008c746  LCOUNT  : 0x00000000
0x4008c73a: i2c_ll_write_txfifo at /opt/esp-idf-sdk/components/hal/esp32/include/hal/i2c_ll.h:548
 (inlined by) i2c_master_cmd_begin_static at /opt/esp-idf-sdk/components/driver/i2c.c:1338

0x4008c746: i2c_master_cmd_begin_static at /opt/esp-idf-sdk/components/driver/i2c.c:1339



Backtrace:0x4008c785:0x3ffbe8d00x4008c91a:0x3ffbe910 0x40082c95:0x3ffbe940 0x401dd203:0x3ffbcf80 0x400d2d33:0x3ffbcfa0 0x40096244:0x3ffbcfc0
0x4008c785: i2c_master_cmd_begin_static at /opt/esp-idf-sdk/components/driver/i2c.c:1345

0x4008c91a: i2c_isr_handler_default at /opt/esp-idf-sdk/components/driver/i2c.c:500

0x40082c95: _xt_lowint1 at /opt/esp-idf-sdk/components/freertos/port/xtensa/xtensa_vectors.S:1111

0x401dd203: cpu_ll_waiti at /opt/esp-idf-sdk/components/hal/esp32/include/hal/cpu_ll.h:183
 (inlined by) esp_pm_impl_waiti at /opt/esp-idf-sdk/components/esp_pm/pm_impl.c:838

0x400d2d33: esp_vApplicationIdleHook at /opt/esp-idf-sdk/components/esp_system/freertos_hooks.c:63

0x40096244: prvIdleTask at /opt/esp-idf-sdk/components/freertos/tasks.c:3956
So it seems like there's an unhandled interrupt. Normal i2c.readfrom() and writeto() do work. I understand I can use those two as a workaround, but for completeness i'm trying to make readfrom_mem to work. Anyone knows what I'm missing? Might be a simple sdk configuration flag I need to add.

Re: Custom build works, except i2c.readfrom_mem

Posted: Tue Oct 26, 2021 2:13 pm
by wbdsgnr
Nevermind, solved it. Bug in sdk v4.4, null pointer dereference.

For future reference, change this line to

Code: Select all

if(p_i2c->cmd_link.head!=NULL)
	p_i2c->cmd_link.head->cmd.bytes_used = 0;

Re: Custom build works, except i2c.readfrom_mem

Posted: Thu Nov 25, 2021 7:17 pm
by uraich
Just wanted to say: "thank you!" This was very helpful to me, because I stumbled over the same problem.
Did you raise an issue at the espidf github repository?

Re: Custom build works, except i2c.readfrom_mem

Posted: Sun Jan 16, 2022 10:02 am
by Klaas
Thank you for the solution after searching for a few hours!

Re: Custom build works, except i2c.readfrom_mem

Posted: Sat Jan 29, 2022 10:45 am
by freak42
Is there a possibility you could make your build available (I'd love to have a enterprise wifi capable build).
Or is there a good tutorial somewhere how to build for esp32 (w/ enterprise wifi)?

Thanks in advance

Re: Custom build works, except i2c.readfrom_mem

Posted: Tue Jun 07, 2022 2:30 pm
by ChrisO
Ran into this issue today as well. For future reference: seems like this is already included in esp-idf v4.4.1