v923z/micropython-usermod

simplefunction module doesn't work on esp32

saramonteiro opened this issue · 11 comments

I was following the docs and I was trying to build the simplefunction example to the esp32. So I placed the simplefunction.c in the working directory (in my case /ports/esp32), added the #define MODULE_SIMPLEFUNCTION_ENABLED (1) to the mpconfigport.h and run the makefile on the terminal only using make, 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 are defined on makefile.
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: ImportError: no module named 'simplefunction'.
So, I think there's something missing... Can someone help me figure out?
One more information: while the make is running it prints a message "QSTR not updated ", in somehow I think it has something to do with it.
@v923z

v923z commented

The point of the user modules is that you can separate your code from the rest of micropython. So, you shouldn't put anything into /ports/esp32. Instead, you should have your files at the same level as the micropython directory. This is discussed in https://micropython-usermod.readthedocs.io/en/latest/usermods_03.html. You also need to pass the make arguments with the location of your user module directory, e.g.,

make USER_C_MODULES=../../../user_modules CFLAGS_EXTRA=-DMODULE_EXAMPLE_ENABLED=1 all

However, you still have to modify the mpconfigport.h file for your port, as you already pointed out.
I hope this helps.

ok, now I created a separated directory user_modules at the same level of micropython. In user_modules I placed simplefunction.c and micropython.mk. The mpconfigport.h is already with the flag enabled. And firstly I run the make like this:
make USER_C_MODULES=../../../user_modules CFLAGS_EXTRA=-DMODULE_EXAMPLE_ENABLED=1 all
And secondly I run a make deploy.
But I still can't import simplefunction on esp32.

v923z commented

I have just realised that I gave contradictory instructions in my first reply. That was a generic make command, and would most certainly not work. (The make flag CFLAGS_EXTRA=-DMODULE_EXAMPLE_ENABLED=1 defines the MODULE_EXAMPLE_ENABLED variable, while you needed MODULE_SIMPLEFUNCTION_ENABLED.)

I have just checked the following steps on the unix port, and they work:

So, if you clone the whole repository, you should have a library structure like this:

usermod/LICENSE  usermod/README.md

usermod/docs:
source micropython-usermod.ipynb  templates

usermod/snippets:
arbitrarykeyword  makeiterable    simpleclass       specialclass       vector
consumeiterable   profiling       simplefunction    stringarg
keywordfunction   returniterable  sliceextiterable  subscriptiterable
largemodule       sillyerrors     sliceiterable     vararg

Assuming that you have micropython and usermod side by side (at the same level), and you have the line

#define MODULE_SIMPLEFUNCTION_ENABLED (1)

at the end of micropython/ports/unix/mpconfigport.h, you should then navigate to micropython/ports/unix/, and run

make USER_C_MODULES=../../../usermod/snippets all

Alternatively, if you don't want to edit the header file, you can run make with

make USER_C_MODULES=../../../usermod/snippets all CFLAGS_EXTRA=-DMODULE_SIMPLEFUNCTION_ENABLED=1

Now, you should see following compiler messages:

Including User C Module from ../../../usermod/snippets/simplefunction
Including User C Module from ../../../usermod/snippets/profiling
Including User C Module from ../../../usermod/snippets/consumeiterable
Including User C Module from ../../../usermod/snippets/returniterable
Including User C Module from ../../../usermod/snippets/vector
Including User C Module from ../../../usermod/snippets/subscriptiterable
Including User C Module from ../../../usermod/snippets/vararg
Including User C Module from ../../../usermod/snippets/sillyerrors
Including User C Module from ../../../usermod/snippets/specialclass
Including User C Module from ../../../usermod/snippets/arbitrarykeyword
Including User C Module from ../../../usermod/snippets/sliceiterable
Including User C Module from ../../../usermod/snippets/stringarg
Including User C Module from ../../../usermod/snippets/largemodule
Including User C Module from ../../../usermod/snippets/keywordfunction
Including User C Module from ../../../usermod/snippets/simpleclass
mkdir -p build/simplefunction/

and

