Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network interface #6

Open
untitledlt opened this issue May 13, 2019 · 13 comments
Open

Network interface #6

untitledlt opened this issue May 13, 2019 · 13 comments

Comments

@untitledlt
Copy link

Is it possible to user network interface on this devboard?
From micropython docs:

To use this module, a MicroPython variant/build with network capabilities must be installed. 

I don't see Driver in network module. Does it mean that this micropython port does not include network capabilities?
Thanks!

@mcauser
Copy link
Owner

mcauser commented May 13, 2019

It's a F407 based board, so it has Ethernet MAC unlike the F405 on the original pyboard.
Haven't implemented it yet though.
If any of the other F407 boards have implemented it, I could try upgrading this board to match.

Maybe try the $4 W5500 module?
https://www.aliexpress.com/item/32894225202.html
https://docs.micropython.org/en/latest/library/network.WIZNET5K.html

@untitledlt
Copy link
Author

Don't think it's worth to use external module if it has built-in support.
How can i help to make it happen faster?

@untitledlt
Copy link
Author

But it's not F407

@mcauser
Copy link
Owner

mcauser commented May 13, 2019

http://www.efton.sk/STM32/STM32F4xx%20misc.pdf

These are the F407 Eth pins:

PA0 ETH_MII_CRS
PA1 ETH_MII_RX_CLK, ETH_RMII_REF_CLK
PA2 ETH_MDIO
PA3 ETH_MII_COL
PA7 ETH_MII_RX_DV, ETH_RMII_CRS_DV
PB0 ETH_MII_RXD2
PB1 ETH_MII_RXD3
PB5 ETH_PPS_OUT
PB8 ETH_MII_TXD3
PB10 ETH_MII_RX_ER
PB11 ETH_MII_TX_EN, ETH_RMII_TX_EN
PB12 ETH_MII_TXD0, ETH_RMII_TXD0
PB13 ETH_MII_TXD1, ETH_RMII_TXD1
PC1 ETH_MDC
PC2 ETH_MII_TXD2
PC3 ETH_MII_TX_CLK
PC4 ETH_MII_RXD0, ETH_RMII_RXD0
PC5 ETH_MII_RXD1, ETH_RMII_RXD1
PE2 ETH_MII_TXD3
PG8 ETH_PPS_OUT
PG11 ETH_MII_TX_EN, ETH_RMII_TX_EN
PG13 ETH_MII_TXD0, ETH_RMII_TXD0
PG14 ETH_MII_TXD1, ETH_RMII_TXD1
PH2 ETH_MII_CRS
PH3 ETH_MII_COL
PH6 ETH_MII_RXD2
PH7 ETH_MII_RXD3
PI10 ETH_MII_RX_ER

@mcauser
Copy link
Owner

mcauser commented May 13, 2019

Try adding this to the bottom of mpconfigboard.h and building.

// Ethernet via RMII
#define MICROPY_HW_ETH_MDC          (pin_C1)
#define MICROPY_HW_ETH_MDIO         (pin_A2)
#define MICROPY_HW_ETH_RMII_REF_CLK (pin_A1)
#define MICROPY_HW_ETH_RMII_CRS_DV  (pin_A7)
#define MICROPY_HW_ETH_RMII_RXD0    (pin_C4)
#define MICROPY_HW_ETH_RMII_RXD1    (pin_C5)
#define MICROPY_HW_ETH_RMII_TX_EN   (pin_G11)
#define MICROPY_HW_ETH_RMII_TXD0    (pin_G13)
#define MICROPY_HW_ETH_RMII_TXD1    (pin_G14)

@untitledlt
Copy link
Author

Here's what i'm getting now:

$ make BOARD=BLACK_F407VE
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
GEN build-BLACK_F407VE/genhdr/moduledefs.h
GEN build-BLACK_F407VE/genhdr/qstr.i.last
eth.c:37:10: fatal error: lwip/etharp.h: No such file or directory
 #include "lwip/etharp.h"
          ^~~~~~~~~~~~~~~
compilation terminated.
network_lan.c:34:10: fatal error: lwip/netif.h: No such file or directory
 #include "lwip/netif.h"
          ^~~~~~~~~~~~~~
