spi-flash-programmer icon indicating copy to clipboard operation
spi-flash-programmer copied to clipboard

Performance

Open userid0x0 opened this issue 5 years ago • 5 comments

Some further improvements

  1. use binary data transmission from the Python script
  2. remove sleep directives Result: Read Performance +30%, Write Performance (+80%)

userid0x0 avatar Apr 11 '19 09:04 userid0x0

I am open for a discussion.

userid0x0 avatar Apr 16 '19 06:04 userid0x0

I like the idea and I'm glad you left the option to read and write using hex in there, but _readPageBinary and _writePageBinary are very similar to _readPage and _writePage -- and those themselves are pretty complex functions, so that's quite a bit of copy paste code. Is there any way to clean that up by extracting the common code?

Also, I'm not in a position to test at the moment, but I think at least the first sleep() (for the bootloader) is required for some boards. Were you able to test on some of the older Arduinos, e.g. a Diecimila?

nfd avatar Apr 18 '19 13:04 nfd

Yes, readPage/writePage and the binary implementations contain lots of duplicate code. I will rework that.

Thanks for the note with 'Diecimila' I wasn't aware of that. Let me dig into the implementation of the reset via DTR. I will do some research if disabling the DTR signal is sufficient or not.

userid0x0 avatar Apr 25 '19 07:04 userid0x0

Thanks, much appreciated! I've just moved and won't have my things for a few weeks, so unfortunately I'm not much help at the moment. :(

nfd avatar Apr 25 '19 07:04 nfd

It looks like the first wait may be required to keep compatibility with older boards. According to https://pyserial.readthedocs.io/en/latest/pyserial_api.html#serial.Serial.open there might be a short glitch on DTR when opening the port. I checked the following sequence

#self.sock = serial.Serial(port, baud_rate, timeout=1) #sequence to disable DTR when opening the port self.sock = serial.Serial() self.sock.baudrate = baud_rate self.sock.port = port self.sock.timeout = 1 self.sock.dsrdtr = False self.sock.dtr = False self.sock.open()`

Using a borrowed Diecimila clone of a friend I can perfectly reproduce the glitch. The first time the port is opened the board gets a reset. The second and following times not. So it looks like we need to keep the wait as described on https://www.arduino.cc/en/Main/ArduinoBoardDiecimila Section Automatic (Software) Reset. Thanks for the hint. I will rework my optimizations in read/writePage later on.

userid0x0 avatar Apr 25 '19 11:04 userid0x0