How to add modules like ujson, upip and etc?

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
houneie
Posts: 8
Joined: Thu Sep 17, 2020 5:22 am

Re: How to add modules like ujson, upip and etc?

Post by houneie » Mon Oct 05, 2020 5:30 am

Update: I found the appropriate version of modujson.c which is compatible with my port of micropython. Now those errors are gone and a new came I think it is related to the implementation of constructor/destructor.

Code: Select all

LINK micropython.elf
/home/abdrehman/src/sifive.com/riscv64-unknown-elf-gcc-8.3.0-2020.04.0-x86_64-linux-ubuntu14/bin/../lib/gcc/riscv64-unknown-elf/8.3.0/../../../../riscv64-unknown-elf/bin/ld: build/py/../extmod/modujson.o: in function `mod_ujson_loads':
modujson.c:(.text.mod_ujson_loads+0x28): undefined reference to `mp_type_stringio'
/home/abdrehman/src/sifive.com/riscv64-unknown-elf-gcc-8.3.0-2020.04.0-x86_64-linux-ubuntu14/bin/../lib/gcc/riscv64-unknown-elf/8.3.0/../../../../riscv64-unknown-elf/bin/ld: modujson.c:(.text.mod_ujson_loads+0x2c): undefined reference to `mp_type_stringio'
collect2: error: ld returned 1 exit status
make: *** [Makefile:107: micropython.elf] Error 1

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

Re: How to add modules like ujson, upip and etc?

Post by stijn » Mon Oct 05, 2020 7:07 am

Undefined reference means the linker doesn't find the code which defines what mp_type_stringio is. So the solution is fairly simple: look for the file which defines mp_type_stringio, make sure the code isn't disabled by preprocessor macros and build the file as well. In this case the file is objstringio.c and MICROPY_PY_IO should be 1. However since you say you're an intern my tip would be to figure out basics like this yourself because it's the best way to learn it, plus you'll be needing this knowledge often :)

houneie
Posts: 8
Joined: Thu Sep 17, 2020 5:22 am

Re: How to add modules like ujson, upip and etc?

Post by houneie » Tue Oct 06, 2020 4:37 am

stijn wrote:
Mon Oct 05, 2020 7:07 am
Undefined reference means the linker doesn't find the code which defines what mp_type_stringio is. So the solution is fairly simple: look for the file which defines mp_type_stringio, make sure the code isn't disabled by preprocessor macros and build the file as well. In this case the file is objstringio.c and MICROPY_PY_IO should be 1. However since you say you're an intern my tip would be to figure out basics like this yourself because it's the best way to learn it, plus you'll be needing this knowledge often :)
Thank you very much for the support I am learning every day :) .

Post Reply