Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for EEFC flash to complete operations before resetting #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/D2xNvmFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ D2xNvmFlash::writeOptions()
}
}

void
D2xNvmFlash::ready()
{
}

void
D2xNvmFlash::writePage(uint32_t page)
{
Expand Down
2 changes: 2 additions & 0 deletions src/D2xNvmFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class D2xNvmFlash : public Flash

void writeOptions();

void ready();

void writePage(uint32_t page);
void readPage(uint32_t page, uint8_t* data);

Expand Down
5 changes: 5 additions & 0 deletions src/D5xNvmFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ D5xNvmFlash::writeOptions()
}
}

void
D5xNvmFlash::ready()
{
}

void
D5xNvmFlash::writePage(uint32_t page)
{
Expand Down
2 changes: 2 additions & 0 deletions src/D5xNvmFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class D5xNvmFlash : public Flash

void writeOptions();

void ready();

void writePage(uint32_t page);
void readPage(uint32_t page, uint8_t* data);

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 @@ -274,6 +274,13 @@ EefcFlash::writeOptions()
}
}

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 @@ -68,6 +68,8 @@ class EefcFlash : public Flash

void writeOptions();

void ready();

void writePage(uint32_t page);
void readPage(uint32_t page, uint8_t* data);

Expand Down
10 changes: 8 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 @@ -212,6 +212,12 @@ EfcFlash::writeOptions()
}
}


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 @@ -67,6 +67,8 @@ class EfcFlash : public Flash

void writeOptions();

void ready();

void writePage(uint32_t page);
void readPage(uint32_t page, uint8_t* data);

Expand Down
4 changes: 3 additions & 1 deletion src/Flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class FlashOption
void set(const T& value) { _value = value; _dirty = true; }
const T& get() { return _value; }
bool isDirty() { return _dirty; }

private:
T _value;
bool _dirty;
Expand Down Expand Up @@ -149,6 +149,8 @@ class Flash

virtual void writeOptions() = 0;

virtual void ready() = 0;

virtual void writePage(uint32_t page) = 0;
virtual void readPage(uint32_t page, uint8_t* data) = 0;

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 @@ -490,8 +490,11 @@ main(int argc, char* argv[])

flash->writeOptions();

if (config.reset)
if (config.reset) {
// Ensure flash operation are complete prior to reset
flash->ready();
device.reset();
}
}
catch (exception& e)
{
Expand Down