Skip to content

Xmodem Loader

February 9, 2017

At close of day today I have dumbed down the loader further by taking all the error checking and recovery out of the 1802 code(!). The connection between the AVR and the 1802 is not subject to line errors and as long as i keep the blocks small i won’t overrun the AVR’s buffer. This seems to work about 4 out of 5 times, the odd time the 1802 program stalls somewhere but of course i don’t know where because: no error checking, no timeouts, no nothing.  The windows program always thinks everything is fine.  I save all the checksums and block numbers and they look fine when it completes.


//ssxload super simple xmodem loader
//loads a single 32 byte block with checksum from a custom host program
//17-02-08 timeout on initial receives
//17-02-09 no timeouts, single start ack, no error checking
//17-02-09 header read moved into main
#include <nstdlib.h>
#include <olduino.h>
#include <cpu1802spd4port7.h>
#include "xloader.h"
#define blocksize 32
unsigned char target[1024];
unsigned char blkno, hdr[256],bseq[256],iseq[256],csum[256];
int readblk(unsigned char * where){//read a block
unsigned int cnt=blocksize;
bseq[blkno]=readch();
iseq[blkno]=readch();
while(cnt>0){
*where++=readch();
cnt--;
}
csum[blkno]=readch(); //read the checksum
return 0;
}
void main(){
int ch='?',eot=0;
unsigned char *t=target;
unsigned int i;
unsigned char thishdr;
blkno=0;
putch(NAK); //send NAK to start
thishdr=readch(); //get the header character
while(thishdr!=EOT){
hdr[blkno]=thishdr;
readblk(t);
blkno++;
t+=blocksize;
putch(ACK);
thishdr=readch();
}
putch(ACK);
//and we're done - god willing

delay(5000);//let python clear out
dump(target,128);
printf("number of blocks %d\n",blkno);
printf("bb hh:bn/in cs\n");
for (i=0;i<blkno;i++){
printf("%cx %cx:%cx/%cx %cx\n",i,hdr[i],bseq[i],iseq[i],csum[i]);
}
while(1);
}
#include <nstdlib.c>
#include <olduino.c>

There’s an 1802 elf/os specific xmodem receiver here http://www.elf-emulation.com/software.html

 

17-02-09-dumber-xmodem

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: