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

Subversion Repositories openarty

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

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

Rev 14 Rev 18
Line 1... Line 1...
//
////////////////////////////////////////////////////////////////////////////////
//
//
// Filename:    wbprogram.cpp
// Filename:    wbprogram.cpp
//
//
// Project:     FPGA library development (Basys3 development board)
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
//
//
// Purpose:     Program the memory with a given '.bin' file.
// Purpose:     Program the memory with a given '.bin' file.
//
//
// Creator:     Dan Gisselquist
// Creator:     Dan Gisselquist, Ph.D.
//              Gisselquist Tecnology, LLC
//              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
 
//
 
//
 
////////////////////////////////////////////////////////////////////////////////
//
//
// Copyright:   2015
 
//
//
//
//
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <unistd.h>
#include <unistd.h>
Line 30... Line 54...
void    closeup(int v) {
void    closeup(int v) {
        m_fpga->kill();
        m_fpga->kill();
        exit(0);
        exit(0);
}
}
 
 
 
unsigned byteswap(unsigned x) {
 
        unsigned r;
 
 
 
        r  = x&0x0ff; x>>=8; r<<= 8;
 
        r |= x&0x0ff; x>>=8; r<<= 8;
 
        r |= x&0x0ff; x>>=8; r<<= 8;
 
        r |= x&0x0ff;
 
 
 
        return r;
 
}
 
 
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 87... Line 122...
 
 
        fp = fopen(argv[argn], "r");
        fp = fopen(argv[argn], "r");
        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++) {
 
                buf[i] = byteswap(buf[i]);
 
        }
 
 
        try {
        try {
                flash->write(addr, sz, buf, true);
                flash->write(addr, sz, buf, true);
        } catch(BUSERR b) {
        } catch(BUSERR b) {
                fprintf(stderr, "BUS-ERR @0x%08x\n", b.addr);
                fprintf(stderr, "BUS-ERR @0x%08x\n", b.addr);
                exit(-1);
                exit(-1);

powered by: WebSVN 2.1.0

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