From 2b8b0ebe95f89a78f782eded3cf42ba1063468d3 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Mon, 11 Nov 2024 10:30:11 -0300 Subject: [PATCH] Pico-SDK support fixes and cleanups --- .github/workflows/nightly.yml | 13 +- .github/workflows/quicktest.yml | 13 +- examples/pico-sdk/pico-w5500 | 2 +- .../CMakeLists.txt | 0 .../Makefile | 0 .../README.md | 0 .../main.c | 17 +-- .../mongoose.c | 0 .../mongoose.h | 0 .../mongoose_config.h | 2 - .../net.c | 0 .../net.h | 0 .../packed_fs.c | 0 .../CMakeLists.txt | 19 +++ .../Makefile | 35 +++++ .../README.md | 3 + .../main.c | 96 +++++++++++++ .../mongoose.c | 1 + .../mongoose.h | 1 + .../mongoose_config.h | 6 + .../net.c | 1 + .../net.h | 1 + .../packed_fs.c | 1 + test/pico-sdk/Makefile | 27 ++-- test/wizard/Makefile | 2 +- test/wizard/test.sh | 133 +++++++++--------- test/xpresso/Makefile | 1 + 27 files changed, 270 insertions(+), 104 deletions(-) rename examples/pico-sdk/{w5500-evb-pico-picosdk-builtin => w5500-evb-pico-picosdk-baremetal-builtin}/CMakeLists.txt (100%) rename examples/pico-sdk/{w5500-evb-pico-picosdk-builtin => w5500-evb-pico-picosdk-baremetal-builtin}/Makefile (100%) rename examples/pico-sdk/{w5500-evb-pico-picosdk-builtin => w5500-evb-pico-picosdk-baremetal-builtin}/README.md (100%) rename examples/pico-sdk/{w5500-evb-pico-picosdk-builtin => w5500-evb-pico-picosdk-baremetal-builtin}/main.c (83%) rename examples/pico-sdk/{w5500-evb-pico-picosdk-builtin => w5500-evb-pico-picosdk-baremetal-builtin}/mongoose.c (100%) rename examples/pico-sdk/{w5500-evb-pico-picosdk-builtin => w5500-evb-pico-picosdk-baremetal-builtin}/mongoose.h (100%) rename examples/pico-sdk/{w5500-evb-pico-picosdk-builtin => w5500-evb-pico-picosdk-baremetal-builtin}/mongoose_config.h (71%) rename examples/pico-sdk/{w5500-evb-pico-picosdk-builtin => w5500-evb-pico-picosdk-baremetal-builtin}/net.c (100%) rename examples/pico-sdk/{w5500-evb-pico-picosdk-builtin => w5500-evb-pico-picosdk-baremetal-builtin}/net.h (100%) rename examples/pico-sdk/{w5500-evb-pico-picosdk-builtin => w5500-evb-pico-picosdk-baremetal-builtin}/packed_fs.c (100%) create mode 100644 examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/CMakeLists.txt create mode 100644 examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/Makefile create mode 100644 examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/README.md create mode 100644 examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/main.c create mode 120000 examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/mongoose.c create mode 120000 examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/mongoose.h create mode 100644 examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/mongoose_config.h create mode 120000 examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/net.c create mode 120000 examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/net.h create mode 120000 examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/packed_fs.c diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 490c349b..52969550 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -402,7 +402,7 @@ jobs: - path: nxp/nxp-lpcxpresso54628-lwip-freertos - path: nxp/nxp-twrk65f180m-lwip-freertos - path: nxp/nxp-twrkv58f220m-lwip-freertos - - path: rp2040/pico-rmii + - path: pico-sdk/pico-rmii - path: stm32/nucleo-f429zi-make-baremetal-builtin-rndis - path: stm32/nucleo-f746zg-make-baremetal-builtin-rndis - path: stm32/nucleo-g031-make-baremetal-builtin @@ -442,9 +442,10 @@ jobs: - path: nxp/rt1060-evk-make-freertos-builtin - path: nxp/rt1170-evk-make-freertos-builtin - path: renesas/ek-ra6m4-make-baremetal-builtin - - path: rp2040/pico-rndis-dashboard - - path: rp2040/pico-w - - path: rp2040/pico-w5500 + - path: pico-sdk/pico-rndis-dashboard + - path: pico-sdk/pico-w + - path: pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin + - path: pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin - path: stm32/nucleo-f746zg-make-freertos-tcp - path: stm32/nucleo-f746zg-make-baremetal-builtin-cmsis_driver name: ${{ matrix.example.path }} ${{ matrix.ssl }} @@ -474,7 +475,7 @@ jobs: fail-fast: false matrix: example: - - path: rp2040/pico-rndis-device + - path: pico-sdk/pico-rndis-device name: ${{ matrix.example.path }} steps: - uses: actions/checkout@v4 @@ -655,5 +656,5 @@ jobs: with: { fetch-depth: 2 } - name: SDK run: sudo apt -y update && sudo apt -y install gcc-arm-none-eabi - - run: make -C examples/rp2040/pico-w5500 test VCON_API_KEY=${{secrets.VCON_API_KEY}} + - run: make -C examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml index 75d23995..45f12614 100644 --- a/.github/workflows/quicktest.yml +++ b/.github/workflows/quicktest.yml @@ -308,9 +308,10 @@ jobs: - path: nxp/rt1060-evk-make-freertos-builtin - path: nxp/rt1170-evk-make-freertos-builtin - path: renesas/ek-ra6m4-make-baremetal-builtin - - path: rp2040/pico-rndis-dashboard - - path: rp2040/pico-w - - path: rp2040/pico-w5500 + - path: pico-sdk/pico-rndis-dashboard + - path: pico-sdk/pico-w + - path: pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin + - path: pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin - path: stm32/nucleo-f746zg-make-freertos-tcp - path: stm32/nucleo-f746zg-make-baremetal-builtin-cmsis_driver name: ${{ matrix.example.path }} @@ -354,7 +355,7 @@ jobs: fail-fast: false matrix: example: - - path: rp2040/pico-rndis-device + - path: pico-sdk/pico-rndis-device name: ${{ matrix.example.path }} env: GO: 0 @@ -734,10 +735,10 @@ jobs: with: { fetch-depth: 2 } - name: SDK run: | - if ./test/match_changed_files.sh "^src|examples/device-dashboard|examples/rp2040/pico-w5500" ; then + if ./test/match_changed_files.sh "^src|examples/device-dashboard|examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin" ; then echo GO=1 >> $GITHUB_ENV sudo apt -y update && sudo apt -y install gcc-arm-none-eabi fi - if: ${{ env.GO == 1 }} - run: make -C examples/rp2040/pico-w5500 test VCON_API_KEY=${{secrets.VCON_API_KEY}} + run: make -C examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin test VCON_API_KEY=${{secrets.VCON_API_KEY}} diff --git a/examples/pico-sdk/pico-w5500 b/examples/pico-sdk/pico-w5500 index 5c3e5172..88ec9255 120000 --- a/examples/pico-sdk/pico-w5500 +++ b/examples/pico-sdk/pico-w5500 @@ -1 +1 @@ -w5500-evb-pico-picosdk-builtin \ No newline at end of file +w5500-evb-pico-picosdk-baremetal-builtin \ No newline at end of file diff --git a/examples/pico-sdk/w5500-evb-pico-picosdk-builtin/CMakeLists.txt b/examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/CMakeLists.txt similarity index 100% rename from examples/pico-sdk/w5500-evb-pico-picosdk-builtin/CMakeLists.txt rename to examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/CMakeLists.txt diff --git a/examples/pico-sdk/w5500-evb-pico-picosdk-builtin/Makefile b/examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/Makefile similarity index 100% rename from examples/pico-sdk/w5500-evb-pico-picosdk-builtin/Makefile rename to examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/Makefile diff --git a/examples/pico-sdk/w5500-evb-pico-picosdk-builtin/README.md b/examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/README.md similarity index 100% rename from examples/pico-sdk/w5500-evb-pico-picosdk-builtin/README.md rename to examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/README.md diff --git a/examples/pico-sdk/w5500-evb-pico-picosdk-builtin/main.c b/examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/main.c similarity index 83% rename from examples/pico-sdk/w5500-evb-pico-picosdk-builtin/main.c rename to examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/main.c index 81586803..548c5746 100644 --- a/examples/pico-sdk/w5500-evb-pico-picosdk-builtin/main.c +++ b/examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/main.c @@ -26,19 +26,10 @@ static uint8_t spi_txn(void *spi, uint8_t byte) { return result; } -bool mg_random(void *buf, size_t len) { - for (size_t n = 0; n < len; n += sizeof(uint32_t)) { - uint32_t r = get_rand_32(); - memcpy((char *) buf + n, &r, n + sizeof(r) > len ? len - n : sizeof(r)); - } - return true; -} - static void timer_fn(void *arg) { - gpio_put(PICO_DEFAULT_LED_PIN, - !gpio_get_out_level(PICO_DEFAULT_LED_PIN)); // Blink LED - struct mg_tcpip_if *ifp = arg; // And show - const char *names[] = {"down", "up", "req", "ready"}; // network stats + gpio_put(PICO_DEFAULT_LED_PIN, !gpio_get(PICO_DEFAULT_LED_PIN)); // Blink LED + struct mg_tcpip_if *ifp = arg; // And show + const char *names[] = {"down", "up", "req", "IP", "ready"}; // network stats MG_INFO(("Ethernet: %s, IP: %M, rx:%u, tx:%u, dr:%u, er:%u", names[ifp->state], mg_print_ip4, &ifp->ip, ifp->nrecv, ifp->nsent, ifp->ndrop, ifp->nerr)); @@ -81,7 +72,7 @@ int main(void) { // .ip = mg_htonl(MG_U32(192, 168, 0, 223)), // .mask = mg_htonl(MG_U32(255, 255, 255, 0)), // .gw = mg_htonl(MG_U32(192, 168, 0, 1)), - .driver = &mg_tcpip_driver_w5500, + .driver = &mg_tcpip_driver_w5500, .driver_data = &spi}; mg_tcpip_init(&mgr, &mif); mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif); diff --git a/examples/pico-sdk/w5500-evb-pico-picosdk-builtin/mongoose.c b/examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/mongoose.c similarity index 100% rename from examples/pico-sdk/w5500-evb-pico-picosdk-builtin/mongoose.c rename to examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/mongoose.c diff --git a/examples/pico-sdk/w5500-evb-pico-picosdk-builtin/mongoose.h b/examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/mongoose.h similarity index 100% rename from examples/pico-sdk/w5500-evb-pico-picosdk-builtin/mongoose.h rename to examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/mongoose.h diff --git a/examples/pico-sdk/w5500-evb-pico-picosdk-builtin/mongoose_config.h b/examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/mongoose_config.h similarity index 71% rename from examples/pico-sdk/w5500-evb-pico-picosdk-builtin/mongoose_config.h rename to examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/mongoose_config.h index f1edd1ec..d3bd3696 100644 --- a/examples/pico-sdk/w5500-evb-pico-picosdk-builtin/mongoose_config.h +++ b/examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/mongoose_config.h @@ -3,6 +3,4 @@ #define MG_ENABLE_TCPIP 1 #define MG_ENABLE_TCPIP_DRIVER_INIT 0 #define MG_ENABLE_DRIVER_W5500 1 -#define MG_ENABLE_CUSTOM_RANDOM 1 #define MG_ENABLE_PACKED_FS 1 -#define MG_ENABLE_POSIX_FS 0 diff --git a/examples/pico-sdk/w5500-evb-pico-picosdk-builtin/net.c b/examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/net.c similarity index 100% rename from examples/pico-sdk/w5500-evb-pico-picosdk-builtin/net.c rename to examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/net.c diff --git a/examples/pico-sdk/w5500-evb-pico-picosdk-builtin/net.h b/examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/net.h similarity index 100% rename from examples/pico-sdk/w5500-evb-pico-picosdk-builtin/net.h rename to examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/net.h diff --git a/examples/pico-sdk/w5500-evb-pico-picosdk-builtin/packed_fs.c b/examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/packed_fs.c similarity index 100% rename from examples/pico-sdk/w5500-evb-pico-picosdk-builtin/packed_fs.c rename to examples/pico-sdk/w5500-evb-pico-picosdk-baremetal-builtin/packed_fs.c diff --git a/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/CMakeLists.txt b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/CMakeLists.txt new file mode 100644 index 00000000..4f54dae2 --- /dev/null +++ b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.13) +include(pico-sdk/pico_sdk_init.cmake) + +project(firmware) +pico_sdk_init() +add_executable(firmware main.c mongoose.c net.c packed_fs.c) +target_include_directories(firmware PUBLIC .) + +target_link_libraries(firmware pico_stdlib hardware_spi pico_rand) +pico_add_extra_outputs(firmware) # create map/bin/hex file etc. + +pico_enable_stdio_usb(firmware 1) # Route stdio +pico_enable_stdio_uart(firmware 0) # to USB + +# Mongoose build flags in mongoose_config.h + +# Example build options +add_definitions(-DHTTP_URL="http://0.0.0.0/") +add_definitions(-DHTTPS_URL="https://0.0.0.0/") diff --git a/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/Makefile b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/Makefile new file mode 100644 index 00000000..3bb3f045 --- /dev/null +++ b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/Makefile @@ -0,0 +1,35 @@ +RM = rm -rf +MKBUILD = test -d build || mkdir build +ifeq ($(OS),Windows_NT) + RM = cmd /C del /Q /F /S + MKBUILD = if not exist build mkdir build +endif +.PHONY: build + +all example: + true + +build build/firmware.uf2: pico-sdk main.c net.c + $(MKBUILD) + cd build && cmake -DPICO_BOARD=pico2 -G "Unix Makefiles" .. && make + +pico-sdk: + git clone --depth 1 -b 2.0.0 https://github.com/raspberrypi/pico-sdk $@ + cd $@ && git submodule update --init + +flash: build/firmware.uf2 + picotool load $< -f + +# Automated remote test. Requires env variable VCON_API_KEY set. See https://vcon.io/automated-firmware-tests/ +DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/?? +# stdio has to be changed from USB to UART in CMakeLists.txt +update: build/firmware.uf2 + curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/ota?uf2=1 --data-binary @$< + +test: update + curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/tx?t=5 | tee /tmp/output.txt + grep 'READY, IP:' /tmp/output.txt # Check for network init +# grep 'MQTT connected' /tmp/output.txt # Check for MQTT connection success + +clean: + $(RM) pico-sdk build diff --git a/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/README.md b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/README.md new file mode 100644 index 00000000..603235cb --- /dev/null +++ b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/README.md @@ -0,0 +1,3 @@ +# RP2350 + W5500 Ethernet chip + +- See [detailed tutorial](https://mongoose.ws/tutorials/rp2040/pico-w5500/) (including hardware connections) diff --git a/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/main.c b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/main.c new file mode 100644 index 00000000..a0872436 --- /dev/null +++ b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/main.c @@ -0,0 +1,96 @@ +// Copyright (c) 2023 Cesanta Software Limited +// All rights reserved + +#include +#include +#include "hardware/spi.h" +#include "pico/rand.h" +#include "pico/stdlib.h" +#include "pico/unique_id.h" + +#include "mongoose.h" +#include "net.h" + +enum { BLINK_PERIOD_MS = 1000 }; +// enum { LED = 25, SPI_CS = 17, SPI_CLK = 18, SPI_TX = 19, SPI_RX = 16 }; // +// Pins +enum { LED = 25, SPI_CS = 5, SPI_CLK = 2, SPI_TX = 3, SPI_RX = 4 }; // Pins + +static void spi_begin(void *spi) { + gpio_put(SPI_CS, 0); +} +static void spi_end(void *spi) { + gpio_put(SPI_CS, 1); +} +static uint8_t spi_txn(void *spi, uint8_t byte) { + uint8_t result = 0; + spi_write_read_blocking(spi0, &byte, &result, 1); + return result; +} + +static void timer_fn(void *arg) { + gpio_put(PICO_DEFAULT_LED_PIN, !gpio_get(PICO_DEFAULT_LED_PIN)); // Blink LED + struct mg_tcpip_if *ifp = arg; // And show + const char *names[] = {"down", "up", "req", "IP", "ready"}; // network stats + MG_INFO(("Ethernet: %s, IP: %M, rx:%u, tx:%u, dr:%u, er:%u", + names[ifp->state], mg_print_ip4, &ifp->ip, ifp->nrecv, ifp->nsent, + ifp->ndrop, ifp->nerr)); +} + +static void eth_spi_init(void) { + // Init SPI pins + spi_init(spi0, 500 * 1000); + gpio_set_function(SPI_RX, GPIO_FUNC_SPI); // MISO + gpio_set_function(SPI_TX, GPIO_FUNC_SPI); // MOSI + gpio_set_function(SPI_CLK, GPIO_FUNC_SPI); // CLK + gpio_init(SPI_CS); // CS + gpio_set_dir(SPI_CS, GPIO_OUT); // Set CS to output + gpio_put(SPI_CS, 1); // And drive CS high (inactive) +} + +// Helper macro for MAC generation +#define GENERATE_LOCALLY_ADMINISTERED_MAC(id) \ + { 2, id[3], id[4], id[5], id[6], id[7] } + +int main(void) { + stdio_init_all(); + gpio_init(LED); // Setup board LED + gpio_set_dir(LED, GPIO_OUT); + eth_spi_init(); // Initialise SPI pins + MG_INFO(("Starting ...")); + + pico_unique_board_id_t board_id; + pico_get_unique_board_id(&board_id); + uint8_t *id = board_id.id; + + struct mg_mgr mgr; // Initialise + mg_mgr_init(&mgr); // Mongoose event manager + mg_log_set(MG_LL_DEBUG); // Set log level + + // Initialise Mongoose network stack + struct mg_tcpip_spi spi = {NULL, spi_begin, spi_end, spi_txn}; + struct mg_tcpip_if mif = {.mac = GENERATE_LOCALLY_ADMINISTERED_MAC(id), + // Uncomment below for static configuration: + // .ip = mg_htonl(MG_U32(192, 168, 0, 223)), + // .mask = mg_htonl(MG_U32(255, 255, 255, 0)), + // .gw = mg_htonl(MG_U32(192, 168, 0, 1)), + .driver = &mg_tcpip_driver_w5500, + .driver_data = &spi}; + mg_tcpip_init(&mgr, &mif); + mg_timer_add(&mgr, BLINK_PERIOD_MS, MG_TIMER_REPEAT, timer_fn, &mif); + + MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, mif.mac)); + while (mif.state != MG_TCPIP_STATE_READY) { + mg_mgr_poll(&mgr, 0); + } + + MG_INFO(("Initialising application...")); + web_init(&mgr); + + MG_INFO(("Starting event loop")); + for (;;) { + mg_mgr_poll(&mgr, 1); + } + + return 0; +} diff --git a/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/mongoose.c b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/mongoose.c new file mode 120000 index 00000000..5e522bbc --- /dev/null +++ b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/mongoose.c @@ -0,0 +1 @@ +../../../mongoose.c \ No newline at end of file diff --git a/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/mongoose.h b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/mongoose.h new file mode 120000 index 00000000..ee4ac823 --- /dev/null +++ b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/mongoose.h @@ -0,0 +1 @@ +../../../mongoose.h \ No newline at end of file diff --git a/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/mongoose_config.h b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/mongoose_config.h new file mode 100644 index 00000000..d3bd3696 --- /dev/null +++ b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/mongoose_config.h @@ -0,0 +1,6 @@ +#define MG_ARCH MG_ARCH_PICOSDK + +#define MG_ENABLE_TCPIP 1 +#define MG_ENABLE_TCPIP_DRIVER_INIT 0 +#define MG_ENABLE_DRIVER_W5500 1 +#define MG_ENABLE_PACKED_FS 1 diff --git a/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/net.c b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/net.c new file mode 120000 index 00000000..fe0e6f06 --- /dev/null +++ b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/net.c @@ -0,0 +1 @@ +../../device-dashboard/net.c \ No newline at end of file diff --git a/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/net.h b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/net.h new file mode 120000 index 00000000..9de896ef --- /dev/null +++ b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/net.h @@ -0,0 +1 @@ +../../device-dashboard/net.h \ No newline at end of file diff --git a/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/packed_fs.c b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/packed_fs.c new file mode 120000 index 00000000..e06bf092 --- /dev/null +++ b/examples/pico-sdk/w5500-evb-pico2-picosdk-baremetal-builtin/packed_fs.c @@ -0,0 +1 @@ +../../device-dashboard/packed_fs.c \ No newline at end of file diff --git a/test/pico-sdk/Makefile b/test/pico-sdk/Makefile index c232064d..ff30158d 100644 --- a/test/pico-sdk/Makefile +++ b/test/pico-sdk/Makefile @@ -1,18 +1,27 @@ -PROJECTS ?= $(wildcard ../../examples/rp2040/*-sdk-*) +PROJECTS ?= $(wildcard ../../examples/pico-sdk/*-picosdk-*) +SDK_PATH ?= $(realpath $(PWD))/pico-sdk +SDK_VERSION ?= 2.0.0 all: $(PROJECTS) echo -$(PROJECTS): pico-sdk - (make -C $@ build && make -C $@ clean) || ( \ - ln -s $(PWD)/pico-sdk $@/pico-sdk && \ +$(PROJECTS): pico-sdk FORCE + (make -C $@ build SDK_PATH=$(SDK_PATH) && make -C $@ clean) || ( \ + ln -s $(SDK_PATH) $@/pico-sdk && \ cd $@ && rm -rf build && mkdir -p build && \ - cd build && cmake -G "Unix Makefiles" .. && make && \ - rm -rf build pico-sdk ) + cd build && cmake -DPICO_BOARD=$(SDKBNAME) -G "Unix Makefiles" .. && make && \ + cd .. && rm -rf build pico-sdk ) + +FORCE: pico-sdk: - git clone --depth 1 -b 1.5.1 https://github.com/raspberrypi/pico-sdk $@ - cd $@ && git submodule update --init + test -d $(SDK_PATH) || ( git clone --depth 1 -b $(SDK_VERSION) https://github.com/raspberrypi/pico-sdk $@ && \ + cd $@ && git submodule update --init ) clean: - rm -rf pico-sdk + rm -rf $(SDK_PATH) + +# Wizard-style board name --> Pico-SDK board name; SDKBNAME = table[BOARD] +SDK_evb-pico := pico +SDK_evb-pico2 := pico2 +SDKBNAME = $(SDK_$(BOARD)) diff --git a/test/wizard/Makefile b/test/wizard/Makefile index c3a86f88..ffa5aaf3 100644 --- a/test/wizard/Makefile +++ b/test/wizard/Makefile @@ -15,7 +15,7 @@ ifeq "$(IDE)" "Keil" BUILD = true endif ifeq "$(IDE)" "Pico-SDK" -BUILD = $(MAKE) -f ../pico-sdk/Makefile PROJECTS=wizard +BUILD = $(MAKE) -f ../pico-sdk/Makefile PROJECTS=wizard BOARD=$(BOARD) endif ifeq "$(IDE)" "ESP-IDF" BUILD = $(MAKE) -f ../esp-idf/Makefile PROJECTS=wizard diff --git a/test/wizard/test.sh b/test/wizard/test.sh index e101fe38..878dbcee 100755 --- a/test/wizard/test.sh +++ b/test/wizard/test.sh @@ -1,12 +1,13 @@ #!/bin/bash RTOSES="baremetal FreeRTOS" - +WIZARD_URL="" +test "$1" != "" && WIZARD_URL="WIZARD_URL=$1" dotest () { echo "BOARD=$1 IDE=$2 RTOS=$3" >> test.log - make BOARD=$1 IDE=$2 RTOS=$3 || ( \ + make BOARD=$1 IDE=$2 RTOS=$3 $4 $WIZARD_URL || ( \ echo "^^^ FAILED ^^^" >> test.log && rm -rf wizard* workspace ) } @@ -15,57 +16,57 @@ cd `dirname "$0"` rm test.log -STM32="f207 f429 f439 f746 f756 f767 h563 h573 h723 h735 h743 h745 h747 h753 h755" -STIDES="GCC+make CubeIDE" -# Keil: f756 -for board in $STM32; do - for ide in $STIDES; do - for rtos in $RTOSES; do - dotest $board $ide $rtos - done - done -done +#STM32="f207 f429 f439 f746 f756 f767 h563 h573 h723 h735 h743 h745 h747 h753 h755" +#STIDES="GCC+make CubeIDE" +## Keil: f756 +#for board in $STM32; do +# for ide in $STIDES; do +# for rtos in $RTOSES; do +# dotest $board $ide $rtos +# done +# done +#done +# +# +#NXP="mcxn947" +#NXPIDES="GCC+make MCUXpresso" +#for board in $NXP; do +# for ide in $NXPIDES; do +# for rtos in $RTOSES; do +# dotest $board $ide $rtos +# done +# done +#done +#NXP="rt1020 rt1024 rt1040 rt1060 rt1064 rt1170" +#for board in $NXP; do +# dotest $board "GCC+make" "baremetal" +#done +# +# +#INFINEON="xmc4400 xmc4700 xmc7200" +#INFINEONIDES="GCC+make" +#for board in $INFINEON; do +# for ide in $INFINEONIDES; do +# for rtos in "baremetal"; do +# dotest $board $ide $rtos +# done +# done +#done +# +# +#TI="tm4c129" +#TIIDES="GCC+make" +#for board in $TI; do +# for ide in $TIIDES; do +# for rtos in $RTOSES; do +# dotest $board $ide $rtos +# done +# done +#done +#dotest "tms570" "CGT+make" "baremetal" -NXP="mcxn947" -NXPIDES="GCC+make MCUXpresso" -for board in $NXP; do - for ide in $NXPIDES; do - for rtos in $RTOSES; do - dotest $board $ide $rtos - done - done -done -NXP="rt1020 rt1024 rt1040 rt1060 rt1064 rt1170" -for board in $NXP; do - dotest $board "GCC+make" "baremetal" -done - - -INFINEON="xmc4400 xmc4700 xmc7200" -INFINEONIDES="GCC+make" -for board in $INFINEON; do - for ide in $INFINEONIDES; do - for rtos in "baremetal"; do - dotest $board $ide $rtos - done - done -done - - -TI="tm4c129" -TIIDES="GCC+make" -for board in $TI; do - for ide in $TIIDES; do - for rtos in $RTOSES; do - dotest $board $ide $rtos - done - done -done -dotest "tms570" "CGT+make" "baremetal" - - -PICO="evb-pico" +PICO="evb-pico evb-pico2" for board in $PICO; do for rtos in "baremetal"; do dotest $board "Pico-SDK" $rtos @@ -73,20 +74,20 @@ for board in $PICO; do done -ESP="esp32" -for board in $ESP; do - dotest $board "ESP-IDF" "baremetal" -done - -# h755 not supported in 3.7.0 branch; master branch currently not building -# other ST boards (PHY address != 0) might build and not work -ZEPHYR="f207 f429 f746 f756 f767 h563 h573 h723 h735 h743 h745 h747 h753 mcxn947 rt1060 rt1064 evb-pico" -for board in $ZEPHYR; do - dotest $board "Zephyr" "baremetal" -done - - -ARDUINO="teensy41" - +#ESP="esp32" +#for board in $ESP; do +# dotest $board "ESP-IDF" "baremetal" +#done +# +## h755 not supported in 3.7.0 branch; master branch currently not building +## other ST boards (PHY address != 0) might build and not work +#ZEPHYR="f207 f429 f746 f756 f767 h563 h573 h723 h735 h743 h745 h747 h753 mcxn947 rt1060 rt1064 evb-pico" +#for board in $ZEPHYR; do +# dotest $board "Zephyr" "baremetal" +#done +# +# +#ARDUINO="teensy41" +# rm -rf workspace pico-sdk mcuxpresso .cache .eclipse .p2 build cd - diff --git a/test/xpresso/Makefile b/test/xpresso/Makefile index 702e9072..0ac24e68 100644 --- a/test/xpresso/Makefile +++ b/test/xpresso/Makefile @@ -13,4 +13,5 @@ $(PROJECTS): FORCE PROJNAME=`xq -r .projectDescription.name $@/.project` && \ ($(DOCKER) $(IMAGE) $(HEADLESS_BUILD) -data workspace -import wizard -cleanBuild $$PROJNAME/$(TARGET) || true) && \ test -f $(@F)/$(TARGET)/$$PROJNAME.axf ) + FORCE: