Skip to content

Commit

Permalink
Updates for SDK 2.0.0; no need for SDK patching for cyw
Browse files Browse the repository at this point in the history
  • Loading branch information
polpo committed Aug 22, 2024
1 parent 319a8a6 commit 650a086
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 26 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!!!
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 10 additions & 4 deletions sw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -322,13 +324,17 @@ 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
)
target_link_libraries(
${TARGET_NAME}
ne2000
pico_cyw43_arch_none
)
endfunction()

Expand Down
1 change: 1 addition & 0 deletions sw/flash_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
16 changes: 8 additions & 8 deletions sw/ne2000/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
# )

3 changes: 3 additions & 0 deletions sw/ne2000/ne2000.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion sw/ne2000play.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void play_ne2000() {
break;
}
}
cyw43_arch_poll();
/* cyw43_arch_poll(); */
/*
if (((time_us_32() >> 21) & 0x1) == 0x1) {
if (flag == false) {
Expand Down
12 changes: 6 additions & 6 deletions sw/pico_extras_import.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand All @@ -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)
add_subdirectory(${PICO_EXTRAS_PATH} pico_extras)
1 change: 1 addition & 0 deletions sw/pico_reflash.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <stdio.h>
#include <hardware/flash.h>
#include "hardware/clocks.h"
#include "pico/multicore.h"
#include "pico/stdlib.h"

Expand Down
15 changes: 13 additions & 2 deletions sw/pico_sdk_import.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 ()

Expand Down
10 changes: 9 additions & 1 deletion sw/picogus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 650a086

Please sign in to comment.