building for BOARD=PYBD_SF to get _threads compiled in

The official PYBD running MicroPython, and its accessories.
Target audience: Users with a PYBD
Post Reply
nherriot
Posts: 24
Joined: Wed Oct 19, 2016 1:02 pm

building for BOARD=PYBD_SF to get _threads compiled in

Post by nherriot » Wed Jun 26, 2019 4:21 pm

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.

User avatar
marfis
Posts: 215
Joined: Fri Oct 31, 2014 10:29 am
Location: Zurich / Switzerland

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

Post by marfis » 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.

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

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

Post by Roberthh » Wed Jun 26, 2019 7:55 pm

.@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.

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

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

Post by dhylands » 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.

nherriot
Posts: 24
Joined: Wed Oct 19, 2016 1:02 pm

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

Post by nherriot » Thu Jun 27, 2019 7:08 am

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.

nherriot
Posts: 24
Joined: Wed Oct 19, 2016 1:02 pm

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

Post by nherriot » Fri Jun 28, 2019 11:17 am

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.

User avatar
ta1db
Posts: 53
Joined: Mon Sep 02, 2019 12:05 pm
Contact:

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

Post by ta1db » Sun Sep 29, 2019 7:51 pm

I could also build firmware with _thread module included in the same way ;
By just adding

Code: Select all

// Whether to provide "_thread" module
#ifndef MICROPY_PY_THREAD
#define MICROPY_PY_THREAD (1)
#endif
in mpconfigboard.h of Nucleo_F401RE , STM32F7DISC.
Thanks.

Post Reply