URL
https://opencores.org/ocsvn/openarty/openarty/trunk
Subversion Repositories openarty
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 13 to Rev 14
- ↔ Reverse comparison
Rev 13 → Rev 14
/openarty/trunk/sw/host/wbprogram.cpp
35,7 → 35,7
int main(int argc, char **argv) { |
FILE *fp; |
const int BUFLN = (1<<20); // 4MB Flash |
DEVBUS::BUSW *buf = new DEVBUS::BUSW[BUFLN], v, addr = QSPIFLASH; |
DEVBUS::BUSW *buf = new DEVBUS::BUSW[BUFLN], v, addr = EQSPIFLASH; |
FLASHDRVR *flash; |
int argn = 1; |
|
69,7 → 69,7
exit(-1); |
} else if (argv[argn][0] == '@') { |
addr = strtoul(&argv[argn][1], NULL, 0); |
if ((addr < QSPIFLASH)||(addr > QSPIFLASH*2)) { |
if ((addr < EQSPIFLASH)||(addr > EQSPIFLASH*2)) { |
printf("BAD ADDRESS: 0x%08x (from %s)\n", addr, argv[argn]); |
exit(-1); |
} argn++; |
90,7 → 90,7
fclose(fp); |
|
try { |
flash->write(addr, sz, buf, false); |
flash->write(addr, sz, buf, true); |
} catch(BUSERR b) { |
fprintf(stderr, "BUS-ERR @0x%08x\n", b.addr); |
exit(-1); |
/openarty/trunk/sw/host/eqspiscope.cpp
58,11 → 58,12
} |
|
class EQSPISCOPE : public SCOPE { |
int m_oword[2], m_iword[2], m_p; |
public: |
EQSPISCOPE(FPGA *fpga, unsigned addr, bool vecread) |
: SCOPE(fpga, addr, false, false) {}; |
~EQSPISCOPE(void) {} |
virtual void decode(DEVBUS::BUSW val) const { |
virtual void decode(DEVBUS::BUSW val) { |
int cyc, cstb, dstb, ack, back, accepted, valid, word, |
out, cs, sck, mod, odat, idat; |
|
81,10 → 82,19
odat = (val>> 4)&15; |
idat = (val )&15; |
|
printf("%s%s%s%s%s%s%s %02x %02x %s%s %d %x-> ->%x", |
(cyc)?"C ":" ", |
(cstb)?"C":" ", |
(dstb)?"D":" ", |
m_p = (m_p^1)&1; |
if (mod&2) { |
m_oword[m_p] = (m_oword[m_p]<<4)|odat; |
m_iword[m_p] = (m_iword[m_p]<<4)|idat; |
} else { |
m_oword[m_p] = (m_oword[m_p]<<1)|(odat&1); |
m_iword[m_p] = (m_iword[m_p]<<1)|((idat&2)?1:0); |
} |
|
printf("%s%s%s%s%s%s%s %02x %02x %s%s %d %x.%d-> ->%x.%d", |
(cyc)?"CYC ":" ", |
(cstb)?"CSTB":" ", |
(dstb)?"DSTB":" ", |
(ack)?"AK":" ", |
(back)?"+":" ", |
(accepted)?"ACC":" ", |
92,7 → 102,9
word<<1, out<<2, |
(cs)?" ":"CS", |
(sck)?"CK":" ", |
(mod), odat, idat); |
(mod), odat, (odat&1)?1:0, idat, (idat&2)?1:0); |
|
printf(" / %08x -> %08x", m_oword[m_p], m_iword[m_p]); |
|
} |
}; |
/openarty/trunk/sw/host/regdefs.cpp
94,6 → 94,10
{ R_GPSCOPED, "GPSSCDATA" }, |
{ R_GPSCOPED, "GPSSCD" }, |
{ R_GPSCOPED, "GPSDATA" }, |
{ R_CFGSCOPE, "CFGSCOPE" }, // Scope one |
{ R_CFGSCOPE, "CFGSCOP" }, |
{ R_CFGSCOPED, "CFGSCDATA" }, |
{ R_CFGSCOPED, "CFGSCD" }, |
{ R_RAMSCOPE, "RAMSCOPE" }, // Scope two |
{ R_RAMSCOPE, "RAMSCOP" }, |
{ R_RAMSCOPED, "RAMSCOPD" }, |
/openarty/trunk/sw/host/dumpflash.cpp
95,7 → 95,14
sz+=1; |
printf("The size of the buffer is 0x%06x or %d words\n", sz, sz); |
|
fp = fopen("eqspidump.bin","w"); |
#define FLASHFILE "eqspidump.bin" |
|
if (access(FLASHFILE, F_OK)==0) { |
fprintf(stderr, "Cowardly refusing to overwrite %s\n", FLASHFILE); |
exit(EXIT_FAILURE); |
} |
|
fp = fopen(FLASHFILE,"w"); |
fwrite(buf, sizeof(buf[0]), sz, fp); |
fclose(fp); |
|
/openarty/trunk/sw/host/regdefs.h
60,7 → 60,9
#define R_QSCOPE 0x00000120 // Quad SPI scope ctrl |
#define R_QSCOPED 0x00000121 // and data |
#define R_GPSCOPE 0x00000122 // GPS configuration scope control |
#define R_GPSCOPED 0x00000123 // and data, uses Mouse scope addrs |
#define R_GPSCOPED 0x00000123 // and data |
#define R_CFGSCOPE 0x00000122 // ICAPE2 configuration scop control |
#define R_CFGSCOPED 0x00000123 // and data |
#define R_RAMSCOPE 0x00000124 // DDR3 SDRAM Scope |
#define R_RAMSCOPED 0x00000125 // |
#define R_NETSCOPE 0x00000126 // Ethernet debug scope |
178,15 → 180,20
#define SCOPEN 0x84000400 // Enable WBSCOPE interrupts |
|
// Flash control constants |
#define ERASEFLAG 0x80000000 |
#define DISABLEWP 0x10000000 |
#define ERASEFLAG 0xc00001be |
#define DISABLEWP 0x40000000 |
#define ENABLEWP 0x00000000 |
|
#define SZPAGE 64 |
#define PGLEN 64 |
#define SZPAGEB 256 |
#define PGLENB 256 |
#define SZPAGEW 64 |
#define PGLENW 64 |
#define NPAGES 256 |
#define SECTORSZ (NPAGES * SZPAGE) |
#define SECTORSZB (NPAGES * SZPAGEB) // In bytes, not words!! |
#define SECTORSZW (NPAGES * SZPAGEW) // In words |
#define NSECTORS 64 |
#define SECTOROF(A) ((A) & (-1<<14)) |
#define SUBSECTOROF(A) ((A) & (-1<<10)) |
#define PAGEOF(A) ((A) & (-1<<6)) |
|
#define CPU_GO 0x0000 |
/openarty/trunk/sw/host/flashdrvr.cpp
1,17 → 1,41
//////////////////////////////////////////////////////////////////////////////// |
// |
// |
// Filename: flashdrvr.cpp |
// |
// Project: FPGA library development (Basys3 development board) |
// Project: OpenArty, an entirely open SoC based upon the Arty platform |
// |
// Purpose: Flash driver. Encapsulate writing to the flash device. |
// Purpose: Flash driver. Encapsulates the erasing and programming (i.e. |
// writing) necessary to set the values in a flash device. |
// |
// Creator: Dan Gisselquist |
// Gisselquist Tecnology, LLC |
// Creator: Dan Gisselquist, Ph.D. |
// Gisselquist Technology, LLC |
// |
// Copyright: 2015 |
//////////////////////////////////////////////////////////////////////////////// |
// |
// 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 |
// |
// |
//////////////////////////////////////////////////////////////////////////////// |
// |
// |
#include <stdio.h> |
#include <stdlib.h> |
#include <unistd.h> |
27,6 → 51,9
|
const bool HIGH_SPEED = false; |
|
#define SETSCOPE m_fpga->writeio(R_QSCOPE, 8180) |
|
|
void FLASHDRVR::flwait(void) { |
DEVBUS::BUSW v; |
|
55,10 → 82,11
} |
|
bool FLASHDRVR::erase_sector(const unsigned sector, const bool verify_erase) { |
DEVBUS::BUSW page[SZPAGE]; |
DEVBUS::BUSW page[SZPAGEW]; |
|
printf("Erasing sector: %08x\n", sector); |
m_fpga->writeio(R_QSPI_EREG, DISABLEWP); |
SETSCOPE; |
m_fpga->writeio(R_QSPI_EREG, ERASEFLAG + sector); |
|
// If we're in high speed mode and we want to verify the erase, then |
71,8 → 99,8
|
printf("@%08x -> %08x\n", R_QSPI_EREG, |
m_fpga->readio(R_QSPI_EREG)); |
printf("@%08x -> %08x\n", R_QSPI_SREG, |
m_fpga->readio(R_QSPI_SREG)); |
printf("@%08x -> %08x\n", R_QSPI_STAT, |
m_fpga->readio(R_QSPI_STAT)); |
printf("@%08x -> %08x\n", sector, |
m_fpga->readio(sector)); |
} |
80,8 → 108,8
// Now, let's verify that we erased the sector properly |
if (verify_erase) { |
for(int i=0; i<NPAGES; i++) { |
m_fpga->readi(sector+i*SZPAGE, SZPAGE, page); |
for(int i=0; i<SZPAGE; i++) |
m_fpga->readi(sector+i*SZPAGEW, SZPAGEW, page); |
for(int i=0; i<SZPAGEW; i++) |
if (page[i] != 0xffffffff) |
return false; |
} |
92,10 → 120,10
|
bool FLASHDRVR::write_page(const unsigned addr, const unsigned len, |
const unsigned *data, const bool verify_write) { |
DEVBUS::BUSW buf[SZPAGE]; |
DEVBUS::BUSW buf[SZPAGEW]; |
|
assert(len > 0); |
assert(len <= PGLEN); |
assert(len <= PGLENW); |
assert(PAGEOF(addr)==PAGEOF(addr+len-1)); |
|
if (len <= 0) |
107,6 → 135,7
m_fpga->writeio(R_ICONTROL, ISPIF_EN); |
printf("Writing page: 0x%08x - 0x%08x\n", addr, addr+len-1); |
m_fpga->writeio(R_QSPI_EREG, DISABLEWP); |
SETSCOPE; |
m_fpga->writei(addr, len, data); |
|
// If we're in high speed mode and we want to verify the write, then |
152,17 → 181,17
// m_fpga->writeio(R_QSPI_SREG, 0); |
// m_fpga->readio(R_VERSION); // Read something innocuous |
|
for(unsigned s=SECTOROF(addr); s<SECTOROF(addr+len+SECTORSZ-1); s+=SECTORSZ) { |
for(unsigned s=SECTOROF(addr); s<SECTOROF(addr+len+SECTORSZW-1); s+=SECTORSZW) { |
// printf("IN LOOP, s=%08x\n", s); |
// Do we need to erase? |
bool need_erase = false; |
unsigned newv = 0; // (s<addr)?addr:s; |
{ |
DEVBUS::BUSW *sbuf = new DEVBUS::BUSW[SECTORSZ]; |
DEVBUS::BUSW *sbuf = new DEVBUS::BUSW[SECTORSZW]; |
const DEVBUS::BUSW *dp; |
unsigned base,ln; |
base = (addr>s)?addr:s; |
ln=((addr+len>s+SECTORSZ)?(s+SECTORSZ):(addr+len))-base; |
ln=((addr+len>s+SECTORSZW)?(s+SECTORSZW):(addr+len))-base; |
m_fpga->readi(base, ln, sbuf); |
|
dp = &data[base-addr]; |
195,13 → 224,13
return false; |
} newv = (s<addr) ? addr : s; |
} |
for(unsigned p=newv; (p<s+SECTORSZ)&&(p<addr+len); p=PAGEOF(p+PGLEN)) { |
for(unsigned p=newv; (p<s+SECTORSZW)&&(p<addr+len); p=PAGEOF(p+PGLENW)) { |
unsigned start = p, len = addr+len-start; |
|
// BUT! if we cross page boundaries, we need to clip |
// our results to the page boundary |
if (PAGEOF(start+len-1)!=PAGEOF(start)) |
len = PAGEOF(start+PGLEN)-start; |
len = PAGEOF(start+PGLENW)-start; |
if (!write_page(start, len, &data[p-addr], verify)) { |
printf("WRITE-PAGE FAILED!\n"); |
return false; |
209,7 → 238,7
} |
} |
|
m_fpga->writeio(R_QSPI_EREG, 0); // Re-enable write protection |
m_fpga->writeio(R_QSPI_EREG, ENABLEWP); // Re-enable write protection |
|
return true; |
} |
/openarty/trunk/sw/host/Makefile
37,17 → 37,16
## |
## |
.PHONY: all |
PROGRAMS := wbregs netuart wbsettime dumpflash # wbprogram |
PROGRAMS := wbregs netuart wbsettime dumpflash wbprogram |
all: $(PROGRAMS) |
CXX := g++ |
OBJDIR := obj-pc |
# ZIPD := /home/dan/work/rnd/zipcpu/trunk/sw/zasm |
BUSOBJS := $(OBJDIR)/ttybus.o $(OBJDIR)/llcomms.o $(OBJDIR)/regdefs.o |
# BUSOBJS := $(OBJDIR)/portbus.o $(OBJDIR)/llcomms.o $(OBJDIR)/regdefs.o |
SOURCES := wbregs.cpp wbprogram.cpp netuart.cpp wbsettime.cpp \ |
ttybus.cpp llcomms.cpp |
# ziprun.cpp |
# dumpmem.cpp nmea.cpp display.cpp |
ttybus.cpp llcomms.cpp dumpflash.cpp eqspiscope.cpp flashdrvr.cpp \ |
portbus.cpp regdefs.cpp scopecls.cpp sdramscope.cpp ttybus.cpp \ |
cfgscope.cpp |
# ziprun.cpp zipload.cpp |
HEADERS := llcomms.h ttybus.h devbus.h |
OBJECTS := $(addprefix $(OBJDIR)/,$(subst .cpp,.o,$(SOURCES))) |
|
62,10 → 61,10
clean: |
rm -rf $(OBJDIR)/*.o $(PROGRAMS) |
|
# dumpflash: $(OBJDIR)/dumpflash.o $(BUSOBJS) |
# $(CXX) -g $^ -o $@ |
# wbprogram: $(OBJDIR)/wbprogram.o $(OBJDIR)/flashdrvr.o $(BUSOBJS) |
# $(CXX) -g $^ -o $@ |
$(OBJDIR)/scopecls.o: scopecls.cpp scopecls.h |
$(OBJDIR)/eqspiscope.o: eqspiscope.cpp scopecls.h |
$(OBJDIR)/dumpflash.o: dumpflash.cpp regdefs.h |
|
netuart: $(OBJDIR)/netuart.o |
$(CXX) -g $^ -o $@ |
hsnetuart: $(OBJDIR)/hsnetuart.o |
82,6 → 81,10
$(CXX) -g $^ -o $@ |
sdramscope: $(OBJDIR)/sdramscope.o $(OBJDIR)/scopecls.o $(BUSOBJS) |
$(CXX) -g $^ -o $@ |
cfgscope: $(OBJDIR)/cfgscope.o $(OBJDIR)/scopecls.o $(BUSOBJS) |
$(CXX) -g $^ -o $@ |
wbprogram: $(OBJDIR)/wbprogram.o $(OBJDIR)/flashdrvr.o $(BUSOBJS) |
$(CXX) -g $^ -o $@ |
# ziprun: $(OBJDIR)/ziprun.o $(OBJDIR)/flashdrvr.o $(BUSOBJS) |
# $(CXX) -g $^ -lelf -o $@ |
# zipdbg: zipdbg.cpp $(ZIPD)/zparser.cpp $(ZIPD)/zopcodes.cpp $(ZIPD)/twoc.cpp $(BUSOBJS) |