, have you addressed how to start COGs in your version of micropython? If not, I'd like to propose that we have a Cpu type to encapsulate some COG code and data. Cpu(N) allocates COG N for use (actually N can have any set of bits that are passed to coginit). Cpu() on its own is the same as Cpu(0x10), that is, it will allocate the next free COG when it's time to start.
The methods on Cpu objects are:
start(code, data): starts a binary blob (compiled COG program) running in the allocated Cpu, or in the next free CPU if one is available. "code" is a bytearray of the PASM instructions to run. "data" is a bytearray or other buffer protocol object which contains the initial data. "code" is read only, but "data" is read/write so the running COG may update it.
On the COG side, "code" is what is passed to PTRB (the code loaded into the COG), and "data" is what is passed to PTRA.
stop(): stops the COG
So for example to start up the binary in the "cogcode.bin" file, with 3 longwords $00000001, $00000002, and $00000003 passed in its mailbox, do:
# read in the code
# prepare the data as an array of integers
data=array.array('i', [1, 2, 3])
# set up the cog; just allocate the next free one
# the cog will update data as necessary
How does this sound?
, you've done some very cool python tools for the P2. Any chance you've written an assembler in python?
It could come in pretty handy. I've actually looked at linking the p2asm assembler in, but it's fairly large by P2 standards and we're already a bit tight on memory in the micropython environment.