Skip to content

Commit 707700f

Browse files
committed
Merging PORTING.md from dev branch
1 parent 619e713 commit 707700f

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

PORTING.md

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ This document describes the process of adding support for a new ESP32 device (wh
1111

1212

1313
# 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.
1521

1622

1723
# Targets
@@ -34,69 +40,67 @@ To get started, locate a target that is the most similar to your device and use
3440

3541
### config.h
3642

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.
4044

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.
4246

47+
#### Display
4348

44-
##### Display
49+
Retro-Go has a single output driver: ILI9341/ST7789. Thankfully most screens out there use this controller!
4550

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.
4752

4853

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.
5055

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`:
5157

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
5459
#if RG_SCREEN_DRIVER == 0 /* ILI9341/ST7789 */
5560
#include "drivers/display/ili9341.h"
61+
#elif RG_SCREEN_DRIVER == 2 // <--
62+
#include "drivers/display/my-driver.h" // <--
5663
#elif RG_SCREEN_DRIVER == 99
5764
#include "drivers/display/sdl2.h"
5865
#else
5966
#include "drivers/display/dummy.h"
6067
#endif
6168
```
6269

70+
#### Input
6371

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
7778

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.
7980

8081

8182
### sdkconfig
8283

8384
This file is used by ESP-IDF to build the code for the ESP32 itself.
8485

8586
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))
8993

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:
9195

9296
1. Build the launcher for your target (this will make sure you have the correct ESP32 board selected and generate a default sdkconfig)
9397
- `./rg_tool.py clean`
94-
- `./rg_tool.py --target my-target build launcher`
98+
- `./rg_tool.py --target=my-target build launcher`
9599
2. Enter the launcher directory: `cd launcher`
96100
3. Run `idf.py menuconfig` and make the changes that you need. Make sure to save the changes and exit.
97101
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)
98102
- `cd ..`
99-
- `./rg_tool.py --target my-target run launcher`
103+
- `./rg_tool.py --target=my-target run launcher`
100104
5. When you're satisfied, copy the `sdkconfig` file from the launcher to the target folder, so that it's used by all apps
101105
- `cd ..`
102106
- `mv -f launcher/sdkconfig components/retro-go/targets/my-target/sdkconfig`

0 commit comments

Comments
 (0)