Skip to content

Commit 7cb0336

Browse files
Add ESP32 port
1 parent c56ff9e commit 7cb0336

File tree

20 files changed

+1317
-31
lines changed

20 files changed

+1317
-31
lines changed

.github/workflows/build.yml

Lines changed: 88 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,37 @@ name: Build
33
on: [push, pull_request]
44

55
jobs:
6-
build-binary:
6+
build-kernel:
7+
runs-on: ubuntu-latest
8+
container:
9+
image: devkitpro/devkitarm:20250102
10+
11+
steps:
12+
- name: Checkout udpih
13+
uses: actions/checkout@v4
14+
with:
15+
path: udpih
16+
17+
- name: Build arm_kernel code
18+
run: |
19+
cd $GITHUB_WORKSPACE/udpih
20+
make arm_kernel
21+
22+
- name: Upload arm_kernel code
23+
uses: actions/upload-artifact@v4
24+
with:
25+
name: udpih-arm_kernel
26+
path: ${{github.workspace}}/udpih/arm_kernel/arm_kernel.bin.h
27+
if-no-files-found: error
28+
29+
build-pico:
30+
needs: build-kernel
731
runs-on: ubuntu-latest
832
steps:
933
- name: Checkout udpih
1034
uses: actions/checkout@v4
1135
with:
1236
path: udpih
13-
submodules: recursive
1437

1538
- name: Checkout pico-sdk
1639
uses: actions/checkout@v4
@@ -24,11 +47,11 @@ jobs:
2447
run: |
2548
sudo apt install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
2649
27-
- name: Build arm_kernel code
28-
run: |
29-
cd ${{github.workspace}}/udpih
30-
docker build -t udpihbuilder .
31-
docker run --rm -v ${PWD}:/project udpihbuilder make arm_kernel
50+
- name: Download arm_kernel code
51+
uses: actions/download-artifact@v4
52+
with:
53+
name: udpih-arm_kernel
54+
path: ${{github.workspace}}/udpih/arm_kernel
3255

3356
- name: Build pico code
3457
run: |
@@ -38,9 +61,65 @@ jobs:
3861
3962
- uses: actions/upload-artifact@v4
4063
with:
41-
name: udpih
64+
name: udpih-pico
4265
path: |
43-
${{github.workspace}}/udpih/arm_kernel/arm_kernel.bin.h
4466
${{github.workspace}}/udpih/pico/build_rp2040/udpih.uf2
4567
${{github.workspace}}/udpih/pico/build_rp2350/udpih.uf2
4668
if-no-files-found: error
69+
70+
build-esp32:
71+
needs: build-kernel
72+
runs-on: ubuntu-latest
73+
steps:
74+
- name: Checkout udpih
75+
uses: actions/checkout@v4
76+
with:
77+
path: udpih
78+
79+
- name: Checkout ESP-IDF
80+
uses: actions/checkout@v4
81+
with:
82+
repository: espressif/esp-idf
83+
ref: master
84+
path: esp-idf
85+
submodules: recursive
86+
87+
- name: Setup ESP-IDF
88+
run: |
89+
sudo apt-get install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
90+
cd ${{github.workspace}}/esp-idf
91+
./install.sh
92+
93+
- name: Download arm_kernel code
94+
uses: actions/download-artifact@v4
95+
with:
96+
name: udpih-arm_kernel
97+
path: ${{github.workspace}}/udpih/arm_kernel
98+
99+
- name: Build ESP32-S2 code
100+
run: |
101+
cd ${{github.workspace}}/udpih/esp32
102+
. ${{github.workspace}}/esp-idf/export.sh
103+
idf.py -B build_esp32-s2 set-target esp32s2
104+
idf.py -B build_esp32-s2 build
105+
106+
- name: Build ESP32-S3 code
107+
run: |
108+
cd ${{github.workspace}}/udpih/esp32
109+
. ${{github.workspace}}/esp-idf/export.sh
110+
idf.py -B build_esp32-s3 set-target esp32s3
111+
idf.py -B build_esp32-s3 build
112+
113+
- uses: actions/upload-artifact@v4
114+
with:
115+
name: udpih-esp32
116+
path: |
117+
${{github.workspace}}/udpih/esp32/build_esp32-s2/flash_args
118+
${{github.workspace}}/udpih/esp32/build_esp32-s2/udpih.bin
119+
${{github.workspace}}/udpih/esp32/build_esp32-s2/bootloader/bootloader.bin
120+
${{github.workspace}}/udpih/esp32/build_esp32-s2/partition_table/partition-table.bin
121+
${{github.workspace}}/udpih/esp32/build_esp32-s3/flash_args
122+
${{github.workspace}}/udpih/esp32/build_esp32-s3/udpih.bin
123+
${{github.workspace}}/udpih/esp32/build_esp32-s3/bootloader/bootloader.bin
124+
${{github.workspace}}/udpih/esp32/build_esp32-s3/partition_table/partition-table.bin
125+
if-no-files-found: error

