Skip to content

Adafruit-Qualia-S3 "pystack exhausted" #8574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jacobmarble opened this issue Nov 10, 2023 · 12 comments · Fixed by #8598
Closed

Adafruit-Qualia-S3 "pystack exhausted" #8574

jacobmarble opened this issue Nov 10, 2023 · 12 comments · Fixed by #8598

Comments

@jacobmarble
Copy link

CircuitPython version

Adafruit CircuitPython 9.0.0-alpha.2-18-gb7b62873f8 on 2023-11-08; Adafruit-Qualia-S3-RGB666 with ESP32S3

Code/REPL

import adafruit_qualia

Behavior

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "adafruit_qualia/__init__.py", line 32, in <module>
  File "adafruit_qualia/network.py", line 31, in <module>
  File "adafruit_portalbase/network.py", line 28, in <module>
  File "adafruit_io/adafruit_io.py", line 30, in <module>
  File "adafruit_minimqtt/adafruit_minimqtt.py", line 47, in <module>
  File "adafruit_minimqtt/matcher.py", line 20, in <module>
RuntimeError: pystack exhausted

Description

Based on an older issue, I tried setting CIRCUITPY_PYSTACK_SIZE=4000 in settings.toml. The result of import adafruit_qualia is then:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "adafruit_qualia/__init__.py", line 32, in <module>
  File "adafruit_qualia/network.py", line 31, in <module>
  File "adafruit_portalbase/network.py", line 28, in <module>
  File "adafruit_io/adafruit_io.py", line 483, in <module>
  File "adafruit_io/adafruit_io.py", line 678, in IO_HTTP
MemoryError: memory allocation failed, allocating 184 bytes

Additional information

  • I've erased and factory-reset this device, then installed "absolute newest" CircuitPython 9.0.0-alpha.2-18-gb7b62873f8.
  • I've installed the base bundles for this device via "circup install adafruit_qualia"; no surprises there.
@RetiredWizard
Copy link

This is the same behavior that led me to open #8573.

@jacobmarble
Copy link
Author

I found the "breaking version". This version allows me to import adafruit_qualia without error:

Adafruit CircuitPython 9.0.0-alpha.2-16-gccd667d97a on 2023-11-06; Adafruit-Qualia-S3-RGB666 with ESP32S3

This subsequent version does not:

Adafruit CircuitPython 9.0.0-alpha.2-17-g01be5f402e on 2023-11-08; Adafruit-Qualia-S3-RGB666 with ESP32S3

@RetiredWizard
Copy link

@jacobmarble Try placing CIRCUITPY_HEAP_START_SIZE=1024000 in your settings.toml file.

@Mark-MDO47
Copy link

Mark-MDO47 commented Nov 10, 2023

I tried CIRCUITPY_HEAP_START_SIZE=1024000 with adafruit-circuitpython-adafruit_qualia_s3_rgb666-en_US-20231109-3ca9802.uf2 and it still gave pystack exhausted.

I tried adafruit-circuitpython-adafruit_qualia_s3_rgb666-en_US-20231106-ccd667d.uf2 and this worked for me. This worked for all four example programs.

@RetiredWizard
Copy link

RetiredWizard commented Nov 10, 2023

You should try both the CIRCUITPY_PYSTACK_SIZE and the CIRCUITPY_HEAP_START_SIZE parameters. I tested the adafruit_qualia library and setting those two parameters allowed the library to load with the latest build version.

@tannewt tannewt added this to the 9.0.0 milestone Nov 10, 2023
@tannewt
Copy link
Member

tannewt commented Nov 10, 2023

I found the "breaking version". This version allows me to import adafruit_qualia without error:

Do you still have the pystack size change with the old version? I think there are two issues here:

  1. We need to adjust pystack size for newer MP core. (Covered by this issue)
  2. We need to tune the split heap behavior. (Covered by Tune auto-growing split heap #8573 )

@jacobmarble
Copy link
Author

I found the "breaking version". This version allows me to import adafruit_qualia without error:

Do you still have the pystack size change with the old version?

I commented the CIRCUITPY_PYSTACK_SIZE line in settings.toml before finding the breaking version.

@tannewt
Copy link
Member

tannewt commented Nov 10, 2023

Ok, that's interesting. Maybe I broke the pystack size with the split heap PR. Still worth a separate issue (this one.)

@Mark-MDO47
Copy link

Using these suggested params in settings.toml
CIRCUITPY_HEAP_START_SIZE=1024000
CIRCUITPY_PYSTACK_SIZE=4000

FWIW I did the following:
factory reset
installed adafruit-circuitpython-adafruit_qualia_s3_rgb666-en_US-20231106-ccd667d.uf2
ran qualia_paint.py
RESULT: WORKS

factory reset
installed adafruit-circuitpython-adafruit_qualia_s3_rgb666-en_US-20231109-3ca9802.uf2
ran qualia_paint.py
RESULT: FAILS see below

soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
fw_version: 10, chip_type: 11
Traceback (most recent call last):
File "code.py", line 23, in
MemoryError: memory allocation failed, allocating 460800 bytes

Code done running.

NOTE: line 23 is as follows:
bitmap = displayio.Bitmap(graphics.display.width, graphics.display.height, 65535)

@RetiredWizard
Copy link

That's progress 😁 try doubling the heap start to 2048000

@Mark-MDO47
Copy link

Mark-MDO47 commented Nov 13, 2023

Steps:

  • Erase and factory reset
  • copied in adafruit-circuitpython-adafruit_qualia_s3_rgb666-en_US-20231109-3ca9802.uf2
  • D:\lib is empty; copied in adafruit-circuitpython-bundle-9.x-mpy-20231109
  • D:\settings.toml now includes
    CIRCUITPY_HEAP_START_SIZE=1024000
    CIRCUITPY_PYSTACK_SIZE=4000
  • copied example qualia_paint.py to D:\code.py changing to "Displays.ROUND21" on line 13
    $$$$$$$$ FAIL $$$$$$$$
    code.py output:
    fw_version: 10, chip_type: 11
    Traceback (most recent call last):
    File "code.py", line 23, in
    MemoryError: memory allocation failed, allocating 460800 bytes
  • D:\settings.toml now includes
    CIRCUITPY_HEAP_START_SIZE=2048000
    CIRCUITPY_PYSTACK_SIZE=4000
  • qualia_paint.py to D:\code.py changing to "Displays.ROUND21" on line 13
    $$$$$$$$ FAIL $$$$$$$$
    code.py output:
    fw_version: 10, chip_type: 11
    Traceback (most recent call last):
    File "code.py", line 23, in
    MemoryError: memory allocation failed, allocating 460800 bytes
  • D:\settings.toml now includes
    CIRCUITPY_HEAP_START_SIZE=4096000
    CIRCUITPY_PYSTACK_SIZE=4000
  • qualia_paint.py to D:\code.py changing to "Displays.ROUND21" on line 13
    $$$$$$$$ SUCCESS - paint program runs $$$$$$$$
    code.py output:
    fw_version: 10, chip_type: 11
  • still works with CIRCUITPY_HEAP_START_SIZE=2500000

@RetiredWizard
Copy link

RetiredWizard commented Nov 13, 2023

I think this is helpful information, especially since your example is pretty easy to reproduce. I've been using a START_SIZE of 3072000 on boards that have enough RAM and 1536000 on the boards with less.

This was referenced Nov 13, 2023
dhalbert pushed a commit that referenced this issue Nov 13, 2023
Original code used uint32_t* so `/ sizeof(size_t)` was needed. It
is a uint8_t* now so that division makes it 4x smaller. Whoops!

Fixes #8574
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants