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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [sw/] [host/] [dumpflash.cpp] - Diff between revs 18 and 51

Show entire file | Details | Blame | View Log

Rev 18 Rev 51
Line 10... Line 10...
// Creator:     Dan Gisselquist, Ph.D.
// Creator:     Dan Gisselquist, Ph.D.
//              Gisselquist Technology, LLC
//              Gisselquist Technology, LLC
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
//
//
// This program is free software (firmware): you can redistribute it and/or
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of  the GNU General Public License as published
// modify it under the terms of  the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
// your option) any later version.
Line 23... Line 23...
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// for more details.
//
//
// You should have received a copy of the GNU General Public License along
// You should have received a copy of the GNU General Public License along
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
// with this program.  (It's in the $(ROOT)/doc directory.  Run make with no
// target there if the PDF file isn't present.)  If not, see
// target there if the PDF file isn't present.)  If not, see
// <http://www.gnu.org/licenses/> for a copy.
// <http://www.gnu.org/licenses/> for a copy.
//
//
// License:     GPL, v3, as defined and found on www.gnu.org,
// License:     GPL, v3, as defined and found on www.gnu.org,
//              http://www.gnu.org/licenses/gpl.html
//              http://www.gnu.org/licenses/gpl.html
Line 52... Line 52...
void    closeup(int v) {
void    closeup(int v) {
        m_fpga->kill();
        m_fpga->kill();
        exit(0);
        exit(0);
}
}
 
 
// #define      DUMPMEM         RAMBASE
 
////////////////////////////////////////////////////////////////////////////////
 
//
 
// Filename:    dumpflash.cpp
 
//
 
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
 
//
 
// Purpose:     The purpose of this program is to read the entire flash memory,
 
//              and dump it to a file.
 
//
 
//
 
// Creator:     Dan Gisselquist, Ph.D.
 
//              Gisselquist Technology, LLC
 
//
 
////////////////////////////////////////////////////////////////////////////////
 
//
 
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
 
//
 
// This program is free software (firmware): you can redistribute it and/or
 
// modify it under the terms of  the GNU General Public License as published
 
// by the Free Software Foundation, either version 3 of the License, or (at
 
// your option) any later version.
 
//
 
// This program is distributed in the hope that it will be useful, but WITHOUT
 
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
 
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
// for more details.
 
//
 
// You should have received a copy of the GNU General Public License along
 
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
 
// target there if the PDF file isn't present.)  If not, see
 
// <http://www.gnu.org/licenses/> for a copy.
 
//
 
// License:     GPL, v3, as defined and found on www.gnu.org,
 
//              http://www.gnu.org/licenses/gpl.html
 
//
 
//
 
////////////////////////////////////////////////////////////////////////////////
 
//
 
//
 
// #define      DUMPWORDS       MEMWORDS
 
 
 
#define DUMPMEM         EQSPIFLASH
#define DUMPMEM         EQSPIFLASH
#define DUMPWORDS       FLASHWORDS      // 1MB Flash
#define DUMPWORDS       (FLASHLEN>>2)
 
 
int main(int argc, char **argv) {
int main(int argc, char **argv) {
        FILE    *fp;
        FILE    *fp;
        const int       BUFLN = FLASHWORDS;
        const int       BUFLN = FLASHLEN;
        FPGA::BUSW      *buf = new FPGA::BUSW[BUFLN];
        char    *buf = new char[FLASHLEN];
 
 
        FPGAOPEN(m_fpga);
        FPGAOPEN(m_fpga);
        fprintf(stderr, "Before starting, nread = %ld\n",
        fprintf(stderr, "Before starting, nread = %ld\n",
                m_fpga->m_total_nread);
                m_fpga->m_total_nread);
 
 
Line 115... Line 73...
        // Enable the faster (vector) reads
        // Enable the faster (vector) reads
        bool    vector_read = true;
        bool    vector_read = true;
        unsigned        sz;
        unsigned        sz;
 
 
        if (vector_read) {
        if (vector_read) {
                m_fpga->readi(DUMPMEM, BUFLN, buf);
                m_fpga->readi(DUMPMEM, BUFLN>>2, (DEVBUS::BUSW *)&buf[0]);
 
                byteswapbuf(BUFLN>>2, buf);
        } else {
        } else {
                for(int i=0; i<BUFLN; i++) {
                for(int i=0; i<BUFLN; i+=4) {
                        buf[i] = m_fpga->readio(DUMPMEM+i);
                        DEVBUS::BUSW    word;
                        // if (0 == (i&0x0ff))
 
                                printf("i = %02x / %04x, addr = i + %04x = %08x\n", i, BUFLN, DUMPMEM, i+DUMPMEM);
                        word = m_fpga->readio(DUMPMEM+i);
 
 
 
                        buf[i  ] = (word>>24) & 0x0ff;
 
                        buf[i+1] = (word>>16) & 0x0ff;
 
                        buf[i+2] = (word>> 8) & 0x0ff;
 
                        buf[i+3] = (word    ) & 0x0ff;
                }
                }
        }
        }
        printf("\nREAD-COMPLETE\n");
        printf("\nREAD-COMPLETE\n");
 
 
        // Now, let's find the end
        // Now, let's find the end
        sz = BUFLN-1;
        sz = BUFLN-1;
        while((sz>0)&&(buf[sz] == 0xffffffff))
        while((sz>0)&&((unsigned char)buf[sz] == 0xff))
                sz--;
                sz--;
        sz+=1;
        sz+=1;
        printf("The size of the buffer is 0x%06x or %d words\n", sz, sz);
 
 
 
#define FLASHFILE       "eqspidump.bin"
#define FLASHFILE       "eqspidump.bin"
 
 
        if (access(FLASHFILE, F_OK)==0) {
        if (access(FLASHFILE, F_OK)==0) {
                fprintf(stderr, "Cowardly refusing to overwrite %s\n", FLASHFILE);
                fprintf(stderr, "Cowardly refusing to overwrite %s\n", FLASHFILE);

powered by: WebSVN 2.1.0

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