SD2SNES, sending rom over USB?

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
johey
Posts: 8
Joined: Fri Aug 26, 2016 3:42 am

SD2SNES, sending rom over USB?

Post by johey »

My idea is to crossdevelope on pc, sending the resulting rom over USB, resetting the SNES which will instantly run the code. Is this possible with the SD2SNES? As I cannot find any information about it, my guess is unfortunately that this is not yet implemented, or in worst case not even possible with the architecture. I would be very happy for a heads up over the situation.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: SD2SNES, sending rom over USB?

Post by koitsu »

To my knowledge there is no "public" documentation regarding what the USB port can do -- only speculative things stated on forums. "Development" is the only thing that has ever been stated semi-definitively, which is a vague statement in itself.

If you want a definitive answer, then it's possible to get one: ask Krikzz or Ikari.

Otherwise, I would suggest looking around to see if there is something like an "SD card emulator", which would be a piece of hardware with, a USB port (or something) that you'd hook to your PC and manage/maintain through software on there -- and on the other end, an SD card/connector which you'd insert into the SD2SNES. I don't know if something like this exists.

Point: back in the day, console copiers had parallel ports for this purpose, but the software and interface was finicky (I even wrote a LPT transfer utility myself), sometimes working for a few transfers then failing (requiring either a PC reboot or a power-cycle of the copier). So, most of us got used to using floppy disks: assemble code on a PC, copy the resulting .smc to the floppy, eject it, put it in the copier, power-cycle the copier, load the file, see the results, rinse lather repeat.

Today, you have SNES emulators. I suggest using them to make your life easier, then when you get something that seems to be working well on several emulators, try it on actual hardware.
Revenant
Posts: 462
Joined: Sat Apr 25, 2015 1:47 pm
Location: FL

Re: SD2SNES, sending rom over USB?

Post by Revenant »

At one point I got the idea to use WiFi enabled SD cards to do basically the same thing, but never actually tried it. Assuming it actually worked, it would have basically been an expensive novelty compared to just doing most of the testing in an emulator.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: SD2SNES, sending rom over USB?

Post by tokumaru »

I didn't even know Wi-Fi SD cards existed! Can you really send files to them remotely? Or is the Wi-Fi only meant for sharing the contents of the SD card with other devices?
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: SD2SNES, sending rom over USB?

Post by lidnariq »

There's both the plain "wifi in SDIO form factor" thing, which is really more of a wireless card that one interacts with using SPI, as well as things like the EyeFi which will use local flash as a cache and upload things over wifi to some configured server.

I don't remember a thing that's useful in the other direction, equivalent to "here's a windows share on an SD card", but it probably exists.
Revenant
Posts: 462
Joined: Sat Apr 25, 2015 1:47 pm
Location: FL

Re: SD2SNES, sending rom over USB?

Post by Revenant »

Toshiba's FlashAir cards are bidirectional, but I have no idea how well they work otherwise (or would work in a sd2snes).

Back to the actual topic, ikari posted a comment some time ago with some info about future USB functionality, and the already-existing serial UART (that I totally forgot about) here: https://sd2snes.de/blog/archives/370#comment-645752
As for USB, yeah I have something in mind for that but the implementation details are still foggy… I’d like to provide an upload/configuration interface as well as a console that can be used to log things from the SNES side.
If you want to upload by wire right now, you can use the serial UART console. It’s available on the 14-pin header on the side of the board, using the pins marked TX3 and RX3 (there’s a pinout table printed on the PCB). It speaks 3.3V 115200 8N1, no flow control, and supports xmodem uploads. When the sd2snes is running you enable the serial console by sending an ESC character. It prompts you with a ‘> ‘.
Relevant commands are put <filename> and load <filename>.
put <filename> requests an xmodem transfer from your side. It might take a longer time for the transfer to start (~30s) if you don’t respond within three seconds… I’m not sure why. Might as well be some issue with my specific xmodem client…
load <filename> loads a ROM and executes it, returning to the prompt.
The console supports some other commands that might be handy, such as memory reads and writes, and hex dumps (all on sd2snes on-board memory only, no SNES WRAM, sorry ^^)
The sd2snes’s memory sharing technology allows you to read and write memory while your code is running.
There is no command reference at the moment but take a look at cli.c to get an idea: https://github.com/mrehkopf/sd2snes/blo ... /src/cli.c
johey
Posts: 8
Joined: Fri Aug 26, 2016 3:42 am

Re: SD2SNES, sending rom over USB?

Post by johey »

Ok, thank you all! As I suspected, nothing is really implemented yet. UART would be quite slow I suspect, and regarding wifi SD cards, I have never seen one able to receive data (only send). Anyway, for now I was only curious over the USB port and not about other options. For now it seems like it's not usable for what I want to do.
Optiroc
Posts: 129
Joined: Thu Feb 07, 2013 1:15 am
Location: Sweden

Re: SD2SNES, sending rom over USB?

Post by Optiroc »

johey wrote:Ok, thank you all! As I suspected, nothing is really implemented yet. UART would be quite slow I suspect, and regarding wifi SD cards, I have never seen one able to receive data (only send). Anyway, for now I was only curious over the USB port and not about other options. For now it seems like it's not usable for what I want to do.
Ah, that was in response to my question... I never got around to fit a nice little serial interface on my SD2SNES, but since nothing's happened with the USB interface since then maybe it's time now. 115200bps isn't too bad compared to the current alternative for testing a ROM (eject SD from SD2SNES, insert in computer, mount, copy file, eject, insert, navigate to file via the sd2snes interface...). At least not when working with a 64KB image, which is usually enough for testing stuff. Having the serial connection active for some caveman debugging while the code is running is pretty nice as well.