CC ../../../usermod/snippets/simplefunction/simplefunction.c
CC ../../../usermod/snippets/profiling/profiling.c
CC ../../../usermod/snippets/consumeiterable/consumeiterable.c
CC ../../../usermod/snippets/returniterable/returniterable.c
CC ../../../usermod/snippets/vector/vector.c
CC ../../../usermod/snippets/subscriptiterable/subscriptiterable.c
CC ../../../usermod/snippets/vararg/vararg.c
CC ../../../usermod/snippets/sillyerrors/sillyerrors.c
CC ../../../usermod/snippets/specialclass/specialclass.c
CC ../../../usermod/snippets/arbitrarykeyword/arbitrarykeyword.c
CC ../../../usermod/snippets/sliceiterable/sliceiterable.c
CC ../../../usermod/snippets/stringarg/stringarg.c
CC ../../../usermod/snippets/largemodule/helper.c
CC ../../../usermod/snippets/largemodule/largemodule.c
CC ../../../usermod/snippets/keywordfunction/keywordfunction.c
CC ../../../usermod/snippets/simpleclass/simpleclass.c

With this, all examples in usermod will be compiled, but only simplefunction will be included, since we set the flag for that particular module only. If you want to include another module, you simply add the corresponding flag to your header file, mpconfigport.h, or add another CFLAGS_EXTRA. You can find out, which flag you need by looking at the very end of the C source file. The last line is always something like

MP_REGISTER_MODULE(MP_QSTR_sillyerrors, sillyerrors_user_cmodule, MODULE_SILLYERRORS_ENABLED);

where the last argument of the MP_REGISTER_MODULE macro is the flag that you have to define in the header file, or add to the CFLAGS_EXTRA, if you want to include that module.

At this point, you should be able to run micropython and import the simplefunction module. (I haven't yet set up the ESP32 environment, and I can only check this on the unix and STM32 ports, but there it works, and I don't think that this is a port-specific problem.)

I hope this helps, and again, sorry for the confusion.

@v923z I got it and I firstly decidided to run it (make USER_C_MODULES=../../../usermod/snippets all CFLAGS_EXTRA=-DMODULE_SIMPLEFUNCTION_ENABLED=1) on unix port and I finally got those compiler messages, but I also had errors as you can see in the image below:

image

Then, I tried on esp32 port and got the following result:
image

Do you know what this might be?

v923z commented

Can you compile micropython without any extra modules? (Leave out usermod altogether!)

Can you post your entire make output? (You can simply copy the console output, and format everything as code.)

