by SOLAR_FIELDS · 4y ago · 0 comments
The downsides are somewhat dramatic though - it’s, of course, a lot slower and hungrier for memory than the C equivalent code, but it’s also still missing a lot of API’s and fine grained control, at least for the ESP32. For instance, what finally made me switch to the ESP-IDF was complete lack of support for ADC2 on ESP32 in Micropython. Having to recompile the Micropython firmware to change a good chunk of the configuration parameters was also annoying because it takes a decent amount of time to compile and reflash firmware.
Bottom line is that Micropython is a great project for certain things - some home automation and simple sensors. On things where performance doesn’t matter or isn’t bottlenecked by the Python interpreter (like simple HTTP communication) it’s great. It also has a surprisingly robust open source driver ecosystem, provided you aren’t trying to do anything fancy with SPI.
It falls apart when you need to work with it professionally though. So use it to build and test your product, but rewrite it in C/C++ when it gets closer to ship time.
https://docs.micropython.org/en/kookaberry/reference/speed_p...
https://docs.micropython.org/en/kookaberry/reference/speed_p...
Indeed, it's helped deliver high-quality solutions quickly...
There is some steps necessary to go from "prototyping MicroPython" to "production MicroPython" and many people either forget about them, are not skilled enough to do them (which is fine, MicroPython is about onboarding people to embedded as well) or they feel like these steps make using MicroPython pointless.
Yes, true! I presented a lightning talk to colleagues on "Ingredients for Commercial MicroPython Success". One of the key points is "People are critical". Maybe folks here might find it useful:
https://docs.google.com/presentation/d/e/2PACX-1vR3DJk-dNTvE...
My colleague gave a good talk on how we use MicroPython, as SOUP, in our devices:
(I typically am to scared to even use malloc on a microcontroller...)
But MicroPython's gc is fairly simple and easy to reason with. We've gotten a lot of value out of two useful tools/techniques: 1) Rendering memory use over long periods of time (micropython.mem_info(1) will output a text representation of how memory is used). It's pretty obvious when memory use starts expanding. 2) Turning the gc off in key unit tests so we can be sure critical sections do not allocate (an exception will be raised if memory is requested from the gc).
But, of course, memory use in any embedded application is critical.
Systems are typically fragile because of poor system design not language choice. I've worked on many C and C++ systems and there's nothing inherently more robust about them. Some would argue that the various ways you can trip over UB makes them more fragile...
That is definitely a factor! But I probably wouldn't pick C++ for a medical device now anyway - I would go with Ada or Rust.
> Systems are typically fragile because of poor system design not language choice.
Poor system design and language choice are both factors. You can work around language choice with a shit load of testing, but it's still much better to use a language that gives you stronger guarantees. Also the choice of language affects system design, so it's not like you can just ignore it.
For example even ignoring anything memory related, Rust's borrowing system pushes you towards code that has fewer bugs. Python... well, not so much!
(BTW, I can't vouch for NASA or SpaceX, but it's no secret that the European Space Agency has been working with MicroPython for many years.)
I don't disagree that reliability, repeatability and fast performance are (often) key; but our experience suggests that these can be (usually, if not always) achieved with MicroPython.
On the archmix, I managed to boot up and that’s about it. There was literally a REPL and I was able to blink the LED and then I couldn’t proceed further, where was I supposed to code? Bad experience.
Teensy: connect the board , fire up the teensyduino ide, choose an interesting example from the drop down menu, run it, rinse and repeat until you are familiar with idioms for all sorts of things, real hardware examples they do real things, real peripheral support in the form of examples
> rinse and repeat until you are familiar with idioms for all sorts of things
Except that the idioms you learn are really not suitable for anything but toy examples. Arduino is rotten from the core: "setup", "loop" and "delay" are the worst imaginable way to write embedded software, yet everyone coming from Arduino thinks this is how well written embedded software should look.
As I understand it, the ability to program Arduino in C was originally kind of an accidental feature of Arduino. The original Arduino downplayed C, and referred to the programming language as "wire." A few people (myself included) discovered that by simply ignoring those constructs, Arduino becomes a full fledged C development environment. But I think doing things "the right way" on a microcontroller really requires learning concepts that are not beginner friendly, like interrupts, and for that matter, electronics.
I agree with "delay", but why do you say setup and loop are the worst imaginable way to write embedded software?
CircuitPython is very nice for beginners, Adafruits tutorials are gold. Switching to MicroPython is very easy (CircuitPython makes some simplifications to be more beginner friendly, MicroPython aims to be as "professional" as possible).
Yeah, right. Now if i find out why it gives syntax error on a perfect part of code.
More accurately: it falls apart when you need it professionally :) Totally depends on the usecase.
As an aside, I really like Micropython and I spent a LOT of hours trying to make it work at a production level for my use case, but in the end I relented and had to write my software in C - it's not like I'm some low level language purist here. And it's not like my use case is what I would consider super edgy either - a fairly typical project with ESP32 where you wake sensors up on a very conservative basis (once per hour), take basic readings and send the data over HTTPS.
Works very well, but: it's still Python. Great, but dynamic so not the best suited for larger applications in my experience - no matter how well-architected the code is. Becomes just really hard to refactor without breaking anything.
Are you prototyping or manufacturing at scale?
What kind of sensors have you attached?
https://zephyr-dashboard.renode.io/dashboard-micropython.htm...
Any of those that are passing would be a good board to choose to start with.