Build Issue

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
dvrhax
Posts: 14
Joined: Fri Jul 07, 2017 11:13 pm

Build Issue

Post by dvrhax » Tue Feb 26, 2019 4:00 am

Hoping someone can help out with an issue I've run into building micropython

I followed the instructions here for setting up the environment:
https://github.com/pfalcon/esp-open-sdk
I then cloned micropython
Ran:

Code: Select all

git submodule update --init
Ran:

Code: Select all

make -C mpy-cross
Ran:

Code: Select all

cd ports/esp8266
Ran:

Code: Select all

make axtls
- This errored out so I moved on...
Ran:

Code: Select all

make
- This worked and appeared to make a binary though I never attempted to load it onto my feather
However the whole purpose of building this was to load my own modules to hopefully fix the memory errors I was getting. So after loading my modules into the modules sub-directory and running make I got the following error which I'm not really sure how to resolve.

Code: Select all

GEN build/frozen_mpy.c
CC build/frozen_mpy.c
build/frozen_mpy.c:280:5: error: redeclaration of enumerator 'MP_QSTR_NULL'
     MP_QSTR_NULL,
     ^
In file included from ../../py/obj.h:31:0,
                 from ../../py/objint.h:30,
                 from build/frozen_mpy.c:2:
build/genhdr/qstrdefs.generated.h:3:6: note: previous definition of 'MP_QSTR_NULL' was here
 QDEF(MP_QSTR_NULL, (const byte*)"\x00\x00\x00" "")
      ^
../../py/qstr.h:41:23: note: in definition of macro 'QDEF'
 #define QDEF(id, str) id,
                       ^
make: *** [../../py/mkrules.mk:47: build/build/frozen_mpy.o] Error 1
I tried deleting the line containing MP_QSTR_NULL from build/genhdr/qstrdefs.generated.h but that didn't work, and that was about the extent of my ideas. Any help would be greatly appreciated. I'm building this on Ubuntu 18.10.

Thanks

pagano.paganino
Posts: 75
Joined: Fri Sep 11, 2015 10:47 pm
Location: Italy

Re: Build Issue

Post by pagano.paganino » Tue Feb 26, 2019 8:20 am

Have you declared a string containing 'NULL'?

Try remove it and rebuild.

bitninja
Posts: 116
Joined: Thu Sep 15, 2016 4:09 pm
Location: Spring, Texas

Re: Build Issue

Post by bitninja » Tue Feb 26, 2019 7:35 pm

Sounds like you are doing everything correctly... I'm not sure why adding your modules causes the build to throw an error.

When you...

Code: Select all

make clean
it deletes the build sub-directory, so messing around in there probably won't help.

And yes, the

Code: Select all

make axtls
doesn't seem to be needed anymore.

User avatar
Roberthh
Posts: 1739
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Build Issue

Post by Roberthh » Tue Feb 26, 2019 8:18 pm

At least I can confirm that building too fails, even if it worked before, in the step building axtls. The error log starts at:

Code: Select all

CC ../../extmod/modlwip.c
../../extmod/modlwip.c: In function 'lwip_udp_send':
../../extmod/modlwip.c:450:5: error: 'MICROPY_PY_LWIP_ENTER' undeclared (first use in this function)
     MICROPY_PY_LWIP_ENTER
     ^
../../extmod/modlwip.c:450:5: note: each undeclared identifier is reported only once for each function it appears in
../../extmod/modlwip.c:453:5: error: expected ';' before 'struct'
     struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, len, PBUF_RAM);
     ^
