Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Itsy Bitsy Code Space
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Itsy Bitsy Code Space

by area540 on Tue Aug 11, 2020 11:04 am

I just got a new itsybitsy M0 the other day and wanted to move some of my Circuit Python code from a custom nrf52840 board. I can successfully move all of the code onto the drive, but then when it actually runs, I hit memory errors. After doing some digging, I saw that memory errors are caused by express M0 boards are limited to 250 lines of code space. I was wondering if there was a way to fit more circuitpython code space on the boards? If I switch to another ATSAMD21 chip, will I run into the same problem? My main goal is to create a custom ATSAMD21 board that runs on circuitpython and was wondering if this code space was a limitation of the express m0 circuitpython build or the ATSAMD21 chip itself.

Any help would be appreciated, Thank!

area540
 
Posts: 6
Joined: Thu May 28, 2020 11:22 am

Re: Itsy Bitsy Code Space

by adafruit_support_carter on Tue Aug 11, 2020 11:09 am

The "express" boards all have a SPI flash attached, which is where the user CircuitPython code is stored. So it's not a limit of the SAMD21, but a limit of the size of the attached SPI flash.

adafruit_support_carter
 
Posts: 16906
Joined: Tue Nov 29, 2016 2:45 pm

Re: Itsy Bitsy Code Space

by area540 on Tue Aug 11, 2020 12:05 pm

That's what I'm confused about, I guess. The itsybitsy express M0 says it has a 2MB flash chip. My program has about 700 lines when not compressed using mpy-cross. I'm confused where the bottlneck is occurring such that there can only be 250 lines of code running at a time?

area540
 
Posts: 6
Joined: Thu May 28, 2020 11:22 am

Re: Itsy Bitsy Code Space

by adafruit_support_carter on Tue Aug 11, 2020 12:50 pm

What else is stored in the CIRCUITPY folder?

adafruit_support_carter
 
Posts: 16906
Joined: Tue Nov 29, 2016 2:45 pm

Re: Itsy Bitsy Code Space

by area540 on Tue Aug 11, 2020 1:10 pm

2020-08-11 Contents.png
2020-08-11 Contents.png (59.16 KiB) Viewed 42 times


Most of my files don't exceed 10 kb, I have several folders for organization and mots of them have one or two files that are about 2 kb.

I did find this in my library.

2020-08-11 lib.png
2020-08-11 lib.png (29.98 KiB) Viewed 42 times


I don't know what these three files are they do seem quite large. When I try to delete them it says that the files are no longer in this location and it can't delete them.

2020-08-11 Can't delete error.png
2020-08-11 Can't delete error.png (19.86 KiB) Viewed 42 times

area540
 
Posts: 6
Joined: Thu May 28, 2020 11:22 am

Re: Itsy Bitsy Code Space

by adafruit_support_carter on Tue Aug 11, 2020 1:53 pm

You can try this to completely erase the filesystem:
https://learn.adafruit.com/welcome-to-c ... 2987288-24

It will erase any user code you have as well, so be sure to back that up.

adafruit_support_carter
 
Posts: 16906
Joined: Tue Nov 29, 2016 2:45 pm

Re: Itsy Bitsy Code Space

by area540 on Tue Aug 11, 2020 2:08 pm

I reset my file system and that did delete the extra files, but I still get a memory error when importing one of the modules that I wrote for my custom board.

2020-08-11 memory error.png
2020-08-11 memory error.png (26.81 KiB) Viewed 40 times


As far as I can tell, I am not running out of flash memory.

2020-08-11 Memory Remaining.png
2020-08-11 Memory Remaining.png (5.32 KiB) Viewed 40 times


The module itself is about 400 lines of code and 16 kb and when I comment the import statement and any code that uses it out, the rest of the code will run fine. The problem is that most of the other code is fairly light weight, this is the largest module that I have written so far.

2020-08-11 Modem Module.png
2020-08-11 Modem Module.png (4.93 KiB) Viewed 40 times


The ATSAMD chip has 32k RAM as well, so I am unsure why I am running into this memory error.

area540
 
Posts: 6
Joined: Thu May 28, 2020 11:22 am

Re: Itsy Bitsy Code Space

by adafruit_support_carter on Tue Aug 11, 2020 5:41 pm

That's a RAM memory issue, not a SPI flash memory issue. Other things are using RAM as well, so you don't have the full 32k available.

You can check free memory with:
Code: Select all | TOGGLE FULL SIZE
import gc
gc.mem_free()


For importing larger modules, you can buy back some space by converting the .py to .mpy using the tool mpy-cross:
https://learn.adafruit.com/creating-and ... 2982472-11

adafruit_support_carter
 
Posts: 16906
Joined: Tue Nov 29, 2016 2:45 pm

Re: Itsy Bitsy Code Space

by area540 on Tue Aug 11, 2020 5:47 pm

Is there any way to see what else is using the RAM? I was able to use mpy-cross to import that module, but then I was unable to import a few of my other modules and was planning on adding more.

area540
 
Posts: 6
Joined: Thu May 28, 2020 11:22 am

Re: Itsy Bitsy Code Space

by adafruit_support_carter on Tue Aug 11, 2020 7:06 pm

Not easily. I think there are ways, but it's a bit beyond my expertise. I've seen the CircuitPython developers do this though.
https://www.youtube.com/watch?v=baa5ILZTRkQ

adafruit_support_carter
 
Posts: 16906
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.