// BootLoad.java: bootstrap program for loading code into HC11 // // Fred Martin / computer science / UML // Thu Oct 10 01:22:26 2002 // updated Sat Oct 4 13:46:39 2003 import java.io.*; class BootLoad { private static Serial s; private static File f; public static void main(String[] argv) { setup(argv); // select serial port and init Serial object System.out.println("Using serial port " + s.getPortName()); byte[] buf = ReadRel.read(f); System.out.println("Serial port is open. Turn on HC11 and press to continue..."); try { System.in.read(); } catch (Exception e) { e.printStackTrace(); } System.out.println("Writing to serial line..."); try { s.put(0xff); // send baud rate detect byte s.put(buf); // dump 512 bytes to serial port } catch (Exception e) { e.printStackTrace(); } s.flush(); // make sure all chars get out before exiting s.close(); System.out.println("done."); } private static void setup(String[] args) { if (args.length < 2) { System.out.println("Usage: BootLoad filename[.rel] serial-port"); System.out.println("Loads a .rel object file into 68HC11E1's 512 bytes of RAM\n"); s = new Serial(); String[] ports=s.portsAvailable(); int nPorts= ports.length; System.out.println("Available ports are:"); for (int i=0; i< nPorts; i++) { System.out.println(" " + ports[i] + " "); } System.out.println(); System.exit(0); } String fn = args[0]; if (!fn.endsWith(".rel")) fn = fn + ".rel"; f = new File(fn); if (!f.exists()) { System.out.println("File " + f + " does not exist. Sorry."); System.exit(1); } if (!f.canRead()) { System.out.println("File " + f + " exists, but I can't read it. Sorry."); System.exit(1); } s = new Serial(args[1]); } }