Page 1 of 2

(resolved) I2C malloc error

Posted: Tue Mar 12, 2019 4:41 pm
by mzimmers
Hi all -

Occasionally my program throws this error:

E (2113976) i2c: i2c command link malloc error
abort() was called at PC 0x40123d9f on core 1

Backtrace: 0x4008da28:0x3ffdd390 0x4008dc7d:0x3ffdd3b0 0x40123d9f:0x3ffdd3d0 0x40123de6:0x3ffdd3f0 0x4010aacb:0x3ffdd410 0x40112823:0x3ffdd430 0x400ec0a5:0x3ffdd450 0x400ec428:0x3ffdd4b0 0x400ec52d

At other times, I get a GME without the message, but the same result (reboot). Is anyone aware of a bug in the I2C library, or am I really running out of heap?

Running the ESP-IDF master branch. Thanks...

Re: I2C malloc error

Posted: Tue Mar 12, 2019 4:53 pm
by ESP_Sprite
Sounds like you're out of memory; the i2c driver throws that error when a malloc of internal RAM fails.

Re: I2C malloc error

Posted: Tue Mar 12, 2019 5:06 pm
by mzimmers
Thanks, Sprite. Well, I can't add memory to our board, so I'll have to try to trim some fat. How do I get make to generate a map file for me?

Re: I2C malloc error

Posted: Tue Mar 12, 2019 5:24 pm
by ESP_Sprite
It should automatically do that while linking iirc, it's under build/[projectname].map .

Re: I2C malloc error

Posted: Tue Mar 12, 2019 5:31 pm
by mzimmers
Doesn't seem to be. Is it possible I have an option set somewhere in my build command files to suppress map generation?

Re: I2C malloc error

Posted: Tue Mar 12, 2019 6:56 pm
by fly135
1) How many threads do you have? Have you tried monitoring the min stack free on those threads to see if you can lower the stack size?

2) Do you need Bluetooth? Both BLE and classic. I freed up a lot of memory by eliminating Bt. If I need BLE, it's only for configuration and I reboot after with Bt disabled.

John A

Re: I2C malloc error

Posted: Tue Mar 12, 2019 7:49 pm
by mzimmers
I have 8 threads besides main(). I'm sure you're right about being able to reduce the stack sizes.

I don't use Bluetooth, or BLE, but I can't rule out the use of it someday, and since we'd rather not have to do 2 FCC compliance tests (one with Bluetooth and one without), I think I need to keep it enabled.

I read here: https://docs.espressif.com/projects/esp ... m-data-ram
DRAM (data RAM)

Non-constant static data and zero-initialized data is placed by the linker into the 256 kB 0x3FFB0000 — 0x3FFF0000 region. Note that this region is reduced by 64kB (by shifting start address to 0x3FFC0000) if Bluetooth stack is used. Length of this region is also reduced by 16 kB or 32kB if trace memory is used.
What is trace memory?

Re: I2C malloc error

Posted: Tue Mar 12, 2019 11:58 pm
by WiFive

Re: I2C malloc error

Posted: Tue Apr 02, 2019 4:04 pm
by mzimmers
Hi all -

I am still trying to chase down the cause of this persistent I2C crash. Evidently, a lot of other users are experiencing similar troubles, and I found a post from last year where it's suggested that the problem may be in the hardware:
https://www.esp32.com/viewtopic.php?f=1 ... =20#p20533
We have no such pull-up resistors on the SDA or SCL lines, so if the poster is correct, this might be an issue.

But...could this lack of pull-ups manifest in a GME panic in a call to i2c_master_cmd_begin_static()? Seems like an odd way for this problem to show up...

Thanks for any insights...I really need to get this fixed soon.

Re: I2C malloc error

Posted: Wed Apr 03, 2019 4:24 am
by ESP_Sprite
You certainly need pull-ups, but the likelyhood of it resulting in a crash like that is low. (Depends on what your code does, however.)