Skip to content

Commit a7efa9e

Browse files
authored
Merge pull request #98 from fhoedemakers/riscv
Binaries can be build for Risc-V and other changes
2 parents a3ce5c9 + 3f1c790 commit a7efa9e

File tree

10 files changed

+363
-126
lines changed

10 files changed

+363
-126
lines changed

.github/workflows/BuildAndRelease.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ jobs:
101101
releases/${{ env.APP_NAME }}WsRP2040PiZero.uf2
102102
releases/pico2_${{ env.APP_NAME }}AdaFruitDVISD.uf2
103103
releases/pico2_${{ env.APP_NAME }}PimoroniDV.uf2
104+
releases/pico2_riscv_${{ env.APP_NAME }}AdaFruitDVISD.uf2
105+
releases/pico2_riscv_${{ env.APP_NAME }}PimoroniDV.uf2
104106
PCB/pico_nesPCB_v2.1.zip
105107
body_path: CHANGELOG.md
106108

CHANGELOG.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Binaries for each configuration and PCB design are at the end of this page.
66

77
>[!NOTE]
8-
>For Raspberry Pi Pico 2 you need to download the .uf2 files starting with pico2_
8+
>For Raspberry Pi Pico 2 you need to download the .uf2 files starting with pico2_ or pico2_riscv_ for Risc-V.
99
1010
[See setup section in readme how to install and wire up](https://github.com/fhoedemakers/pico-infonesPlus#pico-setup)
1111

@@ -22,13 +22,36 @@ For the latest two player PCB 2.0, you need:
2222

2323
# Release notes
2424

25-
## v0.21 ( To Be Released )
25+
## v0.21
2626

2727
### Features
2828

29+
- 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:
30+
- pico2_riscv_piconesPlusAdaFruitDVISD.uf2
31+
- pico2_riscv_piconesPlusPimoroniDV.uf2
32+
- Displays the hardware type in the menu.
33+
- 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:
34+
- Raspberry Pi OS: https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-aarch64-lin.tar.gz
35+
- Linux x86/x64: https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-x86_64-lin.tar.gz
36+
37+
and extract it to $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2 (create the directory tree if needed)
38+
39+
To build run:
40+
- ./bld.sh -c1 -r -t $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin
41+
- ./bld.sh -c2 -r -t $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin
42+
43+
The first command builds a Risc-V binary for the Pimoroni DV Demo base, the second for the PCB or breadboard with Adafruit hardware.
44+
- The colors in the menu can be changed and saved:
45+
- Select + Up/Down changes the foreground color.
46+
- Select + Left/Right changes the background color.
47+
- Select + A saves the colors. Screen will flicker when saved.
48+
- Select + B resets the colors to default. (Black on white)
49+
2950
### Fixes
3051

3152
- Fix scroll in highlighted menu item.
53+
- Fix Splash screen shown when exiting a game.
54+
- Fix in game reset boots back to game in stead of menu.
3255

3356
## v0.20
3457

README.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,22 +659,30 @@ Gavin Knight ([DynaMight1124](https://github.com/DynaMight1124)) designed a NES-
659659

660660
***
661661

662+
# Gamepad and keyboard usage
662663

663-
# Menu Usage
664+
## Menu Usage
664665
Gamepad buttons:
665666
- UP/DOWN: Next/previous item in the menu.
666667
- LEFT/RIGHT: next/previous page.
667668
- A (Circle): Open folder/flash and start game.
668669
- B (X): Back to parent folder.
669670
- START: Starts game currently loaded in flash.
670671

672+
The colors in the menu can be changed and saved:
673+
- Select + Up/Down changes the foreground color.
674+
- Select + Left/Right changes the background color.
675+
- Select + A saves the colors. Screen will flicker when saved.
676+
- Select + B resets the colors to default. (Black on white)
677+
671678
When using an USB-Keyboard:
672679
- Cursor keys: Up, Down, left, right
673680
- Z: Back to parent folder
674681
- X: Open Folder/flash and start a game
675682
- S: Starts game currently loaded in flash.
683+
- A: acts as the select button.
676684

677-
# Emulator (in game)
685+
## Emulator (in game)
678686
Gamepad buttons:
679687
- SELECT + START, Xbox button: Resets back to the SD Card menu. Game saves are saved to the SD card.
680688
- SELECT + UP/SELECT + DOWN: switches screen modes.
@@ -782,10 +790,12 @@ Alternatively, you can use the [bld.sh](bld.sh) shell script:
782790
```
783791
Build script for the pico-InfoNESPlus project
784792
785-
Usage: ./bld.sh [-d] [-2] [-c <hwconfig>]
793+
Usage: ./bld.sh [-d] [-2 | -r] [-t path to toolchain] [-c <hwconfig>]
786794
Options:
787795
-d: build in DEBUG configuration
788-
-2: build for Pico 2 board
796+
-2: build for Pico 2 board (RP2350)
797+
-r: build for Pico 2 board (RP2350) with riscv core
798+
-t <path to toolchain>: only needed for riscv, specify the path to the riscv toolchain bin folder
789799
-c <hwconfig>: specify the hardware configuration
790800
1: Pimoroni Pico DV Demo Base (Default)
791801
2: Breadboard with Adafruit AdaFruit DVI Breakout Board and AdaFruit MicroSD card breakout board
@@ -794,6 +804,24 @@ Options:
794804
4: Waveshare RP2040-PiZero
795805
hwconfig 3 and 4 are RP2040-based boards, so they cannot be built for Pico 2
796806
-h: display this help
807+
808+
To install the RISC-V toolchain:
809+
- Raspberry Pi: https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-aarch64-lin.tar.gz
810+
- X86/64 Linux: https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-x86_64-lin.tar.gz
811+
and extract it to $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2
812+
813+
Example riscv toolchain install for Raspberry Pi OS:
814+
815+
cd
816+
sudo apt-get install wget
817+
wget https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-aarch64-lin.tar.gz
818+
mkdir -p $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2
819+
tar -xzvf riscv-toolchain-14-aarch64-lin.tar.gz -C $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2
820+
821+
To build for riscv:
822+
823+
./bld.sh -c <hwconfig> -r -t $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin
824+
797825
```
798826

799827

bld.sh

Lines changed: 65 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ PROJECT="pico-InfoNESPlus"
66
function usage() {
77
echo "Build script for the ${PROJECT} project"
88
echo ""
9-
echo "Usage: $0 [-d] [-2] [-c <hwconfig>]"
9+
echo "Usage: $0 [-d] [-2 | -r] [-t path to toolchain] [-c <hwconfig>]"
1010
echo "Options:"
1111
echo " -d: build in DEBUG configuration"
12-
echo " -2: build for Pico 2 board"
12+
echo " -2: build for Pico 2 board (RP2350)"
13+
echo " -r: build for Pico 2 board (RP2350) with riscv core"
14+
echo " -t <path to toolchain>: only needed for riscv, specify the path to the riscv toolchain bin folder"
1315
echo " -c <hwconfig>: specify the hardware configuration"
1416
echo " 1: Pimoroni Pico DV Demo Base (Default)"
1517
echo " 2: Breadboard with Adafruit AdaFruit DVI Breakout Board and AdaFruit MicroSD card breakout board"
@@ -18,9 +20,27 @@ function usage() {
1820
echo " 4: Waveshare RP2040-PiZero"
1921
echo " hwconfig 3 and 4 are RP2040-based boards, so they cannot be built for Pico 2"
2022
echo " -h: display this help"
23+
echo ""
24+
echo "To install the RISC-V toolchain:"
25+
echo " - Raspberry Pi: https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-aarch64-lin.tar.gz"
26+
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"
27+
echo "and extract it to \$PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2"
28+
echo ""
29+
echo "Example riscv toolchain install for Raspberry Pi OS:"
30+
echo ""
31+
echo -e "\tcd"
32+
echo -e "\tsudo apt-get install wget"
33+
echo -e "\twget https://github.com/raspberrypi/pico-sdk-tools/releases/download/v2.0.0-5/riscv-toolchain-14-aarch64-lin.tar.gz"
34+
echo -e "\tmkdir -p \$PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2"
35+
echo -e "\ttar -xzvf riscv-toolchain-14-aarch64-lin.tar.gz -C \$PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2"
36+
echo ""
37+
echo "To build for riscv:"
38+
echo ""
39+
echo -e "\t./bld.sh -c <hwconfig> -r -t \$PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin"
40+
echo ""
2141
}
2242

23-
PICO_BOARD=pico
43+
PICO_PLATFORM=rp2040
2444
BUILD=RELEASE
2545
HWCONFIG=1
2646
UF2="${APP}PimoroniDV.uf2"
@@ -35,7 +55,10 @@ if [ ! -d "$PICO_SDK_PATH" ] ; then
3555
exit 1
3656
fi
3757
SDKVERSION=`cat $PICO_SDK_PATH/pico_sdk_version.cmake | grep "set(PICO_SDK_VERSION_MAJOR" | cut -f2 -d" " | cut -f1 -d\)`
38-
while getopts "hd2c:" opt; do
58+
TOOLCHAIN_PATH=
59+
picoarmIsSet=0
60+
picoRiscIsSet=0
61+
while getopts "hd2rc:t:" opt; do
3962
case $opt in
4063
d)
4164
BUILD=DEBUG
@@ -44,12 +67,20 @@ while getopts "hd2c:" opt; do
4467
HWCONFIG=$OPTARG
4568
;;
4669
2)
47-
PICO_BOARD=pico2
70+
PICO_PLATFORM=rp2350-arm-s
71+
picoarmIsSet=1
72+
;;
73+
r)
74+
picoriscIsSet=1
75+
PICO_PLATFORM=rp2350-riscv
76+
;;
77+
t) TOOLCHAIN_PATH=$OPTARG
4878
;;
4979
h)
5080
usage
5181
exit 0
5282
;;
83+
5384
\?)
5485
#echo "Invalid option: -$OPTARG" >&2
5586
usage
@@ -66,7 +97,19 @@ while getopts "hd2c:" opt; do
6697
;;
6798
esac
6899
done
69-
100+
# -2 and -r are mutually exclusive
101+
if [[ $picoarmIsSet -eq 1 && $picoriscIsSet -eq 1 ]] ; then
102+
echo "Options -2 and -r are mutually exclusive"
103+
usage
104+
exit 1
105+
fi
106+
# TOOLCHAIN_PATH is set, check if it is a valid path
107+
if [ ! -z "$TOOLCHAIN_PATH" ] ; then
108+
if [ ! -d "$TOOLCHAIN_PATH" ] ; then
109+
echo "Toolchain path $TOOLCHAIN_PATH not found"
110+
exit 1
111+
fi
112+
fi
70113
case $HWCONFIG in
71114
1)
72115
UF2="${APP}PimoroniDV.uf2"
@@ -86,20 +129,27 @@ case $HWCONFIG in
86129
exit 1
87130
;;
88131
esac
89-
if [ "$PICO_BOARD" = "pico2" ] ; then
132+
133+
if [ "$PICO_PLATFORM" = "rp2350-arm-s" ] ; then
90134
UF2="pico2_$UF2"
91135
fi
136+
if [ "$PICO_PLATFORM" = "rp2350-riscv" ] ; then
137+
UF2="pico2_riscv_$UF2"
138+
fi
92139
echo "Building $PROJECT"
93140
echo "Using Pico SDK version: $SDKVERSION"
94141
echo "Building for $PICO_BOARD with $BUILD configuration and HWCONFIG=$HWCONFIG"
142+
echo "Toolchain path: $TOOLCHAIN_PATH"
95143
echo "UF2 file: $UF2"
96-
if [ $SDKVERSION -lt 2 -a $PICO_BOARD = "pico2" ] ; then
97-
echo "Pico SDK version $SDKVERSION does not support Pico 2. Please update the SDK to version 2 or higher"
144+
145+
# if PICO_PLATFORM starts with rp2350, check if the SDK version is 2 or higher
146+
if [[ $SDKVERSION -lt 2 && $PICO_PLATFORM == rp2350* ]] ; then
147+
echo "Pico SDK version $SDKVERSION does not support RP2350 (pico2). Please update the SDK to version 2 or higher"
98148
echo ""
99149
exit 1
100150
fi
101151
# pico2 board not compatible with HWCONFIG > 2
102-
if [ $HWCONFIG -gt 2 -a $PICO_BOARD = "pico2" ] ; then
152+
if [[ $HWCONFIG -gt 2 && $PICO_PLATFORM == rp2350* ]] ; then
103153
echo "HW configuration $HWCONFIG is a RP2040 based board, not compatible with Pico 2"
104154
exit 1
105155
fi
@@ -110,7 +160,11 @@ if [ -d build ] ; then
110160
fi
111161
mkdir build || exit 1
112162
cd build || exit 1
113-
cmake -DCMAKE_BUILD_TYPE=$BUILD -DHW_CONFIG=$HWCONFIG -DPICO_BOARD=$PICO_BOARD ..
163+
if [ -z "$TOOLCHAIN_PATH" ] ; then
164+
cmake -DCMAKE_BUILD_TYPE=$BUILD -DHW_CONFIG=$HWCONFIG -DPICO_PLATFORM=$PICO_PLATFORM ..
165+
else
166+
cmake -DCMAKE_BUILD_TYPE=$BUILD -DHW_CONFIG=$HWCONFIG -DPICO_PLATFORM=$PICO_PLATFORM -DPICO_TOOLCHAIN_PATH=$TOOLCHAIN_PATH ..
167+
fi
114168
make -j 4
115169
cd ..
116170
echo ""

