issue with setting up a toolchain

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
skoya
Posts: 6
Joined: Fri Apr 17, 2020 12:51 pm

issue with setting up a toolchain

Post by skoya » Mon Aug 17, 2020 10:43 am

Hi, I am trying to set up the toolchain and esp-idf as shown here : https://github.com/micropython/micropyt ... nd-esp-idf

The problem is that when I run make command it says I am lacking files in esp-idf. I tried different branches, downloaded the whole thing again but the problem remains :oops:

Here is the output:

Code: Select all

Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
fatal: cannot change to 'show': No such file or directory
** WARNING **
The git hash of ESP IDF does not match the supported version
The build may complete and the firmware may work but it is not guaranteed
ESP IDF path:       
Current git hash:   
Supported git hash (v3.3): 9e70825d1e1cbf7988cf36981774300066580ea7
Supported git hash (v4.0) (experimental): 4c81978a3e2220674a432a588292a4c860eef27b
fatal: cannot change to 'describe': No such file or directory
find: ‘/components’: No such file or directory
AR build-GENERIC/bootloader/libbootloader_support.a
xtensa-esp32-elf-ar: build-GENERIC/bootloader//components/bootloader_support/src/bootloader_clock.o: No such file or directory
Makefile:849: recipe for target 'build-GENERIC/bootloader/libbootloader_support.a' failed
make: *** [build-GENERIC/bootloader/libbootloader_support.a] Error 1

User avatar
rcolistete
Posts: 352
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: issue with setting up a toolchain

Post by rcolistete » Mon Aug 17, 2020 6:27 pm

List the steps you have used, like the git clone command, etc.
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

skoya
Posts: 6
Joined: Fri Apr 17, 2020 12:51 pm

Re: issue with setting up a toolchain

Post by skoya » Tue Aug 18, 2020 9:25 am

Hi, thanks for the reply

So I am following the steps shown in official micropython github page and I am trying to do this :
https://docs.micropython.org/en/latest/ ... dules.html

I am running this command inside ports/esp32 folder:
make USER_C_MODULES=../../../modules CFLAGS_EXTRA=-DMODULE_EXAMPLE_ENABLED=1 all

the output is:

Code: Select all

USER_C_MODULES=../../../modules CFLAGS_EXTRA=-DMODULE_EXAMPLE_ENABLED=1 all
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Including User C Module from ../../../modules/example
** WARNING **
The git hash of ESP IDF does not match the supported version
The build may complete and the firmware may work but it is not guaranteed
ESP IDF path:       /home/redcorn/esp/esp-idf
Current git hash:   688c62315688ee5ebab07e032eb4f4be19406bcd
Supported git hash (v3.3): 9e70825d1e1cbf7988cf36981774300066580ea7
Supported git hash (v4.0) (experimental): 4c81978a3e2220674a432a588292a4c860eef27b
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Makefile:19: *** Use the BOARD variable instead of SDKCONFIG.  Stop.

any ideas how to fix this?

User avatar
rcolistete
Posts: 352
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: issue with setting up a toolchain

Post by rcolistete » Tue Aug 18, 2020 3:13 pm

Suggestion, before running make with options, try the default (no options) to verify if everything works.

You need to change esp-idf git hash, something like that (for ESP-IDF v3.3) :

Code: Select all

$ cd ~/esp/esp-idf
$ git checkout 9e70825d1e1cbf7988cf36981774300066580ea7
$ git submodule sync   # used by Pycom, maybe it is useful for ESP32 mainline
$ git submodule update --init --recursive
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

skoya
Posts: 6
Joined: Fri Apr 17, 2020 12:51 pm

Re: issue with setting up a toolchain

Post by skoya » Wed Aug 19, 2020 9:31 am

Thanks,
Ive tried this but it doesn't work anyway. Ive downloaded mp again and set this up for unix. Micropython prompt works fine but I still cannot make my example module.

Code: Select all

I run this command: make USER_C_MODULES=../../../modules all
also tried it with CFLAGS_EXTRA=-DMODULE_EXAMPLE_ENABLED=1 but without success

the output from the console is:

Code: Select all

Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Including User C Module from ../../../modules/example
Building with ESP IDF v3
make: *** No rule to make target 'example/python/micropython/my_project/modules/example/example.c', needed by 'build-GENERIC/genhdr/qstr.i.last'.  Stop.

My file tree looks like this:


my_project/
├── modules/
│ └──example/
│ ├──example.c
│ └──micropython.mk
└── micropython/

micropython.mk

Code: Select all

EXAMPLE_MOD_DIR := $(USERMOD_DIR)/python/micropython/my_project/modules/example

# Add all C files to SRC_USERMOD.
SRC_USERMOD += $(EXAMPLE_MOD_DIR)/example.c

# We can add our module folder to include paths if needed
# This is not actually needed in this example.
CFLAGS_USERMOD += -I$(EXAMPLE_MOD_DIR)
While in esp32 folder I ran the command :

Code: Select all

make USER_C_MODULES=../../../modules/example
and it was building and it seemed working but there is no 'example' module in modules folders nor can I import example in mp prompt.
HELP

