MicroPython running "bare metal" in the browser via unicorn.js
MicroPython running "bare metal" in the browser via unicorn.js
Hi everyone!
We have recently developed the ability to run MicroPython "bare metal" in a web browser. This is acomplished using unicorn.js, which is an Emscripted version of unicorn, which is a stripped-down version of QEMU. We have used unicorn.js to implement a Cortex-M3 based "virtual microcontroller" that runs in the browser. And then this virtual microcontroller runs a port of MicroPython, the unicorn port.
Running this unicorn port of MicroPython will give you a good idea of what it's like running MicroPython on the bare metal of real hardware, and allows you to test stuff out quickly, and get to know (new) features of MicroPython.
Find a running version at: https://micropython.org/unicorn/
Find the source code at: https://github.com/micropython/micropython-unicorn
At the moment the port is pretty minimal and doesn't have many features enabled. Plans for the future include different builds of unicorn MicroPython to show-case size vs features, as well as modules such as "machine".
Enjoy!
Damien // George Robotics.
We have recently developed the ability to run MicroPython "bare metal" in a web browser. This is acomplished using unicorn.js, which is an Emscripted version of unicorn, which is a stripped-down version of QEMU. We have used unicorn.js to implement a Cortex-M3 based "virtual microcontroller" that runs in the browser. And then this virtual microcontroller runs a port of MicroPython, the unicorn port.
Running this unicorn port of MicroPython will give you a good idea of what it's like running MicroPython on the bare metal of real hardware, and allows you to test stuff out quickly, and get to know (new) features of MicroPython.
Find a running version at: https://micropython.org/unicorn/
Find the source code at: https://github.com/micropython/micropython-unicorn
At the moment the port is pretty minimal and doesn't have many features enabled. Plans for the future include different builds of unicorn MicroPython to show-case size vs features, as well as modules such as "machine".
Enjoy!
Damien // George Robotics.
Re: MicroPython running "bare metal" in the browser via unicorn.js
Just saw that the link has been updated with examples to select/test virtual LEDs, Servos and ADC in the browser.
Awesome.
Awesome.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: MicroPython running "bare metal" in the browser via unicorn.js
As far as I'm concerned Clarke's third law applies to this. Amazing
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 463
- Joined: Wed Apr 08, 2015 5:19 am
Re: MicroPython running "bare metal" in the browser via unicorn.js
This is really helpful for demonstrating / teaching MicroPython! Well done.
Re: MicroPython running "bare metal" in the browser via unicorn.js
Shame it also became a victim of the ever-changing APIs.
For instance, the "Pin LED" demo errors with: TypeError: 'PIN' object is not callable
For instance, the "Pin LED" demo errors with: TypeError: 'PIN' object is not callable
Re: MicroPython running "bare metal" in the browser via unicorn.js
Thanks for pointing this out. Unicorn is still very much a work-in-progress. The ability to call pin objects was actually implemented recently (see https://github.com/micropython/micropyt ... e2ba40055d), and this commit is now deployed on the website.deshipu wrote:For instance, the "Pin LED" demo errors with: TypeError: 'PIN' object is not callable
Re: MicroPython running "bare metal" in the browser via unicorn.js
I just came by to look at micropython again after a long time away, and it is pretty great to see some of the progress. The ability to run demo code online is extremely cool. Unfortunately, the servo demos seem not to be working at the moment. No errors, just nothing actually moves. When I put in some messages to print between each servo command, they all seemed to run at the same time, so maybe that is a clue.
Re: MicroPython running "bare metal" in the browser via unicorn.js
Hi Damien- thanks for this resource- using it to "spread the word"!
Any chance it can be upgraded to 1.10, please?
Many thanks
Peter
Any chance it can be upgraded to 1.10, please?
Many thanks
Peter
Re: MicroPython running "bare metal" in the browser via unicorn.js
Yes! Could we upgrade ? I like to use it to test things when I don't have my env.
Thanks !
Thanks !
8bits should be enough...
Re: MicroPython running "bare metal" in the browser via unicorn.js
Let me tell you a story.
I have worked in embedded systems all my life, mostly in assembly, sometimes in C (with inline assembly) or FORTH. Some of my designs have gone into production at a rate of 100,000 per hour. For those projects that have lower volumes. over time I have migrated from the 6502/6800/8051 to whichever ARM Cortex chips are the lowest cost.
I have seen various mentions of MicroPython but never looked into it because C is Good Enough as a language to do my initializing and turn it over to inline assembler code that never exits. Then I ran across [ https://micropython.org/unicorn/ ].
I spent days trying things out on it and reading up on MicroPython. One thing led to another and I ordered a Pyboard (which just arrived) and several book on MicroPython, which I have already read once running the examples in my browser and will read again using the actual Pyboard. I am also studying the big Python running on my PC.
Bottom line: if you had not brought MicroPython to the browser it would never have caught my attention. What you have done is make the very start of the learning curve so gentle that people like me -- people who really need MicroPython but don't know it yet -- can find the on-ramp.
I am more exited about learning a new language than I have been in years. Thank you.
I have worked in embedded systems all my life, mostly in assembly, sometimes in C (with inline assembly) or FORTH. Some of my designs have gone into production at a rate of 100,000 per hour. For those projects that have lower volumes. over time I have migrated from the 6502/6800/8051 to whichever ARM Cortex chips are the lowest cost.
I have seen various mentions of MicroPython but never looked into it because C is Good Enough as a language to do my initializing and turn it over to inline assembler code that never exits. Then I ran across [ https://micropython.org/unicorn/ ].
I spent days trying things out on it and reading up on MicroPython. One thing led to another and I ordered a Pyboard (which just arrived) and several book on MicroPython, which I have already read once running the examples in my browser and will read again using the actual Pyboard. I am also studying the big Python running on my PC.
Bottom line: if you had not brought MicroPython to the browser it would never have caught my attention. What you have done is make the very start of the learning curve so gentle that people like me -- people who really need MicroPython but don't know it yet -- can find the on-ramp.
I am more exited about learning a new language than I have been in years. Thank you.