Skip to content

Commit

Permalink
Applied patches from pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
LumitoLuma committed Jun 29, 2021
1 parent ce0ecb2 commit 5eb870e
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 16 deletions.
9 changes: 9 additions & 0 deletions src/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
11 changes: 9 additions & 2 deletions src/EefcFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,7 +14,7 @@
// * Neither the name of the <organization> 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
Expand Down Expand Up @@ -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)
{
Expand Down
6 changes: 4 additions & 2 deletions src/EefcFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,7 +14,7 @@
// * Neither the name of the <organization> 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
Expand Down Expand Up @@ -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);

Expand Down
9 changes: 7 additions & 2 deletions src/EfcFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,7 +14,7 @@
// * Neither the name of the <organization> 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
Expand Down Expand Up @@ -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)
{
Expand Down
6 changes: 4 additions & 2 deletions src/EfcFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,7 +14,7 @@
// * Neither the name of the <organization> 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
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions src/Flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions src/NvmFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ NvmFlash::setBootFlash(bool enable)
throw BootFlashError();
}

void
NvmFlash::ready()
{
}

void
NvmFlash::writePage(uint32_t page)
{
Expand Down
2 changes: 2 additions & 0 deletions src/NvmFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/PosixSerialPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <fcntl.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/select.h>

#include <string>

Expand Down
4 changes: 2 additions & 2 deletions src/Samba.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 9 additions & 6 deletions src/bossac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -124,7 +124,7 @@ void
BossaObserver::onStatus(const char *message, ...)
{
va_list ap;

va_start(ap, message);
vprintf(message, ap);
va_end(ap);
Expand All @@ -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)
{
Expand All @@ -153,7 +153,7 @@ BossaObserver::onProgress(int num, int div)
}
printf("] %d%% (%d/%d pages)", num * 100 / div, num, div);
fflush(stdout);

_lastTicks = 0;
}

Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 5eb870e

Please sign in to comment.