Skip to content

Commit

Permalink
0.2.rev.A. Add VEE control in software; Add Erasable EPROM devices
Browse files Browse the repository at this point in the history
  • Loading branch information
robsonsmartins committed Jan 3, 2024
1 parent 80399f0 commit 0862105
Show file tree
Hide file tree
Showing 15 changed files with 2,236 additions and 722 deletions.
1,895 changes: 1,441 additions & 454 deletions docs/devices_eprom.graphml

Large diffs are not rendered by default.

Binary file added docs/img/devices_eprom_erase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/specs.odt
Binary file not shown.
Binary file modified docs/specs.pdf
Binary file not shown.
14 changes: 13 additions & 1 deletion software/usbflashprog/backend/devices/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ TDeviceCapabilities::TDeviceCapabilities()
hasUnprotect(false),
hasSectorSize(false),
hasFastProg(false),
hasSkipFF(false) {}
hasSkipFF(false),
hasVDD(false),
hasVPP(false) {}

// ---------------------------------------------------------------------------

Expand All @@ -111,6 +113,7 @@ Device::Device(QObject *parent)
vddRd_(5.0f),
vddWr_(5.0f),
vpp_(12.0f),
vee_(12.0f),
skipFF_(false),
fastProg_(false),
sectorSize_(0),
Expand Down Expand Up @@ -196,6 +199,15 @@ float Device::getVpp() const {
return vpp_;
}

void Device::setVee(float value) {
if (vee_ == value) return;
if (value >= 0.0f) vee_ = value;
}

float Device::getVee() const {
return vee_;
}

void Device::setSkipFF(bool value) {
if (skipFF_ == value) return;
skipFF_ = value;
Expand Down
12 changes: 12 additions & 0 deletions software/usbflashprog/backend/devices/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ class Device : public QObject {
* @return VPP value, in volts.
*/
virtual float getVpp() const;
/**
* @brief Sets the VEE.
* @param value VEE value, in volts.
*/
virtual void setVee(float value);
/**
* @brief Returns the configured VEE (in volts).
* @return VEE value, in volts.
*/
virtual float getVee() const;
/**
* @brief Sets the Skip Prog 0xFF.
* @param value If true (default), enables skip prog 0xFF, disables
Expand Down Expand Up @@ -315,6 +325,8 @@ class Device : public QObject {
float vddWr_;
/* @brief VPP, in volts. */
float vpp_;
/* @brief VEE (VPP to Erase), in volts. */
float vee_;
/* @brief Enables skip prog 0xFF. */
bool skipFF_;
/* @brief Enables fast prog/erase. */
Expand Down
1 change: 1 addition & 0 deletions software/usbflashprog/backend/devices/parallel/dummy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Dummy::Dummy(QObject *parent) : Device(parent), protected_(true) {
vddRd_ = 5.0f;
vddWr_ = 5.0f;
vpp_ = 12.0f;
vee_ = 12.0f;
setSize(2048);
}

Expand Down
178 changes: 158 additions & 20 deletions software/usbflashprog/backend/devices/parallel/eprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ EPROM::EPROM(QObject *parent) : SRAM(parent), mode16bit_(false) {
vddRd_ = 5.0f;
vddWr_ = 6.0f;
vpp_ = 13.0f;
vee_ = 13.0f;
size_ = 2048;
maxAttemptsProg_ = 25;
vppPulseDelay_ = 150;
Expand Down Expand Up @@ -293,8 +294,8 @@ bool EPROM::initialize_(kDeviceOperation operation) {
runner_.vddSet(vddRd_);
runner_.vddCtrl();
initControlPins_(true);
// VPP set
runner_.vppSet(vpp_);
// VPP set with VEE
runner_.vppSet(vee_);
if (!isOeVppPin_()) {
// VDD Rd on VPP
runner_.vddOnVpp();
Expand Down Expand Up @@ -412,21 +413,13 @@ bool EPROM::verify_(const QByteArray &buffer, uint32_t &current,
// ---------------------------------------------------------------------------

M27xxx::M27xxx(QObject *parent) : EPROM(parent) {
info_.deviceType = kDeviceParallelMemory;
info_.name = "EPROM 27xxx";
info_.capability.hasRead = true;
info_.capability.hasProgram = true;
info_.capability.hasVerify = true;
info_.capability.hasBlankCheck = true;
info_.capability.hasGetId = true;
info_.capability.hasVDD = true;
info_.capability.hasVPP = true;
skipFF_ = true;
twp_ = 50000;
twc_ = 50;
vddRd_ = 5.0f;
vddWr_ = 5.0f;
vpp_ = 25.0f;
vee_ = 12.0f;
size_ = 2048;
}

Expand All @@ -435,21 +428,13 @@ M27xxx::~M27xxx() {}
// ---------------------------------------------------------------------------

M27Cxxx::M27Cxxx(QObject *parent) : EPROM(parent) {
info_.deviceType = kDeviceParallelMemory;
info_.name = "EPROM 27Cxxx";
info_.capability.hasRead = true;
info_.capability.hasProgram = true;
info_.capability.hasVerify = true;
info_.capability.hasBlankCheck = true;
info_.capability.hasGetId = true;
info_.capability.hasVDD = true;
info_.capability.hasVPP = true;
skipFF_ = true;
twp_ = 500;
twc_ = 8;
vddRd_ = 5.0f;
vddWr_ = 6.0f;
vpp_ = 13.0f;
vee_ = 12.0f;
size_ = 2048;
}

Expand All @@ -463,3 +448,156 @@ M27C16Bit::M27C16Bit(QObject *parent) : M27Cxxx(parent) {
}

M27C16Bit::~M27C16Bit() {}

// ---------------------------------------------------------------------------

W27Exxx::W27Exxx(QObject *parent) : M27Cxxx(parent) {
info_.name = "EPROM W27C/27E/27SF";
info_.capability.hasErase = true;
info_.capability.hasBlankCheck = true;
twp_ = 100;
twc_ = 15;
vddRd_ = 5.0f;
vddWr_ = 5.0f;
vpp_ = 12.0f;
vee_ = 14.0f;
size_ = 2048;
erasePulseDelay_ = 100; // 100 ms
}

W27Exxx::~W27Exxx() {}

bool W27Exxx::erase(bool check) {
canceling_ = false;
int total = static_cast<int>(size_);
// Init pins/bus to Prog operation
if (!initialize_(kDeviceOpErase)) return false;
uint32_t current = 0;
bool error = false;
// Erase the device
if (!erase_(current, total)) error = true;
// If no error and check flag is enabled, verify device
if (!error && check) {
// VDD off and VPP off
runner_.vppCtrl(false);
runner_.vddCtrl(false);
// VDD Rd on
runner_.vddSet(vddRd_);
runner_.vddCtrl();
// VDD Rd on VPP
runner_.vddOnVpp();
// Clear AddrBus
runner_.addrClr();
initControlPins_(true);
runner_.usDelay(initDelay_);
if (runner_.hasError()) return finalize_(0, total, true, false);
current = 0;
// Creates a blank (0xFF) buffer
QByteArray buffer(size_, 0xFF);
// Read the device and verify (compare) buffer
if (!verify_(buffer, current, total)) error = true;
}
if (!error) emit onProgress(total, total, true);
// Close resources
finalize_();
return !error;
}

bool W27Exxx::blankCheck() {
canceling_ = false;
int total = static_cast<int>(size_);
// Init pins/bus to Read operation
if (!initialize_(kDeviceOpRead)) return false;
uint32_t current = 0;
bool error = false;
// Creates a blank (0xFF) buffer
QByteArray buffer(size_, 0xFF);
// Read the device and verify (compare) buffer
if (!verify_(buffer, current, total)) error = true;
if (!error) emit onProgress(total, total, true);
// Close resources
finalize_();
return !error;
}

bool W27Exxx::initialize_(kDeviceOperation operation) {
if (operation != kDeviceOpErase) {
return M27Cxxx::initialize_(operation);
}
// Operation == Erase
if (!runner_.open(port_)) {
emit onProgress(0, size_, true, false);
return false;
}
// Init bus and pins
resetBus_();
// VDD Wr on
runner_.vddSet(vddWr_);
runner_.vddCtrl();
initControlPins_(false);
// VPP set with VEE
// VPP on
runner_.vppSet(vee_);
runner_.vppCtrl();
// VPP on A9
runner_.vppOnA9();
// Data is 0xFF
if (mode16bit_) {
runner_.dataSetW(0xFFFF);
} else {
runner_.dataSet(0xFF);
}
runner_.usDelay(initDelay_);
if (runner_.hasError()) return finalize_(0, size_, true, false);
return true;
}

bool W27Exxx::erase_(uint32_t &current, uint32_t total) {
uint16_t read = 0xFFFF;
int increment = mode16bit_ ? 2 : 1;
uint16_t empty = mode16bit_ ? 0xFFFF : 0xFF;
uint32_t initial = current;
// Repeat for n max attempts
for (int j = 1; j <= maxAttemptsProg_; j++) {
current = initial;
// Erase entire chip
// Addr = 0
runner_.addrClr();
// Data = 0xFF
if (mode16bit_) {
runner_.dataSetW(0xFFFF);
} else {
runner_.dataSet(0xFF);
}
// VPP on A9
runner_.vppOnA9();
// ~PGM is LO (start erase pulse)
runner_.setWE();
runner_.msDelay(erasePulseDelay_);
// ~PGM is HI (end erase pulse)
runner_.setWE(false);
runner_.usDelay(twc_);
// VPP on A9 off
runner_.vppOnA9(false);
bool success = true;
for (int i = 0; i < size_; i += increment) {
// Read byte
read_(read);
// Verify
if (read != empty) {
success = false;
break;
}
if (runner_.hasError() || j == maxAttemptsProg_) {
// Error
emit onProgress(current, total, true, false);
return false;
}
// Increment Address
runner_.addrInc();
current += increment;
}
if (success) break;
}
return true;
}
37 changes: 37 additions & 0 deletions software/usbflashprog/backend/devices/parallel/eprom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,41 @@ class M27C16Bit : public M27Cxxx {
virtual ~M27C16Bit();
};

// ---------------------------------------------------------------------------

/**
* @ingroup Software
* @brief Parallel EPROM W27Exxx Class
* @details The purpose of this class is to program EPROM W27E/SF Memories
* (Electrical Erasable).
* @nosubgrouping
*/
class W27Exxx : public M27Cxxx {
Q_OBJECT

public:
/**
* @brief Constructor.
* @param parent Pointer to parent object. Default is nullptr.
*/
explicit W27Exxx(QObject *parent = nullptr);
/** @brief Destructor. */
virtual ~W27Exxx();
/* Reimplemented */
virtual bool erase(bool check = false);
/* Reimplemented */
virtual bool blankCheck();

protected:
/* @brief Delay of Erase pulse, in msec */
uint32_t erasePulseDelay_;
/* Reimplemented */
virtual bool initialize_(kDeviceOperation operation);
/* @brief Erase the EPROM.
* @param current[in,out] Current progress, in bytes.
* @param total Total progress, in bytes.
* @return True if success, false otherwise. */
virtual bool erase_(uint32_t &current, uint32_t total);
};

#endif // BACKEND_DEVICES_PARALLEL_EPROM_HPP_
2 changes: 2 additions & 0 deletions software/usbflashprog/backend/devices/parallel/sram.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class SRAM : public Device {
kDeviceOpRead,
/* @brief Device Prog */
kDeviceOpProg,
/* @brief Device Erase */
kDeviceOpErase,
/* @brief Device GetId */
kDeviceOpGetId
};
Expand Down
24 changes: 10 additions & 14 deletions software/usbflashprog/i18n/ufprog_en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,6 @@
<source>Press to change unit</source>
<translation>Press to change unit</translation>
</message>
<message>
<source>Adjust VPP [Caution!]</source>
<translation>Adjust VPP [Caution!]</translation>
</message>
<message>
<source>Adjust VDD to Read [Caution!]</source>
<translation>Adjust VDD to Read [Caution!]</translation>
Expand All @@ -510,24 +506,24 @@
<translation>Size</translation>
</message>
<message>
<source>VDD Read</source>
<translation>VDD Read</translation>
<source>Consult the device datasheet for more information.</source>
<translation>Consult the device datasheet for more information.</translation>
</message>
<message>
<source>VDD Prog</source>
<translation>VDD Prog</translation>
<source>Are you sure you want to continue?</source>
<translation>Are you sure you want to continue?</translation>
</message>
<message>
<source>Caution! Check the VDD and VPP voltages and the size of the device before running, otherwise you will damage it!</source>
<translation>Caution! Check the VDD and VPP voltages and the size of the device before running, otherwise you will damage it!</translation>
<source>Adjust VPP to Program [Caution!]</source>
<translation>Adjust VPP to Program [Caution!]</translation>
</message>
<message>
<source>Consult the device datasheet for more information.</source>
<translation>Consult the device datasheet for more information.</translation>
<source>Adjust VPP to Erase [Caution!]</source>
<translation>Adjust VPP to Erase [Caution!]</translation>
</message>
<message>
<source>Are you sure you want to continue?</source>
<translation>Are you sure you want to continue?</translation>
<source>Caution! Check the VDD, VPP and VEE voltages and the size of the device before running, otherwise you will damage it!</source>
<translation>Caution! Check the VDD, VPP and VEE voltages and the size of the device before running, otherwise you will damage it!</translation>
</message>
</context>
</TS>
Loading

0 comments on commit 0862105

Please sign in to comment.