Note: micropython is now included as part of FlexGUI, so the easiest way to run it is start flexgui.exe and select "Special > Run uPython on P2". But micropython does not depend in any way on FlexGUI, so you can also run it with PNut or any other download program, following the instructions below. If you want to run a newer version of micropython with an older FlexGUI, just unzip the upython.zip file somewhere and then copy all of the files into flexgui\samples\upython.
Also note that the current version can run on both revisions of the P2-ES boards and should fully support USB and VGA on both boards. Other boards (such as the P2D2) are untested, and may not work.
This is a micropython binary that can run on the P2.
Basic instructions: unzip and run upython.binary on the P2-ES board. It will communicate with the PC at 230400 baud on the standard serial pins. It will also try to talk to a VGA board on pin group 48 and USB serial host on pin group 16; the serial and USB/VGA communication are merged together, so input may come from either source and output goes to both.
If an SD card is present when upython.binary starts up, it will attempt to mount it and run "main.py" from the root directory.
See README.txt for more details.
Edit: 2020-01-08: v22, reads frequency settings from $14-$18 so loadp2 -PATCH works
Edit: 2020-01-02: v21, with input() function and some rudimentary help text
Edit: 2019-12-11: v20, now with pyb.Cpu() to allow running compiled PASM on other COGs
Edit: 2019-11-05: v19, new USB and VGA drivers which support both original and new P2-ES boards
Edit: 2019-09-16: v18, some minor performance tweaks and a fix to make the code compatible with new silicon
Edit: 2019-07-19: v17, basically the same micropython with tidied up internal code, a bit more user space, and a performance fix
Edit: 2019-07-17: v16b, same source code as v16 but compiled with a newer riscvp2 compiler for a performance boost
Edit: 2019-07-16: v16, with improved sdcard detection
Edit: 2019-07-14: v15, fixes ANSI escape sequences in the built-in VGA terminal
Edit: 2019-07-12: v14: mostly a clean up, with a few more built in modules (enough to support the pye.py editor). I've mentioned it elsewhere, but just in case: source code is now available at https://github.com/totalspectrum/micropython
, using the compiler framework from https://github.com/totalspectrum/riscvp2
Edit: 2019-06-23: v13: built with a new JIT compiler that supports compressed instructions, so it's faster and has more room for user code (we're back up to 200K for a while it was down to 144K due to all the additional built in modules). There are some debugging hooks in the emulator for I/O and other operations, which should make debugging easier and may allow for interesting hacks like @ozpropdev
's editor to be plugged in; see the README.txt for details, and/or ask here.
The SD card support is enhanced, and now micropython automatically runs "main.py" if there's an SD card plugged in when it starts up. The VGA text code is also enhanced, and allows for underline, blinking, and strikethrough as well as 256 foreground and background colors. With a VGA hooked up on pins 48 and a USB module on pins 16 the micropython interpreter can work in stand-alone mode.
Edit: 2019-06-13: v12, now with SD card FAT file system support
Edit: 2019-05-23: v11, fixes a typo in the buffered serial code that could cause characters to get stuck repeating
Edit: 2019-05-22: updated to v10, with buffered serial using another COG
Edit: 2019-05-21: updated to v9, with VGA on pins 48-55 and USB keyboard on pins 16-24 (via garryj's single COG USB keyboard/mouse driver).
Edit: 2019-05-16: updated to v8, with 192K RAM available now and some minor REPL improvements
Edit: 2019-04-04: updated to v7 with more user RAM available (128K now, was 32K before)
Edit: 2019-03-24: updated to v6, with long integer support (so all 32 bits of smartpin registers are accessible), and support for floating point and math functions
Edit: 2019-03-19: updated to v5, with improved counters and some performance tuning. There are two versions of the interpreter, upython.binary and upython_emu.binary. Both run at 160 MHz and communicate at 230_400 baud. Internally they have very different implementations; upython.binary runs on a JIT compiled RISCV emulator which should generally be much faster, but there may be some circumstances where the cache it uses starts to thrash, and then the plain emulator upython_emu.binary might be faster. Also bugs in one hopefully won't appear in the other, but you never know
Edit: 2019-03-18: updated to v4, fixed pin reading an access to Pin(0)
Edit: 2019-03-15: updated to v3, now has a few smart pin functions implemented; docs still in README.txt
Here's a very simple MicroPython interpreter running on the P2 Eval board. Directions are in README.txt. Only one set of P2 functions are provided (in the pyb module) to turn pins on and off.