Does anyone know of examples of CircuitPython extensions written in C++? Google isn't helping much. I'm quite familiar with the "special care" required to link C++ compiled code into a C based app so I'm not looking for general tips on how to do this or whether it's good/bad idea. But if there are projects out there that compile/link some C++ into CircuitPython firmware images, I'd love to hear about them.
#CircuitPython and C++?
1 messages · Page 1 of 1 (latest)
I am interested in potential toolchain roadblocks. I suspect some of the smaller/older MCU architectures may not support modern C++ tool chains - some might even be C only. But I know recent ESP-IDF (for ESP32.*) has great C++ support, and I've been using C++ in ARM/Arduino projects for a long time (although that just means it can be done, not that it works with the toolchain CircuitPython is using on a given build). So if there are flavors (ports/boards) of CircuitPython that are likely to be extra persnickety beacause of poor C++ support in their toolchains, I'd rather know sooner than later...
All ports use some fairly recent version of gcc, I'm pretty sure, so I don't think it should be an issue. If it weren't gcc it would be clang
You may need to tweak the linker scripts and start up code to do the c++ stuff.
depending on the port
I appreciate you gift for understatement 😁
As more of a mid-to-long term possibility, I might try coming up with a process to embed the CircuitPython interpreter within a C++ project. That would get a bit trickier, as it might entail disabling some of the background stuff like web/USC/BLE workflow, REPL, etc... C++ firmware running on a beast of an ESP32 S3 (like those 8M ram 16MB flash monsters - not that I really need that much for my Christmas tree lights but...) with CircuitPython thrown in could get really interesting. I started thinking about porting regular CPython to embed it in an ESP-IDF app a few years ago - ended up using a DSL instead, but CircuitPython might be a better choice going forward.
But that's a bit down the road - won't be nearly as useful until controllers with more ram/flash (like at least 4MB ram and 8 - preferably 16mb flash) start getting more common.
There's things I could do in C++ extensions for CircuitPython firmware today, although it would obviously require a custom firmware build and I'm trying to keep that from becoming necessary for users of my current project (although it would be quite handy for experiments on things like EPS32 RMT / pulseio, GC hacking, ...)
I'd expect C++ to work with ESP already because some of the IDF is IIRC.