(resolved) I2C malloc error

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

(resolved) I2C malloc error

Postby mzimmers » Tue Mar 12, 2019 4:41 pm

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...
Last edited by mzimmers on Wed Apr 17, 2019 8:49 pm, edited 1 time in total.

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

Re: I2C malloc error

Postby ESP_Sprite » Tue Mar 12, 2019 4:53 pm

Sounds like you're out of memory; the i2c driver throws that error when a malloc of internal RAM fails.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: I2C malloc error

Postby mzimmers » Tue Mar 12, 2019 5:06 pm

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?

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

Re: I2C malloc error

Postby ESP_Sprite » Tue Mar 12, 2019 5:24 pm

It should automatically do that while linking iirc, it's under build/[projectname].map .

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: I2C malloc error

Postby mzimmers » Tue Mar 12, 2019 5:31 pm

Doesn't seem to be. Is it possible I have an option set somewhere in my build command files to suppress map generation?

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: I2C malloc error

Postby fly135 » Tue Mar 12, 2019 6:56 pm

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

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: I2C malloc error

Postby mzimmers » Tue Mar 12, 2019 7:49 pm

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?


User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: I2C malloc error

Postby mzimmers » Tue Apr 02, 2019 4:04 pm

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.

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

Re: I2C malloc error

Postby ESP_Sprite » Wed Apr 03, 2019 4:24 am

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.)

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 131 guests