W5500 Ethernet controller on OpenMV

Discussion related to "under the hood" OpenMV topics.
piliwilliam
Posts: 1
Joined: Thu Nov 15, 2018 10:11 pm

W5500 Ethernet controller on OpenMV

Postby piliwilliam » Thu Nov 15, 2018 10:18 pm

Hi all,

I was wondering if anyone successfully built the openmv with the "MICROPY_PY_WIZNET5K=5500" flag?
Below is the error when I try to build it.
Thanks,
Will

Code: Select all

CC src/usbd_uvc_if.c
CC src/usbd_conf.c
CC src/main.c
CC src/usbd_core.c
CC src/usbd_ctlreq.c
CC src/stm32fxxx_it.c
CC src/string0.c
CC src/usbd_uvc.c
CC src/usbd_ioreq.c
CC src/usbd_desc.c
CC src/systick.c
make[1]: Leaving directory '/home/piliwilliam/openmv/src/uvc'
/home/piliwilliam/openmv/src/build/micropython/modnetwork.o:(.rodata.mp_module_network_globals_table+0xc): undefined reference to `mod_network_nic_type_wiznet5k'
collect2: error: ld returned 1 exit status
Makefile:497: recipe for target 'firmware' failed
make: *** [firmware] Error 1
User avatar
kwagyeman
Posts: 4857
Joined: Sun May 24, 2015 2:10 pm

Re: W5500 Ethernet controller on OpenMV

Postby kwagyeman » Thu Nov 15, 2018 11:04 pm

It looks like you need to edit the MakeFile to include the wiznet c code. Usually, this means you need to find what .c file makes that thing up and add it to the MakeFile which compiles the C file and you also need to edit the main MakeFile that links the .o files.
Nyamekye,
User avatar
JackBonnell
Posts: 13
Joined: Mon Nov 09, 2020 9:17 am
Location: London
Contact:

Re: W5500 Ethernet controller on OpenMV

Postby JackBonnell » Fri Nov 13, 2020 11:48 am

Having the same issue the screenshot showed the relevant files needed for this variable are available i'm not expert in C code but any help would be very much appreciated as there is only a hand full of comments on this error online.
Screenshot from 2020-11-13 16-44-16.png
User avatar
kwagyeman
Posts: 4857
Joined: Sun May 24, 2015 2:10 pm

Re: W5500 Ethernet controller on OpenMV

Postby kwagyeman » Fri Nov 13, 2020 12:55 pm

You need to edit the make file system to include the compile the specified file and then include the .o.

I don’t actually know which files you need to modify. However, it’s not hard. You just have to go into the make files and add the missing file in the right places.
Nyamekye,
User avatar
JackBonnell
Posts: 13
Joined: Mon Nov 09, 2020 9:17 am
Location: London
Contact:

Re: W5500 Ethernet controller on OpenMV

Postby JackBonnell » Mon Nov 16, 2020 5:21 am

This is a update of my findings:

Using the "MICROPY_PY_WIZNET5K=5500" flag:

this files the compiling of the c code in the stm32/makefile

Code: Select all

ifneq ($(MICROPY_PY_WIZNET5K),0)
WIZNET5K_DIR=drivers/wiznet5k
INC += -I$(TOP)/$(WIZNET5K_DIR)
CFLAGS_MOD += -DMICROPY_PY_WIZNET5K=$(MICROPY_PY_WIZNET5K) -D_WIZCHIP_=$(MICROPY_PY_WIZNET5K)
ifeq ($(MICROPY_PY_LWIP),1)
# When using MACRAW mode (with lwIP), maximum buffer space must be used for the raw socket
CFLAGS_MOD += -DWIZCHIP_USE_MAX_BUFFER
endif
SRC_MOD += network_wiznet5k.c modnwwiznet5k.c
SRC_MOD += $(addprefix $(WIZNET5K_DIR)/,\
	ethernet/w$(MICROPY_PY_WIZNET5K)/w$(MICROPY_PY_WIZNET5K).c \
	ethernet/wizchip_conf.c \
	ethernet/socket.c \
	internet/dns/dns.c \
	)
endif

This error is still occurring even when i have added the o files that have been compiled in the

Code: Select all

$(BUILD)/$(MICROPY_DIR)/drivers/
After added the relevant compiled libraries into the build in the /src/MakeFile

Code: Select all

ifneq ($(MICROPY_PY_WIZNET5K),0)
FIRM_OBJ += $(addprefix $(BUILD)/$(MICROPY_DIR)/drivers/,\
	wiznet5k/ethernet/w$(MICROPY_PY_WIZNET5K)/w$(MICROPY_PY_WIZNET5K).o \
	wiznet5k/ethernet/wizchip_conf.o \
	wiznet5k/ethernet/socket.o \
	wiznet5k/internet/dns/dns.o \
	)
endif
This is still causing the original issue

Code: Select all

/home/jack/Development/OPENMV_FIRMWARE/openmv/src/build/micropython/modnetwork.o:(.rodata.mp_module_network_globals_table+0xc): undefined reference to `mod_network_nic_type_wiznet5k'
collect2: error: ld returned 1 exit status
Makefile:674: recipe for target 'firmware' failed
make: *** [firmware] Error 1
There is only one modnetwork.o so that doesnt need to be changed. all the relevant files are in place. I am unsure what 'mod_network_nic_type_wiznet5k' maybe its a parameter needed in the make file i have logged an issue with the micropython github hopefully they can give me the parameter i need to declare: https://github.com/micropython/micropython/issues/6625
User avatar
iabdalkader
Posts: 1287
Joined: Sun May 24, 2015 3:53 pm

