Page 1 of 2

Reduced MicroPython

Posted: Thu Aug 27, 2015 7:09 am
by Tetraeder
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?

Re: Reduced MicroPython

Posted: Thu Aug 27, 2015 3:58 pm
by dhylands
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

Re: Reduced MicroPython

Posted: Fri Aug 28, 2015 1:08 pm
by Tetraeder
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?

Re: Reduced MicroPython

Posted: Fri Aug 28, 2015 4:02 pm
by dhylands
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.

Re: Reduced MicroPython

Posted: Mon Aug 31, 2015 7:20 am
by Tetraeder
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

Re: Reduced MicroPython

Posted: Thu Sep 03, 2015 10:42 am
by pfalcon
MicroPython provides minimal-configuration port - literally, "minimal", as described in README: https://github.com/micropython/micropython .

Re: Reduced MicroPython

Posted: Thu Sep 03, 2015 4:14 pm
by dhylands
I just built minimal for ARM (make CROSS=1) and it compiled to about 78K of flash. The 32-bit x86 version was 142K.

Re: Reduced MicroPython

Posted: Fri Sep 04, 2015 9:34 am
by Tetraeder
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.

Re: Reduced MicroPython

Posted: Fri Sep 04, 2015 7:05 pm
by pfalcon
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.

Re: Reduced MicroPython

Posted: Tue Oct 13, 2015 12:38 pm
by Tetraeder
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!!