Page 1 of 1

building PYBv1.1 binary double FP + threading

Posted: Thu Nov 30, 2017 1:22 am
by microzee
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

Re: building PYBv1.1 binary double FP + threading

Posted: Thu Nov 30, 2017 5:18 am
by torwag
Hi,
you will find everything you need on github.

https://github.com/micropython/micropython

Re: building PYBv1.1 binary double FP + threading

Posted: Thu Nov 30, 2017 8:04 am
by SpotlightKid
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.

Re: building PYBv1.1 binary double FP + threading

Posted: Thu Nov 30, 2017 9:00 am
by Roberthh
All options that can set set or unset are defined in py/mpconfig.h. This file also defines the default values.

Re: building PYBv1.1 binary double FP + threading

Posted: Thu Nov 30, 2017 3:02 pm
by SpotlightKid
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?

Re: building PYBv1.1 binary double FP + threading

Posted: Thu Nov 30, 2017 9:14 pm
by jickster
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,

Re: building PYBv1.1 binary double FP + threading

Posted: Fri Dec 01, 2017 12:25 am
by SpotlightKid
This isn't like merely setting a MACRO to 1.
Allright, I'll wait, until this more mature and documented. :)

Re: building PYBv1.1 binary double FP + threading

Posted: Fri Dec 01, 2017 4:57 pm
by jickster
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.

Re: building PYBv1.1 binary double FP + threading

Posted: Fri Dec 01, 2017 5:03 pm
by SpotlightKid
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 ;

Re: building PYBv1.1 binary double FP + threading

Posted: Fri Dec 01, 2017 5:27 pm
by jickster
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.