no _thread module for STM32 B-L475E-IOT01A

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
walecka
Posts: 17
Joined: Wed Apr 08, 2020 9:50 pm

no _thread module for STM32 B-L475E-IOT01A

Post by walecka » Tue Jun 02, 2020 6:02 am

When I attempt to import the _thread module, I am unfortunately met with the

Code: Select all

ImportError: no module named '_thread'
error. Am I correct in assuming that this means the library is not available? I am not sure what the requirements of _thread are, but I am fairly sure the STM32L475VG MCU on my board is capable of running it as I have used it to run some fairly RAM-intensive FreeRTOS programs in the past. Granted, that was in C and I am sure the interpretation of Python certainly adds a layer of complexity. Perhaps it has simply not been implemented for my board-specific port.

In any case, from the small amount of sniffing around that I have done on the forums, it seems like I am probably better off using uasyncio anyways. Would have liked to try my hand at writing a _thread application, but on the bright side this will likely save me hours of pain.

User avatar
jimmo
Posts: 1841
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: no _thread module for STM32 B-L475E-IOT01A

Post by jimmo » Wed Jun 10, 2020 6:21 am

walecka wrote:
Tue Jun 02, 2020 6:02 am
error. Am I correct in assuming that this means the library is not available? I am not sure what the requirements of _thread are, but I am fairly sure the STM32L475VG MCU on my board is capable of running it as I have used it to run some fairly RAM-intensive FreeRTOS programs in the past. Granted, that was in C and I am sure the interpretation of Python certainly adds a layer of complexity. Perhaps it has simply not been implemented for my board-specific port.
Unfortunately the default firmware for the STM32 boards doesn't include the _thread module. There are custom builds available for pyboard (see http://micropython.org/download/pybv1/)

If you build the firmware yourself from source, you can add

Code: Select all

#define MICROPY_PY_THREAD (1)
to ports/stm32/boards/B_L475E_IOT01A/mpconfigboard.h to enable this.
walecka wrote:
Tue Jun 02, 2020 6:02 am
In any case, from the small amount of sniffing around that I have done on the forums, it seems like I am probably better off using uasyncio anyways. Would have liked to try my hand at writing a _thread application, but on the bright side this will likely save me hours of pain.
My experience has been that asyncio is usually a much better alternative.

Post Reply