Skip to content

Code-And-Go: Close But No Cigar

March 3, 2016

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
    from cStringIO import StringIO
    from StringIO import StringIO
from xmodem import XMODEM, CRC
from time import sleep
import os
print "File Size is",fileSize
def readUntil(char = None):
    def serialPortReader():
        while True:
            tmp =
            if not tmp or (char and char == tmp):
            yield tmp
    return ''.join(serialPortReader())

def getc(size, timeout=1):
def putc(data, timeout=1):
    global xCount
    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,
#toggle RTS to reset the Z80 then wait for the bootloader

stream = open('C:\\Users\\bill\\Documents\\olduinoz\\z88dk\\helloworld\\a_code.bin','rb')
print XMODEM(getc, putc).send(stream, quiet = 1)

From → Olduino/Z

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: