Page 1 of 1

building for BOARD=PYBD_SF to get _threads compiled in

Posted: Wed Jun 26, 2019 4:21 pm
by nherriot
Hi Micropython Folks,

And my saga continues! I now have a working build system on my Linux Mint18 machine - thanks to all the help from the community!

The reason for me wanting to compile for the PYBD_SF2 is that I need threads compiled into my firmware. I know it's experimental but it's good enough for me ATM.

I assumed that if I update /py/mpconfig.py I could do a build and have that compiled in. I changed this line of code:

Code: Select all

// Whether to provide "_thread" module
#ifndef MICROPY_PY_THREAD
#define MICROPY_PY_THREAD (1)
#endif
But unfortunately for me, it's more complex than that! Anyone know how to get threads compiled into my firmware.dfu file? :-)

Thank you in advance for all the help!

Kind regards, Nicholas.

Re: building for BOARD=PYBD_SF to get _threads compiled in

Posted: Wed Jun 26, 2019 7:33 pm
by marfis
By accident I just did this yesterday with my pyboard d series sf2, and it worked without issues, using the compiler switch you have mentioned.

What fault did you observe? Does import _thread not work?

btw You dont have to set the compiler switch in py/mpconfig.h. just set it in your board specific mpconfigboard.h.

Re: building for BOARD=PYBD_SF to get _threads compiled in

Posted: Wed Jun 26, 2019 7:55 pm
by Roberthh
.@nherriot Usually the switches are set in the port-specific mpconfigport.h, located in stm32, or the board-specific mpconfigboard.h, located e.g. in stm32/boards/PYBD,_SF2.
Setting the switch in py/mpconfig.h affects all builds in all ports, which may not be the intention.

Re: building for BOARD=PYBD_SF to get _threads compiled in

Posted: Wed Jun 26, 2019 8:40 pm
by dhylands
And since the stm32 port has:
https://github.com/micropython/micropyt ... #L130-L132
the setting in py/mpconfig.h will be ignored.

Re: building for BOARD=PYBD_SF to get _threads compiled in

Posted: Thu Jun 27, 2019 7:08 am
by nherriot
marfis wrote:
Wed Jun 26, 2019 7:33 pm
By accident I just did this yesterday with my pyboard d series sf2, and it worked without issues, using the compiler switch you have mentioned.

What fault did you observe? Does import _thread not work?

btw You dont have to set the compiler switch in py/mpconfig.h. just set it in your board specific mpconfigboard.h.
Mmmm... Well from the repl i did >>> import _thread
It did not work for me.
I'll double check and also read the other posts. Thank you for replying! :-)

Kind regards, Nicholas.

Re: building for BOARD=PYBD_SF to get _threads compiled in

Posted: Fri Jun 28, 2019 11:17 am
by nherriot
dhylands wrote:
Wed Jun 26, 2019 8:40 pm
And since the stm32 port has:
https://github.com/micropython/micropyt ... #L130-L132
the setting in py/mpconfig.h will be ignored.
Hi Dhylands,

that did the trick. :-) Thank you.
My board now has _thread compiled in! And seems to work.

Code: Select all

>
MicroPython v1.11-63-gd889def06-dirty on 2019-06-28; PYBD-SF2W with STM32F722IEK
Type "help()" for more information.
>>> 
>>> import _thread
>>>
I've looked around the Wiki for this type of information.
I've not seen it anywhere - so either hidden or not presetn.

Shall I start a new page to try and capture this information?

Kind regards, Nicholas.