Skip to content

Commit 29cbbcb

Browse files
committed
Update PORTING.md to add very basic code patching insructions
1 parent 8ac2f3d commit 29cbbcb

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

PORTING.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- [Prerequisites](#prerequisites)
33
- [Targets](#targets)
44
- [Porting](#porting)
5+
- [Patching](#patching)
56

67

78
# Introduction
@@ -90,15 +91,15 @@ ESP-IDF provides a tool to edit it, namely `menuconfig`, but to use it in retro-
9091

9192
1. Build the launcher for your target (this will make sure you have the correct ESP32 board selected and generate a default sdkconfig)
9293
- `./rg_tool.py clean`
93-
- `./rg_tool.py --target <targetname> build launcher`
94+
- `./rg_tool.py --target my-target build launcher`
9495
2. Enter the launcher directory: `cd launcher`
9596
3. Run `idf.py menuconfig` and make the changes that you need. Make sure to save the changes and exit.
9697
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)
9798
- `cd ..`
98-
- `./rg_tool.py --target <targetname> run launcher`
99+
- `./rg_tool.py --target my-target run launcher`
99100
5. When you're satisfied, copy the `sdkconfig` file from the launcher to the target folder, so that it's used by all apps
100101
- `cd ..`
101-
- `mv -f launcher/sdkconfig components/retro-go/targets/<targetname>/sdkconfig`
102+
- `mv -f launcher/sdkconfig components/retro-go/targets/my-target/sdkconfig`
102103

103104
Note that any time you modify your target's `sdkconfig` file, you must run `./rg_tool.py clean` to ensure it will be applied.
104105

@@ -109,3 +110,18 @@ Change the target board in `env.py` to match yours
109110

110111

111112
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`**
113+
114+
115+
## Patching
116+
117+
Not everything can be done through `config.h`. Sometimes you have to patch retro-go to add special code for your hardware. Any such modification will be harder to upstream, if that is your goal, but they are easy to perform.
118+
119+
The build system automatically defines a constant for the target in use, eg `RG_TARGET_MY_TARGET` if your target is named `my-target` (the name is capitalized and `-` is replaced with `_`).
120+
121+
Anywhere in retro-go you can add code wrapped in a #ifdef block that will apply only to your target:
122+
123+
````c
124+
#ifdef RG_TARGET_MY_TARGET
125+
// do stuff
126+
#endif
127+
````

0 commit comments

Comments
 (0)