Skip to content

Commit 75d8594

Browse files
committed
Merge branch 'master' into dev
2 parents 7a1a63b + ba84bfc commit 75d8594

File tree

2 files changed

+118
-1
lines changed

2 files changed

+118
-1
lines changed

PORTING.md

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Porting Retro-Go
2+
This document describes the process of adding support for a new ESP32 device (what retro-go calls a *target*).
3+
4+
5+
6+
# Prerequisites
7+
You will need a working installation of [esp-idf](https://docs.espressif.com/projects/esp-idf/en/release-v4.3/esp32/get-started/index.html#get-started-get-prerequisites). Versions 4.3 to 5.2 are supported.
8+
9+
10+
Before using your own patch of retro-go, make a clean build of retro go using bare configurations
11+
```
12+
./rg_tool.py build-img launcher --target esp32s3-devkit-c
13+
```
14+
15+
Since we aren't using other setups, like ODROID-GO, we will be building `.img` files, not `.fw`. Use `./rg_tool.py build-img` to build imgs.
16+
17+
18+
**Make sure a basic setup is working before continuing to patch the code for your setup**
19+
20+
If it doesn't, refer to [BUILDING.md](BUILDING.md). Also check your `esp-idf` installation and make sure you have it set up in your environment (run `idf.py --version` to check)
21+
```
22+
./rg_tool.py build-img launcher --target esp32s3-devkit-c
23+
```
24+
25+
# Patching
26+
Retro-Go uses reusable hardware components, so it is easy to set it up for your own hardware.
27+
28+
29+
You will find the targets (configs for each device) in `components/retro-go/targets`
30+
31+
32+
To make a base one, copy `esp32s3-devkit-c` and rename it.
33+
34+
35+
## config.h
36+
37+
38+
`config.h` has the bulk of your configurations.
39+
40+
41+
First, change `RG_TARGET_NAME` to match the name of your target folder.
42+
43+
44+
45+
46+
Most of it, you will need to figure out the correct parameters for (eg. Storage and Audio)
47+
48+
**Display**
49+
50+
If you aren't using the ILI9341 screen driver, you will need to change the `SCREEN_DRIVER` parameter. (Otherwise, just change the following settings and continue).
51+
52+
53+
(You will find more display configuration in the `SPI Display` section below)
54+
55+
56+
For now, only the ILI9341 is included. Increment the number. Then in `components/retro-go/rg_display.c`, find this part
57+
```
58+
#if RG_SCREEN_DRIVER == 0 /* ILI9341 */
59+
#include "drivers/display/ili9341.h"
60+
#elif RG_SCREEN_DRIVER == 99
61+
#include "drivers/display/sdl2.h"
62+
#else
63+
#include "drivers/display/dummy.h"
64+
#endif
65+
```
66+
67+
68+
Add a `#elif` for your SCREEN_DRIVER. In the body, use `#include "drivers/display/(YOUR DISPLAY DRIVER).h"` (eg. `st7789.h`).
69+
70+
71+
You will need to create that file for your display. Unfortunately, there is no one-for-all way to make this. It will need the same template as the other display drivers there, but it will differ for each display. To start, check the Retro-Go issues on GitHub and try searching on Google.
72+
73+
74+
Make this driver in `components/retro-go/drivers/display`
75+
76+
77+
___
78+
**Input**
79+
80+
Back in `config.h`, you will see the configuration for an I2C gamepad. If you aren't using that, you can make your own parameters based on the existing input forms in `components/retro-go/rg_input.c`
81+
82+
83+
You can also write your own input driver for unique input forms. Just look at the existing code in `rg_input.c` and match that
84+
85+
86+
87+
88+
### sdkconfig
89+
`sdkconfig` is used by ESP-IDF to build the code for the ESP32 itself. It is hard to manually write it all out, so you can use `menuconfig`
90+
91+
92+
For this, go back to your root folder. Build the launcher for your target (this will make sure you have the correct ESP32 board selected).
93+
```
94+
./rg_tool.py clean
95+
./rg_tool.py build launcher --target (YOUR TARGET)
96+
```
97+
98+
99+
Then `cd` into `launcher` and run `idf.py menuconfig`. Navigate to Serial Flasher Config and adjust it all to your board. Make sure to save the changes and exit.
100+
101+
102+
Use this generated sdkconfig in your target with
103+
```
104+
cd ..
105+
mv -f launcher/sdkconfig components/retro-go/targets/retrotoids/sdkconfig
106+
```
107+
This will configure ESP-IDF to run on your board
108+
109+
110+
### env.py
111+
112+
113+
Change the target board in `env.py` to match yours
114+
115+
116+
After completing all these steps, you should be able to build your apps with `rg_tool`. See [BUILDING.md](BUILDING.md#flashing-an-image-for-the-first-time) for more info about this and flashing. **Make sure to use the steps for `.img`, NOT `.fw`**
117+

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ optimized to reduce their cpu, memory, and flash needs without reducing compatib
5454

5555
### Generic ESP32
5656
This method is intended to be used when .fw support isn't available (when [porting to a new device](PORTING.md)) or undesirable (devices with smaller flash).
57-
1. Build a .img file (refer to [Building Retro-Go](#building) below)
57+
1. Build a .img file (refer to [Building Retro-Go](BUILDING.md))
5858
2. Flash the image: `esptool.py write_flash --flash_size detect 0x0 retro-go_*.img`
5959
_Note: Your particular device may require extra steps (like holding a button during power up), different esptool flags, or modifying base.sdkconfig._
6060

0 commit comments

Comments
 (0)