Dockerfile

Lines changed: 0 additions & 5 deletions
This file was deleted.

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Exploits the Wii U's USB Host Stack descriptor parsing. Pronounced like "mud pie
1515
- Raspberry Pi Pico (W) / Pico 2 (W)
1616
- Raspberry Pi Zero (W) / A / A+ / Zero 2 W / 4 / 5
1717
- Steam Deck
18+
- Espressif ESP32 S2 / S3
1819
- Nintendo Switch capable of running [udpih_nxpayload](https://github.com/GaryOderNichts/udpih_nxpayload)
1920

2021
## Instructions
@@ -23,6 +24,7 @@ Follow the setup guide for the device you want to use below:
2324
- [Raspberry Pi Pico / Pico 2](./docs/setup-pico.md)
2425
- [Raspberry Pi Zero (W) / A / A+ / Zero 2 W / 4 / 5](./docs/setup-linux.md)
2526
- [Steam Deck](./docs/setup-linux.md)
27+
- [Espressif ESP32 S2 / S3](./docs/setup-esp32.md)
2628
- [Nintendo Switch](https://github.com/GaryOderNichts/udpih_nxpayload#Instructions)
2729

2830
### Booting the recovery_menu
@@ -40,18 +42,17 @@ Follow the setup guide for the device you want to use below:
4042
If you get no video output or a distorted screen, your timing was most likely wrong.
4143
- After a few seconds you should be in the recovery menu.
4244

45+
> [!NOTE]
46+
> If your console turns off after performing the exploit, the `recovery_menu` file couldn't be loaded from your Wii U's SD Card.
47+
4348
Check out the [recovery_menu README](https://github.com/GaryOderNichts/recovery_menu) for more information about this menu.
4449

4550
## Building
46-
```bash
47-
# build the docker container
48-
docker build -t udpihbuilder .
51+
Building the kernel code requires devkitARM. Device specific instructions can be found in the documentation.
4952

50-
# build the pico code
51-
docker run -it --rm -v ${PWD}:/project udpihbuilder make pico
52-
53-
# to only build the arm kernel code
54-
docker run -it --rm -v ${PWD}:/project udpihbuilder make arm_kernel
53+
```bash
54+
# only build the arm kernel code
55+
make arm_kernel
5556
```
5657

5758
**Special thanks to Maschell, rw-r-r-0644, QuarkTheAwesome, vgmoose, exjam, dimok789, and everyone else who contributed to the Wii U scene!**

common/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ typedef struct udpih_device {
7878
int state;
7979
} udpih_device_t;
8080

81-
int device_bind(udpih_device_t* device, uint16_t maxpacket);
81+
int device_bind(udpih_device_t* device, uint8_t maxpacket);
8282

8383
int device_setup(udpih_device_t* device, const struct usb_ctrlrequest* ctrlrequest, uint8_t* buf, bool high_speed);

common/device.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ static const struct usb_config_descriptor config_descriptor = {
252252
.bMaxPower = 50,
253253
};
254254

255-
int device_bind(udpih_device_t* device, uint16_t maxpacket)
255+
int device_bind(udpih_device_t* device, uint8_t maxpacket)
256256
{
257-
device_descriptor.bMaxPacketSize0 = cpu_to_le16(maxpacket);
257+
device_descriptor.bMaxPacketSize0 = maxpacket;
258258

259259
return 0;
260260
}
@@ -309,6 +309,7 @@ int device_setup(udpih_device_t *device, const struct usb_ctrlrequest *ctrlreque
309309
const uint32_t descriptor5_size = 0x40 * 3;
310310
const uint32_t descriptor6_size = 0x2380; // <- point into the middle of the pEp0DmaBuf
311311

312+
// uhs quirk, uhs uses wIndex instead of the index field in wValue for descriptor indices
312313
switch (wIndex) {
313314
case 0:
314315
if (wLength == sizeof(config_descriptor)) {

docs/setup-esp32.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# ESP32
2+
## Instructions
3+
- Download the latest `udpih_esp32-s2.zip` for the ESP32-S2, or `udpih_esp32-s3.zip` for the ESP32-S3, from the [releases page](https://github.com/GaryOderNichts/udpih/releases).
4+
Other chips don't support USB-OTG or the esp32sx driver, and are not supported.
5+
- Extract the `.bin` files to a folder on your PC. Then open a terminal session (or command prompt in Windows) and navigate to that folder.
6+
- To install UDPIH on your board, you need to have esptool installed. You can download the esptool tool from the [github repo](https://github.com/espressif/esptool) or by running `pip install esptool`.
7+
- Hold down the `BOOT` button on the board and plug it into your PC.
8+
9+
You can now run the following command to flash UDPIH to the board:
10+
11+
> [!NOTE]
12+
> The `-p xxx` argument needs to be adjusted, depending on your operation system.
13+
> For Linux this will be something like `/dev/ttyACM0`.
14+
> For macOS `/dev/cu.usbmodem111101`.
15+
> For Windows use the correct COMxxx port.
16+
17+
### ESP32-S2
18+
```
19+
esptool --chip esp32s2 -p xxx --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size detect 0x1000 bootloader.bin 0x10000 udpih.bin 0x8000 partition-table.bin
20+
```
21+
22+
### ESP32-S3
23+
```
24+
esptool --chip esp32s3 -p xxx --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size detect 0x0 bootloader.bin 0x10000 udpih.bin 0x8000 partition-table.bin
25+
```
26+
27+
You can now disconnect the board from the PC. Make sure to use the dedicated USB port on the board for connecting to the Wii U.
28+
If you power the board externally, you need to reset the board after every UDPIH run.
29+
30+
The board is now flashed and can be used for udpih. Continue with ["Booting the recovery_menu"](../README.md#booting-the-recovery_menu).
31+
32+
## Building from source
33+
Make sure to set up the latest [ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/index.html).
34+
35+
Download the latest `arm_kernel.bin.h` from the [releases page](https://github.com/GaryOderNichts/udpih/releases) and copy it to the `arm_kernel` directory (or build it from source).
36+
You can also simply run:
37+
```bash
38+
curl -L https://github.com/GaryOderNichts/udpih/releases/latest/download/arm_kernel.bin.h > arm_kernel/arm_kernel.bin.h
39+
```
40+
41+
Run `idf.py set-target esp32s2` or `idf.py set-target esp32s3` depending on the target you are building for.
42+
43+
When building the ESP32 code from source, the RGB LED can be enabled for feedback (if the board has one).
44+
Run `idf.py menuconfig` and navigate to `UDPIH Configuration`. There you can enable the LED and set the GPIO number for your board.
45+
46+
To build the binary run `idf.py build`. Then you can flash UDPIH to your board using `idf.py -p PORT flash`.
47+
Replace `PORT` with your ESP32 board's USB port name. See the [ESP-IDF Programming Guide](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/index.html#build-your-first-project) for more information.

docs/setup-linux.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Some devices require additional setup for UDPIH to work. Click on the device you
77

88
> :information_source: For the Pi Zero and Zero 2 W you will need 2 USB cables, one for powering the Zero and one which can be connected to the Wii U.
99
10-
> :information_source: For the Pi 4 and 5 you need to provide power through the power headers because the USB-C port is the only port the supports USB OTG and must get connected to the Wii U. Unfortunately, when trying to power the Pi over USB-C using the Wii U's USB ports, the Pi doesn't boot fast enough. The USB-A ports do not support USB OTG and cannot be used for this exploit: you **must** connect the USB-C port to the Wii U during the exploit.
10+
> :information_source: For the Pi 4 and 5 you need to provide power through the power headers or use an OTG splitter. This is because the USB-C port is the only port supporting USB OTG, which must get connected to the Wii U. Unfortunately, when trying to power the Pi over USB-C using the Wii U's USB ports, the Pi doesn't boot fast enough.
11+
> The USB-A ports do not support USB OTG and cannot be used for this exploit: You **must** connect the USB-C port to the Wii U during the exploit.
1112
1213
> :information_source: This guide expects that you use Raspberry Pi OS.
1314

docs/setup-pico.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,12 @@
66
- Copy the `.uf2` file to the Pico. It will disconnect after a few seconds.
77

88
The Pico is now flashed and can be used for udpih. Continue with ["Booting the recovery_menu"](../README.md#booting-the-recovery_menu).
9+
10+
## Building from source
11+
1. Set up the [pico-sdk](https://github.com/raspberrypi/pico-sdk).
12+
1. Download the latest `arm_kernel.bin.h` from the [releases page](https://github.com/GaryOderNichts/udpih/releases) and copy it to the `arm_kernel` directory (or build it from source).
13+
You can also simply run:
14+
```bash
15+
curl -L https://github.com/GaryOderNichts/udpih/releases/latest/download/arm_kernel.bin.h > arm_kernel/arm_kernel.bin.h
16+
```
17+
1. Run `make pico`. The built files will be in the `pico/build_*` directories.

esp32/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
build*/
2+
managed_components/
3+
dependencies.lock
4+
sdkconfig
5+
sdkconfig.old

esp32/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
4+
project(udpih)

0 commit comments

Comments
 (0)