diff --git a/.github/workflows/buildandrelease.yml b/.github/workflows/buildandrelease.yml index 536fe80..95ae3ef 100644 --- a/.github/workflows/buildandrelease.yml +++ b/.github/workflows/buildandrelease.yml @@ -104,6 +104,8 @@ jobs: releases/${{ env.APP_NAME }}WsRP2040PiZero.uf2 releases/pico2_${{ env.APP_NAME }}AdaFruitDVISD.uf2 releases/pico2_${{ env.APP_NAME }}PimoroniDV.uf2 + releases/pico2_riscv_${{ env.APP_NAME }}AdaFruitDVISD.uf2 + releases/pico2_riscv_${{ env.APP_NAME }}PimoroniDV.uf2 PCB/pico_nesPCB_v2.1.zip body_path: CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 590b594..8ae35a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ Binaries are at the end of this page. >[!NOTE] ->For Raspberry Pi Pico 2 you need to download the .uf2 files starting with pico2_ +>For Raspberry Pi Pico 2 you need to download the .uf2 files starting with pico2_ or pico2_riscv_ for Risc-V. [See readme section how to install and wire up](https://github.com/fhoedemakers/pico-smsplus#pico-smsplus). For more detailed instructions how to setup specific configurations, see the [Pico-InfonesPlus sister project](https://github.com/fhoedemakers/pico-infonesPlus). @@ -14,8 +14,11 @@ Binaries are at the end of this page. - picosmsPlusimoroniDV.uf2: Pimoroni Pico DV Demo Base with Pico - picosmsPlusFeatherDVI.uf2: Adafruit Feather DVI - picosmsPlusWsRP2040PiZero.uf2: Waveshare RP2040-Pizero -- pico2_picosmsPlusAdaFruitDVISD.uf2: Printed Circuit Board or Breadboard config with Pico 2/RP2350 -- pico2_picosmsPlusimoroniDV.uf2: Pimoroni Pico DV Demo Base with Pico 2/RP2350 +- pico2_picosmsPlusAdaFruitDVISD.uf2: Printed Circuit Board or Breadboard config with Pico 2/RP2350 - Arm-s +- pico2_picosmsPlusimoroniDV.uf2: Pimoroni Pico DV Demo Base with Pico 2/RP2350 - Arm-s +- pico2_riscv_picosmsPlusAdaFruitDVISD.uf2: Printed Circuit Board or Breadboard config with Pico 2/RP2350 - Risc-V +- pico2_riscv_picosmsPlusimoroniDV.uf2: Pimoroni Pico DV Demo Base with Pico 2/RP2350 - Risc-V + - pico_nesPCB_v2.1.zip: PCB Design. For more info see the [Pico-InfonesPlus sister project](https://github.com/fhoedemakers/pico-infonesPlus#pcb-with-raspberry-pi-pico-or-pico-2). 3D-printed case design for PCB: [https://www.thingiverse.com/thing:6689537](https://www.thingiverse.com/thing:6689537). @@ -31,6 +34,30 @@ For the latest two player PCB 2.0, you need: # Release notes +## v0.13 + +### Features + +- For RP2350, Risc-V binaries can be build and are included in the release. In Risc-V there is one display mode missing because the Risc-V assembly code for that display mode is not implemented. The following Risc-V binaries are included in the release: + - pico2_riscv_smsPlusAdaFruitDVISD.uf2 + - pico2_riscv_smsPlusPimoroniDV.uf2 +- Displays the hardware type in the menu. +- updated bld.sh and buildAll.sh scripts to include the Risc-V build. For this to work, you need to have the Risc-V toolchain installed. Depending on your development environment you need to download: + - Raspberry Pi OS: https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-aarch64-lin.tar.gz + - Linux x86/x64: https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-x86_64-lin.tar.gz + + and extract it to $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2 (create the directory tree if needed) + + To build run: + - ./bld.sh -c1 -r -t $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin + - ./bld.sh -c2 -r -t $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin + + The first command builds a Risc-V binary for the Pimoroni DV Demo base, the second for the PCB or breadboard with Adafruit hardware. + +### Fixes + +- Fix in game reset boots back to game in stead of menu. + ## v0.12 ### Features diff --git a/bld.sh b/bld.sh index fdb9e79..81bf08d 100755 --- a/bld.sh +++ b/bld.sh @@ -6,10 +6,12 @@ PROJECT="pico-smsPlus" function usage() { echo "Build script for the ${PROJECT} project" echo "" - echo "Usage: $0 [-d] [-2] [-c ]" + echo "Usage: $0 [-d] [-2 | -r] [-t path to toolchain] [-c ]" echo "Options:" echo " -d: build in DEBUG configuration" - echo " -2: build for Pico 2 board" + echo " -2: build for Pico 2 board (RP2350)" + echo " -r: build for Pico 2 board (RP2350) with riscv core" + echo " -t : only needed for riscv, specify the path to the riscv toolchain bin folder" echo " -c : specify the hardware configuration" echo " 1: Pimoroni Pico DV Demo Base (Default)" echo " 2: Breadboard with Adafruit AdaFruit DVI Breakout Board and AdaFruit MicroSD card breakout board" @@ -18,9 +20,27 @@ function usage() { echo " 4: Waveshare RP2040-PiZero" echo " hwconfig 3 and 4 are RP2040-based boards, so they cannot be built for Pico 2" echo " -h: display this help" + echo "" + echo "To install the RISC-V toolchain:" + echo " - Raspberry Pi: https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-aarch64-lin.tar.gz" + echo " - X86/64 Linux: https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-x86_64-lin.tar.gz" + echo "and extract it to \$PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2" + echo "" + echo "Example riscv toolchain install for Raspberry Pi OS:" + echo "" + echo -e "\tcd" + echo -e "\tsudo apt-get install wget" + echo -e "\twget https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-aarch64-lin.tar.gz" + echo -e "\tmkdir -p \$PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2" + echo -e "\ttar -xzvf riscv-toolchain-14-aarch64-lin.tar.gz -C \$PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2" + echo "" + echo "To build for riscv:" + echo "" + echo -e "\t./bld.sh -c -r -t \$PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin" + echo "" } -PICO_BOARD=pico +PICO_PLATFORM=rp2040 BUILD=RELEASE HWCONFIG=1 UF2="${APP}PimoroniDV.uf2" @@ -35,7 +55,10 @@ if [ ! -d "$PICO_SDK_PATH" ] ; then exit 1 fi SDKVERSION=`cat $PICO_SDK_PATH/pico_sdk_version.cmake | grep "set(PICO_SDK_VERSION_MAJOR" | cut -f2 -d" " | cut -f1 -d\)` -while getopts "hd2c:" opt; do +TOOLCHAIN_PATH= +picoarmIsSet=0 +picoRiscIsSet=0 +while getopts "hd2rc:t:" opt; do case $opt in d) BUILD=DEBUG @@ -44,12 +67,20 @@ while getopts "hd2c:" opt; do HWCONFIG=$OPTARG ;; 2) - PICO_BOARD=pico2 + PICO_PLATFORM=rp2350-arm-s + picoarmIsSet=1 + ;; + r) + picoriscIsSet=1 + PICO_PLATFORM=rp2350-riscv + ;; + t) TOOLCHAIN_PATH=$OPTARG ;; h) usage exit 0 ;; + \?) #echo "Invalid option: -$OPTARG" >&2 usage @@ -66,7 +97,19 @@ while getopts "hd2c:" opt; do ;; esac done - +# -2 and -r are mutually exclusive +if [[ $picoarmIsSet -eq 1 && $picoriscIsSet -eq 1 ]] ; then + echo "Options -2 and -r are mutually exclusive" + usage + exit 1 +fi +# TOOLCHAIN_PATH is set, check if it is a valid path +if [ ! -z "$TOOLCHAIN_PATH" ] ; then + if [ ! -d "$TOOLCHAIN_PATH" ] ; then + echo "Toolchain path $TOOLCHAIN_PATH not found" + exit 1 + fi +fi case $HWCONFIG in 1) UF2="${APP}PimoroniDV.uf2" @@ -86,20 +129,27 @@ case $HWCONFIG in exit 1 ;; esac -if [ "$PICO_BOARD" = "pico2" ] ; then + +if [ "$PICO_PLATFORM" = "rp2350-arm-s" ] ; then UF2="pico2_$UF2" fi +if [ "$PICO_PLATFORM" = "rp2350-riscv" ] ; then + UF2="pico2_riscv_$UF2" +fi echo "Building $PROJECT" echo "Using Pico SDK version: $SDKVERSION" echo "Building for $PICO_BOARD with $BUILD configuration and HWCONFIG=$HWCONFIG" +echo "Toolchain path: $TOOLCHAIN_PATH" echo "UF2 file: $UF2" -if [ $SDKVERSION -lt 2 -a $PICO_BOARD = "pico2" ] ; then - echo "Pico SDK version $SDKVERSION does not support Pico 2. Please update the SDK to version 2 or higher" + +# if PICO_PLATFORM starts with rp2350, check if the SDK version is 2 or higher +if [[ $SDKVERSION -lt 2 && $PICO_PLATFORM == rp2350* ]] ; then + echo "Pico SDK version $SDKVERSION does not support RP2350 (pico2). Please update the SDK to version 2 or higher" echo "" exit 1 fi # pico2 board not compatible with HWCONFIG > 2 -if [ $HWCONFIG -gt 2 -a $PICO_BOARD = "pico2" ] ; then +if [[ $HWCONFIG -gt 2 && $PICO_PLATFORM == rp2350* ]] ; then echo "HW configuration $HWCONFIG is a RP2040 based board, not compatible with Pico 2" exit 1 fi @@ -110,7 +160,11 @@ if [ -d build ] ; then fi mkdir build || exit 1 cd build || exit 1 -cmake -DCMAKE_BUILD_TYPE=$BUILD -DHW_CONFIG=$HWCONFIG -DPICO_BOARD=$PICO_BOARD .. +if [ -z "$TOOLCHAIN_PATH" ] ; then + cmake -DCMAKE_BUILD_TYPE=$BUILD -DHW_CONFIG=$HWCONFIG -DPICO_PLATFORM=$PICO_PLATFORM .. +else + cmake -DCMAKE_BUILD_TYPE=$BUILD -DHW_CONFIG=$HWCONFIG -DPICO_PLATFORM=$PICO_PLATFORM -DPICO_TOOLCHAIN_PATH=$TOOLCHAIN_PATH .. +fi make -j 4 cd .. echo "" diff --git a/buildAll.sh b/buildAll.sh index 500d45d..d99fb5b 100755 --- a/buildAll.sh +++ b/buildAll.sh @@ -20,12 +20,23 @@ for HWCONFIG in $HWCONFIGS do ./bld.sh -c $HWCONFIG done -# build for Pico 2 +# build for Pico 2 -arm-s HWCONFIGS="1 2" for HWCONFIG in $HWCONFIGS do ./bld.sh -c $HWCONFIG -2 done +# build for Pico 2 -riscv +HWCONFIGS="1 2" +if [ ! -d $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin ] ; then + echo "RISC-V toolchain not found in $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin" + echo "To install the RISC-V toolchain, execute \"bld.sh -h\" for instructions" +else + for HWCONFIG in $HWCONFIGS + do + ./bld.sh -c $HWCONFIG -r -t $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin + done +fi if [ -z "$(ls -A releases)" ]; then echo "No UF2 files found in releases folder" exit diff --git a/main.cpp b/main.cpp index 5156671..ee2fae5 100644 --- a/main.cpp +++ b/main.cpp @@ -741,7 +741,7 @@ int main() } // When a game is started from the menu, the menu will reboot the device. // After reboot the emulator will start the selected game. - if (watchdog_caused_reboot() && isFatalError == false && selectedRom[0] != 0) + if (watchdog_enable_caused_reboot() && isFatalError == false && selectedRom[0] != 0) { // Determine loaded rom printf("Rebooted by menu\n"); diff --git a/menu.cpp b/menu.cpp index 135a905..00a0648 100644 --- a/menu.cpp +++ b/menu.cpp @@ -41,7 +41,7 @@ static char connectedGamePadName[sizeof(io::GamePadState::GamePadName)]; #define CWHITE 0x3f #define CRED 3 #define CGREEN 0x40 -#define CBLUE 0x54 +#define CBLUE 36 #define CLIGHTBLUE 0x63 #define DEFAULT_FGCOLOR CBLACK // 60 #define DEFAULT_BGCOLOR CWHITE @@ -199,8 +199,10 @@ void displayRoms(Frens::RomLister romlister, int startIndex) putText(i, ENDROW + 1, "-", fgcolor, bgcolor); } strcpy(s, "A Select, B Back"); - putText(SCREEN_COLS / 2 - strlen(s) / 2, ENDROW + 2, s, fgcolor, bgcolor); + + putText(1, ENDROW + 2, s, fgcolor, bgcolor); putText(SCREEN_COLS - strlen(SWVERSION), SCREEN_ROWS - 1, SWVERSION, fgcolor, bgcolor); + putText(SCREEN_COLS - strlen(PICOHWNAME_) - 1, ENDROW + 2, PICOHWNAME_, fgcolor, bgcolor); for (auto index = startIndex; index < romlister.Count(); index++) { if (y <= ENDROW) diff --git a/menu.h b/menu.h index a4f8595..867a945 100644 --- a/menu.h +++ b/menu.h @@ -3,6 +3,17 @@ #define ROMSELECT #define ROMINFOFILE "/currentloadedrom.txt" #define SWVERSION "VX.X" + +#if PICO_RP2350 +#if __riscv +#define PICOHWNAME_ "rp2350-riscv" +#else +#define PICOHWNAME_ "rp2350-arm" +#endif +#else +#define PICOHWNAME_ "rp2040" +#endif + void processinput(DWORD *pdwPad1, DWORD *pdwPad2, DWORD *pdwSystem, bool ignorepushed, char *gamepadType ); void menu(uintptr_t NES_FILE_ADDR, char *errorMessage, bool isFatalError, bool reset); char getcharslicefrom8x8font(char c, int rowInChar);