From fe42d91e2a5ee843bd7a452aed3e1552614313af Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Thu, 16 Nov 2023 06:21:41 +0000 Subject: [PATCH] w5500-test on rpi pico, but it doesn't work --- flake.nix | 2 +- zephyr/w5500-test/boards/rpi_pico.conf | 1 + zephyr/w5500-test/boards/rpi_pico.overlay | 10 ++++++ zephyr/w5500-test/prj.conf | 19 ++++++++++ zephyr/w5500-test/src/main.c | 42 ++++------------------- 5 files changed, 37 insertions(+), 37 deletions(-) create mode 100644 zephyr/w5500-test/boards/rpi_pico.conf create mode 100644 zephyr/w5500-test/boards/rpi_pico.overlay diff --git a/flake.nix b/flake.nix index c4b03ab..5236b18 100644 --- a/flake.nix +++ b/flake.nix @@ -20,7 +20,7 @@ riscv64-zephyr-elf ]; modules = with artemist-packages.packages.${system}.zephyr.modules; - [ mbedtls ]; + [ mbedtls hal_rpi_pico cmsis ]; }; formatter = pkgs.nixfmt; }); diff --git a/zephyr/w5500-test/boards/rpi_pico.conf b/zephyr/w5500-test/boards/rpi_pico.conf new file mode 100644 index 0000000..dc910b1 --- /dev/null +++ b/zephyr/w5500-test/boards/rpi_pico.conf @@ -0,0 +1 @@ +CONFIG_TEST_RANDOM_GENERATOR=y diff --git a/zephyr/w5500-test/boards/rpi_pico.overlay b/zephyr/w5500-test/boards/rpi_pico.overlay new file mode 100644 index 0000000..96e7530 --- /dev/null +++ b/zephyr/w5500-test/boards/rpi_pico.overlay @@ -0,0 +1,10 @@ +&spi0 { + cs-gpios = <&gpio0 17 GPIO_ACTIVE_LOW>; + + w5500@0 { + compatible = "wiznet,w5500"; + reg = <0>; + int-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>; + spi-max-frequency = <10000000>; + }; +}; diff --git a/zephyr/w5500-test/prj.conf b/zephyr/w5500-test/prj.conf index db5ef19..6aed1b4 100644 --- a/zephyr/w5500-test/prj.conf +++ b/zephyr/w5500-test/prj.conf @@ -4,8 +4,27 @@ CONFIG_ETH_W5500=y CONFIG_NETWORKING=y CONFIG_NET_IPV6=y +CONFIG_NET_IPV4=y +CONFIG_NET_DHCPV4=y CONFIG_NET_TCP=y +CONFIG_NET_MAX_ROUTES=2 + CONFIG_NET_SOCKETS=y CONFIG_NET_SOCKETS_POSIX_NAMES=y CONFIG_NET_SOCKETS_POLL_MAX=4 + +CONFIG_NET_CONFIG_AUTO_INIT=y +CONFIG_NET_CONFIG_NEED_IPV6=y +CONFIG_NET_CONFIG_NEED_IPV6_ROUTER=y + +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +CONFIG_LOG_PRINTK=y +CONFIG_LOG_BACKEND_UART=y +CONFIG_LOG=y +CONFIG_NET_CONFIG_LOG_LEVEL_INF=y + +CONFIG_NET_LOG=y +CONFIG_NET_SHELL=y diff --git a/zephyr/w5500-test/src/main.c b/zephyr/w5500-test/src/main.c index a6d0954..418d808 100644 --- a/zephyr/w5500-test/src/main.c +++ b/zephyr/w5500-test/src/main.c @@ -1,44 +1,14 @@ -/* - * Copyright (c) 2016 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ +#include +LOG_MODULE_REGISTER(w5500_test, LOG_LEVEL_DBG); #include -#include - -/* 1000 msec = 1 sec */ -#define SLEEP_TIME_MS 1000 - -/* The devicetree node identifier for the "led0" alias. */ -#define LED0_NODE DT_ALIAS(led0) - -/* - * A build error on this line means your board is unsupported. - * See the sample documentation for information on how to fix this. - */ -static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios); +#include int main(void) { - int ret; - - if (!gpio_is_ready_dt(&led)) { - return 0; + LOG_INF("owo"); + while(1) { + k_sleep(K_MSEC(1000)); } - - ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE); - if (ret < 0) { - return 0; - } - - while (1) { - ret = gpio_pin_toggle_dt(&led); - if (ret < 0) { - return 0; - } - k_msleep(SLEEP_TIME_MS); - } - return 0; }