From 650a086b26c637d8dd1696765abae58d86db4aef Mon Sep 17 00:00:00 2001 From: Ian Scott Date: Wed, 21 Aug 2024 22:02:05 -0600 Subject: [PATCH] Updates for SDK 2.0.0; no need for SDK patching for cyw --- .github/workflows/build.yml | 18 ++++++++++++++---- sw/CMakeLists.txt | 14 ++++++++++---- sw/flash_settings.c | 1 + sw/ne2000/CMakeLists.txt | 16 ++++++++-------- sw/ne2000/ne2000.c | 3 +++ sw/ne2000play.cpp | 2 +- sw/pico_extras_import.cmake | 12 ++++++------ sw/pico_reflash.c | 1 + sw/pico_sdk_import.cmake | 15 +++++++++++++-- sw/picogus.cpp | 10 +++++++++- 10 files changed, 66 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5089171..1fcee8b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,9 +5,10 @@ jobs: runs-on: ubuntu-22.04 env: BUILD_TYPE: "Release" - PICOSDK_VER: "1.5.1" - PICOEXTRA_VER: "sdk-1.5.1" + PICOSDK_VER: "2.0.0" + PICOEXTRA_VER: "sdk-2.0.0" # The Pico-SDK will listen to these environment vars + PICOTOOL_FETCH_FROM_GIT_PATH: ${{github.workspace}}/pico/picotool PICO_SDK_PATH: ${{github.workspace}}/pico/pico-sdk PICO_EXTRAS_PATH: ${{github.workspace}}/pico/pico-extras OUTPUT_DIR: ${{github.workspace}}/binaries @@ -20,7 +21,7 @@ jobs: - name: Install Arm GNU Toolchain (arm-none-eabi-gcc) uses: carlosperate/arm-none-eabi-gcc-action@v1 with: - release: '13.2.Rel1' + release: '13.3.Rel1' # Since we reference stable versions of Pico-SDK and pico-extras, we can cache their downloads. # If this were to reference changing branches (like "master"), this caching step must be removed!!! @@ -50,7 +51,7 @@ jobs: run: cmake -E make_directory ${{github.workspace}}/build - name: Patch Pico SDK to allow LTO - run: sed -i 's/WRAPPER_FUNC(x) __wrap_/WRAPPER_FUNC(x) __attribute__((used)) __wrap_/' ${{env.PICO_SDK_PATH}}/src/rp2_common/pico_platform/include/pico/platform.h + run: sed -i 's/WRAPPER_FUNC(x) __wrap_/WRAPPER_FUNC(x) __attribute__((used)) __wrap_/' ${{env.PICO_SDK_PATH}}/src/rp2_common/pico_platform_compiler/include/pico/platform/compiler.h - name: Build Mega Firmware shell: bash @@ -61,6 +62,15 @@ jobs: cmake --build . --config $BUILD_TYPE --parallel $(nproc) cp picogus.uf2 $OUTPUT_DIR/picogus.uf2 + - name: Build NE2000 Firmware + shell: bash + working-directory: ${{github.workspace}}/build + run: | + mkdir -p $OUTPUT_DIR + cmake $GITHUB_WORKSPACE/sw -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPROJECT_TYPE="NE2000" -DPICO_BOARD=pico_w -DUSE_LTO=1 + cmake --build . --config $BUILD_TYPE --parallel $(nproc) + cp picogus.uf2 $OUTPUT_DIR/picogus.uf2 + # will generate PicoGUS Firmwares.zip as downloadable artifact with all .uf2 files - name: Upload All Firmwares uses: actions/upload-artifact@v4 diff --git a/sw/CMakeLists.txt b/sw/CMakeLists.txt index ceccd91..01bdbea 100644 --- a/sw/CMakeLists.txt +++ b/sw/CMakeLists.txt @@ -2,6 +2,12 @@ cmake_minimum_required(VERSION 3.13) +set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}) +if(NOT PICO_BOARD) + set(PICO_BOARD "picogus2") + message("PICO_BOARD not set, defaulting to ${PROJECT_TYPE}") +endif() +set(PICO_COPY_TO_RAM 1) # Initialise pico_sdk from installed location # (note this can come from environment, CMake cache etc) @@ -22,10 +28,6 @@ set(CMAKE_CXX_STANDARD 17) include(pico_extras_import.cmake) -set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}) -set(PICO_BOARD PICO_W) -set(PICO_COPY_TO_RAM 1) - # Tell the Pico SDK to use our local tinyusb instead of the one included in the SDK # This is needed to support tusb_xinput set(PICO_TINYUSB_PATH ${CMAKE_CURRENT_LIST_DIR}/tinyusb) @@ -322,6 +324,9 @@ function(build_ne2000 TARGET_NAME MULTIFW) target_compile_definitions(${TARGET_NAME} PRIVATE NE2000=1 PICOW=1 + # CYW43_RESOURCE_ATTRIBUTE="__in_flash()" + CYW43_CONFIG_FILE="cyw43_firmware.h" + CYW43_PIO_CLOCK_DIV_INT=3 ) target_sources(${TARGET_NAME} PRIVATE ne2000play.cpp @@ -329,6 +334,7 @@ function(build_ne2000 TARGET_NAME MULTIFW) target_link_libraries( ${TARGET_NAME} ne2000 + pico_cyw43_arch_none ) endfunction() diff --git a/sw/flash_settings.c b/sw/flash_settings.c index db75980..cd6c687 100644 --- a/sw/flash_settings.c +++ b/sw/flash_settings.c @@ -4,6 +4,7 @@ #include "flash_settings.h" #include "hardware/flash.h" #include "hardware/sync.h" +#include "hardware/clocks.h" #include "pico/stdlib.h" #include "pico/flash.h" diff --git a/sw/ne2000/CMakeLists.txt b/sw/ne2000/CMakeLists.txt index 74ff96a..b3359e9 100644 --- a/sw/ne2000/CMakeLists.txt +++ b/sw/ne2000/CMakeLists.txt @@ -16,13 +16,13 @@ target_sources(ne2000 INTERFACE ) target_link_libraries(ne2000 INTERFACE - # pico_cyw43_arch_none - pico_cyw43_arch_poll + pico_cyw43_arch_none + # pico_cyw43_arch_poll ) -target_compile_definitions(pico_cyw43_arch_poll_headers INTERFACE - CYW43_LWIP=0 -) -target_compile_definitions(ne2000 INTERFACE - CYW43_LWIP=0 -) +# target_compile_definitions(pico_cyw43_arch_poll_headers INTERFACE +# CYW43_LWIP=0 +# ) +# target_compile_definitions(ne2000 INTERFACE +# CYW43_LWIP=0 +# ) diff --git a/sw/ne2000/ne2000.c b/sw/ne2000/ne2000.c index 65eba21..a22c1c9 100644 --- a/sw/ne2000/ne2000.c +++ b/sw/ne2000/ne2000.c @@ -235,6 +235,9 @@ void cyw43_cb_tcpip_init(cyw43_t *self, int itf) {} void cyw43_cb_tcpip_deinit(cyw43_t *self, int itf) {} void cyw43_cb_tcpip_set_link_up(cyw43_t *self, int itf) {} void cyw43_cb_tcpip_set_link_down(cyw43_t *self, int itf) {} +struct pbuf; +uint16_t pbuf_copy_partial(const struct pbuf *p, void *dataptr, uint16_t len, uint16_t offset) {} + static void ne2000_raise_irq(ne2000_t *ne2000) { PIC_ActivateIRQ(); diff --git a/sw/ne2000play.cpp b/sw/ne2000play.cpp index dcd292f..b5a2863 100644 --- a/sw/ne2000play.cpp +++ b/sw/ne2000play.cpp @@ -52,7 +52,7 @@ void play_ne2000() { break; } } - cyw43_arch_poll(); + /* cyw43_arch_poll(); */ /* if (((time_us_32() >> 21) & 0x1) == 0x1) { if (flag == false) { diff --git a/sw/pico_extras_import.cmake b/sw/pico_extras_import.cmake index 706add0..b75b9b3 100644 --- a/sw/pico_extras_import.cmake +++ b/sw/pico_extras_import.cmake @@ -26,14 +26,14 @@ if (NOT PICO_EXTRAS_PATH) get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_EXTRAS_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}") endif () FetchContent_Declare( - PICO_EXTRAS + pico_extras GIT_REPOSITORY https://github.com/raspberrypi/pico-extras GIT_TAG master ) - if (NOT PICO_EXTRAS) - message("Downloading PICO EXTRAS") - FetchContent_Populate(PICO_EXTRAS) - set(PICO_EXTRAS_PATH ${PICO_EXTRAS_SOURCE_DIR}) + if (NOT pico_extras) + message("Downloading Raspberry Pi Pico Extras") + FetchContent_Populate(pico_extras) + set(PICO_EXTRAS_PATH ${pico_extras_SOURCE_DIR}) endif () set(FETCHCONTENT_BASE_DIR ${FETCHCONTENT_BASE_DIR_SAVE}) else () @@ -59,4 +59,4 @@ endif () set(PICO_EXTRAS_PATH ${PICO_EXTRAS_PATH} CACHE PATH "Path to the PICO EXTRAS" FORCE) -add_subdirectory(${PICO_EXTRAS_PATH} pico_extras) \ No newline at end of file +add_subdirectory(${PICO_EXTRAS_PATH} pico_extras) diff --git a/sw/pico_reflash.c b/sw/pico_reflash.c index 5f0d0db..d87e896 100644 --- a/sw/pico_reflash.c +++ b/sw/pico_reflash.c @@ -2,6 +2,7 @@ #include #include +#include "hardware/clocks.h" #include "pico/multicore.h" #include "pico/stdlib.h" diff --git a/sw/pico_sdk_import.cmake b/sw/pico_sdk_import.cmake index 65f8a6f..a0721d0 100644 --- a/sw/pico_sdk_import.cmake +++ b/sw/pico_sdk_import.cmake @@ -18,9 +18,20 @@ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_P message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')") endif () +if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_TAG} AND (NOT PICO_SDK_FETCH_FROM_GIT_TAG)) + set(PICO_SDK_FETCH_FROM_GIT_TAG $ENV{PICO_SDK_FETCH_FROM_GIT_TAG}) + message("Using PICO_SDK_FETCH_FROM_GIT_TAG from environment ('${PICO_SDK_FETCH_FROM_GIT_TAG}')") +endif () + +if (PICO_SDK_FETCH_FROM_GIT AND NOT PICO_SDK_FETCH_FROM_GIT_TAG) + set(PICO_SDK_FETCH_FROM_GIT_TAG "master") + message("Using master as default value for PICO_SDK_FETCH_FROM_GIT_TAG") +endif() + set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK") set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable") set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK") +set(PICO_SDK_FETCH_FROM_GIT_TAG "${PICO_SDK_FETCH_FROM_GIT_TAG}" CACHE FILEPATH "release tag for SDK") if (NOT PICO_SDK_PATH) if (PICO_SDK_FETCH_FROM_GIT) @@ -34,14 +45,14 @@ if (NOT PICO_SDK_PATH) FetchContent_Declare( pico_sdk GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk - GIT_TAG master + GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG} GIT_SUBMODULES_RECURSE FALSE ) else () FetchContent_Declare( pico_sdk GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk - GIT_TAG master + GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG} ) endif () diff --git a/sw/picogus.cpp b/sw/picogus.cpp index 945dd4a..a35d8a1 100644 --- a/sw/picogus.cpp +++ b/sw/picogus.cpp @@ -321,10 +321,14 @@ __force_inline void write_picogus_high(uint8_t value) { break; case MODE_WIFIAPPLY: printf("Applying wifi settings: %s %s\n", settings.WiFi.ssid, settings.WiFi.password); +#ifdef PICOW PG_Wifi_Connect(settings.WiFi.ssid, settings.WiFi.password); +#endif break; case MODE_WIFISTAT: - multicore_fifo_push_blocking(FIFO_WIFI_STATUS); +#ifdef PICOW + multicore_fifo_push_blocking(FIFO_WIFI_STATUS); +#endif break; case MODE_WIFISCAN: break; @@ -436,7 +440,11 @@ __force_inline uint8_t read_picogus_high(void) { break; */ case MODE_WIFISTAT: +#ifdef PICOW return PG_Wifi_ReadStatusStr(); +#else + return 0; +#endif break; /* case MODE_WIFISCAN: