Skip to content

Commit f9bda0f

Browse files
committed
Makefile & mpconfigport for atmel-samd with wiznet
1 parent d33f621 commit f9bda0f

File tree

3 files changed

+76
-4
lines changed

3 files changed

+76
-4
lines changed

ports/atmel-samd/Makefile

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ endif
123123

124124
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT)
125125

126-
127126
ifeq ($(CHIP_FAMILY), samd21)
128127
CFLAGS += \
129128
-mthumb \
@@ -287,6 +286,25 @@ SRC_C = \
287286
freetouch/adafruit_ptc.c \
288287
supervisor/shared/memory.c
289288

289+
ifeq ($(MICROPY_PY_NETWORK),1)
290+
CFLAGS += -DMICROPY_PY_NETWORK=1
291+
292+
SRC_MOD += lib/netutils/netutils.c
293+
294+
ifneq ($(MICROPY_PY_WIZNET5K),0)
295+
WIZNET5K_DIR=drivers/wiznet5k
296+
INC += -I$(TOP)/$(WIZNET5K_DIR)
297+
CFLAGS_MOD += -DMICROPY_PY_WIZNET5K=$(MICROPY_PY_WIZNET5K) -D_WIZCHIP_=$(MICROPY_PY_WIZNET5K)
298+
SRC_MOD += $(addprefix $(WIZNET5K_DIR)/,\
299+
ethernet/w$(MICROPY_PY_WIZNET5K)/w$(MICROPY_PY_WIZNET5K).c \
300+
ethernet/wizchip_conf.c \
301+
ethernet/socket.c \
302+
internet/dns/dns.c \
303+
)
304+
305+
endif # MICROPY_PY_WIZNET5K
306+
endif # MICROPY_PY_NETWORK
307+
290308
# Choose which flash filesystem impl to use.
291309
# (Right now INTERNAL_FLASH_FILESYSTEM and SPI_FLASH_FILESYSTEM are mutually exclusive.
292310
# But that might not be true in the future.)
@@ -362,7 +380,6 @@ SRC_LIBM = $(addprefix lib/,\
362380
)
363381
endif
364382

365-
366383
# These don't have corresponding files in each port but are still located in
367384
# shared-bindings to make it clear what the contents of the modules are.
368385
SRC_BINDINGS_ENUMS = \
@@ -401,6 +418,13 @@ SRC_SHARED_MODULE = \
401418
uheap/__init__.c \
402419
ustack/__init__.c
403420

421+
ifeq ($(MICROPY_PY_NETWORK),1)
422+
SRC_SHARED_MODULE += socket/__init__.c network/__init__.c
423+
ifneq ($(MICROPY_PY_WIZNET5K),0)
424+
SRC_SHARED_MODULE += wiznet/__init__.c
425+
endif
426+
endif
427+
404428
# SAMRs don't have a DAC
405429
ifneq ($(CHIP_VARIANT),SAMR21G18A)
406430
SRC_COMMON_HAL += \
@@ -441,6 +465,7 @@ ifeq ($(INTERNAL_LIBM),1)
441465
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
442466
endif
443467
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
468+
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
444469

445470
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) $(STM_SRC_C)
446471
# Sources that only hold QSTRs after pre-processing.

ports/atmel-samd/mpconfigport.h

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@
6767
#define MICROPY_FLOAT_HIGH_QUALITY_HASH (1)
6868
#define MICROPY_STREAMS_NON_BLOCK (1)
6969

70+
#ifndef MICROPY_PY_NETWORK
71+
#define MICROPY_PY_NETWORK (0)
72+
#endif
73+
74+
#ifndef MICROPY_PY_WIZNET5K
75+
#define MICROPY_PY_WIZNET5K (0)
76+
#endif
77+
78+
#ifndef MICROPY_PY_CC3K
79+
#define MICROPY_PY_CC3K (0)
80+
#endif
81+
7082
// fatfs configuration used in ffconf.h
7183
#define MICROPY_FATFS_ENABLE_LFN (1)
7284
#define MICROPY_FATFS_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
@@ -84,6 +96,7 @@
8496
#define MICROPY_VFS (1)
8597
#define MICROPY_VFS_FAT (1)
8698
#define MICROPY_PY_MACHINE (1)
99+
#define MICROPY_MODULE_BUILTIN_INIT (1)
87100
#define MICROPY_MODULE_WEAK_LINKS (0)
88101
#define MICROPY_REPL_AUTO_INDENT (1)
89102
#define MICROPY_HW_ENABLE_DAC (1)
@@ -121,6 +134,9 @@ typedef unsigned mp_uint_t; // must be pointer size
121134

