yes, I think you need to specify the full path in this case
Also, looking at the script, here is some code that should allow to use it to erase, write and verify (based on your cmd line)
NOTE THAT IT IS NOT TESTED SO USE IT ON YOUR OWN RISK, but should help you start and experiment
import smt32loader as smtl
# default address and baudrate, but in the script the defaults are set in if name == '_-main__'
# so we need to set up it here
address = 0x08000000
#baudrate = 115200
# default QUITE is 20, but if run the script from cmd and don't supply -V or -q, QUITE=5
# mdebug is commented right now
smtl.QUITE = 5
port = '/dev/ttyAMA0'
bin_file = 'sthdbg.bin' # full path should be here
cmd = smtl.CommandInterface()
cmd.open(port)
# smtl.mdebug(10, "Open port %(port)s, baud %(baud)d" % {'port':port, 'baud':baud})
try:
try:
cmd.initChip()
except:
print "Can't init. Ensure that BOOT0 is enabled and reset device"
bootversion = cmd.cmdGet()
# smtl.mdebug(0, "Bootloader version %X" % bootversion)
id = cmd.cmdGetID()
# smtl.mdebug(0, "Chip id: 0x%x (%s)" % (id, smtl.chip_ids.get(id, "Unknown")))
# data
data = map(lambda c: ord(c), file(bin_file, 'rb').read())
# erase
cmd.cmdEraseMemory()
# write
cmd.writeMemory(address, data)
# verify
verify = cmd.readMemory(address, len(data))
if(data == verify):
print "Verification OK"
else:
print "Verification FAILED"
print str(len(data)) + ' vs ' + str(len(verify))
for i in xrange(0, len(data)):
if data[i] != verify[i]:
print hex(i) + ': ' + hex(data[i]) + ' vs ' + hex(verify[i])
finally:
cmd.releaseChip()
there are at least two parts of the code, that I would write differently - line 31 and the loop in lines 42-44, but that's how it is in the original code