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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [sw/] [host/] [wbprogram.cpp] - Diff between revs 18 and 30

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

Rev 18 Rev 30
Line 65... Line 65...
        r |= x&0x0ff;
        r |= x&0x0ff;
 
 
        return r;
        return r;
}
}
 
 
 
void    usage(void) {
 
        printf("USAGE: wbprogram [@<Address>] file.bit\n");
 
        printf("\tYou can also use a .bin file in place of the file.bit.\n");
 
}
 
 
int main(int argc, char **argv) {
int main(int argc, char **argv) {
        FILE    *fp;
        FILE    *fp;
        const int       BUFLN = (1<<20); // 4MB Flash
        const int       BUFLN = (1<<20); // 4MB Flash
        DEVBUS::BUSW    *buf = new DEVBUS::BUSW[BUFLN], v, addr = EQSPIFLASH;
        DEVBUS::BUSW    *buf = new DEVBUS::BUSW[BUFLN], v, addr = EQSPIFLASH;
        FLASHDRVR       *flash;
        FLASHDRVR       *flash;
Line 98... Line 103...
        unsigned        sz;
        unsigned        sz;
        bool            esectors[NSECTORS];
        bool            esectors[NSECTORS];
 
 
        argn = 1;
        argn = 1;
        if (argc <= argn) {
        if (argc <= argn) {
                printf("BAD USAGE: program [@<Address>] file.bin\n");
                usage();
                exit(-1);
                exit(-1);
        } else if (argv[argn][0] == '@') {
        } else if (argv[argn][0] == '@') {
                addr = strtoul(&argv[argn][1], NULL, 0);
                addr = strtoul(&argv[argn][1], NULL, 0);
                if ((addr < EQSPIFLASH)||(addr > EQSPIFLASH*2)) {
                if ((addr < EQSPIFLASH)||(addr > EQSPIFLASH*2)) {
                        printf("BAD ADDRESS: 0x%08x (from %s)\n", addr, argv[argn]);
                        printf("BAD ADDRESS: 0x%08x (from %s)\n", addr, argv[argn]);
 
                        printf("The address you've selected, 0x%08x, is outside the range", addr);
 
                        printf("from 0x%08x to 0x%08x\n", EQSPIFLASH, EQSPIFLASH*2);
                        exit(-1);
                        exit(-1);
                } argn++;
                } argn++;
        }
        }
 
 
        if (argc<= argn) {
        if (argc<= argn) {
Line 118... Line 125...
                exit(-1);
                exit(-1);
        }
        }
 
 
        flash = new FLASHDRVR(m_fpga);
        flash = new FLASHDRVR(m_fpga);
 
 
 
        if ((strcmp(&argv[argn][strlen(argv[argn])-4],".bit")!=0)
 
                &&(strcmp(&argv[argn][strlen(argv[argn])-4],".bin")!=0)) {
 
                printf("I'm expecting a '.bit' or \'.bin\' file extension\n");
 
                exit(-1);
 
        }
 
 
        fp = fopen(argv[argn], "r");
        fp = fopen(argv[argn], "r");
 
        if (strcmp(&argv[argn][strlen(argv[argn])-4],".bit")==0)
 
                fseek(fp, 0x5dl, SEEK_SET);
        sz = fread(buf, sizeof(buf[0]), BUFLN, fp);
        sz = fread(buf, sizeof(buf[0]), BUFLN, fp);
        fclose(fp);
        fclose(fp);
 
 
        for(int i=0; i<sz; i++) {
        for(int i=0; i<sz; i++) {
                buf[i] = byteswap(buf[i]);
                buf[i] = byteswap(buf[i]);
Line 141... Line 156...
        } catch(BUSERR b) {
        } catch(BUSERR b) {
                fprintf(stderr, "BUS-ERR, trying to read QSPI port\n");
                fprintf(stderr, "BUS-ERR, trying to read QSPI port\n");
                exit(-1);
                exit(-1);
        }
        }
 
 
        if (m_fpga->poll())
        printf("ALL-DONE\n");
                printf("FPGA was interrupted\n");
 
        delete  m_fpga;
        delete  m_fpga;
}
}
 
 
 
 
 
 
 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.