buildAll.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,23 @@ for HWCONFIG in $HWCONFIGS
2020
do
2121
./bld.sh -c $HWCONFIG
2222
done
23-
# build for Pico 2
23+
# build for Pico 2 -arm-s
2424
HWCONFIGS="1 2"
2525
for HWCONFIG in $HWCONFIGS
2626
do
2727
./bld.sh -c $HWCONFIG -2
2828
done
29+
# build for Pico 2 -riscv
30+
HWCONFIGS="1 2"
31+
if [ ! -d $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin ] ; then
32+
echo "RISC-V toolchain not found in $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin"
33+
echo "To install the RISC-V toolchain, execute \"bld.sh -h\" for instructions"
34+
else
35+
for HWCONFIG in $HWCONFIGS
36+
do
37+
./bld.sh -c $HWCONFIG -r -t $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin
38+
done
39+
fi
2940
if [ -z "$(ls -A releases)" ]; then
3041
echo "No UF2 files found in releases folder"
3142
exit

main.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ const WORD __not_in_flash_func(NesPalette)[64] = {
145145
CC(0x7ae7), CC(0x4342), CC(0x2769), CC(0x2ff3), CC(0x03bb), CC(0x0000), CC(0x0000), CC(0x0000),
146146
CC(0x7fff), CC(0x579f), CC(0x635f), CC(0x6b3f), CC(0x7f1f), CC(0x7f1b), CC(0x7ef6), CC(0x7f75),
147147
CC(0x7f94), CC(0x73f4), CC(0x57d7), CC(0x5bf9), CC(0x4ffe), CC(0x0000), CC(0x0000), CC(0x0000)};
148+
int nesPaletteItems = sizeof(NesPalette) / sizeof(NesPalette[0]);
148149

