OpenCores
URL https://opencores.org/ocsvn/xulalx25soc/xulalx25soc/trunk

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [sw/] [flashdrvr.cpp] - Diff between revs 29 and 38

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 29 Rev 38
Line 72... Line 72...
                }
                }
        } while(v & ERASEFLAG);
        } while(v & ERASEFLAG);
}
}
 
 
bool    FLASHDRVR::erase_sector(const unsigned sector, const bool verify_erase) {
bool    FLASHDRVR::erase_sector(const unsigned sector, const bool verify_erase) {
        DEVBUS::BUSW    v, page[SZPAGE];
        DEVBUS::BUSW    page[SZPAGE];
 
 
        printf("Erasing sector: %08x\n", sector);
        printf("Erasing sector: %08x\n", sector);
        m_fpga->writeio(R_QSPI_EREG, DISABLEWP);
        m_fpga->writeio(R_QSPI_EREG, DISABLEWP);
        m_fpga->writeio(R_QSPI_EREG, ERASEFLAG + sector);
        m_fpga->writeio(R_QSPI_EREG, ERASEFLAG + sector);
 
 
Line 109... Line 109...
        return true;
        return true;
}
}
 
 
bool    FLASHDRVR::write_page(const unsigned addr, const unsigned len,
bool    FLASHDRVR::write_page(const unsigned addr, const unsigned len,
                const unsigned *data, const bool verify_write) {
                const unsigned *data, const bool verify_write) {
        DEVBUS::BUSW    v, buf[SZPAGE];
        DEVBUS::BUSW    buf[SZPAGE];
 
 
        assert(len > 0);
        assert(len > 0);
        assert(len <= PGLEN);
        assert(len <= PGLEN);
        assert(PAGEOF(addr)==PAGEOF(addr+len-1));
        assert(PAGEOF(addr)==PAGEOF(addr+len-1));
 
 
Line 136... Line 136...
        if ((!HIGH_SPEED)||(!verify_write)) {
        if ((!HIGH_SPEED)||(!verify_write)) {
                flwait();
                flwait();
        } if (verify_write) {
        } if (verify_write) {
                // NOW VERIFY THE PAGE
                // NOW VERIFY THE PAGE
                m_fpga->readi(addr, len, buf);
                m_fpga->readi(addr, len, buf);
                for(int i=0; i<len; i++) {
                for(unsigned i=0; i<len; i++) {
                        if (buf[i] != data[i]) {
                        if (buf[i] != data[i]) {
                                printf("\nVERIFY FAILS[%d]: %08x\n", i, i+addr);
                                printf("\nVERIFY FAILS[%d]: %08x\n", i, i+addr);
                                printf("\t(Flash[%d]) %08x != %08x (Goal[%08x])\n",
                                printf("\t(Flash[%d]) %08x != %08x (Goal[%08x])\n",
                                        i, buf[i], data[i], i+addr);
                                        i, buf[i], data[i], i+addr);
                                return false;
                                return false;
Line 211... Line 211...
                                return false;
                                return false;
                }
                }
        }
        }
 
 
        m_fpga->writeio(R_QSPI_EREG, 0); // Re-enable write protection
        m_fpga->writeio(R_QSPI_EREG, 0); // Re-enable write protection
 
 
 
        return true;
}
}
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.