And I would like to refer to your first comment: it seemed that the code was compiled, but simplefunction was linked. Is that correct? (If you go back to that state, can you see CC simplefunction somewhere in the compiler messages?) One reason, why you could not import simplefunction could be that the makefile fragment (micropython.mk) was missing. You should have simplefunction.c, and the corresponding fragment in the same directory (https://github.com/v923z/micropython-usermod/tree/master/snippets/simplefunction) Without the fragment, the compiler will succeed, but your module won't be included.

As for your last question, could you, please, run make clean before you run your make command? I have the feeling that make would be confused, if you simply dropped a new file into the code base. With make clean you start from scratch.

  1. Firstly, I would like to thank you for all the attention.

  2. Ok, I went to unix port for while (only to be sure that it's not a port specific problem since you've been tested on unix) and as you asked for I ran make clean and got the following output:

Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity. rm -f micropython rm -f micropython.map rm -rf build

and after I performed only make and got the following output:

Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity. mkdir -p build/genhdr GEN build/genhdr/mpversion.h GEN build/genhdr/moduledefs.h GEN build/genhdr/qstr.i.last GEN build/genhdr/qstr.split GEN build/genhdr/qstrdefs.collected.h QSTR updated GEN build/genhdr/qstrdefs.generated.h mkdir -p build/build/ mkdir -p build/extmod/ mkdir -p build/lib/axtls/crypto/ mkdir -p build/lib/axtls/ssl/ mkdir -p build/lib/berkeley-db-1.xx/btree/ mkdir -p build/lib/berkeley-db-1.xx/mpool/ mkdir -p build/lib/embed/ mkdir -p build/lib/mp-readline/ mkdir -p build/lib/timeutils/ mkdir -p build/lib/utils/ mkdir -p build/py/ CC ../../py/mpstate.c CC ../../py/nlr.c CC ../../py/nlrx86.c CC ../../py/nlrx64.c CC ../../py/nlrthumb.c CC ../../py/nlrpowerpc.c CC ../../py/nlrxtensa.c CC ../../py/nlrsetjmp.c CC ../../py/malloc.c CC ../../py/gc.c CC ../../py/pystack.c CC ../../py/qstr.c CC ../../py/vstr.c CC ../../py/mpprint.c CC ../../py/unicode.c CC ../../py/mpz.c CC ../../py/reader.c CC ../../py/lexer.c CC ../../py/parse.c CC ../../py/scope.c CC ../../py/compile.c CC ../../py/emitcommon.c CC ../../py/emitbc.c CC ../../py/asmbase.c CC ../../py/asmx64.c CC ../../py/emitnx64.c CC ../../py/asmx86.c CC ../../py/emitnx86.c CC ../../py/asmthumb.c CC ../../py/emitnthumb.c CC ../../py/emitinlinethumb.c CC ../../py/asmarm.c CC ../../py/emitnarm.c CC ../../py/asmxtensa.c CC ../../py/emitnxtensa.c CC ../../py/emitinlinextensa.c CC ../../py/emitnxtensawin.c CC ../../py/formatfloat.c CC ../../py/parsenumbase.c CC ../../py/parsenum.c CC ../../py/emitglue.c CC ../../py/persistentcode.c CC ../../py/runtime.c CC ../../py/runtime_utils.c CC ../../py/scheduler.c CC ../../py/nativeglue.c CC ../../py/ringbuf.c CC ../../py/stackctrl.c CC ../../py/argcheck.c CC ../../py/warning.c CC ../../py/profile.c CC ../../py/map.c CC ../../py/obj.c CC ../../py/objarray.c CC ../../py/objattrtuple.c CC ../../py/objbool.c CC ../../py/objboundmeth.c CC ../../py/objcell.c CC ../../py/objclosure.c CC ../../py/objcomplex.c CC ../../py/objdeque.c CC ../../py/objdict.c CC ../../py/objenumerate.c CC ../../py/objexcept.c CC ../../py/objfilter.c CC ../../py/objfloat.c CC ../../py/objfun.c CC ../../py/objgenerator.c CC ../../py/objgetitemiter.c CC ../../py/objint.c CC ../../py/objint_longlong.c CC ../../py/objint_mpz.c CC ../../py/objlist.c CC ../../py/objmap.c CC ../../py/objmodule.c CC ../../py/objobject.c CC ../../py/objpolyiter.c CC ../../py/objproperty.c CC ../../py/objnone.c CC ../../py/objnamedtuple.c CC ../../py/objrange.c CC ../../py/objreversed.c CC ../../py/objset.c CC ../../py/objsingleton.c CC ../../py/objslice.c CC ../../py/objstr.c CC ../../py/objstrunicode.c CC ../../py/objstringio.c CC ../../py/objtuple.c CC ../../py/objtype.c CC ../../py/objzip.c CC ../../py/opmethods.c CC ../../py/sequence.c CC ../../py/stream.c CC ../../py/binary.c CC ../../py/builtinimport.c CC ../../py/builtinevex.c CC ../../py/builtinhelp.c CC ../../py/modarray.c CC ../../py/modbuiltins.c CC ../../py/modcollections.c CC ../../py/modgc.c CC ../../py/modio.c CC ../../py/modmath.c CC ../../py/modcmath.c CC ../../py/modmicropython.c CC ../../py/modstruct.c CC ../../py/modsys.c CC ../../py/moduerrno.c CC ../../py/modthread.c CC ../../py/vm.c CC ../../py/bc.c CC ../../py/showbc.c CC ../../py/repl.c CC ../../py/smallint.c CC ../../py/frozenmod.c CC ../../extmod/moductypes.c CC ../../extmod/modujson.c CC ../../extmod/modure.c CC ../../extmod/moduzlib.c CC ../../extmod/moduheapq.c CC ../../extmod/modutimeq.c CC ../../extmod/moduhashlib.c CC ../../extmod/moducryptolib.c CC ../../extmod/modubinascii.c CC ../../extmod/virtpin.c CC ../../extmod/machine_mem.c CC ../../extmod/machine_pinbase.c CC ../../extmod/machine_signal.c CC ../../extmod/machine_pulse.c CC ../../extmod/machine_i2c.c CC ../../extmod/machine_spi.c CC ../../extmod/modbluetooth.c CC ../../extmod/modussl_axtls.c CC ../../extmod/modussl_mbedtls.c CC ../../extmod/modurandom.c CC ../../extmod/moduselect.c CC ../../extmod/moduwebsocket.c CC ../../extmod/modwebrepl.c CC ../../extmod/modframebuf.c CC ../../extmod/vfs.c CC ../../extmod/vfs_blockdev.c CC ../../extmod/vfs_reader.c CC ../../extmod/vfs_posix.c CC ../../extmod/vfs_posix_file.c CC ../../extmod/vfs_fat.c CC ../../extmod/vfs_fat_diskio.c CC ../../extmod/vfs_fat_file.c CC ../../extmod/vfs_lfs.c CC ../../extmod/utime_mphal.c CC ../../extmod/uos_dupterm.c CC ../../lib/embed/abort_.c CC ../../lib/utils/printf.c MPY upip.py MPY upip_utarfile.py GEN build/frozen_content.c CC build/frozen_content.c CC main.c CC gccollect.c CC unix_mphal.c CC mpthreadport.c CC input.c CC file.c CC modmachine.c CC modos.c CC moduos_vfs.c CC modtime.c CC moduselect.c CC alloc.c CC coverage.c CC fatfs_port.c CC ../../lib/axtls/ssl/asn1.c CC ../../lib/axtls/ssl/loader.c CC ../../lib/axtls/ssl/tls1.c CC ../../lib/axtls/ssl/tls1_svr.c CC ../../lib/axtls/ssl/tls1_clnt.c CC ../../lib/axtls/ssl/x509.c CC ../../lib/axtls/crypto/aes.c CC ../../lib/axtls/crypto/bigint.c CC ../../lib/axtls/crypto/crypto_misc.c CC ../../lib/axtls/crypto/hmac.c CC ../../lib/axtls/crypto/md5.c CC ../../lib/axtls/crypto/rsa.c CC ../../lib/axtls/crypto/sha1.c CC ../../extmod/modbtree.c CC ../../lib/berkeley-db-1.xx/btree/bt_close.c CC ../../lib/berkeley-db-1.xx/btree/bt_conv.c CC ../../lib/berkeley-db-1.xx/btree/bt_debug.c CC ../../lib/berkeley-db-1.xx/btree/bt_delete.c CC ../../lib/berkeley-db-1.xx/btree/bt_get.c CC ../../lib/berkeley-db-1.xx/btree/bt_open.c CC ../../lib/berkeley-db-1.xx/btree/bt_overflow.c CC ../../lib/berkeley-db-1.xx/btree/bt_page.c CC ../../lib/berkeley-db-1.xx/btree/bt_put.c CC ../../lib/berkeley-db-1.xx/btree/bt_search.c CC ../../lib/berkeley-db-1.xx/btree/bt_seq.c CC ../../lib/berkeley-db-1.xx/btree/bt_split.c CC ../../lib/berkeley-db-1.xx/btree/bt_utils.c CC ../../lib/berkeley-db-1.xx/mpool/mpool.c CC modtermios.c CC modusocket.c CC modffi.c CC ../../lib/mp-readline/readline.c CC ../../lib/timeutils/timeutils.c LINK micropython text data bss dec hex filename 2095 6553 0 8648 21c8 build/build/frozen_content.o 440614 54888 2120 497622 797d6 micropython
And after this I got to execute ./micropython and enter in the REPL console without no problems.
Then I left the console and ran the whole command:

make USER_C_MODULES=../../../usermod/snippets all CFLAGS_EXTRA=-DMODULE_SIMPLEFUNCTION_ENABLED=1

and I got the following output:

Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity. Including User C Module from ../../../usermod/snippets/simplefunction Including User C Module from ../../../usermod/snippets/profiling Including User C Module from ../../../usermod/snippets/consumeiterable Including User C Module from ../../../usermod/snippets/returniterable Including User C Module from ../../../usermod/snippets/vector Including User C Module from ../../../usermod/snippets/subscriptiterable Including User C Module from ../../../usermod/snippets/vararg Including User C Module from ../../../usermod/snippets/sillyerrors Including User C Module from ../../../usermod/snippets/stringarg Including User C Module from ../../../usermod/snippets/specialclass Including User C Module from ../../../usermod/snippets/arbitrarykeyword Including User C Module from ../../../usermod/snippets/sliceiterable Including User C Module from ../../../usermod/snippets/largemodule Including User C Module from ../../../usermod/snippets/keywordfunction Including User C Module from ../../../usermod/snippets/simpleclass mkdir -p build/arbitrarykeyword/ mkdir -p build/consumeiterable/ mkdir -p build/keywordfunction/ mkdir -p build/largemodule/ mkdir -p build/profiling/ mkdir -p build/returniterable/ mkdir -p build/sillyerrors/ mkdir -p build/simpleclass/ mkdir -p build/simplefunction/ mkdir -p build/sliceiterable/ mkdir -p build/specialclass/ mkdir -p build/stringarg/ mkdir -p build/subscriptiterable/ mkdir -p build/vararg/ mkdir -p build/vector/ CC ../../../usermod/snippets/simplefunction/simplefunction.c In file included from ../../../usermod/snippets/simplefunction/simplefunction.c:11:0: ../../../usermod/snippets/simplefunction/simplefunction.c:23:50: error: ‘MP_QSTR_simplefunction’ undeclared here (not in a function); did you mean ‘MP_QSTR_implementation’? { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_simplefunction) }, ^ ../../py/obj.h:92:56: note: in definition of macro ‘MP_OBJ_NEW_QSTR’ #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)) ^~~ ../../../usermod/snippets/simplefunction/simplefunction.c:23:38: note: in expansion of macro ‘MP_ROM_QSTR’ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_simplefunction) }, ^~~~~~~~~~~ ../../../usermod/snippets/simplefunction/simplefunction.c:24:19: error: ‘MP_QSTR_add_ints’ undeclared here (not in a function); did you mean ‘MP_QSTR_kbd_intr’? { MP_ROM_QSTR(MP_QSTR_add_ints), MP_ROM_PTR(&simplefunction_add_ints_obj) }, ^ ../../py/obj.h:92:56: note: in definition of macro ‘MP_OBJ_NEW_QSTR’ #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2)) ^~~ ../../../usermod/snippets/simplefunction/simplefunction.c:24:7: note: in expansion of macro ‘MP_ROM_QSTR’ { MP_ROM_QSTR(MP_QSTR_add_ints), MP_ROM_PTR(&simplefunction_add_ints_obj) }, ^~~~~~~~~~~ ../../py/mkrules.mk:47: recipe for target 'build/simplefunction/simplefunction.o' failed make: *** [build/simplefunction/simplefunction.o] Error 1
As you may see, actually It got to include everything and create the directories, but it fails when compiling simplefunction.c.

  1. No, the micropython.mk is in the same directory that simplefunctio.c because I git cloned micropython-usermod side by side to the micropython directory as you asked for.

