Skip to content

Commit

Permalink
Create builds for pico 2
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryOderNichts committed Nov 28, 2024
1 parent 40487e3 commit 97e533d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ jobs:
name: udpih
path: |
arm_kernel/arm_kernel.bin.h
pico/build/udpih.uf2
pico/build_rp2040/udpih.uf2
pico/build_rp2350/udpih.uf2
if-no-files-found: error
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.vscode/
build/
build*/

*.elf
*.bin
Expand All @@ -14,3 +14,5 @@ build/
*.mod
*.mod.c
*.order

*.uf2
6 changes: 3 additions & 3 deletions pico/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 3.12)
# Pull in SDK (must be before project)
include(pico_sdk_import.cmake)

if (PICO_SDK_VERSION_STRING VERSION_LESS "1.3.0")
message(FATAL_ERROR "Raspberry Pi Pico SDK version 1.3.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
if (PICO_SDK_VERSION_STRING VERSION_LESS "2.0.0")
message(FATAL_ERROR "Raspberry Pi Pico SDK version 2.0.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
endif()

set(CMAKE_C_STANDARD 11)
Expand Down Expand Up @@ -45,4 +45,4 @@ pico_add_extra_outputs(udpih)
pico_set_program_name(udpih "udpih")
pico_set_program_description(udpih "Wii U USB Host Stack exploit")
pico_set_program_url(udpih "https://github.com/GaryOderNichts/udpih")
pico_set_program_version(udpih "0")
pico_set_program_version(udpih "4")
21 changes: 14 additions & 7 deletions pico/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
CMAKE_BUILD_DIR := build
CMAKE_SOURCE_DIR := .
CMAKE_BUILD_RP2040_DIR := build_rp2040
CMAKE_BUILD_RP2350_DIR := build_rp2350

.PHONY: all clean $(CMAKE_BUILD_DIR)/Makefile $(CMAKE_BUILD_DIR)/udpih.uf2
.PHONY: all clean $(CMAKE_BUILD_RP2040_DIR)/Makefile $(CMAKE_BUILD_RP2040_DIR)/udpih.uf2 $(CMAKE_BUILD_RP2350_DIR)/Makefile $(CMAKE_BUILD_RP2350_DIR)/udpih.uf2

all: $(CMAKE_BUILD_DIR)/udpih.uf2
all: $(CMAKE_BUILD_RP2040_DIR)/udpih.uf2 $(CMAKE_BUILD_RP2350_DIR)/udpih.uf2

$(CMAKE_BUILD_DIR)/Makefile: $(CMAKE_SOURCE_DIR)/CMakeLists.txt
cmake -S $(<D) -B $(@D)
$(CMAKE_BUILD_RP2040_DIR)/Makefile: $(CMAKE_SOURCE_DIR)/CMakeLists.txt
cmake -S $(<D) -B $(@D) -DPICO_BOARD=pico

$(CMAKE_BUILD_DIR)/udpih.uf2: $(CMAKE_BUILD_DIR)/Makefile
$(CMAKE_BUILD_RP2040_DIR)/udpih.uf2: $(CMAKE_BUILD_RP2040_DIR)/Makefile
$(MAKE) -C $(@D)

$(CMAKE_BUILD_RP2350_DIR)/Makefile: $(CMAKE_SOURCE_DIR)/CMakeLists.txt
cmake -S $(<D) -B $(@D) -DPICO_BOARD=pico2

$(CMAKE_BUILD_RP2350_DIR)/udpih.uf2: $(CMAKE_BUILD_RP2350_DIR)/Makefile
$(MAKE) -C $(@D)

clean:
rm -rf $(CMAKE_BUILD_DIR)
rm -rf $(CMAKE_BUILD_RP2040_DIR) $(CMAKE_BUILD_RP2350_DIR)
32 changes: 27 additions & 5 deletions pico/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 @@ -29,11 +40,22 @@ if (NOT PICO_SDK_PATH)
if (PICO_SDK_FETCH_FROM_GIT_PATH)
get_filename_component(FETCHCONTENT_BASE_DIR "${PICO_SDK_FETCH_FROM_GIT_PATH}" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
endif ()
FetchContent_Declare(
pico_sdk
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
GIT_TAG master
)
# GIT_SUBMODULES_RECURSE was added in 3.17
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0")
FetchContent_Declare(
pico_sdk
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
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 ${PICO_SDK_FETCH_FROM_GIT_TAG}
)
endif ()

if (NOT pico_sdk)
message("Downloading Raspberry Pi Pico SDK")
FetchContent_Populate(pico_sdk)
Expand Down
3 changes: 1 addition & 2 deletions pico/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ void usb_device_stall_endpoint(uint8_t ep_address)
*/
void usb_device_init(void) {
// Reset usb controller
reset_block(RESETS_RESET_USBCTRL_BITS);
unreset_block_wait(RESETS_RESET_USBCTRL_BITS);
reset_unreset_block_num_wait_blocking(RESET_USBCTRL);

// Clear any previous state in dpram just in case
memset(usb_dpram, 0, sizeof(*usb_dpram)); // <1>
Expand Down

0 comments on commit 97e533d

Please sign in to comment.