guild icon
Toit
#Out of memory following the OLED display example
Thread channel in help
Tony
Tony 08/16/2024 07:18 PM
Here is the message:

[jaguar] INFO: program 8358aee2-45c6-0193-6318-b75de00f59f3 stopped [jaguar] INFO: program c6925192-2d45-548f-7f78-726e3c457cad started Heap report @ out of memory in primitive 6:2: ┌───────────┬──────────┬─────────────────────────────────────────────────────┐ │ Bytes │ Count │ Type │ ├───────────┼──────────┼─────────────────────────────────────────────────────┤ │ 40960 │ 12 │ toit processes │ │ 16384 │ 4 │ system 0 0ff85ae2-63d2-e530-c9fe-c844785c0276 │ │ 20480 │ 5 │ other 1 31709de1-906c-ce7d-8698-87e163711ebb │ │ 4096 │ 1 │ current 7 c6925192-2d45-548f-7f78-726e3c457cad │ │ 667648 │ 1 │ heap metadata │ │ 4096 │ 1 │ spare new-space │ │ 16808 │ 7 │ heap overhead │ │ 192 │ 4 │ thread/other │ └───────────┴──────────┴─────────────────────────────────────────────────────┘ Total: 729704 bytes in 16 allocations (8%), largest free 7452k, total free 7471k ****************************************************************************** Decoding by `jag`, device has version <2.0.0-alpha.159> ****************************************************************************** MALLOC_FAILED error. 0: Bus.test <sdk>/i2c.toit:65:5 1: Bus.scan <sdk>/i2c.toit:60:10 2: main display.toit:23:18 ****************************************************************************** [jaguar] ERROR: program c6925192-2d45-548f-7f78-726e3c457cad stopped - exit code 1

I am trying to upload the OLED example with only the I2C pins changed. At first I thought it was genuinely out of memory, but it doesn't appear so looking at the table.
Tony
Tony 08/16/2024 07:19 PM
It seems unlikely that a single allocation asked for the remaining 7.5 MB of memory. Could it have something to do with the chip configuration --chip esp32s3-spiram-octo?
floitsch
floitsch 08/16/2024 07:24 PM
Interesting...
I will try to figure out what primitive 6:2 is and what it does.
I think there is a possibility that it needs internal ram and we only have external. But that's a wild guess...
Did you run any other programs first?
floitsch
floitsch 08/16/2024 07:25 PM
Primite 6:2 is i2c-write.
floitsch
floitsch 08/16/2024 07:28 PM
I wonder if we are hitting this:
// NOTE: // 'i2c_master_X' functions allocate data, but return `ESP_FAIL` if that allocation // fails. There is no way to differentiate the kind of error. // Initiate the sequence by issuing a `start`. That will notify slaves to // listen (if possible) and promote self to current master, in case of // multi-master setup. if (i2c_master_start(cmd) != ESP_OK) FAIL(MALLOC_FAILED);
floitsch
floitsch 08/16/2024 07:31 PM
Unfortunately not much I can do right now: I don't have any ESP32 with me to try to reproduce. That will have to wait until next week.
Do you know if the OLED example worked without spiram? With the standard envelope?
floitschfloitsch
Interesting... I will try to figure out what primitive 6:2 is and what it does. I think there is a possibility that it needs internal ram and we only have external. But that's a wi...
Tony
Tony 08/16/2024 07:39 PM
Yes. I ran hello-world and blink programs without issue.
floitschfloitsch
Unfortunately not much I can do right now: I don't have any ESP32 with me to try to reproduce. That will have to wait until next week. Do you know if the OLED example worked witho...
Tony
Tony 08/16/2024 07:39 PM
I don't know. I will try!
TonyOPTony
Yes. I ran hello-world and blink programs without issue.
floitsch
floitsch 08/16/2024 07:40 PM
So two things to try:
Run the OLED program after a reset. (Best chance that memory is still available).
Run on the other (non spiram) envelope.
That could give us some hints.
floitsch
floitsch 08/16/2024 07:41 PM
Maybe @bitphlipphar has other ideas, when he catches up on this thread.
floitschfloitsch
So two things to try: Run the OLED program after a reset. (Best chance that memory is still available). Run on the other (non spiram) envelope. That could give us some hints.
Tony
Tony 08/16/2024 07:43 PM
Thank you for your suggestion. The program DOES run with --chip esp32s3. Does that effectively mean programs do not have access to the 8 MB SPRAM if I need to run all programs in this way?
floitsch
floitsch 08/16/2024 07:44 PM
Some low level operations need to have their memory in specific regions. We might allocate something in the I2C functions incorrectly.
At least that's what I think
floitsch
floitsch 08/16/2024 07:46 PM
One more request: could you make us a repro? Basically instructions that consistently create the error.
We should be able to find a device with external memory and then debug it. (When I come back next week).
floitschfloitsch
One more request: could you make us a repro? Basically instructions that consistently create the error. We should be able to find a device with external memory and then debug it. ...
Tony
Tony 08/16/2024 07:47 PM
Yes. I should be able to do that later today.
Tony
Tony 08/16/2024 07:48 PM
Thank you!
floitsch
floitsch 08/16/2024 07:48 PM
Thanks
Tony
Tony 08/16/2024 07:48 PM
I've been mostly in the application-level-programming for a while, but I'd be happy to help too.
floitsch
floitsch 08/16/2024 07:50 PM
If I can reproduce it should be relatively straightforward to figure out what's going wrong. If not, getting your help would be very valuable.
Tony
Tony 08/16/2024 10:37 PM
floitsch
floitsch 08/16/2024 10:38 PM
So flash the spiram envelope and then run this program and there is always a memory error?
Tony
Tony 08/16/2024 11:50 PM
Yes. That is correct.
👍1
Tyrone Smith
Tyrone Smith 08/19/2024 12:38 PM
I'm having the same issue with the default --chip esp32s3 configuration.(edited)
floitsch
floitsch 08/19/2024 05:58 PM
Ok. Good to know.
floitsch
floitsch 08/21/2024 11:35 AM
@Tyrone Smith I have uploaded an esp32s3-debug envelope.
If you could try to reproduce the error with that one and report back the debug output it produces that would be helpful.
You should be able to just run jag flash --chip=esp32s3-debug.
Tyrone Smith
Tyrone Smith 08/21/2024 11:59 AM
I'll be able to try it in about a hour :👍:
floitschfloitsch
@Tyrone Smith I have uploaded an esp32s3-debug envelope. If you could try to reproduce the error with that one and report back the debug output it produces that would be...
Tyrone Smith
Tyrone Smith 08/26/2024 08:18 AM
I'm sorry, forgot about this, I'll provide u the debug output today!
👍1
Tyrone SmithTyrone Smith
I'm sorry, forgot about this, I'll provide u the debug output today!
floitsch
floitsch 09/04/2024 10:10 AM
Any update?
Tyrone Smith
Tyrone Smith 09/05/2024 02:22 PM
It's what we talked about in dms
Tyrone Smith
Tyrone Smith 09/05/2024 02:23 PM
A problem on my side, the i2c was not properly powered
floitsch
floitsch 09/05/2024 02:41 PM
Right.
It's still a bug on our side that we report it as OOM, but we will have to rewrite the i2c driver anyway (since espressif deprecated the API we are currently using).
30 messages in total