Once more, thank you

v923z commented
1. Firstly, I would like to thank you for all the attention.

Not at all. But it would actually be much better, if we could somehow solve the problem.

And after this I got to execute ./micropython and enter in the REPL console without no problems.
Then I left the console and ran the whole command:

make USER_C_MODULES=../../../usermod/snippets all CFLAGS_EXTRA=-DMODULE_SIMPLEFUNCTION_ENABLED=1

and I got the following output:

Exactly. If I do this, my compilation also fails with the same error. You really have to run make clean before trying to include a new module. Try to execute

make clean
make USER_C_MODULES=../../../usermod/snippets all CFLAGS_EXTRA=-DMODULE_SIMPLEFUNCTION_ENABLED=1

I think this should be the solution.

Look, I think we're almost there. I decided to review the micropython.mk and I remembered what you said about the name of the variables. Then I changed the variable USERMODULES_DIR to SIMPLEFUNCTION_MOD_DIR . Really silly error. Then I ran make clean an after make USER_C_MODULES=../../../usermod/snippets all CFLAGS_EXTRA=-DMODULE_SIMPLEFUNCTION_ENABLED=1 and it worked!!!!

But on esp32 port it still gave me an error, look this snippet from the very end of the output:
CC machine_rtc.c CC machine_sdcard.c CC ../../../usermod/snippets/simplefunction/simplefunction.c CC ../../../usermod/snippets/profiling/profiling.c ../../../usermod/snippets/profiling/profiling.c: In function 'measure_cpu': ../../../usermod/snippets/profiling/profiling.c:20:13: error: implicit declaration of function 'm_get_current_bytes_allocated' [-Werror=implicit-function-declaration] start = m_get_current_bytes_allocated(); ^ cc1: all warnings being treated as errors ../../py/mkrules.mk:47: recipe for target 'build-GENERIC/profiling/profiling.o' failed make: *** [build-GENERIC/profiling/profiling.o] Error 1
But as you can see, this time the problem is on profililing example. I changed the micropython.mk file variable, but it continues giving the same error. It's very strange why it works on unix port and does not work on esp32.

