MicroPython - Porting python to microcontrollers

aswinvenu


15

Votes

Description:

Have you ever worked on embedded system projects? Does that challenge your C skills? What if you have a python interpreter running on a bare metal microcontroller? Then you should have a look at MicroPython project.

What is Micropython ?

MicroPython is a lean and fast implementation of the Python 3 programming language that is optimised to run on a microcontroller. The MicroPython board is a small electronic circuit board that runs MicroPython on the bare metal, and gives you a low-level Python operating system that can be used to control all kinds of electronic projects.

About the Talk

Running an interpreter based programming language in a microprocessor with an OS is considered to be easier than running a the same in a microcontroller environment ,where you won't get the luxury of the RAM (System memory) and available ROM ( It can be flash or EEPROM etc.).

In the most modern microcontrollers with ARM Cortex M4 or even M7 series the RAM is limited to few hundred kiloBytes and Flash will be few MegaBytes.

Keeping the limited memory availability in the mind micropython is an effort to port python 3 (cpython) into microcontrollers.

some of the currently supported platforms are:

  • PyBoard ( Official micropython boards) *STM32F4 ( Discovery boards )
  • Tiva TM4C123G ( Launchpad board from TI)
  • Arduino Due
  • Teensy
  • ESP8366 etc.

We will be running micropython with some of these boards.

The talk will be divided into three parts.

Part One : Micropython and cpython implementation

In this section I will briefly explain micropython architecture. including :

  • Decoding
  • Tokenizing
  • Parsing
  • AST
  • Compiling and Virtual Machine

I will point out how a typical cpython implementation differ from the micropython implementation.

Part Two : Hands on with micropython

This will be more interesting part. we will port micropython in few supported platform and run some examples.

Through example we will check the working of all main functionalities ( Accessing driver level functions etc.).

Note : In the end of this section I will give some hints on how to port micropython into other currently unsupported platforms.

Part Three : Application

IOT is a hot spot now. Everything is connected now. We will discuss how we can increase the pace of IOT development using the simplicity of python.

Prerequisites:

Any one who has python knowledge can attend. It will be great if you the following skills

  • Basic C skills
  • Basics of Micro Controllers

Content URLs:

MicroPython Website : https://micropython.org/

MicoPython GitHub Repo: https://github.com/micropython/micropython

Some PyCon Talks on Micropython : https://www.youtube.com/watch?v=MZ_KOS2BSEo&feature=youtu.be

https://www.youtube.com/watch?v=4loeAfwaWM4&feature=youtu.ben

MicroPython - Porting Python to microcontrollers ( Proposed talk presentation slides ) : https://github.com/aswinvenu/Micropython-Talk/blob/master/MicroPython-Presentation.pdf

Speaker Info:

I am a free and open source enthusiast. Currently working for a Bangalore based startup. I holds a B E degree in Electronics and Communication Engineering from Anna University. I have been doing research in Brain Computer Interface and distributed sensor networks for last two years. I am an OpenSuse Advocate and Fedora community member. I have been a part of volunteering committee of Pycon India for last 2 years.

Speaker Links:

https://www.linkedin.com/in/aswinvenu

https://en.opensuse.org/User:Aswinvenu

https://fedoraproject.org/wiki/User:Aswin22

Section: Embedded Python
Type: Talks
Target Audience: Intermediate
Last Updated:

Please add what your talk will cover about MicroPython. It will be a good idea to add talk outline, see https://us.pycon.org/2015/speaking/proposal_advice/samples/SpacePug/ for an example.

Vijay Kumar (~bravegnu)

I have added the details. Please have a look at that.

aswinvenu

Thanks for the details. Please be aware that the talk duration is 30 min + 10 min for questions. Rather than talking about many different things about Micropython it would be nice to focus on one aspect. For example you might just want to drop of the part three.

In part one, you might just want to focus on those areas that are different in Micropython. For example it would be interesting to talk about Micropython's viper and inline assembler support, and other speed optimizations done in Micropython.

In part two, not sure why you want to use "few" different boards. Wouldn't a single type board suffice? You might want to list out the demos you are planning to do.

Vijay Kumar (~bravegnu)

I don't think that 30 min will be sufficient to talk about the entire internal architecture of Micropython. I think I can start by introducing the board and then starting from simple examples to various code optimization parts like using native code emitters and micropython's viper code emitters. I said multiple boards because say if you have esp8266, you can't get the inline assembler functionality( the core is based on Xtensa ) . esp8266 is the cheapest micropython board that you can get online. just for Rs.200. I can cover those areas using pyboard. I am getting 4 pyboards next week. :)

If I talk too much about the internals then I am not sure that how many of the audience can catch-up all those. It will be better to cover those areas through examples without opening the "C" part of it.

I wish I could get more suggestions and comments here.

Thank you

aswinvenu

I just thought that it would be a good idea to focus on the areas that made MicroPython special. I don't think Micropython does anything special when it comes to tokenizing and parsing (correct me if I am wrong.)

Vijay Kumar (~bravegnu)

You are right. Lexical analyzer/ Lexer and tokenizer are functionally the same as the original Cpython. But the way Damien wrote these blocks are in a different way compared to the typical cpython implementation.

aswinvenu

OK. Didn't realize that. If you have a point to make, then fine.

Vijay Kumar (~bravegnu)

I'm waiting for this with great impatience. I try to read more about that on different resources. And I think that is really great job!

brandonturner

I'm waiting for this with great impatience. I try to read more about that on different resources. And I think that is really great job!

brandonturner

Login to add a new comment.