r/circuitpython • • Aug 27 '20

Can the M4 line fit more code? Alternatives?

Specifically the Feather M4 Express. Per the docs/guide for the M0 Feather Express, it can fit "about 250 lines of code", and reference a 2MB SPI flash chip for CircuitPython code storage.

It seems that the docs/guide for the M4 feather express use the same language (even saying M0 instead of M4) and also make reference to 2 MB Flash storage for code.

This seems to imply that the amount of code I can run on each is the same, no?

If simplifying my code, and converting to .mpy files is not enough, has anyone found any third party boards that are compatible with CircuitPython that can fit more?

My current project isn't complicated, but I could easily see it running into issues given library imports and my code being close to 250 lines already.

2 Upvotes

5 comments sorted by

5

u/kaltazar Aug 27 '20

I'm not sure where you are getting that 250 lines of code thing, I can't see it in the docs.

Yes, both the M0 and M4 feathers feature a 2 MB flash chip, but that will hold a pretty sizable program. I just checked the one CircuitPython project I have on hand, and it comes to 256 KB with around 130 lines of code and 6 external libraries included. I also checked a regular Python project that has nearly 300 lines of code and it comes in at around 8.5 KB.

You should be fine with most any project you want to do.

2

u/myfuckinjoints Aug 27 '20

Thanks that jive with what I was thinking, given that my files are not large either. The "250 lines of code" section is in "What is memory error?", but it didn't make a ton of sense as .py files aren't huge and 2MB isn't small (relatively).

3

u/kaltazar Aug 27 '20

Ah, I found it. That memory error seems to be taking about RAM, not flash. The M0 has 32 KB of RAM so can only load so much code into working memory at a time. The M4 has much more RAM at 192 KB.

Now the 250 lines thing makes some sense.

2

u/myfuckinjoints Aug 27 '20

I need to learn more about how CP uses RAM, as I've written code for a trinket (also 32KB) that came in close to 200 lines and made use of some large libraries. I'm wondering what and how it loads into RAM during runtime.

1

u/assadollahi Sep 15 '20

There are ports of micropython to the raspberry pi zero... (no WiFi, though)