Author Topic: Serial upload-script for linux v0.1  (Read 3556 times)

0 Members and 1 Guest are viewing this topic.

Offline saturnu

  • ヽ(^o^)丿
  • Hero Member
  • *****
  • Posts: 1182
  • Karma: +156/-0
    • View Profile
    • :D
Serial upload-script for linux v0.1
« on: August 18, 2014, 02:21 PM »
Here is my
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]
#!/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]
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
« Last Edit: August 19, 2014, 12:20 AM by saturnu »