Skip to content

Commit 72077c2

Browse files
IFX-Anushaactions-user
authored andcommitted
ports/psoc6: Remove unwanted files.
Signed-off-by: IFX-Anusha <Anusha.TR@infineon.com>
1 parent c91aceb commit 72077c2

File tree

6 files changed

+9
-163
lines changed

6 files changed

+9
-163
lines changed

ports/psoc6/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ ifeq ($(MICROPY_PSOC6_LWIP),1)
134134
netutils/netutils.c \
135135
netutils/trace.c \
136136
)
137-
CFLAGS += -DMICROPY_PY_LWIP=0
138137
MOD_SRC_C += modsocket.c
139138
endif
140139

ports/psoc6/irq.h

Lines changed: 0 additions & 74 deletions
This file was deleted.

ports/psoc6/lwip_inc/lwipopts.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#define MEM_ALIGNMENT (4)
3737

3838
#define LWIP_RAW (1)
39-
#define NO_SYS 0
39+
#define NO_SYS (0)
4040

4141
//
4242
// Enable IPV4 networking
@@ -262,8 +262,6 @@
262262
*/
263263
#define LWIP_NETIF_API 1
264264

265-
// #define TCP_LISTEN_BACKLOG 1
266-
267265
#define LWIP_DNS (1)
268266

269267
#define LWIP_NETIF_TX_SINGLE_PBUF (1)

ports/psoc6/modsocket.c

