Can't build a module to micropython on esp32 port

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
sara
Posts: 7
Joined: Thu Oct 03, 2019 12:26 pm

Can't build a module to micropython on esp32 port

Post by sara » Thu Nov 28, 2019 5:29 pm

Hi!
I was following the docs from this new guide (https://micropython-usermod.readthedocs ... index.html) to create modules and build the micropython firmware and I was trying to build the simplefunction.c example to the esp32.
So I placed the simplefunction.c in the working directory (in my case /ports/esp32), added the 

Code: Select all

#define MODULE_SIMPLEFUNCTION_ENABLED (1)
 to the mpconfigport.h and run the makefile on the terminal only using make without no arguments, because as the code is in the same directory I don't need to specify a path and the others constants such as board and compiler because they are already defined on makefile.
The result: So It built with no error, when I gave a make deploy and tried to import the module on my esp32 I got the following message from the REPL: 

Code: Select all

ImportError: no module named 'simplefunction'.
So, I think there's something missing... Can someone help me figure out?
One more information: while the make was running it printed out a message "QSTR not updated ", in somehow I think maybe it has something to do with it.

I am using:
OS: Ubuntu 18.04
IDF version: v3
port: esp32
micropython version: 1.11

Thanks in advance

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

Re: Can't build a module to micropython on esp32 port

Post by jimmo » Tue Dec 03, 2019 2:37 am

The build process don't wildcard match files. It's not enough just to place the file in ports/esp32. It might actually work if you put it in the board directory (i.e. ports/esp32/boards/GENERIC) but you're better off using the instructions that you linked to and setting it up in a different directory and using micropython.mk.

But if your goal is to actually add a new module to core MicroPython, then the approach is a bit different. Look at for example ports/esp32/modesp.c, and the corresponding line in ports/esp32/Makefile which adds it to SRC_C

"QSTR not updated" just means that it didn't find any differences in the interned strings. Which in this case is because it's not finding simplefunction.c. But if you don't modify any QSTR_foo strings (i.e. most of the time), then you'll get that message on most builds.

sara
Posts: 7
Joined: Thu Oct 03, 2019 12:26 pm

Re: Can't build a module to micropython on esp32 port

Post by sara » Tue Dec 03, 2019 3:30 pm

Thank you jimmo!
Now I followed those instructions and then I got the compiler messages! But I also got errors I can't understand:
Screenshot from 2019-12-03 12-29-13.png
Screenshot from 2019-12-03 12-29-13.png (118.15 KiB) Viewed 173 times
Would you know what is happening?

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

Re: Can't build a module to micropython on esp32 port

Post by jimmo » Sat Dec 07, 2019 12:04 pm

Possibly try doing a `make clean` and then try again? It's possible that the QSTR generation got confused by files moving around?

I tried the instructions at https://docs.micropython.org/en/latest/ ... dules.html (which is the "official" version that the guide you're using is extended from) and it worked fine.

- Put example.c and micropython.mk into /tmp/modules/example
- Build with make USER_C_MODULES=/tmp/modules CFLAGS_EXTRA=-DMODULE_EXAMPLE_ENABLED=1

sara
Posts: 7
Joined: Thu Oct 03, 2019 12:26 pm

Re: Can't build a module to micropython on esp32 port

Post by sara » Sun Dec 08, 2019 7:51 pm

Yes, you are right!
A more detailed discussion can be seen here: https://github.com/v923z/micropython-usermod/issues/3.
Summary:
make clean does work
The instructions from the official guide also works, and I reported at the link above which modules from the second guide don't work for esp32 port.
Now I am able to use.
Thank you very much for the attention!

Post Reply