+if(sys.argv[1]=="flash"):
+ f = sys.argv[2];
+ start=0x0000;
+ stop=0x100000; #TODO, adjust this by the JEDEC size parameter.
+ if(len(sys.argv)>3):
+ start=int(sys.argv[3],16);
+ if(len(sys.argv)>4):
+ stop=int(sys.argv[4],16);
+
+ print "Flashing code from %06x to %06x with %s." % (start,stop,f);
+ file = open(f, mode='rb')
+
+ i=start;
+ bytes=file.read();
+ while i<=stop:
+ client.SPIpokebyte(i,ord(bytes[i]));
+
+ i+=1;
+ if(i%0x100==0):
+ print "Flashed %06x."%i;
+ file.close()
+
+