Skip to content

Commit 5eb870e

Browse files
committed
Applied patches from pull requests
shumatech#118 shumatech#124 shumatech#134 shumatech#151
1 parent ce0ecb2 commit 5eb870e

11 files changed

+54
-16
lines changed

src/Device.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -434,13 +434,16 @@ Device::create()
434434
case 0x10010027: // E15B
435435
case 0x10010056: // E15B WLCSP
436436
case 0x10010063: // E15C WLCSP
437+
case 0x1001003f: // E15L
437438
_family = FAMILY_SAMD21;
438439
flashPtr = new NvmFlashD2x(_samba, "ATSAMD21x15", 0x2000, 512, 64, 1, 16, 0x20000800, 0x20001000, true) ;
439440
break;
440441

441442
case 0x10010002: // J16A
442443
case 0x10010007: // G16A
444+
case 0x10010057: // G16L
443445
case 0x1001000c: // E16A
446+
case 0x1001003e: // E16L
444447
case 0x10010020: // J16B
445448
case 0x10010023: // G16B
446449
case 0x10010026: // E16B
@@ -453,7 +456,13 @@ Device::create()
453456
case 0x10010001: // J17A
454457
case 0x10010006: // G17A
455458
case 0x1001000b: // E17A
459+
case 0x10010094: // E17D
460+
case 0x10010095: // E17D WLCSP
461+
case 0x10010097: // E17L
456462
case 0x10010010: // G17A WLCSP
463+
case 0x10010093: // G17D
464+
case 0x10010096: // G17L
465+
case 0x10010092: // J17D
457466
_family = FAMILY_SAMD21;
458467
flashPtr = new NvmFlashD2x(_samba, "ATSAMD21x17", 0x2000, 2048, 64, 1, 16, 0x20002000, 0x20004000, true) ;
459468
break;

src/EefcFlash.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//
44
// Copyright (c) 2011-2018, ShumaTech
55
// All rights reserved.
6-
//
6+
//
77
// Redistribution and use in source and binary forms, with or without
88
// modification, are permitted provided that the following conditions are met:
99
// * Redistributions of source code must retain the above copyright
@@ -14,7 +14,7 @@
1414
// * Neither the name of the <organization> nor the
1515
// names of its contributors may be used to endorse or promote products
1616
// derived from this software without specific prior written permission.
17-
//
17+
//
1818
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1919
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2020
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -267,6 +267,13 @@ EefcFlash::setBootFlash(bool enable)
267267
writeFCR0(enable ? EEFC_FCMD_SGPB : EEFC_FCMD_CGPB, (_canBrownout ? 3 : 1));
268268
}
269269

270+
void
271+
EefcFlash::ready()
272+
{
273+
// wait for Flash operations to be done
274+
waitFSR();
275+
}
276+
270277
void
271278
EefcFlash::writePage(uint32_t page)
272279
{

src/EefcFlash.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//
44
// Copyright (c) 2011-2018, ShumaTech
55
// All rights reserved.
6-
//
6+
//
77
// Redistribution and use in source and binary forms, with or without
88
// modification, are permitted provided that the following conditions are met:
99
// * Redistributions of source code must retain the above copyright
@@ -14,7 +14,7 @@
1414
// * Neither the name of the <organization> nor the
1515
// names of its contributors may be used to endorse or promote products
1616
// derived from this software without specific prior written permission.
17-
//
17+
//
1818
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1919
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2020
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -72,6 +72,8 @@ class EefcFlash : public Flash
7272
void setBootFlash(bool enable);
7373
bool canBootFlash() { return true; }
7474

75+
void ready();
76+
7577
void writePage(uint32_t page);
7678
void readPage(uint32_t page, uint8_t* data);
7779

src/EfcFlash.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//
44
// Copyright (c) 2011-2018, ShumaTech
55
// All rights reserved.
6-
//
6+
//
77
// Redistribution and use in source and binary forms, with or without
88
// modification, are permitted provided that the following conditions are met:
99
// * Redistributions of source code must retain the above copyright
@@ -14,7 +14,7 @@
1414
// * Neither the name of the <organization> nor the
1515
// names of its contributors may be used to endorse or promote products
1616
// derived from this software without specific prior written permission.
17-
//
17+
//
1818
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1919
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2020
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -215,6 +215,11 @@ EfcFlash::setBootFlash(bool enable)
215215
writeFCR0(enable ? EFC_FCMD_SGPB : EFC_FCMD_CGPB, 2);
216216
}
217217

