Porting to Zephyr RTOS (zephyrproject.org)

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
mishka27
Posts: 2
Joined: Sun Oct 02, 2016 9:22 am

Porting to Zephyr RTOS (zephyrproject.org)

Post by mishka27 » Sun Oct 02, 2016 11:24 am

I'd like to add support I2c to boards, running zephyr OS
I have MicroPython running on Galileo for example
Is there any reference how to add - import machine?
Then I would connect zephyr calls, but don't understand the flow yet
import machine returns error, even I've added to config file
#define MICROPY_PY_MACHINE (1)

Please help, any document or readme how to add import and maybe "machine" specific

Thanks

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Porting to Zephyr RTOS (zephyrproject.org)

Post by pfalcon » Wed Oct 05, 2016 5:04 pm

Hello mishka27, thanks for bringing this discussion to forum from the email, and sorry for delay with the response and for confusion your post may have caused.

So, the current situation with Zephyr RTOS port is that:
One of the issues we had is that is wasn't easy to integrate (non-trivial) 3rd-party project with Zephyr build system, and it required hacks of various levels. This is now largely resolved with https://gerrit.zephyrproject.org/r/#/c/4915/ . Given that there're now 2 diverged branches, and few people expressed interest in the port, I submitted RFC for merging it to MicroPython master: https://github.com/micropython/micropython/issues/2481 . So, over coming weeks we'll work with @daniel-thompson on reconciling our branches and gradually spooling code to the master.

Now answering your question, if you don't want to wait and would like to play with something now, you may want to look at Daniel Thompson's fork, specifically this is a commit which implements machine.Pin class: https://github.com/daniel-thompson/micr ... 74225dbba4 . Note that it will need rework before being merged to master. You can look at any other port to see how machine.I2C is implemented: stmhal, esp8266. If you're interested to learn basics of how to implement a module for MicroPython, looking in extmod/ subdir would give you few easy to follow, mostly self-contained modules, https://github.com/micropython/micropyt ... binascii.c is a good example.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Porting to Zephyr RTOS (zephyrproject.org)

Post by pfalcon » Wed Oct 26, 2016 3:31 pm

Some updates on Zephyr port: 1.8.5 release went with basic support for Zephyr port. Since then, "utime" module implementation was merged. machine.Pin support is next in queue.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Porting to Zephyr RTOS (zephyrproject.org)

Post by pfalcon » Thu Oct 11, 2018 9:39 am

Just as an update: Zephyr port is updated in mainline (should build with each last released Zephyr version), and maintained in my fork (https://github.com/pfalcon/micropython). There wasn't too much development of the port over last couple of years, but some was, e.g. Zephyr's Sensor API was wrapped into port-specific "zsensor" module. That for example allows to develop sensor devices communicating over network.

Here's example demo of an STM32 demo running a webserver with webapp showing sensor output:

https://www.youtube.com/watch?v=_CC6JJCSJiY
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

Post Reply