Skip to content

DonutShop is an Arduino Nano ESP32 + OTG adapter that changes profiles for the RT4K based on gameID.

License

Notifications You must be signed in to change notification settings

svirant/DonutShop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DonutShop

Donut Shop is an Arduino Nano ESP32 + OTG adapter that changes profiles for the RT4K based on gameID.


See it in action: https://youtu.be/ldbfFbKzjh8

Updates

  • New Web UI!
  • Detection rates have been sped up!
    • Unpowered consoles that are DNS address based, timeout after 7 seconds. This is reduced to 2 seconds after a console's first power up.
      • console DNS addresses will be automatically replaced by IP in order for the 2 second timeout to work.
    • Quickest if IP address is used versus Domain address.

Parts used

gameID devices currently supported

Device Supported Notes
PS1Digital yes, confirmed first hand
N64Digital yes, confirmed first hand
RetroGEM N64 yes
RetroGEM PS1 yes
MemCardPro 2 yes, for GameCube, PS1, & PS2
Fenrir ?
more on the way...

LED activity

Color Blinking On Notes
BLUE WiFi active, querying gameID addresses Longer blinks represent an unsuccessful query of gameID address. Usually a powered off console in the list. After initial power, no blue light means WiFi not found.
GREEN 1 second blink is gameID match found and SVS profile being sent to RT4K
RED Power No way to control as it's hardwired in. May just need to cover with tape.

You can disable the BLUE / GREEN LEDs by commenting out the following lines in the .ino:

 //pinMode(LED_GREEN, OUTPUT);
 //pinMode(LED_BLUE, OUTPUT);

Programming the Arduino Nano ESP32

I recommend the Official Arduino IDE and guide if you're unfamiliar with Arduinos. All .ino files used for programming are listed above. The following Libraries will also need to be added in order to Compile successfully.

  • Libraries:
    • If a Library is missing, it's usually available through the built-in Library Manager under "Tools" -> "Manage Libraries..."
    • <EspUsbHostSerial_FTDI.h> Follow these steps to add EspUsbHostSerial_FTDI.h

To put the Nano ESP32 into programming mode

  • Double-click the button on top right after connecting the usb-c cable. (or triple-click w/o disconnecting)
  • You will see the GREEN led strobe if successful.
  • TLDR is: Because DonutShop takes over the usb port, this resets that.

Additional steps for latest version of DonutShop.ino

Requires you to short the B1 and Gnd pins during one of the steps. This method is the best I got at the moment.

  1. "double click" the physical RST button right after connecting to your PC/Mac to put into "bootloader mode". You'll see the green led strobe if successful.
  2. Open up the DonutShop.ino in the Arduino IDE
  3. In Arduino IDE, under the "Tools" menu, make sure..
  • Board - "Arduino Nano ESP32" selected
  • Port - The listed "Serial" port is chosen, not dfu one.
  • Partition Scheme - "With SPIFFS partition (advanced)" is chosen
  • Pin Numbering - "By Arduino pin (default)"
  • USB Mode - "Normal mode (TinyUSB)"
  • Programmer - "Esptool" is selected
  1. Select the last option in "Tools" menu. "Burn Bootloader"
  2. THIS WILL FAIL the first time. Wait about 15 seconds and then go back and select the new "Serial" port that is available and select "Burn Bootloader" again.
  3. This should successfully burn the bootloader and now your board will have a half red/blue led that is lit.
  4. Disconnect the usb cable and short the B1 pin with the Gnd pin next to it. I used some metal tweezers.

Image

  1. With B1 and Gnd shorted, reconnect the usb cable and the led should now be a solid Green.
  2. Return to the Arduino IDE and select "Sketch", "Upload Using Programmer". Make sure to use THIS option and NOT the normal "Upload" option.
  3. If successful, the sketch will compile and upload leaving you with a message "Hard resetting via RTS pin..."
  4. Disconnect the usb cable and remove the short on B1 and Gnd.
  5. Upon reconnecting the usb cable your board should Successfully boot DonutShop. You should see the blue led return indicating it's connected to WiFi and looking for addresses to connect to. If the blue led does not return, press the RST button and/or make sure you have your WiFi settings correctly entered. Remember, only 2.4GHz wifi is supported.
  6. For all future changes/uploads...
  • The board will always need to be in "bootloader" mode by "double clicking" the RST button right after connecting the usb cable.
  • You can also now return to using the normal "Sketch" -> "Upload" option.