122135
typedef long mp_off_t;
123136

137+
// XXX check we don't need this
138+
#define MICROPY_THREAD_YIELD()
139+
124140
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
125141

126142
#define mp_type_fileio mp_type_vfs_fat_fileio
@@ -194,6 +210,9 @@ extern const struct _mp_obj_module_t gamepad_module;
194210
extern const struct _mp_obj_module_t stage_module;
195211
extern const struct _mp_obj_module_t touchio_module;
196212
extern const struct _mp_obj_module_t usb_hid_module;
213+
extern const struct _mp_obj_module_t network_module;
214+
extern const struct _mp_obj_module_t socket_module;
215+
extern const struct _mp_obj_module_t wiznet_module;
197216

198217
// Internal flash size dependent settings.
199218
#if BOARD_FLASH_SIZE > 192000
@@ -234,18 +253,36 @@ extern const struct _mp_obj_module_t usb_hid_module;
234253
#endif
235254

236255
#ifdef CIRCUITPY_DISPLAYIO
237-
#define DISPLAYIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_displayio), (mp_obj_t)&displayio_module },
256+
#define DISPLAYIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_displayio), (mp_obj_t)&displayio_module },
238257
#else
239-
#define DISPLAYIO_MODULE
258+
#define DISPLAYIO_MODULE
240259
#endif
241260

261+
#if MICROPY_PY_NETWORK
262+
#define NETWORK_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_network), (mp_obj_t)&network_module },
263+
#define SOCKET_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_socket), (mp_obj_t)&socket_module },
264+
#if MICROPY_PY_WIZNET5K
265+
#define WIZNET_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_wiznet), (mp_obj_t)&wiznet_module },
266+
#else
267+
#define WIZNET_MODULE
268+
#endif
269+
#else
270+
#define NETWORK_MODULE
271+
#define SOCKET_MODULE
272+
#define WIZNET_MODULE
273+
#endif
274+
275+
242276
#ifndef EXTRA_BUILTIN_MODULES
243277
#define EXTRA_BUILTIN_MODULES \
244278
AUDIOIO_MODULE \
245279
AUDIOBUSIO_MODULE \
246280
{ MP_OBJ_NEW_QSTR(MP_QSTR_bitbangio), (mp_obj_t)&bitbangio_module }, \
247281
DISPLAYIO_MODULE \
248282
I2CSLAVE_MODULE \
283+
NETWORK_MODULE \
284+
SOCKET_MODULE \
285+
WIZNET_MODULE \
249286
{ MP_OBJ_NEW_QSTR(MP_QSTR_rotaryio), (mp_obj_t)&rotaryio_module }, \
250287
{ MP_OBJ_NEW_QSTR(MP_QSTR_gamepad),(mp_obj_t)&gamepad_module }
251288
#endif
@@ -345,13 +382,20 @@ extern const struct _mp_obj_module_t usb_hid_module;
345382

346383
#include "peripherals/samd/dma.h"
347384

385+
#if MICROPY_PY_NETWORK
386+
#define NETWORK_ROOT_POINTERS mp_obj_list_t mod_network_nic_list;
387+
#else
388+
#define NETWORK_ROOT_POINTERS
389+
#endif
390+
348391
#define MICROPY_PORT_ROOT_POINTERS \
349392
const char *readline_hist[8]; \
350393
vstr_t *repl_line; \
351394
mp_obj_t playing_audio[AUDIO_DMA_CHANNEL_COUNT]; \
352395
mp_obj_t rtc_time_source; \
353396
FLASH_ROOT_POINTERS \
354397
mp_obj_t gamepad_singleton; \
398+
NETWORK_ROOT_POINTERS \
355399

356400
void run_background_tasks(void);
357401
#define MICROPY_VM_HOOK_LOOP run_background_tasks();

ports/atmel-samd/mpconfigport.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ endif
1616

1717

1818
INTERNAL_LIBM = 1
19+
20+
MICROPY_PY_NETWORK = 1
21+
MICROPY_PY_WIZNET5K = 5500

0 commit comments

Comments
 (0)