Reduced MicroPython

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Reduced MicroPython

Post by Tetraeder » Thu Aug 27, 2015 7:09 am

Hello everyone,

In my try to understand MicroPython(is an still ongoing process :? :?: ) i reduced the whole MicroPython project to the minium. Only Repl running over UART (no USB driver, leds, pins, spi, i2c,...) on the pyBoard.
For me it's the best starting point to port MicroPython to another target.

Does that make someone else?
Or it needs someone?

User avatar
dhylands
Posts: 3459
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Reduced MicroPython

Post by dhylands » Thu Aug 27, 2015 3:58 pm

Yep - that's the approach I would take as well.

I tend to start with the "full" featured micropython and comment out stuff to strip it down. You could also start with the minimal vesion (in the minimal directory) and flesh it out. Which way you go depends on which you think your final version will be closest to.

I generally do things in this order:
1 - flash a LED
2 - get HW UART working and then the REPL running on UART
3 - work on additional peripherals

Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Re: Reduced MicroPython

Post by Tetraeder » Fri Aug 28, 2015 1:08 pm

The strip down method was better for me. Yielded faster results.

My reduced MicroPython:
- /tools
- /extmod
- /lib
- /py
- /stmhal
  • * bufhelper
    * extint
    * gccollect
    * gchelpers.s
    * irq
    * main
    * Makefile
    * make-stmconst.py
    * modpyb
    * modstm
    * modstmconst.gen.c
    * moduselect
    * mpconfigport.h/.mk
    * mphal
    * pendsv
    * portmodules.h
    * printf
    * pybioctl
    * pyexe
    * qstrdefsport
    * startup_stm32f4xx.s
    * stm32f4xx_it
    * system_stm32f4xx.c
    * uart



Can I reduce the project even further? If so, which files?
Or must I now look for source code I can comment out?

User avatar
dhylands
Posts: 3459
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Reduced MicroPython

Post by dhylands » Fri Aug 28, 2015 4:02 pm

You can configure on and off quite a few things using the mpconfigport.h/mpconfigboard.h files, and override settings in the py/mpconfig.py file.

But without knowing why you're trying to cut stuff and what your final objectives are, it's hard to say. For example, you can disable floating point support, but you haven't said whether that's important or not.

Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Re: Reduced MicroPython

Post by Tetraeder » Mon Aug 31, 2015 7:20 am

I want at the end micro python which consists only of the UART repl and the necessary files for Python.

Ok thanks for the tip. Let's see how much I can still reduce to nothing more goes :D

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

Re: Reduced MicroPython

Post by pfalcon » Thu Sep 03, 2015 10:42 am

MicroPython provides minimal-configuration port - literally, "minimal", as described in README: https://github.com/micropython/micropython .
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/

User avatar
dhylands
Posts: 3459
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Reduced MicroPython

Post by dhylands » Thu Sep 03, 2015 4:14 pm

I just built minimal for ARM (make CROSS=1) and it compiled to about 78K of flash. The 32-bit x86 version was 142K.

Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Re: Reduced MicroPython

Post by Tetraeder » Fri Sep 04, 2015 9:34 am

Thanks for the information,

I think the minimal its at my knowledge base not the right way to port micropython. It's to raw for me. I prefer to change existing code as write new.
I try it with my reduced version and when i don't make progress I try it with the minimal.

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

Re: Reduced MicroPython

Post by pfalcon » Fri Sep 04, 2015 7:05 pm

Hmmm, strange, because in the previous message you wrote:
I want at the end micro python which consists only of the UART repl and the necessary files for Python.
And that's exactly what minimal has always been. But nevermind.
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/

Tetraeder
Posts: 53
Joined: Thu Mar 05, 2015 1:12 pm
Location: Germany

Re: Reduced MicroPython

Post by Tetraeder » Tue Oct 13, 2015 12:38 pm

pfalcon is right!!
After many attempts, it makes no sense to use a reduced stmhal for porting. To much that needs to be adapted and many sources of errors.
minimal is the best way.

The thread can be deleted!!

Post Reply