compilation terminated.
make: *** [build-BLACK_F407VE/genhdr/qstr.i.last] Error 1
make: *** Deleting file `build-BLACK_F407VE/genhdr/qstr.i.last'

Any ideas?

@mcauser
Copy link
Owner

mcauser commented May 13, 2019

# MicroPython settings
MICROPY_PY_LWIP = 1

In mpconfigboard.mk?

As per:
https://github.com/micropython/micropython/blob/master/ports/stm32/boards/NUCLEO_F429ZI/mpconfigboard.mk

@untitledlt
Copy link
Author

I had to clone micropython with --recursive flag but now i'm stuck with new errors:

$ make BOARD=BLACK_F407VE
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
CC eth.c
In file included from eth.c:31:
eth.c: In function 'eth_mac_init':
eth.c:190:106: error: implicit declaration of function 'STATIC_AF_ETH_RMII_REF_CLK'; did you mean 'STATIC_AF_ETH_RMII__REF_CLK'? [-Werror=implicit-function-declaration]
     mp_hal_pin_config_alt_static(MICROPY_HW_ETH_RMII_REF_CLK, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, STATIC_AF_ETH_RMII_REF_CLK);
                                                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
pin_static_af.h:42:48: note: in definition of macro 'mp_hal_pin_config_alt_static'
         mp_hal_pin_config(pin_obj, mode, pull, fn_type(pin_obj)) /* Overflow Error => alt func not found */
                                                ^~~~~~~
boards/BLACK_F407VE/mpconfigboard.h:151:38: error: 'pin_G11' undeclared (first use in this function); did you mean 'pin_B11'?
 #define MICROPY_HW_ETH_RMII_TX_EN   (pin_G11)
                                      ^~~~~~~
pin_static_af.h:42:27: note: in definition of macro 'mp_hal_pin_config_alt_static'
         mp_hal_pin_config(pin_obj, mode, pull, fn_type(pin_obj)) /* Overflow Error => alt func not found */
                           ^~~~~~~
eth.c:194:34: note: in expansion of macro 'MICROPY_HW_ETH_RMII_TX_EN'
     mp_hal_pin_config_alt_static(MICROPY_HW_ETH_RMII_TX_EN, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, STATIC_AF_ETH_RMII_TX_EN);
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
boards/BLACK_F407VE/mpconfigboard.h:151:38: note: each undeclared identifier is reported only once for each function it appears in
 #define MICROPY_HW_ETH_RMII_TX_EN   (pin_G11)
                                      ^~~~~~~
pin_static_af.h:42:27: note: in definition of macro 'mp_hal_pin_config_alt_static'
         mp_hal_pin_config(pin_obj, mode, pull, fn_type(pin_obj)) /* Overflow Error => alt func not found */
                           ^~~~~~~
eth.c:194:34: note: in expansion of macro 'MICROPY_HW_ETH_RMII_TX_EN'
     mp_hal_pin_config_alt_static(MICROPY_HW_ETH_RMII_TX_EN, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, STATIC_AF_ETH_RMII_TX_EN);
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from pin_static_af.h:31,
                 from eth.c:31:
build-BLACK_F407VE/genhdr/pins_af_defs.h:29:100: error: conversion from 'long long unsigned int' to 'uint32_t' {aka 'long unsigned int'} changes value from '18446744073709551615' to '4294967295' [-Werror=overflow]
 #define STATIC_AF_ETH_RMII_TX_EN(pin_obj) ( \
                                           ~~~
     ((strcmp( #pin_obj , "(&pin_B11_obj)")  & strcmp( #pin_obj , "((&pin_B11_obj))")) == 0) ? (11) : \
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
     (0xffffffffffffffffULL))
     ~~~~~~~~~~~~~~~~~~~~~~~~
pin_static_af.h:42:48: note: in expansion of macro 'STATIC_AF_ETH_RMII_TX_EN'
         mp_hal_pin_config(pin_obj, mode, pull, fn_type(pin_obj)) /* Overflow Error => alt func not found */
                                                ^~~~~~~
eth.c:194:5: note: in expansion of macro 'mp_hal_pin_config_alt_static'
     mp_hal_pin_config_alt_static(MICROPY_HW_ETH_RMII_TX_EN, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, STATIC_AF_ETH_RMII_TX_EN);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from eth.c:31:
boards/BLACK_F407VE/mpconfigboard.h:152:38: error: 'pin_G13' undeclared (first use in this function); did you mean 'pin_B13'?
 #define MICROPY_HW_ETH_RMII_TXD0    (pin_G13)
                                      ^~~~~~~
pin_static_af.h:42:27: note: in definition of macro 'mp_hal_pin_config_alt_static'
         mp_hal_pin_config(pin_obj, mode, pull, fn_type(pin_obj)) /* Overflow Error => alt func not found */
                           ^~~~~~~
eth.c:195:34: note: in expansion of macro 'MICROPY_HW_ETH_RMII_TXD0'
     mp_hal_pin_config_alt_static(MICROPY_HW_ETH_RMII_TXD0, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, STATIC_AF_ETH_RMII_TXD0);
                                  ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from pin_static_af.h:31,
                 from eth.c:31:
build-BLACK_F407VE/genhdr/pins_af_defs.h:932:100: error: conversion from 'long long unsigned int' to 'uint32_t' {aka 'long unsigned int'} changes value from '18446744073709551615' to '4294967295' [-Werror=overflow]
 #define STATIC_AF_ETH_RMII_TXD0(pin_obj) ( \
                                          ~~~
     ((strcmp( #pin_obj , "(&pin_B12_obj)")  & strcmp( #pin_obj , "((&pin_B12_obj))")) == 0) ? (11) : \
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
     (0xffffffffffffffffULL))
     ~~~~~~~~~~~~~~~~~~~~~~~~
pin_static_af.h:42:48: note: in expansion of macro 'STATIC_AF_ETH_RMII_TXD0'
         mp_hal_pin_config(pin_obj, mode, pull, fn_type(pin_obj)) /* Overflow Error => alt func not found */
                                                ^~~~~~~
eth.c:195:5: note: in expansion of macro 'mp_hal_pin_config_alt_static'
     mp_hal_pin_config_alt_static(MICROPY_HW_ETH_RMII_TXD0, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, STATIC_AF_ETH_RMII_TXD0);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from eth.c:31:
boards/BLACK_F407VE/mpconfigboard.h:153:38: error: 'pin_G14' undeclared (first use in this function); did you mean 'pin_B14'?
 #define MICROPY_HW_ETH_RMII_TXD1    (pin_G14)
                                      ^~~~~~~
pin_static_af.h:42:27: note: in definition of macro 'mp_hal_pin_config_alt_static'
         mp_hal_pin_config(pin_obj, mode, pull, fn_type(pin_obj)) /* Overflow Error => alt func not found */
                           ^~~~~~~
eth.c:196:34: note: in expansion of macro 'MICROPY_HW_ETH_RMII_TXD1'
     mp_hal_pin_config_alt_static(MICROPY_HW_ETH_RMII_TXD1, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, STATIC_AF_ETH_RMII_TXD1);
                                  ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from pin_static_af.h:31,
                 from eth.c:31:
build-BLACK_F407VE/genhdr/pins_af_defs.h:260:100: error: conversion from 'long long unsigned int' to 'uint32_t' {aka 'long unsigned int'} changes value from '18446744073709551615' to '4294967295' [-Werror=overflow]
 #define STATIC_AF_ETH_RMII_TXD1(pin_obj) ( \
                                          ~~~
     ((strcmp( #pin_obj , "(&pin_B13_obj)")  & strcmp( #pin_obj , "((&pin_B13_obj))")) == 0) ? (11) : \
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
     (0xffffffffffffffffULL))
     ~~~~~~~~~~~~~~~~~~~~~~~~
pin_static_af.h:42:48: note: in expansion of macro 'STATIC_AF_ETH_RMII_TXD1'
         mp_hal_pin_config(pin_obj, mode, pull, fn_type(pin_obj)) /* Overflow Error => alt func not found */
                                                ^~~~~~~
eth.c:196:5: note: in expansion of macro 'mp_hal_pin_config_alt_static'
     mp_hal_pin_config_alt_static(MICROPY_HW_ETH_RMII_TXD1, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, STATIC_AF_ETH_RMII_TXD1);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [build-BLACK_F407VE/eth.o] Error 1

@mcauser
Copy link
Owner

mcauser commented May 14, 2019

My bad. This is the VET6 board, not the ZET6 or ZGT6. There's no G pins on this board. Use the B pins instead.

Try replacing this:

#define MICROPY_HW_ETH_RMII_TX_EN   (pin_G11)
#define MICROPY_HW_ETH_RMII_TXD0    (pin_G13)
#define MICROPY_HW_ETH_RMII_TXD1    (pin_G14)

With this:

#define MICROPY_HW_ETH_RMII_TX_EN   (pin_B11)
#define MICROPY_HW_ETH_RMII_TXD0    (pin_B12)
#define MICROPY_HW_ETH_RMII_TXD1    (pin_B13)

@untitledlt
Copy link
Author

Thanks, that helped a bit but still errors remains:

In file included from eth.c:31:
eth.c: In function 'eth_mac_init':
eth.c:190:106: error: implicit declaration of function 'STATIC_AF_ETH_RMII_REF_CLK'; did you mean 'STATIC_AF_ETH_RMII__REF_CLK'? [-Werror=implicit-function-declaration]
     mp_hal_pin_config_alt_static(MICROPY_HW_ETH_RMII_REF_CLK, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, STATIC_AF_ETH_RMII_REF_CLK);
                                                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
pin_static_af.h:42:48: note: in definition of macro 'mp_hal_pin_config_alt_static'
         mp_hal_pin_config(pin_obj, mode, pull, fn_type(pin_obj)) /* Overflow Error => alt func not found */
                                                ^~~~~~~
cc1: all warnings being treated as errors
make: *** [build-BLACK_F407VE/eth.o] Error 1

@mcauser
Copy link
Owner

mcauser commented Nov 8, 2019

Fixed typo in stm32f405_af.csv
micropython/micropython#5308

@LouDnl
Copy link

LouDnl commented Jan 25, 2021

Tried about everything I could find online to get a LAN8720 from Aliexpress to work.
After compiling the board just doesn't seem to work. Green led on ETH port lights up and thats it.

>>> import network
>>> l = network.LAN()
>>> l.active(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 110] ETIMEDOUT

I know it's not the module as it works fine on an ESP32 with Micropython

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants