URL
https://opencores.org/ocsvn/s6soc/s6soc/trunk
Subversion Repositories s6soc
Compare Revisions
- This comparison shows the changes necessary to convert path
/s6soc
- from Rev 18 to Rev 19
- ↔ Reverse comparison
Rev 18 → Rev 19
/trunk/sw/host/dumpuart.cpp
0,0 → 1,102
//////////////////////////////////////////////////////////////////////////////// |
// |
// Filename: dumpuart.cpp |
// |
// Project: CMod S6 System on a Chip, ZipCPU demonstration project |
// |
// Purpose: To produce any and all data from the UART port onto an output |
// pipe and/or an output file. This replaces the minicom |
// interface. This is necessary because 1) minicom can take a while to |
// set up, 2) the default interface is at 9600 Baud (not minicom's |
// default), 3) this produces an unfiltered/unbuffered terminal output, |
// and 4) it also guarantees that output goes to a file (when requested). |
// |
// 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. |
// |
// 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 <sys/types.h> |
#include <sys/stat.h> |
#include <fcntl.h> |
#include <unistd.h> |
#include <strings.h> |
#include <ctype.h> |
#include <string.h> |
#include <signal.h> |
#include <assert.h> |
#include <termios.h> |
|
int main(int argc, char **argv) { |
const char *dev = argv[1]; |
const char *fname = (argc>=3)?argv[2]:NULL; |
int ttyfd = -1, dumpfd = -1; |
|
ttyfd = open(dev, O_RDONLY); |
if (fname) |
dumpfd = open(fname, O_CREAT|O_TRUNC|O_WRONLY, 0644); |
|
// Set the baud rate ... |
{ |
struct termios tb; |
|
tcgetattr(ttyfd, &tb); |
// Set to raw mode |
cfmakeraw(&tb); |
// Non-canonical mode (no line editing ...) |
tb.c_lflag &= (~(ICANON)); |
// Set no parity, 8 bit |
tb.c_cflag &= (~(CRTSCTS)); |
// One stop bit |
tb.c_cflag &= (~(CSTOPB)); |
// 9600 Baud |
cfsetspeed(&tb, B9600); |
// Block until at least one byte is available |
tb.c_cc[VMIN] = 1; |
tb.c_cc[VTIME] = 0; |
// Commit the changes |
tcsetattr(ttyfd, TCSANOW, &tb); |
} |
|
/* |
if (isatty(STDOUT_FILENO)) { |
struct termios tb; |
tcgetattr(STDOUT_FILENO, &tb); |
} |
*/ |
|
char buf[64]; |
int nr; |
|
while((nr=read(ttyfd, buf, sizeof(buf)))>0) { |
if (dumpfd >= 0) |
write(dumpfd, buf, nr); |
write(STDOUT_FILENO, buf, nr); |
} |
|
close(ttyfd); |
if (dumpfd >= 0) |
close(dumpfd); |
} |
/trunk/sw/host/zipload.cpp
493,6 → 493,7
} |
} |
|
unsigned startaddr = RESET_ADDRESS, codelen = 0; |
for(int i=0; secpp[i]->m_len; i++) { |
secp = secpp[i]; |
if ((secp->m_start >= RAMBASE) |
502,14 → 503,26
if (secp->m_data[i] != 0) { |
fprintf(stderr, "ERR: Cannot set RAM upon bootup!\n"); |
fprintf(stderr, "(The bootloaders just not that smart ... yet)\n"); |
fprintf(stderr, "Attempting to set %08x - %08x\n", secp->m_start, secp->m_start+secp->m_len-1); |
fprintf(stderr, "%08x cannot be set to %08x\n", secp->m_start+i, secp->m_data[i]); |
exit(EXIT_FAILURE); |
} |
} |
} else if (!flash->write(secp->m_start, secp->m_len, secp->m_data, true)) { |
fprintf(stderr, "ERR: Could not write program to flash\n"); |
exit(EXIT_FAILURE); |
} else { |
if (secp->m_start < startaddr) { |
codelen += (startaddr-secp->m_start); |
startaddr = secp->m_start; |
} if (secp->m_start+secp->m_len > startaddr+codelen) { |
codelen = secp->m_start+secp->m_len-startaddr; |
} memcpy(&fbuf[secp->m_start-SPIFLASH], |
secp->m_data, |
secp->m_len*sizeof(FPGA::BUSW)); |
} |
} |
if (!flash->write(startaddr, codelen, &fbuf[startaddr-SPIFLASH], true)) { |
fprintf(stderr, "ERR: Could not write program to flash\n"); |
exit(EXIT_FAILURE); |
} |
m_fpga->readio(R_VERSION); // Check for bus errors |
|
// Now ... how shall we start this CPU? |
/trunk/sw/host/flashdrvr.cpp
156,6 → 156,10
// If this buffer is equal to the sector value(s), go on |
// If not, erase the sector |
|
/* |
fprintf(stderr, "FLASH->write(%08x, %d, ..., %s)\n", addr, len, |
(verify)?"Verify":""); |
*/ |
// m_fpga->writeio(R_QSPI_CREG, 2); |
// m_fpga->readio(R_VERSION); // Read something innocuous |
// m_fpga->writeio(R_QSPI_SREG, 0); |
/trunk/sw/host/Makefile
39,7 → 39,7
## |
## |
all: |
PROGRAMS := wbregs readflash zipload buildsamples |
PROGRAMS := wbregs readflash zipload buildsamples dumpuart |
all: $(PROGRAMS) |
|
CXX := g++ |
74,6 → 74,9
buildsamples: buildsamples.cpp |
$(CXX) $(CFLAGS) $^ -o $@ |
|
dumpuart: dumpuart.cpp |
$(CXX) $(CFLAGS) $^ -o $@ |
|
define build-depends |
@echo "Building dependency file(s)" |
@$(CXX) $(CFLAGS) -MM $(SOURCES) $(BUSSRCS) > $(OBJDIR)/xdepends.txt |