From ec4686bfa0aa3a1e6156cec985347aabf6987827 Mon Sep 17 00:00:00 2001 From: Tom Nisbet Date: Wed, 11 Nov 2020 17:46:31 -0500 Subject: [PATCH] File transfer default back to XModem-CRC for #20 --- TommyPROM/PromDevice.cpp | 3 +++ TommyPROM/PromDevice.h | 11 ++++++----- TommyPROM/TommyPROM.ino | 4 ++-- TommyPROM/XModem.cpp | 8 +++++++- docs/index.md | 13 ++++++++++++- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/TommyPROM/PromDevice.cpp b/TommyPROM/PromDevice.cpp index 934da65..1c8d5ea 100644 --- a/TommyPROM/PromDevice.cpp +++ b/TommyPROM/PromDevice.cpp @@ -71,6 +71,7 @@ void PromDevice::resetDebugStats() { debugLastAddress = 0; debugLastExpected = 0; debugLastReadback = 0; + debugStartChar = 0; } void PromDevice::printDebugStats() { Serial.print(F("debugBlockWrites: ")); @@ -81,6 +82,8 @@ void PromDevice::printDebugStats() { Serial.println(debugLastExpected, HEX); Serial.print(F("debugLastReadback: ")); Serial.println(debugLastReadback, HEX); + Serial.print(F("debugStartChar: ")); + Serial.println(debugStartChar, HEX); } // BEGIN PRIVATE METHODS diff --git a/TommyPROM/PromDevice.h b/TommyPROM/PromDevice.h index 2a4fbfa..4105abe 100644 --- a/TommyPROM/PromDevice.h +++ b/TommyPROM/PromDevice.h @@ -28,17 +28,18 @@ class PromDevice virtual void disableSoftwareWriteProtect() {} virtual void enableSoftwareWriteProtect() {} + uint32_t debugBlockWrites; // Number of block write operations + uint32_t debugLastAddress; // Last address with an issue + uint8_t debugLastExpected; // Last expected readback value + uint8_t debugLastReadback; // Last actual readback value + uint8_t debugStartChar; // XModem start char sent or received + protected: uint32_t mSize; // Size of the device, in bytes unsigned int mBlockSize; // Block size for page writes, zero if N/A unsigned int mMaxWriteTime; // Max time (in ms) to wait for write cycle to complete bool mSupportsDataPoll; // End of write detected by data polling - uint32_t debugBlockWrites; // Number of block write operations - uint32_t debugLastAddress; // Last address with an issue - uint8_t debugLastExpected; // Last expected readback value - uint8_t debugLastReadback; // Last actual readback value - void setDataBusMode(uint8_t mode); byte readDataBus(); void writeDataBus(byte data); diff --git a/TommyPROM/TommyPROM.ino b/TommyPROM/TommyPROM.ino index bbc4ea3..1c5cf7b 100644 --- a/TommyPROM/TommyPROM.ino +++ b/TommyPROM/TommyPROM.ino @@ -19,7 +19,7 @@ #include "XModem.h" -static const char * MY_VERSION = "2.5"; +static const char * MY_VERSION = "2.6"; // Global status @@ -399,7 +399,7 @@ void fillBlock(uint32_t start, uint32_t end, byte val) for (uint32_t addr = start; (addr <= end); addr += BLOCK_SIZE) { - uint32_t writeLen = ((end - addr + 1) < BLOCK_SIZE) ? (end - addr + 1) : BLOCK_SIZE; + uint32_t writeLen = ((end - addr + 1) < BLOCK_SIZE) ? (end - addr + 1) : uint32_t(BLOCK_SIZE); if (!prom.writeData(block, writeLen, addr)) { cmdStatus.error("Write failed"); diff --git a/TommyPROM/XModem.cpp b/TommyPROM/XModem.cpp index 43408c5..0f7ff11 100644 --- a/TommyPROM/XModem.cpp +++ b/TommyPROM/XModem.cpp @@ -9,7 +9,10 @@ // they did over the long distance dail-up lines that XModem was designed for. Uncomment // the XMODEM_CRC_PROTOCOL line below to restore the original XMODEM CRC support. -//#define XMODEM_CRC_PROTOCOL +// Update!!! - Teraterm does not seem to like sending files to TommyPROM with plain +// XModem, so the default is back to CRC. For Linux, comment out the line below to use +// checksum. +#define XMODEM_CRC_PROTOCOL enum { @@ -126,6 +129,7 @@ bool XModem::SendFile(uint32_t address, uint32_t fileSize) { rxChar = GetChar(); } + promDevice.debugStartChar = rxChar; if (rxChar != XMDM_TRANSFER_START) { #ifdef XMODEM_CRC_PROTOCOL @@ -222,6 +226,7 @@ bool XModem::StartReceive() // seconds. If nothing is received in that time then return false to indicate // that the transfer did not start. Serial.write(XMDM_TRANSFER_START); + promDevice.debugStartChar = XMDM_TRANSFER_START; for (int ms = 1000; (ms); --ms) { if (Serial.available() > 0) @@ -312,6 +317,7 @@ void XModem::SendPacket(uint32_t address, uint8_t seq) Serial.write(c); crc = UpdateCrc(crc, c); } + #ifdef XMODEM_CRC_PROTOCOL Serial.write(crc >> 8); #endif diff --git a/docs/index.md b/docs/index.md index 7db83e8..0230f13 100755 --- a/docs/index.md +++ b/docs/index.md @@ -94,11 +94,22 @@ received file size. Once the READ or WRITE command is issued to the programmer, the transfer must be started on the host program. -Note that previous versions of TommyPROM used the XMODEM-CRC protocol to complete the file +~~Note that previous versions of TommyPROM used the XMODEM-CRC protocol to complete the file transfers for the READ and WRITE commands. This did not work well with minicom and other Linux programs that rely on the sz/rz commands. Versions 2.5 and later of TommyPROM now use basic XModem with the 8-bit checksum. The XModem-CRC support is still available as a compile-time option. See [issue #19](https://github.com/TomNisbet/TommyPROM/issues/19) +for details.~~ + +**UPDATE: XModem troubles continue!** + +It seems that TeraTerm does not like to send files to TommyPROM in XModem checksum mode. +The default transfer has been restored to XModem-CRC mode. +* For TeraTerm, be sure to select the XModem-CRC option in the dialog box when receiving files. +* For Linux/minicom, comment out the XMODEM_CRC_PROTOCOL in XModem.cpp and use checksum mode. + +Given that there are now problems with both minicomm and TeraTerm, it seems likely that the +actual problem lies somewhere in the TommyPROM code. See [issue #20](https://github.com/TomNisbet/TommyPROM/issues/20) for details. The files used for READ and WRITE are simple binary images. This can be created directly