diff --git a/src/Device.cpp b/src/Device.cpp index 0a06d8a..26c13f4 100644 --- a/src/Device.cpp +++ b/src/Device.cpp @@ -434,13 +434,16 @@ Device::create() case 0x10010027: // E15B case 0x10010056: // E15B WLCSP case 0x10010063: // E15C WLCSP + case 0x1001003f: // E15L _family = FAMILY_SAMD21; flashPtr = new NvmFlashD2x(_samba, "ATSAMD21x15", 0x2000, 512, 64, 1, 16, 0x20000800, 0x20001000, true) ; break; case 0x10010002: // J16A case 0x10010007: // G16A + case 0x10010057: // G16L case 0x1001000c: // E16A + case 0x1001003e: // E16L case 0x10010020: // J16B case 0x10010023: // G16B case 0x10010026: // E16B @@ -453,7 +456,13 @@ Device::create() case 0x10010001: // J17A case 0x10010006: // G17A case 0x1001000b: // E17A + case 0x10010094: // E17D + case 0x10010095: // E17D WLCSP + case 0x10010097: // E17L case 0x10010010: // G17A WLCSP + case 0x10010093: // G17D + case 0x10010096: // G17L + case 0x10010092: // J17D _family = FAMILY_SAMD21; flashPtr = new NvmFlashD2x(_samba, "ATSAMD21x17", 0x2000, 2048, 64, 1, 16, 0x20002000, 0x20004000, true) ; break; diff --git a/src/EefcFlash.cpp b/src/EefcFlash.cpp index c8d62c1..0b36e00 100644 --- a/src/EefcFlash.cpp +++ b/src/EefcFlash.cpp @@ -3,7 +3,7 @@ // // Copyright (c) 2011-2018, ShumaTech // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright @@ -14,7 +14,7 @@ // * Neither the name of the nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -267,6 +267,13 @@ EefcFlash::setBootFlash(bool enable) writeFCR0(enable ? EEFC_FCMD_SGPB : EEFC_FCMD_CGPB, (_canBrownout ? 3 : 1)); } +void +EefcFlash::ready() +{ + // wait for Flash operations to be done + waitFSR(); +} + void EefcFlash::writePage(uint32_t page) { diff --git a/src/EefcFlash.h b/src/EefcFlash.h index 96af5aa..41dd44f 100644 --- a/src/EefcFlash.h +++ b/src/EefcFlash.h @@ -3,7 +3,7 @@ // // Copyright (c) 2011-2018, ShumaTech // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright @@ -14,7 +14,7 @@ // * Neither the name of the nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -72,6 +72,8 @@ class EefcFlash : public Flash void setBootFlash(bool enable); bool canBootFlash() { return true; } + void ready(); + void writePage(uint32_t page); void readPage(uint32_t page, uint8_t* data); diff --git a/src/EfcFlash.cpp b/src/EfcFlash.cpp index 521bd48..57a60c6 100644 --- a/src/EfcFlash.cpp +++ b/src/EfcFlash.cpp @@ -3,7 +3,7 @@ // // Copyright (c) 2011-2018, ShumaTech // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright @@ -14,7 +14,7 @@ // * Neither the name of the nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -215,6 +215,11 @@ EfcFlash::setBootFlash(bool enable) writeFCR0(enable ? EFC_FCMD_SGPB : EFC_FCMD_CGPB, 2); } +void +EfcFlash::ready() +{ +} + void EfcFlash::writePage(uint32_t page) { diff --git a/src/EfcFlash.h b/src/EfcFlash.h index ac4f7ba..3219e60 100644 --- a/src/EfcFlash.h +++ b/src/EfcFlash.h @@ -3,7 +3,7 @@ // // Copyright (c) 2011-2018, ShumaTech // All rights reserved. -// +// // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright @@ -14,7 +14,7 @@ // * Neither the name of the nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -71,6 +71,8 @@ class EfcFlash : public Flash void setBootFlash(bool enable); bool canBootFlash() { return _canBootFlash; } + void ready(); + void writePage(uint32_t page); void readPage(uint32_t page, uint8_t* data); diff --git a/src/Flash.h b/src/Flash.h index 19a4080..de1caa4 100644 --- a/src/Flash.h +++ b/src/Flash.h @@ -126,6 +126,8 @@ class Flash virtual void setBootFlash(bool enable) = 0; virtual bool canBootFlash() = 0; + virtual void ready() = 0; + virtual void writePage(uint32_t page) = 0; virtual void readPage(uint32_t page, uint8_t* data) = 0; diff --git a/src/NvmFlash.cpp b/src/NvmFlash.cpp index 2d31362..7b96a54 100644 --- a/src/NvmFlash.cpp +++ b/src/NvmFlash.cpp @@ -291,6 +291,11 @@ NvmFlash::setBootFlash(bool enable) throw BootFlashError(); } +void +NvmFlash::ready() +{ +} + void NvmFlash::writePage(uint32_t page) { diff --git a/src/NvmFlash.h b/src/NvmFlash.h index 93ff271..8969cb6 100644 --- a/src/NvmFlash.h +++ b/src/NvmFlash.h @@ -74,6 +74,8 @@ class NvmFlash : public Flash void setBootFlash(bool enable); bool canBootFlash() { return false; } + void ready(); + void writePage(uint32_t page); void readPage(uint32_t page, uint8_t* data); diff --git a/src/PosixSerialPort.cpp b/src/PosixSerialPort.cpp index ccd9848..9b1153a 100644 --- a/src/PosixSerialPort.cpp +++ b/src/PosixSerialPort.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include diff --git a/src/Samba.h b/src/Samba.h index 84bea40..29f8f79 100644 --- a/src/Samba.h +++ b/src/Samba.h @@ -82,11 +82,11 @@ class Samba bool canWriteBuffer() { return _canWriteBuffer; } void writeBuffer(uint32_t src_addr, uint32_t dst_addr, uint32_t size); - uint32_t writeBufferSize() { return 4096; } + uint32_t writeBufferSize() { return 2048; } bool canChecksumBuffer() { return _canChecksumBuffer; } uint16_t checksumBuffer(uint32_t start_addr, uint32_t size); - uint32_t checksumBufferSize() { return 4096; } + uint32_t checksumBufferSize() { return 2048; } uint16_t checksumCalc(uint8_t c, uint16_t crc); private: diff --git a/src/bossac.cpp b/src/bossac.cpp index 67841c3..ef38eba 100644 --- a/src/bossac.cpp +++ b/src/bossac.cpp @@ -113,7 +113,7 @@ class BossaObserver : public FlasherObserver public: BossaObserver() : _lastTicks(-1) {} virtual ~BossaObserver() {} - + virtual void onStatus(const char *message, ...); virtual void onProgress(int num, int div); private: @@ -124,7 +124,7 @@ void BossaObserver::onStatus(const char *message, ...) { va_list ap; - + va_start(ap, message); vprintf(message, ap); va_end(ap); @@ -137,10 +137,10 @@ BossaObserver::onProgress(int num, int div) int bars = 30; ticks = num * bars / div; - + if (ticks == _lastTicks) return; - + printf("\r["); while (ticks-- > 0) { @@ -153,7 +153,7 @@ BossaObserver::onProgress(int num, int div) } printf("] %d%% (%d/%d pages)", num * 100 / div, num, div); fflush(stdout); - + _lastTicks = 0; } @@ -488,8 +488,11 @@ main(int argc, char* argv[]) if (config.lock) flasher.lock(config.lockArg, true); - if (config.reset) + if (config.reset) { + // Ensure flash operation are complete prior to reset + flash->ready(); device.reset(); + } } catch (exception& e) {