Do native modules work on ESP32?

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
pythoncoder
Posts: 4787
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Do native modules work on ESP32?

Post by pythoncoder » Sun Dec 20, 2020 4:18 pm

I have these working fine on STM but am getting no joy on ESP32. I'm new to compiling ESP32 so am unsure if the problem is my toolchain. Please could someone with a working toolchain try this and report the outcome.

Go to examples/natmod/features0. Edit Makefile so the ARCH line reads

Code: Select all

ARCH = xtensawin
Issue make.
Copy the resultant features0.mpy to an ESP32.
At the REPL issue

Code: Select all

>>> import features0
I get a crash, even after erasing flash and installing a new build (IDF3 or IDF4).
Peter Hinch

User avatar
mattyt
Posts: 322
Joined: Mon Jan 23, 2017 6:39 am

Re: Do native modules work on ESP32?

Post by mattyt » Mon Dec 28, 2020 12:48 pm

(In a very brief response to quickly asking him, Damien tells me that native modules should work on the ESP32. Sorry, I don't know much more!)

User avatar
Mike Teachman
Posts: 97
Joined: Mon Jun 13, 2016 3:19 pm
Location: Victoria, BC, Canada

Re: Do native modules work on ESP32?

Post by Mike Teachman » Mon Dec 28, 2020 4:12 pm

Hi Peter, this example worked on my ESP32 SPIRAM build.
Build info:
  • rebased to the mainline at commit 5a70279 (Nov 23, 2020)
  • environment is Win10/WSL2/Ubuntu
  • ESP-IDF v3.3.2
I attached the mpy file

Code: Select all

>>>
>>> import features0
>>> features0.
__class__       __name__        __file__        factorial
>>> features0.factorial(3)
6
>>>
build msgs:

Code: Select all

GEN build/features0.config.h
CC features0.c
LINK build/features0.o
arch:         EM_XTENSA
text size:    104
rodata size:  8
bss size:     0
GOT entries:  3
GEN features0.mpy
features0.zip
(307 Bytes) Downloaded 10 times

User avatar
pythoncoder
Posts: 4787
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Do native modules work on ESP32?

Post by pythoncoder » Mon Dec 28, 2020 6:16 pm

Thanks both. @Mike Teachman your file imports and runs on my board so there is evidently something wrong with my toolchain. I'll investigate - despite going the Docker route I must have got something wrong. It's odd that compilation seemed successful.
Peter Hinch

User avatar
tve
Posts: 216
Joined: Wed Jan 01, 2020 10:12 pm
Location: Santa Barbara, CA
Contact:

Re: Do native modules work on ESP32?

Post by tve » Fri Jan 15, 2021 5:14 am

If you're talking about dynamically loaded native modules, check out: https://github.com/micropython/micropython/issues/6769

User avatar
pythoncoder
Posts: 4787
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Do native modules work on ESP32?

Post by pythoncoder » Fri Jan 15, 2021 9:05 am

tve wrote:
Fri Jan 15, 2021 5:14 am
If you're talking about dynamically loaded native modules, check out: https://github.com/micropython/micropython/issues/6769
Thanks, I saw that.

My current state of play is that I can now build and run the features0 demo. However my own module, which builds and runs on STM32, crashes on import when built for STM32. I'm still not confident that my toolchain is right as I can't build ESP32 firmware, so I was waiting for a resolution to this issue before trying again.

My problem is that I'm trying to do too many things at once ;)
Peter Hinch

Post Reply