../../extmod/modlwip.c:454:9: error: 'p' undeclared (first use in this function)
     if (p == NULL) {
         ^
../../extmod/modlwip.c:455:9: error: unknown type name 'MICROPY_PY_LWIP_EXIT'
         MICROPY_PY_LWIP_EXIT
As soon as I deleted today's commits to the repository, it worked again. So if you do:
git reset 5801a003f055a9db6d569fbb0ffc3018dcaa8c3e --hard
it should work.

pagano.paganino
Posts: 75
Joined: Fri Sep 11, 2015 10:47 pm
Location: Italy

Re: Build Issue

Post by pagano.paganino » Tue Feb 26, 2019 9:44 pm

to reproduce:

copy the test.py file to the 'modules' subfolder, uncomment any of these tests and try to compile.

Code: Select all

# # FAIL
# _B = ('NULL',)

# # FAIL
#_B1 = ['NULL']

# # FAIL
# _B2 = {'NULL':None}

# # FAIL
# _B3 = dict(NULL=None)

# # FAIL
# def NULL():
#     pass

# # FAIL
# class NULL(object):
#     pass

# # FAIL
# class B(object):
#     _B = ('NULL',)

# # FAIL
# class B(object):
#     _B = ['NULL']

# # FAIL
# class B1(object):
#     _B1 = {'NULL':None}

# # FAIL
# class B2(object):
#     _B2 = dict(NULL=None)

# # FAIL
# class B3(object):
#     def NULL(self):
#         pass

Code: Select all

MBP-di-Damiano:~/projects/micropython$ make -j12 BOARD=PYBV11 -C ports/stm32/
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
MPY modules/test.py
GEN build-PYBV11/frozen_mpy.c
CC build-PYBV11/frozen_mpy.c
build-PYBV11/frozen_mpy.c:164:5: error: redeclaration of enumerator 'MP_QSTR_NULL'
     MP_QSTR_NULL,
     ^~~~~~~~~~~~
In file included from ../../py/obj.h:31,
                 from ../../py/objint.h:30,
                 from build-PYBV11/frozen_mpy.c:2:
build-PYBV11/genhdr/qstrdefs.generated.h:3:6: note: previous definition of 'MP_QSTR_NULL' was here
 QDEF(MP_QSTR_NULL, (const byte*)"\x00\x00\x00" "")
      ^~~~~~~~~~~~
../../py/qstr.h:41:23: note: in definition of macro 'QDEF'
 #define QDEF(id, str) id,
                       ^~
make: *** [build-PYBV11/build-PYBV11/frozen_mpy.o] Error 1

dvrhax
Posts: 14
Joined: Fri Jul 07, 2017 11:13 pm

Re: Build Issue

Post by dvrhax » Tue Feb 26, 2019 10:52 pm

Thanks for all the response and help on this.

Code: Select all

__init__.py:NULL = "NULL"
__init__.py:    'InterfaceError', 'InternalError', 'MySQLError', 'NULL', 'NUMBER',
__init__.py:    "NULL", "__version__",
constants/CR.py:CR_NULL_POINTER		= 2029
constants/ER.py:BAD_NULL_ERROR = 1048
constants/ER.py:NULL_COLUMN_IN_INDEX = 1121
constants/ER.py:INVALID_USE_OF_NULL = 1138
constants/ER.py:PRIMARY_CANT_HAVE_NULL = 1171
constants/ER.py:SPATIAL_CANT_HAVE_NULL = 1252
constants/ER.py:WARN_NULL_TO_NOTNULL = 1263
constants/FIELD_TYPE.py:NULL = 6
constants/FLAG.py:NOT_NULL = 1
connections.py:NULL_COLUMN = 251
connections.py:        if c == NULL_COLUMN:
converters.py:    return 'NULL'
These are the instances of NULL in the code. So if I read the replies right I would need to recode the first 3 and the last occurrence of NULL and the the reference in Field_TYPE?

dvrhax
Posts: 14
Joined: Fri Jul 07, 2017 11:13 pm

Re: Build Issue

Post by dvrhax » Tue Feb 26, 2019 11:20 pm

So commenting out those lines did allow it to compile past that step. Unfortunately I've now found that my library is 34k to large. I guess it's time to start cutting.

Thanks for everyone's help, but can someone explain to me why this happens? It would appear to me that this would not be the expected behavior.

Thanks again



https://github.com/dvrhax/uPyMySQL

dvrhax
Posts: 14
Joined: Fri Jul 07, 2017 11:13 pm

Re: Build Issue

Post by dvrhax » Wed Feb 27, 2019 1:22 pm

Apologize if I missed this in the docs somewhere, but where do you set the optimization level for mpy-cross during the build? I'd like to run -O3 but can't seem to find where I would set that.

Thanks

User avatar
Roberthh
Posts: 1739
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Build Issue

Post by Roberthh » Wed Feb 27, 2019 1:39 pm

If you do not need it, you can exclude the Btree database from the build by setting
MICROPY_PY_BTREE = 0
in the Makefile. That alone saves ~20k in the image.
If that is not sufficient, you have to increase the rom page size in the loader file esp8266.ld.

dvrhax
Posts: 14
Joined: Fri Jul 07, 2017 11:13 pm

Re: Build Issue

Post by dvrhax » Thu Feb 28, 2019 2:57 am

That did it. I removed a lot of the custom error handling and between that and removing BTree I'm now compiled and running on the board. So now just sifting through some errors on the board from the limited scope of some of the models that didn't show itself when I was running the Unix port. Thanks again to everyone for their help.

Post Reply