michids
Posts: 4
Joined: Wed Jun 03, 2020 1:42 pm

Re: issue with setting up a toolchain

Post by michids » Tue Aug 25, 2020 10:00 am

Try changing these things:

Code: Select all

# this already should be the right directory path
EXAMPLE_MOD_DIR := $(USERMOD_DIR)
Also you have to enable the module. You have three options :

1. you add this to the module makefile:

Code: Select all

override CFLAGS_EXTRA += -DMODULE_EXAMPLE_ENABLED=1
# then run the make command
make USER_C_MODULES=../../../modules/example all
2. you add this to the make command:

Code: Select all

make USER_C_MODULES=../../../modules/example CFLAGS_EXTRA+=-DMODULE_EXAMPLE_ENABLED=1 all
3. edit the mpconfigport.h or mpconfigboard.h:

Code: Select all

#define MODULE_EXAMPLE_ENABLED (1)
Hope this helps.

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: issue with setting up a toolchain

Post by stijn » Tue Aug 25, 2020 2:37 pm

I'm having problems as well, I just installed esp idf v4 from scratch, followed the steps in cmodules.rst, but the build fails with

Code: Select all

make USER_C_MODULES=../../../modules CFLAGS_EXTRA=-DMODULE_EXAMPLE_ENABLED=1 all
...
xtensa-esp32-elf-ld: build-GENERIC/../../../modules/example/example.o:(.rodata.example_user_cmodule+0x0): multiple definition of `example_user_cmodule'; build-GENERIC/example/example.o:(.rodata.example_user_cmodule+0x0): first defined here
Anyone has an idea? It can't be right that the build creates both micropython/modules/example/example.P and micropython/ports/esp32/build-GENERIC/example/example.P, especially because the former is within the source directory instead of the build directory.

User avatar
rcolistete
Posts: 352
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil
Contact:

Re: issue with setting up a toolchain

Post by rcolistete » Tue Aug 25, 2020 11:36 pm

See this issue and solution (add 'extern'), seems to be the same :
ulab GitHub issue #135 "Incompatibility between gcc-arm 10.1 and ulab+MicroPython"
My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: issue with setting up a toolchain

Post by stijn » Wed Aug 26, 2020 8:37 am

Hmm, started with 'make clean' today and the problem doesn't happen anymore. Plus I first had the problem yesterday with another custom module and that already declared the mp_obj_module_t as extern so looks like a different problem.

It's a pity the build system is so fragile, especially when it comes to dependency tracking. Maybe it's just because I don't know 'make' enough but I constantly find myself manually deleting certain .o files to get them built again (without having to resort to make -B which takes way too long just to get a build after chaging 1 file).

E.g. I just built the example module, now I just call 'make' so without the example module, so objmodule.o should be built again since there's one less module in the list but that doesn't happen so that's a link error.

Or, I pass a different value to USER_C_MODULES to build another module and it fails to scan the new module for qstrs so the module's .c file fails to compile.

skoya
Posts: 6
Joined: Fri Apr 17, 2020 12:51 pm

Re: issue with setting up a toolchain

Post by skoya » Wed Aug 26, 2020 11:05 am

Hey I've managed to fix that error by chaning the line to EXAMPLE_MOD_DIR := $(USERMOD_DIR)

Now when I am inside esp32 folder and I run make USER_C_MODULES=../../../modules all
I get the following error:

Code: Select all

Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Including User C Module from ../../../modules/example
Building with ESP IDF v3
GEN build-GENERIC/genhdr/compressed.collected
Compressed data not updated
example module doesn't appear in the modules catalogue and I still can't import it

when I am inside unix folder and run the same command I get:

Code: Select all

Including User C Module from ../../../modules/example
GEN build-standard/genhdr/qstrdefs.collected.h
QSTR not updated
CC ../../../modules/example/example.c
In file included from ../../../modules/example/example.c:2:0:
../../../modules/example/example.c:24:50: error: ‘MP_QSTR_example’ undeclared here (not in a function); did you mean ‘MP_QSTR_enable’?
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_example) },
                                                  ^
../../py/obj.h:96:56: note: in definition of macro ‘MP_OBJ_NEW_QSTR’
 #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 3) | 2))
                                                        ^~~
../../../modules/example/example.c:24:38: note: in expansion of macro ‘MP_ROM_QSTR’
     { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_example) },
                                      ^~~~~~~~~~~
../../../modules/example/example.c:25: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(&example_add_ints_obj) },
                   ^
../../py/obj.h:96:56: note: in definition of macro ‘MP_OBJ_NEW_QSTR’
 #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 3) | 2))
                                                        ^~~
../../../modules/example/example.c:25:7: note: in expansion of macro ‘MP_ROM_QSTR’
     { MP_ROM_QSTR(MP_QSTR_add_ints), MP_ROM_PTR(&example_add_ints_obj) },
       ^~~~~~~~~~~
../../py/mkrules.mk:63: recipe for target 'build-standard/example/example.o' failed
make: *** [build-standard/example/example.o] Error 1
What's wrong?

Post Reply