Implement enough of socketpool to do ntp and non-https requests
This commit is contained in:
parent
a7a1bd7880
commit
ff7731491e
|
@ -310,3 +310,9 @@
|
|||
[submodule "ports/espressif/esp32-camera"]
|
||||
path = ports/espressif/esp32-camera
|
||||
url = https://github.com/adafruit/esp32-camera/
|
||||
[submodule "ports/raspberrypi/lib/cyw43-driver"]
|
||||
path = ports/raspberrypi/lib/cyw43-driver
|
||||
url = https://github.com/georgerobotics/cyw43-driver.git
|
||||
[submodule "ports/raspberrypi/lib/lwip"]
|
||||
path = ports/raspberrypi/lib/lwip
|
||||
url = https://github.com/lwip-tcpip/lwip.git
|
||||
|
|
|
@ -59,18 +59,14 @@ HAL_DIR=hal/$(MCU_SERIES)
|
|||
|
||||
ifeq ($(CIRCUITPY_CYW43),1)
|
||||
INC_CYW43 := \
|
||||
-isystem sdk/lib/cyw43-driver/firmware \
|
||||
-isystem sdk/lib/cyw43-driver/src \
|
||||
-isystem sdk/lib/lwip/src/include \
|
||||
-isystem lib/cyw43-driver/firmware \
|
||||
-isystem lib/cyw43-driver/src \
|
||||
-isystem lib/lwip/src/include \
|
||||
-isystem sdk/src/rp2_common/pico_cyw43_arch/include/ \
|
||||
-isystem sdk/src/rp2_common/pico_lwip/include/ \
|
||||
|
||||
CFLAGS_CYW43 := -DCYW43_LWIP=1 -DPICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1 -DCYW43_USE_SPI -DIGNORE_GPIO25
|
||||
CFLAGS_CYW43 := -DCYW43_LWIP=1 -DPICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1 -DCYW43_USE_SPI -DIGNORE_GPIO25 -DCYW43_LOGIC_DEBUG=0
|
||||
SRC_SDK_CYW43 := \
|
||||
lib/cyw43-driver/src/cyw43_ctrl.c \
|
||||
lib/cyw43-driver/src/cyw43_ll.c \
|
||||
lib/cyw43-driver/src/cyw43_lwip.c \
|
||||
lib/cyw43-driver/src/cyw43_stats.c \
|
||||
src/common/pico_sync/sem.c \
|
||||
src/rp2_common/cyw43_driver/cyw43_bus_pio_spi.c \
|
||||
src/rp2_common/pico_cyw43_arch/cyw43_arch.c \
|
||||
|
@ -80,19 +76,24 @@ SRC_SDK_CYW43 := \
|
|||
|
||||
SRC_LWIP := \
|
||||
shared/netutils/netutils.c \
|
||||
$(wildcard sdk/lib/lwip/src/core/*.c) \
|
||||
$(wildcard sdk/lib/lwip/src/core/ipv4/*.c) \
|
||||
sdk/lib/lwip/src/netif/ethernet.c \
|
||||
$(wildcard lib/lwip/src/core/*.c) \
|
||||
$(wildcard lib/lwip/src/core/ipv4/*.c) \
|
||||
lib/lwip/src/netif/ethernet.c \
|
||||
$(wildcard lwip_src/*.c) \
|
||||
|
||||
SRC_CYW43 := $(wildcard bindings/cyw43/*.c)
|
||||
SRC_CYW43 := \
|
||||
$(wildcard bindings/cyw43/*.c) \
|
||||
lib/cyw43-driver/src/cyw43_stats.c \
|
||||
lib/cyw43-driver/src/cyw43_ctrl.c \
|
||||
lib/cyw43-driver/src/cyw43_ll.c \
|
||||
lib/cyw43-driver/src/cyw43_lwip.c \
|
||||
|
||||
PIOASM = $(BUILD)/sdk/pioasm/pioasm
|
||||
PIOASM = $(BUILD)/pioasm/pioasm/pioasm
|
||||
.PHONY: PioasmBuild
|
||||
PioasmBuild: $(PIOASM)
|
||||
$(PIOASM):
|
||||
$(Q)cmake -S sdk -B $(BUILD)/sdk
|
||||
$(Q)make -C $(BUILD)/sdk PioasmBuild
|
||||
$(Q)cmake -S pioasm -B $(BUILD)/pioasm
|
||||
$(Q)$(MAKE) -C $(BUILD)/pioasm PioasmBuild
|
||||
|
||||
$(BUILD)/cyw43_bus_pio_spi.pio.h: sdk/src/rp2_common/cyw43_driver/cyw43_bus_pio_spi.pio $(PIOASM)
|
||||
$(Q)$(PIOASM) -o c-sdk $< $@
|
||||
|
@ -100,13 +101,13 @@ $(BUILD)/sdk/src/rp2_common/cyw43_driver/cyw43_bus_pio_spi.o: $(BUILD)/cyw43_bus
|
|||
|
||||
CYW43_FIRMWARE_BIN = 43439A0-7.95.49.00.combined
|
||||
|
||||
$(BUILD)/cyw43_resource.o: sdk/lib/cyw43-driver/firmware/$(CYW43_FIRMWARE_BIN)
|
||||
$(BUILD)/cyw43_resource.o: lib/cyw43-driver/firmware/$(CYW43_FIRMWARE_BIN)
|
||||
$(Q)$(OBJCOPY) -I binary -O elf32-littlearm -B arm \
|
||||
--readonly-text \
|
||||
--rename-section .data=.big_const,contents,alloc,load,readonly,data \
|
||||
--redefine-sym _binary_sdk_lib_cyw43_driver_firmware_43439A0_7_95_49_00_combined_start=fw_43439A0_7_95_49_00_start \
|
||||
--redefine-sym _binary_sdk_lib_cyw43_driver_firmware_43439A0_7_95_49_00_combined_size=fw_43439A0_7_95_49_00_size \
|
||||
--redefine-sym _binary_sdk_lib_cyw43_driver_firmware_43439A0_7_95_49_00_combined_end=fw_43439A0_7_95_49_00_end \
|
||||
--redefine-sym _binary_lib_cyw43_driver_firmware_43439A0_7_95_49_00_combined_start=fw_43439A0_7_95_49_00_start \
|
||||
--redefine-sym _binary_lib_cyw43_driver_firmware_43439A0_7_95_49_00_combined_size=fw_43439A0_7_95_49_00_size \
|
||||
--redefine-sym _binary_lib_cyw43_driver_firmware_43439A0_7_95_49_00_combined_end=fw_43439A0_7_95_49_00_end \
|
||||
$< $@
|
||||
OBJ_CYW43 := $(BUILD)/cyw43_resource.o
|
||||
# need to do the equivalent of this in cmake
|
||||
|
@ -270,7 +271,7 @@ SRC_SDK := \
|
|||
$(SRC_SDK_CYW43) \
|
||||
|
||||
SRC_SDK := $(addprefix sdk/, $(SRC_SDK))
|
||||
$(patsubst %.c,$(BUILD)/%.o,$(SRC_SDK)): CFLAGS += -Wno-missing-prototypes -Wno-undef
|
||||
$(patsubst %.c,$(BUILD)/%.o,$(SRC_SDK) $(SRC_CYW43)): CFLAGS += -Wno-missing-prototypes -Wno-undef
|
||||
|
||||
SRC_C += \
|
||||
boards/$(BOARD)/board.c \
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -57,8 +57,7 @@ STATIC void lwip_getaddrinfo_cb(const char *name, const ip_addr_t *ipaddr, void
|
|||
}
|
||||
}
|
||||
|
||||
mp_obj_t common_hal_socketpool_socketpool_gethostbyname(socketpool_socketpool_obj_t *self,
|
||||
const char *host) {
|
||||
int socketpool_resolve_host(socketpool_socketpool_obj_t *self, const char *host, ip_addr_t *addr) {
|
||||
|
||||
getaddrinfo_state_t state;
|
||||
state.status = 0;
|
||||
|
@ -85,13 +84,27 @@ mp_obj_t common_hal_socketpool_socketpool_gethostbyname(socketpool_socketpool_ob
|
|||
}
|
||||
|
||||
if (state.status < 0) {
|
||||
return state.status;
|
||||
// TODO: CPython raises gaierror, we raise with native lwIP negative error
|
||||
// values, to differentiate from normal errno's at least in such way.
|
||||
mp_raise_OSError(state.status);
|
||||
}
|
||||
|
||||
*addr = state.ipaddr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
mp_obj_t common_hal_socketpool_socketpool_gethostbyname(socketpool_socketpool_obj_t *self,
|
||||
const char *host) {
|
||||
|
||||
ip_addr_t addr;
|
||||
int result = socketpool_resolve_host(self, host, &addr);
|
||||
if (result < 0) {
|
||||
mp_raise_OSError(-result);
|
||||
}
|
||||
|
||||
char ip_str[IP4ADDR_STRLEN_MAX];
|
||||
inet_ntoa_r(state.ipaddr, ip_str, IP4ADDR_STRLEN_MAX);
|
||||
inet_ntoa_r(addr, ip_str, IP4ADDR_STRLEN_MAX);
|
||||
mp_obj_t ip_obj = mp_obj_new_str(ip_str, strlen(ip_str));
|
||||
return ip_obj;
|
||||
}
|
||||
|
|
|
@ -31,3 +31,5 @@
|
|||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
} socketpool_socketpool_obj_t;
|
||||
|
||||
int socketpool_resolve_host(socketpool_socketpool_obj_t *self, const char *host, ip_addr_t *addr);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 195dfcc10bb6f379e3dea45147590db2203d3c7b
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 239918ccc173cb2c2a62f41a40fd893f57faf1d6
|
|
@ -0,0 +1,8 @@
|
|||
cmake_minimum_required(VERSION 3.12)
|
||||
project(pioasm)
|
||||
set(PICO_TINYUSB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../lib/tinyusb)
|
||||
include(../sdk/pico_sdk_init.cmake)
|
||||
pico_sdk_init()
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PICO_SDK_PATH}/tools)
|
||||
find_package(Pioasm REQUIRED)
|
|
@ -158,10 +158,7 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_output(size_t n_args, const mp_
|
|||
drive_mode = DRIVE_MODE_OPEN_DRAIN;
|
||||
}
|
||||
// do the transfer
|
||||
digitalinout_result_t result = common_hal_digitalio_digitalinout_switch_to_output(self, args[ARG_value].u_bool, drive_mode);
|
||||
if (result == DIGITALINOUT_INPUT_ONLY) {
|
||||
mp_raise_NotImplementedError(translate("Pin is input only"));
|
||||
}
|
||||
check_result(common_hal_digitalio_digitalinout_switch_to_output(self, args[ARG_value].u_bool, drive_mode));
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(digitalio_digitalinout_switch_to_output_obj, 1, digitalio_digitalinout_switch_to_output);
|
||||
|
@ -229,10 +226,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_direction(mp_obj_t self_in, mp_ob
|
|||
if (value == MP_ROM_PTR(&digitalio_direction_input_obj)) {
|
||||
check_result(common_hal_digitalio_digitalinout_switch_to_input(self, PULL_NONE));
|
||||
} else if (value == MP_ROM_PTR(&digitalio_direction_output_obj)) {
|
||||
digitalinout_result_t result = common_hal_digitalio_digitalinout_switch_to_output(self, false, DRIVE_MODE_PUSH_PULL);
|
||||
if (result == DIGITALINOUT_INPUT_ONLY) {
|
||||
mp_raise_NotImplementedError(translate("Pin is input only"));
|
||||
}
|
||||
check_result(common_hal_digitalio_digitalinout_switch_to_output(self, false, DRIVE_MODE_PUSH_PULL));
|
||||
} else {
|
||||
mp_arg_error_invalid(MP_QSTR_direction);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue