Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.
0

Importing NeoTrellis uses 83% of RAM -- how to fix?
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Importing NeoTrellis uses 83% of RAM -- how to fix?

by jppearson on Sun May 02, 2021 6:34 pm

Hello! I am really enjoying the "NeoTrellis Game" project [1], which uses the Feather M0 Express [2] and a 4x4 NeoTrellis RGB driver [3].
However, I'm running out of RAM in my CircuitPython program. I notice that importing the NeoTrellis library takes 83% of the available RAM:

Code: Select all | TOGGLE FULL SIZE
import gc
print(gc.mem_free())   # 15728 bytes free
from adafruit_neotrellis.neotrellis import NeoTrellis
print(gc.mem_free())   # 2672 bytes free

I'm wondering if there's some way around this? For example, by building CircuitPython with the NeoTrellis library added as a "frozen module", as described here [4]?
Thanks,
Justin

[1] "NeoTrellis Game" : https://learn.adafruit.com/neotrellis-box-game/overview
[2] "Adafruit Feather M0 Express - Designed for CircuitPython - ATSAMD21 Cortex M0" : https://www.adafruit.com/product/3403
[3] "Adafruit NeoTrellis RGB Driver PCB for 4x4 Keypad" : https://www.adafruit.com/product/3954
[4] "Building CircuitPython – Adding Frozen Modules" : https://learn.adafruit.com/building-cir ... en-modules

jppearson
 
Posts: 3
Joined: Fri Dec 18, 2020 10:11 am

Re: Importing NeoTrellis uses 83% of RAM -- how to fix?

by dastels on Sun May 02, 2021 7:42 pm

I suspect the modules (neotrellis and seesaw) have grown since that guide was written in late 2018.

I see 3 options off the top of my head:
- Switch to a Feather M4 Express. This is the easiest and would be my choice.
- get a build of CircuitPython and the bundle from Oct '18
- as you suggest, make a custom build of CircuitPython freezing in the neotrellis and seesaw libraries.

Dave

dastels
 
Posts: 6129
Joined: Tue Oct 20, 2015 3:22 pm

Re: Importing NeoTrellis uses 83% of RAM -- how to fix?

by jppearson on Sun May 02, 2021 10:34 pm

These are great options! Thank you Dave!
-Justin

jppearson
 
Posts: 3
Joined: Fri Dec 18, 2020 10:11 am

Re: Importing NeoTrellis uses 83% of RAM -- how to fix?

by dastels on Mon May 03, 2021 9:46 am

Let me know what you decide an how it goes.

Dave

dastels
 
Posts: 6129
Joined: Tue Oct 20, 2015 3:22 pm

Re: Importing NeoTrellis uses 83% of RAM -- how to fix?

by jppearson on Mon May 10, 2021 9:33 am

Update: I bought a Feather M4 Express and it solved my RAM shortage! Now
Code: Select all | TOGGLE FULL SIZE
gc.mem_free()
shows more than 100kB instead of just 15kB for the M0 Express. Thanks Dave!
-Justin

jppearson
 
Posts: 3
Joined: Fri Dec 18, 2020 10:11 am

Re: Importing NeoTrellis uses 83% of RAM -- how to fix?

by dastels on Mon May 10, 2021 10:45 am

Awesome! Have fun.

FYI, the ESP2-S2 can have tons more. The Funhouse reports about 2M free before loading code. It will vary on board since it' supports external RAM.

For example, my FeatherS2 reports:
Code: Select all | TOGGLE FULL SIZE
Adafruit CircuitPython 6.2.0 on 2021-04-05; FeatherS2 with ESP32S2
>>> import gc
>>> gc.mem_free()
8196176

Dave

dastels
 
Posts: 6129
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.