218+
void
219+
EfcFlash::ready()
220+
{
221+
}
222+
218223
void
219224
EfcFlash::writePage(uint32_t page)
220225
{

src/EfcFlash.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//
44
// Copyright (c) 2011-2018, ShumaTech
55
// All rights reserved.
6-
//
6+
//
77
// Redistribution and use in source and binary forms, with or without
88
// modification, are permitted provided that the following conditions are met:
99
// * Redistributions of source code must retain the above copyright
@@ -14,7 +14,7 @@
1414
// * Neither the name of the <organization> nor the
1515
// names of its contributors may be used to endorse or promote products
1616
// derived from this software without specific prior written permission.
17-
//
17+
//
1818
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1919
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2020
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -71,6 +71,8 @@ class EfcFlash : public Flash
7171
void setBootFlash(bool enable);
7272
bool canBootFlash() { return _canBootFlash; }
7373

74+
void ready();
75+
7476
void writePage(uint32_t page);
7577
void readPage(uint32_t page, uint8_t* data);
7678

src/Flash.h

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ class Flash
126126
virtual void setBootFlash(bool enable) = 0;
127127
virtual bool canBootFlash() = 0;
128128

129+
virtual void ready() = 0;
130+
129131
virtual void writePage(uint32_t page) = 0;
130132
virtual void readPage(uint32_t page, uint8_t* data) = 0;
131133

src/NvmFlash.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,11 @@ NvmFlash::setBootFlash(bool enable)
291291
throw BootFlashError();
292292
}
293293

294+
void
295+
NvmFlash::ready()
296+
{
297+
}
298+
294299
void
295300
NvmFlash::writePage(uint32_t page)
296301
{

src/NvmFlash.h

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class NvmFlash : public Flash
7474
void setBootFlash(bool enable);
7575
bool canBootFlash() { return false; }
7676

77+
void ready();
78+
7779
void writePage(uint32_t page);
7880
void readPage(uint32_t page, uint8_t* data);
7981

src/PosixSerialPort.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <fcntl.h>
3535
#include <termios.h>
3636
#include <sys/ioctl.h>
37+
#include <sys/select.h>
3738

3839
#include <string>
3940

src/Samba.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ class Samba
8282

8383
bool canWriteBuffer() { return _canWriteBuffer; }
8484
void writeBuffer(uint32_t src_addr, uint32_t dst_addr, uint32_t size);
85-
uint32_t writeBufferSize() { return 4096; }
85+
uint32_t writeBufferSize() { return 2048; }
8686

8787
bool canChecksumBuffer() { return _canChecksumBuffer; }
8888
uint16_t checksumBuffer(uint32_t start_addr, uint32_t size);
89-
uint32_t checksumBufferSize() { return 4096; }
89+
uint32_t checksumBufferSize() { return 2048; }
9090
uint16_t checksumCalc(uint8_t c, uint16_t crc);
9191

9292
private:

src/bossac.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class BossaObserver : public FlasherObserver
113113
public:
114114
BossaObserver() : _lastTicks(-1) {}
115115
virtual ~BossaObserver() {}
116-
116+
117117
virtual void onStatus(const char *message, ...);
118118
virtual void onProgress(int num, int div);
119119
private:
@@ -124,7 +124,7 @@ void
124124
BossaObserver::onStatus(const char *message, ...)
125125
{
126126
va_list ap;
127-
127+
128128
va_start(ap, message);
129129
vprintf(message, ap);
130130
va_end(ap);
@@ -137,10 +137,10 @@ BossaObserver::onProgress(int num, int div)
137137
int bars = 30;
138138

139139
ticks = num * bars / div;
140-
140+
141141
if (ticks == _lastTicks)
142142
return;
143-
143+
144144
printf("\r[");
145145
while (ticks-- > 0)
146146
{
@@ -153,7 +153,7 @@ BossaObserver::onProgress(int num, int div)
153153
}
154154
printf("] %d%% (%d/%d pages)", num * 100 / div, num, div);
155155
fflush(stdout);
156-
156+
157157
_lastTicks = 0;
158158
}
159159

@@ -488,8 +488,11 @@ main(int argc, char* argv[])
488488
if (config.lock)
489489
flasher.lock(config.lockArg, true);
490490

491-
if (config.reset)
491+
if (config.reset) {
492+
// Ensure flash operation are complete prior to reset
493+
flash->ready();
492494
device.reset();
495+
}
493496
}
494497
catch (exception& e)
495498
{

0 commit comments

Comments
 (0)