v923z commented

Look, I think we're almost there. I decided to review the micropython.mk and I remembered what you said about the name of the variables. Then I changed the variable USERMODULES_DIR to SIMPLEFUNCTION_MOD_DIR . Really silly error.

I find this strange. I thought that USERMODULES_DIR should be OK. At least, I have never had problems with that, and no one has ever complained about any issues in this regard. ulab, which probably has higher exposure, is organised in the same way, and the couple of compilation issues that people reported were related to an entirely different problem. So, I am a bit at a loss here.

But on esp32 port it still gave me an error, look this snippet from the very end of the output:
CC machine_rtc.c CC machine_sdcard.c CC ../../../usermod/snippets/simplefunction/simplefunction.c CC ../../../usermod/snippets/profiling/profiling.c ../../../usermod/snippets/profiling/profiling.c: In function 'measure_cpu': ../../../usermod/snippets/profiling/profiling.c:20:13: error: implicit declaration of function 'm_get_current_bytes_allocated' [-Werror=implicit-function-declaration] start = m_get_current_bytes_allocated(); ^ cc1: all warnings being treated as errors ../../py/mkrules.mk:47: recipe for target 'build-GENERIC/profiling/profiling.o' failed make: *** [build-GENERIC/profiling/profiling.o] Error 1
But as you can see, this time the problem is on profililing example. I changed the micropython.mk file variable, but it continues giving the same error. It's very strange why it works on unix port and does not work on esp32.

