emlearn / emlearn-micropython

Efficient Machine Learning engine for MicroPython
51 stars 13 forks source link

CircuitPython support #3

Open jonnor opened 10 months ago

jonnor commented 10 months ago

CircuitPython is a very popular Python-for-microcontrollers. https://circuitpython.org/ It would be nice if that could be supported in addition to MicroPython. Preferably in a way that has minimal divergence/extra ongoing work to support.

jonnor commented 10 months ago

Right now we primarily use MicroPython native modules, and that works quite well. In order to use the same strategy with CircuitPython, we would need https://github.com/adafruit/circuitpython/issues/6040 to go in.

jonnor commented 10 months ago

The only documentation I have found for extending CircuitPython in C is https://learn.adafruit.com/extending-circuitpython and that is not updated since 2019 - with notes that there are known incompatible changes since then. So it will be use-the-source-Luke.

It seems that for user-modules there is still an open issue in CircuitPython, https://github.com/adafruit/circuitpython/issues/2825 Though it is stated that "it is possible". One user has reported a problem with it, unclear if is a blocker for all usages. https://github.com/adafruit/circuitpython/issues/5910

So it seems that in the short-term the officially supported way is to create an in-tree module that is built as part of upstream CircuitPython. It seems possible to have a separate repository that is pulled into the main build process. https://github.com/adafruit/circuitpython-ulab is probably the most relevant example. And the commits there are probably a good indicator of the difference that are needed to adapt to CircuitPython.

tannewt commented 10 months ago

The only documentation I have found for extending CircuitPython in C is https://learn.adafruit.com/extending-circuitpython and that is not updated since 2019 - with notes that there are known incompatible changes since then. So it will be use-the-source-Luke.

We're happy to help you get going on the CP internals. The best place to get guidance is the Adafruit Discord in the #circuitpython-dev channel. Adafruit-funded CP devs are there usually during US business hours. Volunteers are also there at other times.

jonnor commented 10 months ago

Thank you @tannewt ! I am in the Adafruit Discord already. I will make sure to reach out if I find time to work on this :)