Code-And-Go: Close But No Cigar
With the original 1802 Olduino I have quite a sweet coding setup. I use TextPad as my editor and I have one of its ‘tool’ buttons fitted out to run LCC1802 and another one to load the 1802:click, click, and it’s done. For the Olduino/Z I’m also using TextPad and I can compile with one button but loading the Z80 is a bit trickier.
The 1802 bootloads courtesy of an AVR chip that talks to avrdude on windows so my TextPad tool button just invokes avrdude which handles the rest.
The Olduino/Z is using Josh Bensadon’s monitor in ROM which has xmodem built in and I’ve modified it so that when it starts it looks for an xmodem transmission – if it doesn’t see it within a couple of seconds, it runs the program which is already loaded in ram. So the workflow is:
- compile using the textpad tool
- start PuTTY or switch to it if it’s already running
- click the ExtraPuTTY file-transfer menu, select xmodem send, navigate to the location of the binary and select it.
- Physically click the reset button on the Olduino/Z so the bootloader runs and does the job.
It’s not horrible because at least I end up in PuTTY which is where I usually want to be but it does get old clicking around and it can be inconvenient to reach for the reset button if the Olduino/Z is connected to something else.
ExtraPuTTY is supposed to have some scripting tools but I just can NOT figure out the documentation or follow the Q&A on Stack Exchange so I’ve resorted to Python.
Python has an xmodem module so I’m able to make a simple xmodem sender as included below. I’ve hard coded the comm port and file name in it but that’s just a small matter of programming. The bootloader runs and loads the code into the Z80 and it starts but when I switch to, or start, the terminal program the bootloader runs again. Looking at the RTS line I can see it going low briefly when PuTTY starts. I’ve tried other programs and they all seem to do it.
Maybe the real problem is that the Olduino/Z’s bootloader is more intrusive but I’m pretty sure with the 1802 I can switch from the completed avrdude to my terminal program without it resetting a second time. If I have an 1802 with me here I’ll try to verify that tomorrow.
import serial try: from cStringIO import StringIO except: from StringIO import StringIO from xmodem import XMODEM, CRC from time import sleep import os fileSize=os.path.getsize('C:\\Users\\bill\\Documents\\olduinoz\\z88dk\\helloworld\\a_code.bin') print "File Size is",fileSize def readUntil(char = None): def serialPortReader(): while True: tmp = port.read(1) if not tmp or (char and char == tmp): break yield tmp return ''.join(serialPortReader()) def getc(size, timeout=1): return port.read(size) xCount=0 def putc(data, timeout=1): global xCount xCount=xCount+1 port.write(data) print("block %d(%d)" % (xCount,len(data))) sleep(0.001) # give device time to send ACK #Main program starts here - open the serial port port = serial.Serial(port='COM3',parity=serial.PARITY_NONE,bytesize=serial.EIGHTBITS, stopbits=serial.STOPBITS_ONE,timeout=5,xonxoff=0, rtscts=0,dsrdtr=0,baudrate=9600) #toggle RTS to reset the Z80 then wait for the bootloader port.setRTS(False) port.setRTS(True) readUntil(CRC) stream = open('C:\\Users\\bill\\Documents\\olduinoz\\z88dk\\helloworld\\a_code.bin','rb') print XMODEM(getc, putc).send(stream, quiet = 1) stream.close()