Line 188... |
Line 188... |
bool FLASHDRVR::write(const unsigned addr, const unsigned len,
|
bool FLASHDRVR::write(const unsigned addr, const unsigned len,
|
const unsigned *data, const bool verify) {
|
const unsigned *data, const bool verify) {
|
|
|
if (!verify_config()) {
|
if (!verify_config()) {
|
set_config();
|
set_config();
|
if (!verify_config())
|
if (!verify_config()) {
|
|
printf("Invalid configuration, cannot program flash\n");
|
return false;
|
return false;
|
}
|
}
|
|
}
|
|
|
// Work through this one sector at a time.
|
// Work through this one sector at a time.
|
// If this buffer is equal to the sector value(s), go on
|
// If this buffer is equal to the sector value(s), go on
|
// If not, erase the sector
|
// If not, erase the sector
|
|
|
Line 221... |
Line 223... |
base = (addr>s)?addr:s;
|
base = (addr>s)?addr:s;
|
ln=((addr+len>s+SECTORSZW)?(s+SECTORSZW):(addr+len))-base;
|
ln=((addr+len>s+SECTORSZW)?(s+SECTORSZW):(addr+len))-base;
|
m_fpga->readi(base, ln, sbuf);
|
m_fpga->readi(base, ln, sbuf);
|
|
|
dp = &data[base-addr];
|
dp = &data[base-addr];
|
|
SETSCOPE;
|
for(unsigned i=0; i<ln; i++) {
|
for(unsigned i=0; i<ln; i++) {
|
if ((sbuf[i]&dp[i]) != dp[i]) {
|
if ((sbuf[i]&dp[i]) != dp[i]) {
|
printf("\nNEED-ERASE @0x%08x ... %08x != %08x (Goal)\n",
|
printf("\nNEED-ERASE @0x%08x ... %08x != %08x (Goal)\n",
|
i+base-addr, sbuf[i], dp[i]);
|
i+base-addr, sbuf[i], dp[i]);
|
need_erase = true;
|
need_erase = true;
|