149150
uint32_t getCurrentNVRAMAddr()
150151
{
@@ -849,17 +850,20 @@ int main()
849850
gpio_set_dir(LED_GPIO_PIN, GPIO_OUT);
850851
gpio_put(LED_GPIO_PIN, 1);
851852
#endif
853+
// reset settings to default in case SD card could not be mounted
854+
resetsettings();
852855
tusb_init();
853856
isFatalError = !initSDCard();
854857
if (isFatalError == false)
855858
{
856859
loadsettings();
857-
}
858-
859-
860+
}
860861
// When a game is started from the menu, the menu will reboot the device.
861862
// After reboot the emulator will start the selected game.
862-
if (watchdog_caused_reboot() && isFatalError == false)
863+
// The watchdog timer is used to detect if the reboot was caused by the menu.
864+
// Use watchdog_enable_caused_reboot in stead of watchdog_caused_reboot because
865+
// when reset is pressed while in game, the watchdog will also be triggered.
866+
if (watchdog_enable_caused_reboot() && isFatalError == false)
863867
{
864868
// Determine loaded rom
865869
printf("Rebooted by menu\n");
@@ -1036,18 +1040,19 @@ int main()
10361040
dvi_->getAudioRingBuffer().advanceWritePointer(255);
10371041

10381042
multicore_launch_core1(core1_main);
1039-
1043+
bool showSplash = true;
10401044
while (true)
10411045
{
10421046
if (strlen(selectedRom) == 0)
10431047
{
10441048
applyScreenMode(ScreenMode::NOSCANLINE_8_7);
1045-
menu(NES_FILE_ADDR, ErrorMessage, isFatalError); // never returns, but reboots upon selecting a game
1049+
menu(NES_FILE_ADDR, ErrorMessage, isFatalError, showSplash); // never returns, but reboots upon selecting a game
10461050
}
10471051
printf("Now playing: %s\n", selectedRom);
10481052
romSelector_.init(NES_FILE_ADDR);
10491053
InfoNES_Main();
10501054
selectedRom[0] = 0;
1055+
showSplash = false;
10511056
}
10521057

10531058
return 0;

0 commit comments

Comments
 (0)