Merge pull request #4 from igor-m/master

Mods to ZMODEM, rz may work better now
This commit is contained in:
Matt Jenkins
2014-04-11 12:02:41 +01:00
4 changed files with 75 additions and 32 deletions

View File

@@ -4,7 +4,8 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror -DV7 -DMD=2 -DTXBSIZE=8192 -DNFGVMIN -DSEGMENTS=32
CFLAGS += -Werror -DV7 -DMD=2 -DTXBSIZE=4096 -DNFGVMIN -DSEGMENTS=2
#CFLAGS += -Werror -DV7 -DMD=2 -DTXBSIZE=1024 -DNFGVMIN -DSEGMENTS=8
SRCS = rz.c sz.c
OBJS = rz.o sz.o

View File

@@ -117,6 +117,9 @@
#define HOWMANY 133
#endif
// PITO:
#define readline_timeout 1
/* Ward Christensen / CP/M parameters - Don't change these! */
#define ENQ 005
#define CAN ('X'&037)
@@ -209,6 +212,7 @@ char zconv; /* ZMODEM file conversion request */
char zmanag; /* ZMODEM file management request */
char ztrans; /* ZMODEM file transport request */
int Zctlesc; /* Encode control characters */
int Zrwindow = 1400; /* RX window size (controls garbage count) */
jmp_buf tohere; /* For the interrupt on RX timeout */
@@ -358,15 +362,22 @@ char *argv[];
usage()
{
cucheck();
fprintf(stderr,"Usage: rz [-abeuvy] (ZMODEM)\n");
fprintf(stderr,"Usage: rz [-+abDepqtuvy] (ZMODEM)\n");
fprintf(stderr,"or rb [-abuvy] (YMODEM)\n");
fprintf(stderr,"or rx [-abcv] file (XMODEM or XMODEM-1k)\n");
fprintf(stderr," -+ append transmitted data to an existing file\n");
fprintf(stderr," -a ASCII transfer (strip CR)\n");
fprintf(stderr," -b Binary transfer for all files\n");
#ifndef vax11c
fprintf(stderr," -c Use 16 bit CRC (XMODEM)\n");
#endif
fprintf(stderr," -D Output file to /dev/null\n");
fprintf(stderr," -e Escape control characters (ZMODEM)\n");
fprintf(stderr," -p Skip file if destination exists\n");
fprintf(stderr," -q Quiet suppresses verbosity\n");
fprintf(stderr," -t tim Change Rxtimeout to tim tenths of seconds (10-1000)\n");
fprintf(stderr," -u Do not make file pathnames lower case \n");
fprintf(stderr," -w n Rx window size to n bytes (ZMODEM)\n");
fprintf(stderr," -v Verbose more v's give more info\n");
fprintf(stderr," -y Yes, clobber existing file if any\n");
fprintf(stderr,"%s %s for %s by Chuck Forsberg, Omen Technology INC\n",
@@ -466,7 +477,7 @@ char *rpn; /* receive a pathname */
register c;
#ifdef NFGVMIN
readline(1);
readline(readline_timeout);
#else
purgeline();
#endif
@@ -480,7 +491,7 @@ et_tu:
zperr( "Pathname fetch returned %d", c);
sendline(ACK);
Lleft=0; /* Do read next time ... */
readline(1);
readline(readline_timeout);
goto et_tu;
}
return ERROR;
@@ -565,20 +576,20 @@ int maxtime;
if (firstch==SOH) {
Blklen=128;
get2:
sectcurr=readline(1);
if ((sectcurr+(oldcrc=readline(1)))==0377) {
sectcurr=readline(readline_timeout);
if ((sectcurr+(oldcrc=readline(readline_timeout)))==0377) {
oldcrc=checksum=0;
for (p=rxbuf,wcj=Blklen; --wcj>=0; ) {
if ((firstch=readline(1)) < 0)
if ((firstch=readline(readline_timeout)) < 0)
goto bilge;
oldcrc=updcrc(firstch, oldcrc);
checksum += (*p++ = firstch);
}
if ((firstch=readline(1)) < 0)
if ((firstch=readline(readline_timeout)) < 0)
goto bilge;
if (Crcflg) {
oldcrc=updcrc(firstch, oldcrc);
if ((firstch=readline(1)) < 0)
if ((firstch=readline(readline_timeout)) < 0)
goto bilge;
oldcrc=updcrc(firstch, oldcrc);
if (oldcrc & 0xFFFF)
@@ -600,7 +611,7 @@ get2:
}
/* make sure eot really is eot and not just mixmash */
#ifdef NFGVMIN
else if (firstch==EOT && readline(1)==TIMEOUT)
else if (firstch==EOT && readline(readline_timeout)==TIMEOUT)
return WCEOT;
#else
else if (firstch==EOT && Lleft==0)
@@ -626,7 +637,7 @@ bilge:
humbug:
Lastrx=0;
while(readline(1)!=TIMEOUT)
while(readline(readline_timeout)!=TIMEOUT)
;
if (Firstsec) {
sendline(Crcflg?WANTCRC:NAK);
@@ -650,10 +661,12 @@ humbug:
* timeout is in tenths of seconds
*/
readline(timeout)
int timeout;
unsigned int timeout;
{
register n;
unsigned int n;
register char *p;
static char *cdq; /* pointer for removing chars from linbuf */
int c;
if (--Lleft >= 0) {
if (Verbose > 8) {
@@ -662,8 +675,10 @@ int timeout;
return (*cdq++ & 0377);
}
n = timeout/10;
if (n < 2)
if (n < 2 && timeout!=1)
n = 3;
else if (n==0)
n=1;
if (Verbose > 5)
fprintf(stderr, "Calling read: alarm=%d Readnum=%d ",
n, Readnum);
@@ -677,6 +692,7 @@ int timeout;
return TIMEOUT;
}
signal(SIGALRM, alrm); alarm(n);
//errno=0;
Lleft=read(0, cdq=linbuf, Readnum);
alarm(0);
if (Verbose > 5) {
@@ -684,10 +700,22 @@ int timeout;
}
if (Lleft < 1)
return TIMEOUT;
--Lleft;
if (Verbose > 8) {
fprintf(stderr, "%02x ", *cdq&0377);
for (p=cdq, n = Lleft; --n >= 0; ) {
fprintf(stderr, "%02x ", *p++ &0377);
}
fprintf(stderr, "\n");
for (p=cdq, n = Lleft; --n >= 0; ) {
c = *p++ & 0177;
if (!isprint(c))
c = '.';
fprintf(stderr, " %c ", c);
}
fprintf(stderr, "\n");
}
--Lleft;
return (*cdq++ & 0377);
}
@@ -1483,7 +1511,7 @@ ackbibi()
zshhdr(4,ZFIN, Txhdr);
switch (readline(100)) {
case 'O':
readline(1); /* Discard 2nd 'O' */
readline(readline_timeout); /* Discard 2nd 'O' */
vfile("ackbibi complete");
return;
case RCDO:

View File

@@ -6,7 +6,7 @@ S = ../../../tools/configsys/../../sys/kernel
vpath %.c $(M):$(S)
vpath %.S $(M):$(S)
KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o glcd.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o oc.o rd_sd.o rdisk.o signal.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o usb_device.o usb_function_cdc.o usb_uart.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o
KERNOBJ += _startup.o adc.o clock.o cons.o devsw.o exception.o gpio.o init_main.o init_sysent.o kern_clock.o kern_descrip.o kern_exec.o kern_exit.o kern_fork.o kern_mman.o kern_proc.o kern_prot.o kern_prot2.o kern_resource.o kern_sig.o kern_sig2.o kern_subr.o kern_synch.o kern_sysctl.o kern_time.o machdep.o mem.o oc.o rd_sd.o rd_sramc.o rdisk.o signal.o spi.o spi_bus.o subr_prf.o subr_rmap.o swap.o sys_generic.o sys_inode.o sys_pipe.o sys_process.o syscalls.o sysctl.o tty.o tty_subr.o tty_tty.o uart.o ufs_alloc.o ufs_bio.o ufs_bmap.o ufs_dsort.o ufs_fio.o ufs_inode.o ufs_mount.o ufs_namei.o ufs_subr.o ufs_syscalls.o ufs_syscalls2.o vers.o vfs_vnops.o vm_sched.o vm_swap.o vm_swp.o
EXTRA_TARGETS = bootloader
DEFS += -DADC_ENABLED=YES
@@ -16,11 +16,11 @@ DEFS += -DBL_CRYSTAL=8
DEFS += -DBL_LED_PIN=5
DEFS += -DBL_LED_PORT=TRISE
DEFS += -DBUS_DIV=1
DEFS += -DBUS_KHZ=80000
DEFS += -DCONSOLE_DEVICE=ttyUSB0
DEFS += -DCPU_IDIV=2
DEFS += -DCPU_KHZ=80000
DEFS += -DCPU_MUL=20
DEFS += -DBUS_KHZ=120000
DEFS += -DCONSOLE_DEVICE=tty1
DEFS += -DCPU_IDIV=1
DEFS += -DCPU_KHZ=120000
DEFS += -DCPU_MUL=15
DEFS += -DCPU_ODIV=1
DEFS += -DCRYSTAL=8
DEFS += -DDC0_DEBUG=DEVCFG0_DEBUG_DISABLED
@@ -35,8 +35,8 @@ DEFS += -DDC1_POSCMOD=DEVCFG1_POSCMOD_HS
DEFS += -DDC1_SOSC=0
DEFS += -DDC1_WDTEN=0
DEFS += -DDC1_WDTPS=DEVCFG1_WDTPS_1
DEFS += -DDC2_PLLIDIV=DEVCFG2_FPLLIDIV_2
DEFS += -DDC2_PLLMUL=DEVCFG2_FPLLMUL_20
DEFS += -DDC2_PLLIDIV=DEVCFG2_FPLLIDIV_1
DEFS += -DDC2_PLLMUL=DEVCFG2_FPLLMUL_15
DEFS += -DDC2_PLLODIV=DEVCFG2_FPLLODIV_1
DEFS += -DDC2_UPLL=0
DEFS += -DDC2_UPLLIDIV=DEVCFG2_UPLLIDIV_2
@@ -48,7 +48,6 @@ DEFS += -DDC3_USBID=DEVCFG3_FUSBIDIO
DEFS += -DDC3_USERID=0xffff
DEFS += -DDC3_VBUSON=DEVCFG3_FVBUSONIO
DEFS += -DFLASH_JUMP=0x9d000000
DEFS += -DGLCD_ENABLED=YES
DEFS += -DGPIO_ENABLED=YES
DEFS += -DHID_FEATURE_REPORT_BYTES=2
DEFS += -DHID_INPUT_REPORT_BYTES=2
@@ -56,24 +55,35 @@ DEFS += -DHID_INT_IN_EP_SIZE=64
DEFS += -DHID_INT_OUT_EP_SIZE=64
DEFS += -DHID_OUTPUT_REPORT_BYTES=2
DEFS += -DHID_RPT01_SIZE=29
DEFS += -DHZ=1000
DEFS += -DKERNEL
DEFS += -DLED_KERNEL_PIN=5
DEFS += -DLED_KERNEL_PORT=TRISE
DEFS += -DNBUF=8
DEFS += -DNMOUNT=3
DEFS += -DNPROC=25
DEFS += -DOC_ENABLED=YES
DEFS += -DPARTITION="sramc0:sa@2048,fs@6140"
DEFS += -DPIC32MX7
DEFS += -DSD0_CS_PIN=9
DEFS += -DSD0_CS_PORT=TRISG
DEFS += -DSD0_MHZ=20
DEFS += -DSD0_PORT=2
DEFS += -DUARTUSB_ENABLED=YES
DEFS += -DSPI_ENABLED=YES
DEFS += -DSRAMC_ENABLED=YES
DEFS += -DUART1_BAUD=115200
DEFS += -DUART1_ENABLED=YES
DEFS += -DUART2_BAUD=115200
DEFS += -DUART2_ENABLED=YES
DEFS += -DUCB_METER
DEFS += -DUSB_EP0_BUFF_SIZE=8
DEFS += -DUSB_MAX_EP_NUMBER=3
DEFS += -DUSB_MAX_EP_NUMBER=1
DEFS += -DUSB_NUM_STRING_DESCRIPTORS=3
LDSCRIPT = ../../../tools/configsys/../../sys/pic32/cfg/bootloader.ld
CONFIG = FUBARINO
CONFIG = FUBARINO-UART2CONS-UART1-SRAMC
CONFIGPATH = ../../../tools/configsys
include ../../../tools/configsys/../../sys/pic32/kernel-post.mk

View File

@@ -1026,6 +1026,10 @@
#define DEVCFG1_WDTPS_524288 0x00130000 /* 1:524288 */
#define DEVCFG1_WDTPS_1048576 0x00140000 /* 1:1048576 */
#define DEVCFG1_FWDTEN 0x00800000 /* Watchdog enable */
#define WDTCON PIC32_R (0x0000) /* Watchdog timer control */
#define WDTCONCLR PIC32_R (0x0004) /* Watchdog timer control */
#define WDTCONSET PIC32_R (0x0008) /* Watchdog timer control */
/*
* Config2 register at 1fc02ff4.