Notifications
Clear all

Scott (@tannewt) from Adafruit  


tannewt
(@tannewt)
New Member
Joined: 2 months ago
Posts: 4
Topic starter  

Hi folks, I'm the lead for CircuitPython and am sponsored by Adafruit to work on it full time. I'm happy to answer any questions about CP when they come up. Cheers!


Quote
Sean451
(@sean451)
Trusted Member
Joined: 4 months ago
Posts: 66
 

Famous last words. 😉 

Welcome, Scott!

--->Sean

(◕(' 人 ') ◕)


tannewt liked
ReplyQuote
byron
(@byron)
Honorable Member
Joined: 2 years ago
Posts: 503
 
Posted by: @tannewt

I'm happy to answer any questions about CP when they come up. Cheers!

Its very good to see a CircuitPython expert willing to contribute to this forum. 👍 

And I do have a question on CP for you 😎 

A couple of months back I got a Seeduino XIAO and loaded up the version of CircuitPython suitable for this board.  All worked OK.  

I then hooked up a TMP117 temperature sensor and loaded the library from the marvellous CP library bundle.  I think I had to also load some other support libraries too, but I no longer have it all hooked up so memory may fail me.

Whilst I could read the temperature OK, attempting to do other things like send commands to the TMP117 to control stuff like the averaging of readings, whilst the library could accommodate this, the XIAO complained about not enough memory. (I do not recall the exact message, but it was to that effect)

No I know the XIAO is a weeny board without much memory, but I understand that one can build ones own XIAO CP version for oneself, leaving out what may not be required for a particular project, but including that which may be desirable, in this instance the TMP117 library as 'frozen code' if thats what its called?  (and this own CP build applies not just to the XIAO board of course)

So the question is how do I go about building my own CP version for my board.   I expect this may turn out to be a rather complicated process, but I was wondering if you could point me to where I could get more information on this topic and maybe a sentence or two on what is involved.  


ReplyQuote
TheOutlander
(@theoutlander)
Trusted Member
Joined: 4 months ago
Posts: 64
 
Posted by: @tannewt

Hi folks, I'm the lead for CircuitPython and am sponsored by Adafruit to work on it full time. I'm happy to answer any questions about CP when they come up. Cheers!

We appreciate you joining us!

"Hardware eventually fails. Software eventually works." - Michael Hartung


tannewt liked
ReplyQuote
tannewt
(@tannewt)
New Member
Joined: 2 months ago
Posts: 4
Topic starter  
Posted by: @byron
Posted by: @tannewt

I'm happy to answer any questions about CP when they come up. Cheers!

Its very good to see a CircuitPython expert willing to contribute to this forum. 👍 

And I do have a question on CP for you 😎 

A couple of months back I got a Seeduino XIAO and loaded up the version of CircuitPython suitable for this board.All worked OK.

I then hooked up a TMP117 temperature sensor and loaded the library from the marvellous CP library bundle.I think I had to also load some other support libraries too, but I no longer have it all hooked up so memory may fail me.

There are two types of memory errors you'll see.

The first is running out of disk space. This happens when you drag files over. It can happen easily on boards without external SPI flash like the XIAO. Building a different version of CircuitPython will only help of you increase the space allocation for the internal flash.

The second is running out of RAM. This happens when your code is running and you'll get an OutOfMemory error. It can also happen on the SAMD21 (which the XIAO has) because it only has 32k RAM. Importing libraries from the drive loads them into memory so one way to use less RAM is to modify the library to remove extra functionality. Freezing it in will place the code in flash instead and thus save RAM (but having space in flash can be tricky itself.) The down side of freezing is that you have to maintain your own bespoke build. I'd try optimizing the libraries first since that's just editing Python.

So the question is how do I go about building my own CP version for my board. I expect this may turn out to be a rather complicated process, but I was wondering if you could point me to where I could get more information on this topic and maybe a sentence or two on what is involved.  

We've got a guide for that! See: learn.adafruit.com/building-circuitpython


ReplyQuote
Sean451
(@sean451)
Trusted Member
Joined: 4 months ago
Posts: 66
 
Posted by: @tannewt Importing libraries from the drive loads them into memory so one way to use less RAM is to modify the library to remove extra functionality.

So instead of including the entire library, it would be better to just import the parts of the library you're actually using?

--->Sean

(◕(' 人 ') ◕)


ReplyQuote
tannewt
(@tannewt)
New Member
Joined: 2 months ago
Posts: 4
Topic starter  
Posted by: @sean451
Posted by: @tannewt Importing libraries from the drive loads them into memory so one way to use less RAM is to modify the library to remove extra functionality.

So instead of including the entire library, it would be better to just import the parts of the library you're actually using?

--->Sean

Doing a `from foo import Bar` doesn't usually help because the whole library is still loaded. All code from a single file (aka module) will be loaded into memory. To reduce the code size, you'll need to modify the file itself to comment out the parts you don't use.

 

This is really only an issue on 32k RAM boards. Most others have more RAM that can hold all the code most folks want to use.

 


Sean451 liked
ReplyQuote