Skip to content

Commit

Permalink
mimxrt/mpconfigport: Allow configuring different network interfaces.
Browse files Browse the repository at this point in the history
This commit allows boards to disable Ethernet and keep the networking stack
enabled, to use an alternate networking interface, such as WiFi.

Note that the `network` and `socket` modules are now enabled by default for
a board.
  • Loading branch information
iabdalkader authored and dpgeorge committed Apr 11, 2023
1 parent 944b4c2 commit 8b72721
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions ports/mimxrt/eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "py/mperrno.h"
#include "ticks.h"

#if defined(MICROPY_HW_ETH_MDC)
#if defined(IOMUX_TABLE_ENET)

#include "pin.h"
#include "shared/netutils/netutils.h"
Expand Down Expand Up @@ -639,4 +639,4 @@ void eth_low_power_mode(eth_t *self, bool enable) {
ENET_EnableSleepMode(ENET, enable);
#endif
}
#endif // defined(MICROPY_HW_ETH_MDC)
#endif // defined(IOMUX_TABLE_ENET)
23 changes: 12 additions & 11 deletions ports/mimxrt/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,19 @@ uint32_t trng_random_u32(void);
#define MICROPY_FATFS_MAX_SS (4096)
#define MICROPY_FATFS_LFN_CODE_PAGE 437 /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */

// If MICROPY_PY_LWIP is defined, add network support
#if MICROPY_PY_LWIP

#ifndef MICROPY_PY_NETWORK
#define MICROPY_PY_NETWORK (1)
#endif
#ifndef MICROPY_PY_USOCKET
#define MICROPY_PY_USOCKET (1)
#define MICROPY_PY_UWEBSOCKET (1)
#define MICROPY_PY_WEBREPL (1)
#define MICROPY_PY_UHASHLIB_SHA1 (1)
#define MICROPY_PY_LWIP_SOCK_RAW (1)
#define MICROPY_HW_ETH_MDC (1)
#endif
#define MICROPY_PY_UWEBSOCKET (MICROPY_PY_LWIP)
#define MICROPY_PY_WEBREPL (MICROPY_PY_LWIP)
#define MICROPY_PY_LWIP_SOCK_RAW (MICROPY_PY_LWIP)
#define MICROPY_PY_USSL_FINALISER (MICROPY_PY_USSL)
// #define MICROPY_PY_UHASHLIB_MD5 (MICROPY_PY_USSL)
#define MICROPY_PY_UHASHLIB_SHA1 (MICROPY_PY_USSL)
// #define MICROPY_PY_UCRYPTOLIB (MICROPY_PY_USSL)

// Prevent the "LWIP task" from running.
#define MICROPY_PY_LWIP_ENTER MICROPY_PY_PENDSV_ENTER
Expand All @@ -122,8 +125,6 @@ uint32_t trng_random_u32(void);
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "mpy-mimxrt"
#endif

#endif

// For regular code that wants to prevent "background tasks" from running.
// These background tasks (LWIP, Bluetooth) run in PENDSV context.
// TODO: Check for the settings of the STM32 port in irq.h
Expand Down Expand Up @@ -165,7 +166,7 @@ static inline void restore_irq_pri(uint32_t basepri) {
#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq()
#define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state)

#if defined(MICROPY_HW_ETH_MDC)
#if defined(IOMUX_TABLE_ENET)
extern const struct _mp_obj_type_t network_lan_type;
#define MICROPY_HW_NIC_ETH { MP_ROM_QSTR(MP_QSTR_LAN), MP_ROM_PTR(&network_lan_type) },
#else
Expand Down
4 changes: 2 additions & 2 deletions ports/mimxrt/network_lan.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "py/mphal.h"
#include "extmod/modnetwork.h"

#if defined(MICROPY_HW_ETH_MDC)
#if defined(IOMUX_TABLE_ENET)

#include "fsl_phy.h"
#include "eth.h"
Expand Down Expand Up @@ -264,4 +264,4 @@ MP_DEFINE_CONST_OBJ_TYPE(
);


#endif // defined(MICROPY_HW_ETH_MDC)
#endif // defined(IOMUX_TABLE_ENET)

0 comments on commit 8b72721

Please sign in to comment.