Re: W5500 Ethernet controller on OpenMV

Postby iabdalkader » Mon Nov 16, 2020 3:53 pm

You need to link the object file that has the object, grep is your friend:

Code: Select all

> grep -r mod_network_nic_type_wiznet5k *
ports/stm32/modnwwiznet5k.c:    wiznet5k_obj.base.type = (mp_obj_type_t*)&mod_network_nic_type_wiznet5k;
ports/stm32/modnwwiznet5k.c:const mod_network_nic_type_t mod_network_nic_type_wiznet5k = {
In that file you'll see that it also needs LWIP enabled:

Code: Select all

#if MICROPY_PY_WIZNET5K && !MICROPY_PY_LWIP
User avatar
JackBonnell
Posts: 13
Joined: Mon Nov 09, 2020 9:17 am
Location: London
Contact:

Re: W5500 Ethernet controller on OpenMV

Postby JackBonnell » Mon Nov 16, 2020 7:18 pm

Hi,
Thank you for the response you're a life saver, wish i knew about grep before! it has fixed all my issues! now on to testing :shock:
That a hardware engineer trying to learn firmware for you :lol:
I will make a pull request in the morning!
All the Best,
Jack
User avatar
JackBonnell
Posts: 13
Joined: Mon Nov 09, 2020 9:17 am
Location: London
Contact:

Re: W5500 Ethernet controller on OpenMV

Postby JackBonnell » Tue Nov 17, 2020 12:01 pm

Now Receiving this error:

Code: Select all

Warning: FROZEN_MPY_DIR is deprecated in favour of FROZEN_MANIFEST
CC modnetwork.c
In file included from /home/jack/Development/OPENMV_FIRMWARE/openmv/src/micropython/py/objlist.h:29:0,
                 from modnetwork.c:31:
modnetwork.c:148:46: error: 'mod_network_nic_type_winc' undeclared here (not in a function); did you mean 'mod_network_nic_type_wiznet5k'?
     { MP_ROM_QSTR(MP_QSTR_WINC), MP_ROM_PTR(&mod_network_nic_type_winc) },
                                              ^
/home/jack/Development/OPENMV_FIRMWARE/openmv/src/micropython/py/obj.h:249:24: note: in definition of macro 'MP_ROM_PTR'
 #define MP_ROM_PTR(p) (p)
                        ^
../../py/mkrules.mk:47: recipe for target '/home/jack/Development/OPENMV_FIRMWARE/openmv/src/build/micropython/modnetwork.o' failed
make[1]: *** [/home/jack/Development/OPENMV_FIRMWARE/openmv/src/build/micropython/modnetwork.o] Error 1
Makefile:643: recipe for target 'FIRMWARE_OBJS' failed
make: *** [FIRMWARE_OBJS] Error 2
when is use the grep command i get this:

Code: Select all

grep -r mod_network_nic_type_winc *
build/micropython/genhdr/qstr.i.last:    { ((mp_obj_t)((((mp_uint_t)(MP_QSTR_WINC)) << 2) | 2)), (&mod_network_nic_type_winc) },
micropython/ports/stm32/modnetwork.h:extern const mod_network_nic_type_t mod_network_nic_type_winc;
micropython/ports/stm32/modnetwork.c:    { MP_ROM_QSTR(MP_QSTR_WINC), MP_ROM_PTR(&mod_network_nic_type_winc) },
omv/py/py_winc.c:static const winc_obj_t winc_obj = {{(mp_obj_type_t*)&mod_network_nic_type_winc}};
omv/py/py_winc.c:const mod_network_nic_type_t mod_network_nic_type_winc = {
All of these files except for :
build/micropython/genhdr/qstr.i.last

are accounted for in the make files, is there anything obvious im missing?
User avatar
kwagyeman
Posts: 4857
Joined: Sun May 24, 2015 2:10 pm

Re: W5500 Ethernet controller on OpenMV

Postby kwagyeman » Tue Nov 17, 2020 12:27 pm

You've disabled the winc1500, you need to re-enable it too or remove that line.
Nyamekye,
User avatar
JackBonnell
Posts: 13
Joined: Mon Nov 09, 2020 9:17 am
Location: London
Contact:

Re: W5500 Ethernet controller on OpenMV

Postby JackBonnell » Tue Nov 17, 2020 3:43 pm

Forcing the compile flag has the same result with or without

Code: Select all

MICROPY_PY_WIZNET5K=5500
same error as above has been causing with:

Code: Select all

 make TARGET=OPENMV4 MICROPY_PY_LWIP=1 MICROPY_PY_WINC1500=1
when force disable MICROPY_PY_WINC1500 with:

Code: Select all

make TARGET=OPENMV4 MICROPY_PY_WIZNET5K=5500 MICROPY_PY_LWIP=1 MICROPY_PY_WINC1500=0
This is my error message:

Code: Select all

CC src/systick.c
/usr/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld: /home/jack/Development/OPENMV_FIRMWARE/openmv/src/build/bin/firmware.elf section `.text' will not fit in region `FLASH_TEXT'
/usr/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld: /home/jack/Development/OPENMV_FIRMWARE/openmv/src/build/bin/firmware.elf section `._heap' will not fit in region `SRAM1'
/usr/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld: region `SRAM1' overflowed by 24012 bytes
/usr/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld: region `FLASH_TEXT' overflowed by 16 bytes
/home/jack/Development/OPENMV_FIRMWARE/openmv/src/build/micropython/modnetwork.o: In function `pyb_lwip_poll':
/home/jack/Development/OPENMV_FIRMWARE/openmv/src/micropython/ports/stm32/modnetwork.c:61: undefined reference to `wiznet5k_poll'
/home/jack/Development/OPENMV_FIRMWARE/openmv/src/build/micropython/modnetwork.o:(.rodata.mp_module_network_globals_table+0xc): undefined reference to `mod_network_nic_type_wiznet5k'
collect2: error: ld returned 1 exit status
Makefile:667: recipe for target 'firmware' failed
make: *** [firmware] Error 1
It looks likes LWIP is causing this somehow, any ideas?
User avatar
iabdalkader
Posts: 1287
Joined: Sun May 24, 2015 3:53 pm

Re: W5500 Ethernet controller on OpenMV

Postby iabdalkader » Wed Nov 18, 2020 8:50 am

I see multiple issues, first if you want to disable modules like WINC you need to edit this file:

Code: Select all

omv/boards/OPENMV4/omv_boardconfig.mk
Set WINC to 0.

I think this config will work for you:

Code: Select all

MICROPY_PY_ULAB = 0
MICROPY_PY_WINC1500 = 0
MICROPY_PY_IMU = 0
MICROPY_PY_LWIP = 1
MICROPY_PY_WIZNET5K = 1
/usr/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld: region `SRAM1' overflowed by 24012 bytes
/usr/bin/../lib/gcc/arm-none-eabi/7.3.1/../../../../arm-none-eabi/bin/ld: region `FLASH_TEXT' overflowed by 16 bytes
If you get this you need to disable things until the firmware fits, try to disable things in imlib_config.h and you need to lower the heap in omv_boardconfig.h

Code: Select all

/home/jack/Development/OPENMV_FIRMWARE/openmv/src/build/micropython/modnetwork.o: In function `pyb_lwip_poll':
/home/jack/Development/OPENMV_FIRMWARE/openmv/src/micropython/ports/stm32/modnetwork.c:61: undefined reference to `wiznet5k_poll'
I think the above config will fix these.

Finally keep in mind that even if it builds it still may not work with our firmware, it may be missing a callback or something, so you're on your own here.

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests