building PYBv1.1 binary double FP + threading

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
microzee
Posts: 1
Joined: Thu Nov 30, 2017 1:07 am

building PYBv1.1 binary double FP + threading

Post by microzee » Thu Nov 30, 2017 1:22 am

I have found the binaries for the PYBv1.1 which include threading and double floating points in the downloads section on the micropython website.
However I'm wanting to be able to build the binaries myself and am have a bit of trouble with it.
Can anyone help or provide the required Makefile/configuration etc changes required to get these features to build.

Thanks

torwag
Posts: 220
Joined: Fri Dec 13, 2013 9:25 am

Re: building PYBv1.1 binary double FP + threading

Post by torwag » Thu Nov 30, 2017 5:18 am

Hi,
you will find everything you need on github.

https://github.com/micropython/micropython

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: building PYBv1.1 binary double FP + threading

Post by SpotlightKid » Thu Nov 30, 2017 8:04 am

Enabling these options is not documented in the READMEs in the repo, AFAIK. Enabling double floats should be the MICROPY_FLOAT_IMPL=double define and threads MICROPY_PY_THREAD=1.

Never tried it myself though.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: building PYBv1.1 binary double FP + threading

Post by Roberthh » Thu Nov 30, 2017 9:00 am

All options that can set set or unset are defined in py/mpconfig.h. This file also defines the default values.

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: building PYBv1.1 binary double FP + threading

Post by SpotlightKid » Thu Nov 30, 2017 3:02 pm

When I try to compile the firmware for the Pyboard V1.1 with double floats and thread module, using the command line in ports/stm32 and setting #define MICROPY_PY_THREAD (1) in py/mpconfig.h:

Code: Select all

LC_ALL=C make BOARD=PYBV11 MICROPY_FLOAT_IMPL=double V=1
I get the following error:

Code: Select all

CC ../py/mpstate.c
gcc -I. -I.. -Ibuild -Wall -Werror -Wpointer-arith -Wuninitialized -std=gnu99 -DFFCONF_H=\"lib/oofatfs/ffconf.h\" -Os   -fdata-sections -ffunction-sections -fno-asynchronous-unwind-tables -c -MD -o build/py/mpstate.o ../py/mpstate.c
In file included from ../py/mpstate.h:32:0,
                 from ../py/mpstate.c:27:
../py/mpthread.h:36:10: fatal error: mpthreadport.h: No such file or directory
 #include <mpthreadport.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [../py/mkrules.mk:47: build/py/mpstate.o] Error 1
make[1]: Leaving directory '/home/chris/work/micropython/micropython-mine/mpy-cross'
make: *** [../../py/mkrules.mk:107: ../../mpy-cross/mpy-cross] Error 2
What is the correct way to enable the thread module?

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: building PYBv1.1 binary double FP + threading

Post by jickster » Thu Nov 30, 2017 9:14 pm

SpotlightKid wrote:
Thu Nov 30, 2017 3:02 pm
When I try to compile the firmware for the Pyboard V1.1 with double floats and thread module, using the command line in ports/stm32 and setting #define MICROPY_PY_THREAD (1) in py/mpconfig.h:

Code: Select all

LC_ALL=C make BOARD=PYBV11 MICROPY_FLOAT_IMPL=double V=1
I get the following error:

Code: Select all

CC ../py/mpstate.c
gcc -I. -I.. -Ibuild -Wall -Werror -Wpointer-arith -Wuninitialized -std=gnu99 -DFFCONF_H=\"lib/oofatfs/ffconf.h\" -Os   -fdata-sections -ffunction-sections -fno-asynchronous-unwind-tables -c -MD -o build/py/mpstate.o ../py/mpstate.c
In file included from ../py/mpstate.h:32:0,
                 from ../py/mpstate.c:27:
../py/mpthread.h:36:10: fatal error: mpthreadport.h: No such file or directory
 #include <mpthreadport.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [../py/mkrules.mk:47: build/py/mpstate.o] Error 1