Lines changed: 6 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
/*
22
* This file is part of the MicroPython project, http://micropython.org/
33
*
4-
* Development of the code in this file was sponsored by Microbric Pty Ltd
5-
* and Mnemote Pty Ltd
6-
*
74
* The MIT License (MIT)
85
*
9-
* Copyright (c) 2016, 2017 Nick Moore @mnemote
6+
* Copyright (c) 2022-2024 Infineon Technologies AG
107
*
11-
* Based on extmod/modlwip.c
12-
* Copyright (c) 2013, 2014 Damien P. George
13-
* Copyright (c) 2015 Galen Hazelwood
8+
* Based on ports/esp32/modsocket.c
9+
* Copyright (c) 2016, 2017 Nick Moore @mnemote
1410
*
1511
* Permission is hereby granted, free of charge, to any person obtaining a copy
1612
* of this software and associated documentation files (the "Software"), to deal
@@ -83,7 +79,6 @@ typedef struct _socket_obj_t {
8379
#endif
8480
} socket_obj_t;
8581

86-
// static const char *TAG = "modsocket";
8782

8883
void _socket_settimeout(socket_obj_t *sock, uint64_t timeout_ms);
8984

@@ -156,62 +151,6 @@ static inline void check_for_exceptions(void) {
156151
mp_handle_pending(true);
157152
}
158153

159-
#if MICROPY_HW_ENABLE_MDNS_QUERIES
160-
// This function mimics lwip_getaddrinfo, but makes an mDNS query
161-
static int mdns_getaddrinfo(const char *host_str, const char *port_str,
162-
const struct addrinfo *hints, struct addrinfo **res) {
163-
int host_len = strlen(host_str);
164-
const int local_len = sizeof(MDNS_LOCAL_SUFFIX) - 1;
165-
if (host_len <= local_len ||
166-
strcasecmp(host_str + host_len - local_len, MDNS_LOCAL_SUFFIX) != 0) {
167-
return 0;
168-
}
169-
170-
// mDNS query
171-
char host_no_local[host_len - local_len + 1];
172-
memcpy(host_no_local, host_str, host_len - local_len);
173-
host_no_local[host_len - local_len] = '\0';
174-
175-
esp_ip4_addr_t addr = {0};
176-
177-
esp_err_t err = mdns_query_a(host_no_local, MDNS_QUERY_TIMEOUT_MS, &addr);
178-
if (err != ESP_OK) {
179-
if (err == ESP_ERR_NOT_FOUND) {
180-
*res = NULL;
181-
return 0;
182-
}
183-
*res = NULL;
184-
return err;
185-
}
186-
187-
struct addrinfo *ai = memp_malloc(MEMP_NETDB);
188-
if (ai == NULL) {
189-
*res = NULL;
190-
return EAI_MEMORY;
191-
}
192-
memset(ai, 0, sizeof(struct addrinfo) + sizeof(struct sockaddr_storage));
193-
194-
struct sockaddr_in *sa = (struct sockaddr_in *)((uint8_t *)ai + sizeof(struct addrinfo));
195-
inet_addr_from_ip4addr(&sa->sin_addr, &addr);
196-
sa->sin_family = AF_INET;
197-
sa->sin_len = sizeof(struct sockaddr_in);
198-
sa->sin_port = lwip_htons((u16_t)atoi(port_str));
199-
ai->ai_family = AF_INET;
200-
ai->ai_canonname = ((char *)sa + sizeof(struct sockaddr_storage));
201-
memcpy(ai->ai_canonname, host_str, host_len + 1);
202-
ai->ai_addrlen = sizeof(struct sockaddr_storage);
203-
ai->ai_addr = (struct sockaddr *)sa;
204-
ai->ai_socktype = SOCK_STREAM;
205-
if (hints) {
206-
ai->ai_socktype = hints->ai_socktype;
207-
ai->ai_protocol = hints->ai_protocol;
208-
}
209-
210-
*res = ai;
211-
return 0;
212-
}
213-
#endif // MICROPY_HW_ENABLE_MDNS_QUERIES
214-
215154
static void _getaddrinfo_inner(const mp_obj_t host, const mp_obj_t portx,
216155
const struct addrinfo *hints, struct addrinfo **res) {
217156
int retval = 0;
@@ -235,10 +174,6 @@ static void _getaddrinfo_inner(const mp_obj_t host, const mp_obj_t portx,
235174

236175
MP_THREAD_GIL_EXIT();
237176

238-
#if MICROPY_HW_ENABLE_MDNS_QUERIES
239-
retval = mdns_getaddrinfo(host_str, port_str, hints, res);
240-
#endif
241-
242177
if (retval == 0 && *res == NULL) {
243178
// Normal query
244179
retval = lwip_getaddrinfo(host_str, port_str, hints, res);
@@ -288,7 +223,7 @@ static mp_obj_t socket_make_new(const mp_obj_type_t *type_in, size_t n_args, siz
288223

289224
sock->fd = lwip_socket(sock->domain, sock->type, sock->proto);
290225
if (sock->fd < 0 && errno == ENFILE) {
291-
// ESP32 LWIP has a hard socket limit, ENFILE is returned when this is
226+
// LWIP has a hard socket limit, ENFILE is returned when this is
292227
// reached. Similar to the logic elsewhere for MemoryError, try running
293228
// GC before failing outright.
294229
gc_collect();
@@ -408,7 +343,7 @@ static mp_obj_t socket_connect(const mp_obj_t arg0, const mp_obj_t arg1) {
408343
// - Allows emulating a connect timeout, which is not supported by LWIP or
409344
// required by POSIX but is normal behaviour for CPython.
410345
if (fcntl(self->fd, F_SETFL, flags | O_NONBLOCK) < 0) {
411-
// ESP_LOGE(TAG, "fcntl set failed %d", errno); // Unexpected internal failure
346+
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("fcntl set failed %d"), errno);
412347
raise_err = errno;
413348
}
414349
}
@@ -425,7 +360,7 @@ static mp_obj_t socket_connect(const mp_obj_t arg0, const mp_obj_t arg1) {
425360
// Set the socket back to blocking. We can still pass it to select() in this state.
426361
int r = fcntl(self->fd, F_SETFL, flags);
427362
if (r != 0 && (raise_err == 0 || raise_err == EINPROGRESS)) {
428-
// ESP_LOGE(TAG, "fcntl restore failed %d", errno); // Unexpected internal failure
363+
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("fcntl restore failed %d"), errno);
429364
raise_err = errno;
430365
}
431366
}
@@ -978,7 +913,6 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(psoc6_socket_getaddrinfo_obj, 2, 6, p
978913
static mp_obj_t psoc6_socket_initialize() {
979914
static int initialized = 0;
980915
if (!initialized) {
981-
// ESP_LOGI(TAG, "Initializing");
982916
cy_network_init();
983917

984918
initialized = 1;

ports/psoc6/mphalport.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ void mp_hal_delay_us(mp_uint_t us) {
7272
cyhal_system_delay_us(us);
7373
}
7474

75+
7576
// Issues may arise if time is incremented only each second.
7677
// Would require proper ns count from epoch of clock the source (see also "extmod/vfs_lfs.c", function "lfs_get_mtime" and "mphalport.c", function "mp_hal_time_ns")
7778
uint64_t mp_hal_time_ns(void) {

ports/psoc6/mphalport.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,19 @@
3333
#include "py/mpconfig.h"
3434
#include "py/runtime.h"
3535

36+
3637
// MTB includes
3738
#include "cyhal.h"
3839

3940

4041
// port-specific includes
41-
#include "irq.h"
4242

4343
#define MICROPY_BEGIN_ATOMIC_SECTION() cyhal_system_critical_section_enter()
4444
#define MICROPY_END_ATOMIC_SECTION(state) cyhal_system_critical_section_exit(state)
4545

4646
// #define MICROPY_BEGIN_ATOMIC_SECTION() (0)
4747
// #define MICROPY_END_ATOMIC_SECTION(state) {(void)state;}
4848

49-
// For regular code that wants to prevent "background tasks" from running.
50-
// These background tasks (LWIP) run in PENDSV context.
51-
#define MICROPY_PY_PENDSV_ENTER uint32_t atomic_state = raise_irq_pri(IRQ_PRI_PENDSV);
52-
#define MICROPY_PY_PENDSV_REENTER atomic_state = raise_irq_pri(IRQ_PRI_PENDSV);
53-
#define MICROPY_PY_PENDSV_EXIT restore_irq_pri(atomic_state);
54-
55-
// Prevent the "lwIP task" from running.
56-
#define MICROPY_PY_LWIP_ENTER MICROPY_PY_PENDSV_ENTER
57-
#define MICROPY_PY_LWIP_REENTER MICROPY_PY_PENDSV_REENTER
58-
#define MICROPY_PY_LWIP_EXIT MICROPY_PY_PENDSV_EXIT
59-
60-
6149
#define MP_HAL_PIN_FMT "%u"
6250
#define mp_hal_pin_obj_t uint
6351

0 commit comments

Comments
 (0)