Actually, ESP32 is a strange beast: on that platform, micropython runs as a subprocess, and is not implemented natively: https://docs.micropython.org/en/latest/esp32/general.html . For this reason, hardware-related functions might or might not work in the same way as with, e.g., STM32. I have to admit, I haven't tested the code on ESP32, and since I am a bit tied down with ulab at the moment, I don't think I can commit to that in the near future.

It could also be that the m_get_current_bytes_allocated function has recently been removed. I will look into that, and if that is the case, I will update the snippet.

I find this strange. I thought that USERMODULES_DIR should be OK. At least, I have never had problems with that, and no one has ever complained about any issues in this regard. ulab, which probably has higher exposure, is organised in the same way, and the couple of compilation issues that people reported were related to an entirely different problem. So, I am a bit at a loss here.

No, you were write, I returned the names and ran a make clean and had no problems on unix port, sorry for the confusion. This is now really solved with:

make clean
make USER_C_MODULES=../../../usermod/snippets all CFLAGS_EXTRA=-DMODULE_SIMPLEFUNCTION_ENABLED=1

Actually, ESP32 is a strange beast: on that platform, micropython runs as a subprocess, and is not implemented natively: https://docs.micropython.org/en/latest/esp32/general.html . For this reason, hardware-related functions might or might not work in the same way as with, e.g., STM32. I have to admit, I haven't tested the code on ESP32, and since I am a bit tied down with ulab at the moment, I don't think I can commit to that in the near future. It could also be that the m_get_current_bytes_allocated function has recently been removed. I will look into that, and if that is the case, I will update the snippet.

I decided to create a another directory mymodules side by side to the micropython directory and I placed the modules from usermod there one by one. Each time I added one module I ran:

make clean
make USER_C_MODULES=../../../mymodules CFLAGS_EXTRA=-DMODULE_SIMPLEFUNCTION_ENABLED=1 all PYTHON=python2

What I had as a result:
The following modules trigger errors on esp32 port:

profiling
sliceiterable
stringarg
vararg

The first one because of the already mentioned m_get_current_bytes_allocated function.
The sliceiterable:
error: format '%ld' expects argument of type 'long int', but argument 2 has type 'mp_uint_t
The stringarg:
error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'size_t
The vararg:
error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'mp_int_t

The later three ones are kind of similar, I decided to register them here, but I am satisfied, I believe the ones I got to compile and use are enough for me to continue. Thank you very much!

v923z commented

The first one because of the already mentioned m_get_current_bytes_allocated function.
The sliceiterable:
error: format '%ld' expects argument of type 'long int', but argument 2 has type 'mp_uint_t
The stringarg:
error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'size_t
The vararg:
error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'mp_int_t

The later three ones are kind of similar, I decided to register them here, but I am satisfied, I believe the ones I got to compile and use are enough for me to continue.

OK, I would then keep this issue open, so that I don't forget about it. Thanks for taking the time for reporting!

Incidentally, mp_int_t and mp_uint_t are defined in mpconfigport.h, and for ESP32, they are int32_t, and uint32_t.This means, that those print statements you can fix by setting the format specifiers properly (i.e., %lu in sliceiterable, and %ld in vararg.