General Setup

For consoles list, quickest if IP address is used versus Domain address:


If you have multiple consoles on when DonutShop is booting, the console furthest down the list wins. If more than 2 consoles are active when one is powered off, the console highest on the list takes over.

There are a multiple moving parts with this setup, and if you have issues, please use the "DonutShop_usb-only-test.ino". More info in the troublehshooting section at the end.

I believe the only library you need to add is a fork of "EspUsbHost"

Go to: https://github.com/wakwak-koba/EspUsbHost

  • Click the GREEN "<> Code" box and "Download ZIP"
  • In the Arudino IDE; goto "Sketch" -> "Include Library" -> "Add .ZIP Library"

Adding gameIDs, Consoles, and other Options

The new Web UI allows you to live update the Consoles and gameID table. You no longer have to reflash for changes. You can also now import and export your config if anything were to happen and you need to rebuild.

The "S0" options are now configurable in the Web UI.

/*
////////////////////
//    OPTIONS    //
//////////////////
*/

bool const VGASerial = false;    // Use onboard TX1 pin to send Serial Commands to RT4K.

bool S0_pwr = false;        // Load "S0_pwr_profile" when all consoles defined below are off. Defined below.

int S0_pwr_profile = -12;    // When all consoles definied below are off, load this profile. set to 0 means that S0_<whatever>.rt4 profile will load.
                                 // "S0_pwr" must be set true
                                 //
                                 // If using a "remote button profile" which are valued 1 - 12, place a "-" before the profile number. 
                                 // Example: -1 means "remote button profile 1"
                                 //          -12 means "remote button profile 12"

bool S0_gameID = true;     // When a gameID match is not found for a powered on console, DefaultProf for that console will load

WiFi setup

ONLY compatible with 2.4GHz WiFi APs. Replace SSID and password with your network's. Make sure to not leave out the " " quotes.

WiFi.begin("SSID","password");

Thank you!

  • Thanks to https://github.com/wakwak-koba for his fork of the EspUsbHost library. Without it, it would have taken much longer to figure out the usb communication bits.
  • Huge thanks to @CielFricker249 / "Aru" on the RetroTink discord for the idea and testing of the Donut Dongle project as well!

TroubleShooting

If only the red status and power led are red, and you can ping the device but not access the web ui, the SPIFFS partition has not been configured. Make sure to follow the steps above to ensure the bootloader has been burned and device flashed properly the first time.

The GREEN and BLUE leds indicate WiFi and usb serial/gameID lookup respectively. This should help diagnose as a first step.

After that, confirm the following:

  • Configured Wifi settings in .ino.
    • Make sure it's to a 2.4GHz Wifi AP. 5GHz is NOT supported by the Arduino Nano ESP32.
  • Have at least 1 gameID to profile in the gameDB
  • Have at least 1 address in the consoles db that you can access with a web browser

If you are sure of these settings, and it still does not work, try the following to test the usb serial connection:

  • Configure your Arduino Nano ESP32 with the provided "DonutShop_usb-only-test.ino". This is configured to only load "remote profile 8".

    • You can change the 8 to 1 - 9 if needed.
  • Verify that everything is connected with your OTG adapter and has power.

  • Press the reset button on top of the Arduino and within a couple of seconds it should load the remote profile.

    If this works, then there must be a wifi connectivity issue somewhere.

    Here is a video of the "usb only test" being performed: https://www.youtube.com/watch?v=XP7OSW7X0DQ

About

DonutShop is an Arduino Nano ESP32 + OTG adapter that changes profiles for the RT4K based on gameID.

Resources

License

Stars

Watchers

Forks

Languages