This cable should do the trick, right? PL2303HX-USB-to-TTL-Serial-Cable
Optiroc
Posts: 129
Joined: Thu Feb 07, 2013 1:15 am
Location: Sweden

Re: SD2SNES, sending rom over USB?

Post by Optiroc »

Serial cable and header strip ordered! Thinking about usage, it would indeed be neat to facilitate printing from the SNES side via an MMIO register. Maybe right above the MSU-1 registers at $00-3f:2008/$80-bf:2008. While connected, any bytes written there would simply be printed over the TTY.
User avatar
saturnu
Posts: 23
Joined: Wed Aug 05, 2015 2:22 pm

Re: SD2SNES, sending rom over USB?

Post by saturnu »

Hi, a year ago i patched the sd2snes firmware for usb uploads.
Yesterday i posted a link on another forum and sanni reminded me, that here is an active thread on this topic, too.
It's a good idea to have the USART Adapter connected as well for debug outputs. ^^

Example:

Upload rom + sram - COM4
./usb2snes --device=4 --sram --write --file=myrom.srm
./usb2snes --device=4 --write --file=myrom.smc
./usb2snes --device=4 --boot


Hint:
some games have an additional 512byte backup unit header,
use the --skip option here


greetings, saturnu
Attachments
linux_bin_64bit.zip
linux 64bit static binary
(335.42 KiB) Downloaded 215 times
sd2snes_firmware_v0.1.7c_usb.zip
firmware
(304.7 KiB) Downloaded 244 times
usb2snes_v04_win32.zip
upload tool windows port
(36.13 KiB) Downloaded 214 times
Last edited by saturnu on Tue Aug 30, 2016 1:17 am, edited 2 times in total.
User avatar
saturnu
Posts: 23
Joined: Wed Aug 05, 2015 2:22 pm

Re: SD2SNES, sending rom over USB?

Post by saturnu »

If you still need to upload via USART, here is my old xmodem upload script.

Serial upload-script for linux v0.1

What's needed:
USB to UART with +3.3V TTL Adapter
i'm using a PL-2303HX
http://www.dx.com/p/pl2303hx-usb-to-ttl-converter-module-149859#.U_HgrnWfnIY

Connection:
sd2snes 14-pin-connector 6 (TX3) to uart RX
sd2snes 14-pin-connector 7 (RX3) to uart TX

Howto:
- install the minicom and lrzsz packages

- add user to uucp group
# usermod -a -G uucp saturnu

- relogin the user

- start and config minicom once
115200 8N1
no flowcontrol

- set the script executable
# chmod +x upload.sh

- start the script with filename and device
# ./upload.sh homebrew.sfc /dev/ttyUSB0

- wait until script asks to start the snes
- wait until game starts

upload.sh

Code: Select all

#!/bin/bash

if [[ $# -eq 0 ]] ; then
    echo 'sd2snes uploader script - by saturnu'
    echo 'upload.sh <file> <device>'
    echo 'upload.sh test.smc /dev/ttyUSB0'
    exit 0
fi

TMP_BN=$(basename $1)
TMP_DN=$(dirname $1)

cat xmodem.script | sed -e 's/fname/'$TMP_BN'/' -e "s|path|"$TMP_DN"/|g" > xmodem.tmp

minicom -D $2 -S xmodem.tmp
rm xmodem.tmp


xmodem.script

Code: Select all

verbose on
print "script loaded - please start snes"
sleep 2

expect {
      "ok"
      timeout 10 goto panic
     }

print "\nneed prompt\n"
sleep 1
send "^["


expect {
    ">"
  timeout 10 goto panic
}
print "set filename\n"
send "put fname"

expect {
    "OK, start xmodem transfer now."
}
! sx pathfname

expect {
    ">"
}
send "load fname"

panic:
 ! killall -20 minicom
lint
Posts: 25
Joined: Thu May 15, 2008 4:05 am

Re: SD2SNES, sending rom over USB?

Post by lint »

saturnu wrote:Hi, a year ago i patched the sd2snes firmware for usb uploads.
Yesterday i posted a link on another forum and sanni reminded me, that here is an active thread on this topic, too.
It's a good idea to have the USART Adapter connected as well for debug outputs. ^^
You should do a merge request to integrate it in the official repos.

Thanks anyway, i will test that tonight.

Do you think it might be possible to have a linux / macosx build of usb2snes ?
https://twitter.com/Lint_
http://snesdev.antihero.org/ [depecated blog, new one coming one of these days]
User avatar
saturnu
Posts: 23
Joined: Wed Aug 05, 2015 2:22 pm

Re: SD2SNES, sending rom over USB?

Post by saturnu »

ikari_01 has the firmware patchset and source since about a year now. ^^
he is still busy with other features that have a higher priority for him, like an upcoming wallpaper support. (but it's still on the agenda)
i've already attached a linux 64bit static binary as well.

as the business man says, "in the long run we are all dead". :D
so i decided to release it as an interim solution anyway.


if someone really needs to improve this for personal needs, i can upload the source to my github account. ^^
lint
Posts: 25
Joined: Thu May 15, 2008 4:05 am

Re: SD2SNES, sending rom over USB?

Post by lint »

saturnu wrote:if someone really needs to improve this for personal needs, i can upload the source to my github account. ^^
I would not mind to have access so I can make a osx build. ;)
https://twitter.com/Lint_
http://snesdev.antihero.org/ [depecated blog, new one coming one of these days]
User avatar
saturnu
Posts: 23
Joined: Wed Aug 05, 2015 2:22 pm

Re: SD2SNES, sending rom over USB?

Post by saturnu »

here is the link to the github repo, if you want to compile the upload tool under osx

https://github.com/saturnu/usb2snes
Post Reply