make[1]: Leaving directory '/home/chris/work/micropython/micropython-mine/mpy-cross'
make: *** [../../py/mkrules.mk:107: ../../mpy-cross/mpy-cross] Error 2
What is the correct way to enable the thread module?
This isn't like merely setting a MACRO to 1.

First of all, there's reason why the header is called mpthreadport.h: threading is very OS specific and even possibly hardware specific. If you search for one of the functions in mpthread.h like mp_thread_start(), you'll see it is defined in three different ports: cc3200, stm32, unix.

Furthermore, if you drill down further, you'll see that in the stm32, the port is specifically for FreeRTOS i.e. unless you're using FreeRTOS on the stm32, the "stm32 port for threading" is not usable to you.

Assuming you're running FreeRTOS, to make the BUILD work, you have to defined MICROPY_PY_THREAD as 1 in mpconfigport.h (or mpconfig.h) which it looks like you've done since you got the include error.

mpthreadport.h is located in \ports\stm32\
If you launch `make` from that directory,
Last edited by jickster on Fri Dec 01, 2017 4:58 pm, edited 1 time in total.

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: building PYBv1.1 binary double FP + threading

Post by SpotlightKid » Fri Dec 01, 2017 12:25 am

This isn't like merely setting a MACRO to 1.
Allright, I'll wait, until this more mature and documented. :)

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: building PYBv1.1 binary double FP + threading

Post by jickster » Fri Dec 01, 2017 4:57 pm

SpotlightKid wrote:
Fri Dec 01, 2017 12:25 am
This isn't like merely setting a MACRO to 1.
Allright, I'll wait, until this more mature and documented. :)
You'll be waiting awhile for it to be documented.
The hallmark of open source projects is lack of documentation. I'm not joking.

Furthermore, it's not about documentation. As I mentioned, you have to provide a port for your own OS/HW combination.

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: building PYBv1.1 binary double FP + threading

Post by SpotlightKid » Fri Dec 01, 2017 5:03 pm

The question remains then, how were these compiled:

Code: Select all

    standard: v1.9.3-72-gbb047558 (latest) ; v1.9.3 ; v1.9.2 ; v1.9.1 ; v1.9 ; v1.8.7 ;
    double FP: v1.9.3-72-gbb047558 (latest) ; v1.9.3 ; v1.9.2 ;
    threading: v1.9.3-72-gbb047558 (latest) ; v1.9.3 ; v1.9.2 ;
    double FP + threading: v1.9.3-72-gbb047558 (latest) ; v1.9.3 ; v1.9.2 ;
    network: v1.9.3-72-gbb047558 (latest) ; v1.9.3 ; v1.9.2 ; v1.9.1 ; v1.9 ; v1.8.7 ;

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: building PYBv1.1 binary double FP + threading

Post by jickster » Fri Dec 01, 2017 5:27 pm

SpotlightKid wrote:
Fri Dec 01, 2017 5:03 pm
The question remains then, how were these compiled:

Code: Select all

    standard: v1.9.3-72-gbb047558 (latest) ; v1.9.3 ; v1.9.2 ; v1.9.1 ; v1.9 ; v1.8.7 ;
    double FP: v1.9.3-72-gbb047558 (latest) ; v1.9.3 ; v1.9.2 ;
    threading: v1.9.3-72-gbb047558 (latest) ; v1.9.3 ; v1.9.2 ;
    double FP + threading: v1.9.3-72-gbb047558 (latest) ; v1.9.3 ; v1.9.2 ;
    network: v1.9.3-72-gbb047558 (latest) ; v1.9.3 ; v1.9.2 ; v1.9.1 ; v1.9 ; v1.8.7 ;
Have you verified the threading build is actually multithreaded?
It could be that there's just emtpy stubs for the threading API.

Post Reply