You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: PORTING.md
+34-30Lines changed: 34 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,13 @@ This document describes the process of adding support for a new ESP32 device (wh
11
11
12
12
13
13
# Prerequisites
14
-
Before doing anything, make sure that your development environment is working properly and that you can build retro-go for the default target. Please read [BUILDING.md](BUILDING.md) carefully for more information.
14
+
15
+
## Hardware prerequisites
16
+
Retro-Go will run on any device that use an esp32 chip (including variants like s2, s3, p4), as long as it has PSRAM (also called SPIRAM or external RAM). You will also need a serial cable (most esp32 devices expose the serial interface over USB).
17
+
18
+
19
+
## Software prerequisites
20
+
You will need a working installation of esp-idf. Retro-Go supports many versions, refer to [BUILDING.md](BUILDING.md) for more information. If you are new to esp-idf/esp32 development, you might want to try flashing a few sample programs to your device to make sure that everything works, before attempting a complicated project like retro-go.
15
21
16
22
17
23
# Targets
@@ -34,69 +40,67 @@ To get started, locate a target that is the most similar to your device and use
34
40
35
41
### config.h
36
42
37
-
This file contains the bulk of your configurations.
38
-
39
-
First, change `RG_TARGET_NAME` to match the name of your target folder.
43
+
This file contains the bulk of your configurations. There is currently no exhaustive documentation of all the options you can define in this file, but you can refer to odroid-go's config.h that contains most of them.
40
44
41
-
Most of it, you will need to figure out the correct parameters for (eg. Storage and Audio)
45
+
Don't forget to change `RG_TARGET_NAME`to match the name of your target folder.
42
46
47
+
#### Display
43
48
44
-
##### Display
49
+
Retro-Go has a single output driver: ILI9341/ST7789. Thankfully most screens out there use this controller!
45
50
46
-
If you aren't using the ILI9341/ST7789 screen driver, you will need to change the `SCREEN_DRIVER` parameter. (Otherwise, just change the following settings and continue).
51
+
You will need to define the correct pinout (RG_GPIO_LCD_*) and the corrent init sequence (RG_SCREEN_INIT). To find the required sequence of commands you can refer to other example code meant for your display/device.
47
52
48
53
49
-
(You will find more display configuration in the `SPI Display` section below)
54
+
If you aren't using the ILI9341/ST7789 screen driver, you will need to write your own.
50
55
56
+
You can clone `components/retro-go/drivers/ili9341.h` to use as a starting point. Don't forget to add it to the top of `rg_display.c`:
51
57
52
-
For now, only the ILI9341/ST7789 driver is included. Increment the number. Then in `components/retro-go/rg_display.c`, find this part
53
-
```
58
+
```c
54
59
#if RG_SCREEN_DRIVER == 0 /* ILI9341/ST7789 */
55
60
#include "drivers/display/ili9341.h"
61
+
#elif RG_SCREEN_DRIVER == 2 // <--
62
+
#include "drivers/display/my-driver.h" // <--
56
63
#elif RG_SCREEN_DRIVER == 99
57
64
#include "drivers/display/sdl2.h"
58
65
#else
59
66
#include "drivers/display/dummy.h"
60
67
#endif
61
68
```
62
69
70
+
#### Input
63
71
64
-
Add a `#elif` for your RG_SCREEN_DRIVER. In the body, use `#include "drivers/display/(YOUR DISPLAY DRIVER).h"` (eg. `ssd1306.h`).
65
-
66
-
67
-
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.
68
-
69
-
70
-
Make this driver in `components/retro-go/drivers/display`
71
-
72
-
73
-
##### Input
74
-
75
-
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`
76
-
72
+
Retro-Go has five input drivers:
73
+
- GPIO: This is a button connected to a pin of the esp32
74
+
- ADC: This is usually used with a voltage divider to put multiple buttons on a single esp32 pin
75
+
- I2C: Also known as a GPIO extender, retro-go supports many chips (AW9523, PCF9539, MCP23017, PCF8575)
76
+
- Shift register: Like a SNES controller or a 74HC165
77
+
- Virtual: If your device doesn't have enough button, you can map combos to the missing keys. eg start+select = menu
77
78
78
-
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
79
+
You can combine any of them by defining the appropriate `RG_GAMEPAD_*_MAP` in your `config.h`. Refer to `rg_input.h` or other targets to see how configuration is done.
79
80
80
81
81
82
### sdkconfig
82
83
83
84
This file is used by ESP-IDF to build the code for the ESP32 itself.
84
85
85
86
Retro-Go, for the most part, doesn't care about the sdkconfig and its content will depend entirely the chip/board used. But there are things that you should keep in mind:
86
-
- The main task stack size has to be at least 8KB for retro-go
87
-
- The CPU frequency should be set to the maximum possible and power management be disabled
88
-
- SPIRAM should be enabled and configured correctly for your device
87
+
- The main task stack size has to be at least 8KB for retro-go ([CONFIG_ESP_MAIN_TASK_STACK_SIZE](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/kconfig-reference.html#config-esp-main-task-stack-size))
88
+
- The CPU frequency should be set to the maximum possible and power management be disabled ([CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/kconfig-reference.html#config-esp-default-cpu-freq-mhz), [CONFIG_PM_ENABLE](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/kconfig-reference.html#config-pm-enable))
89
+
- SPIRAM should be enabled and configured correctly for your device ([CONFIG_SPIRAM_\*](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/kconfig-reference.html#esp-psram))
90
+
- Flash and SPIRAM speed should be set to the maximum supported by your device ([CONFIG_ESPTOOLPY_FLASHFREQ](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/kconfig-reference.html#config-esptoolpy-flashfreq), [CONFIG_SPIRAM_SPEED](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/kconfig-reference.html#config-spiram-speed))
91
+
- Long filenames support should be enabled in FATFS ([CONFIG_FATFS_LFN_HEAP](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/kconfig-reference.html#config-fatfs-long-filenames))
92
+
- UTF-8 support should be enabled in FATFS ([CONFIG_FATFS_API_ENCODING_UTF_8](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/kconfig-reference.html#config-fatfs-api-encoding))
89
93
90
-
ESP-IDF provides a tool to edit it, namely `menuconfig`, but to use it in retro-go you must follow the following steps:
94
+
ESP-IDF provides a tool to edit it, namely `idf.py menuconfig`, but to use it in retro-go you must follow the following steps:
91
95
92
96
1. Build the launcher for your target (this will make sure you have the correct ESP32 board selected and generate a default sdkconfig)
93
97
-`./rg_tool.py clean`
94
-
-`./rg_tool.py --targetmy-target build launcher`
98
+
-`./rg_tool.py --target=my-target build launcher`
95
99
2. Enter the launcher directory: `cd launcher`
96
100
3. Run `idf.py menuconfig` and make the changes that you need. Make sure to save the changes and exit.
97
101
4. Optionally test the app with the new config (but do NOT run `rg_tool.py clean` at this point, your new config will be deleted)
98
102
-`cd ..`
99
-
-`./rg_tool.py --targetmy-target run launcher`
103
+
-`./rg_tool.py --target=my-target run launcher`
100
104
5. When you're satisfied, copy the `sdkconfig` file from the launcher to the target folder, so that it's used by all apps
0 commit comments