unknown version
This commit is contained in:
parent
a581ab3e4f
commit
c09c84eb58
251
isp_down.c
251
isp_down.c
@ -3,143 +3,110 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
//#define BAUDRATE B115200
|
#define BAUDRATE B115200
|
||||||
//#define BAUDRATE B57600
|
|
||||||
#define BAUDRATE B38400
|
|
||||||
|
|
||||||
unsigned char sign[6][3]=
|
struct chip_ {
|
||||||
{0x00,0x90,0x1E, /* AT90S1200 tested 05.04.2001 */
|
char shortname[8];
|
||||||
0x01,0x91,0x1E, /* AT90S2313 tested 21.02.2001 */
|
char longname[16];
|
||||||
0x02,0x91,0x1E, /* AT90S2323 */
|
char signatur[3];
|
||||||
0x03,0x91,0x1E, /* AT90S2343 */
|
int flash_size;
|
||||||
0x01,0x92,0x1E, /* AT90S4414 */
|
int eeprom_size;
|
||||||
0x01,0x93,0x1E}; /* AT90S8515 tested 12.11.2001 */
|
};
|
||||||
|
|
||||||
unsigned int mem_size[6][2]=
|
typedef struct chip_ CHIP;
|
||||||
{0x1FF,0x3F, /* AT90S1200 tested 05.04.2001 */
|
|
||||||
0x3FF,0x7F, /* AT90S2313 tested 21.02.2001 */
|
|
||||||
0x3FF,0x7F, /* AT90S2323 */
|
|
||||||
0x3FF,0x7F, /* AT90S2343 */
|
|
||||||
0x7FF,0xFF, /* AT90S4414 */
|
|
||||||
0xFFF,0x1FF}; /* AT90S8515 tested 12.11.2001*/
|
|
||||||
|
|
||||||
struct termios oldtio, newtio;
|
CHIP chips[] = {
|
||||||
int ser;
|
{ "1200", "AT90S1200", { 0x00, 0x90, 0x1E }, 0x200, 0x40 },
|
||||||
|
{ "2313", "AT90S2313", { 0x01, 0x91, 0x1E }, 0x400, 0x80 },
|
||||||
|
{ "8515", "AT90S8515", { 0x01, 0x93, 0x1E }, 0x1000, 0x200 },
|
||||||
|
{ "\0", "\0", {0, 0, 0}, 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
void end_prg(char level);
|
|
||||||
void show_usage();
|
void show_usage();
|
||||||
|
|
||||||
main(int argc,char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int avr_device=5, verify=0, flash=0, eeprom=0, reset=0;
|
char arg;
|
||||||
char arg, ser_device[64]="/dev/ttyS0", flash_file[64]="", eeprom_file[64]="";
|
|
||||||
|
|
||||||
unsigned char inbuf[8], outbuf[8], databuf[8];
|
printf("\nISP for Atmel-AVRs:\n");
|
||||||
int fdat, eedat;
|
if (argc <= 1) {
|
||||||
unsigned int t;
|
show_usage();
|
||||||
|
exit(-1);
|
||||||
printf("\n***************************************\n");
|
}
|
||||||
printf("* In-System-Programmer for Atmel AVRs *\n");
|
|
||||||
printf("***************************************\n\n");
|
|
||||||
if (argc <= 1)
|
|
||||||
{
|
|
||||||
show_usage();
|
|
||||||
end_prg(0);
|
|
||||||
}
|
|
||||||
for (arg=1; arg<argc; arg++)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* check AVR-device */
|
|
||||||
if (!strcmp (argv[arg], "-avr"))
|
|
||||||
{
|
|
||||||
if (++arg == argc)
|
|
||||||
{
|
|
||||||
printf("ERROR: No AVR-Device\n\n");
|
|
||||||
end_prg(0);
|
|
||||||
}
|
|
||||||
if (!strcmp (argv[arg], "1200"))
|
|
||||||
avr_device=0;
|
|
||||||
else if (!strcmp (argv[arg], "2313"))
|
|
||||||
avr_device=1;
|
|
||||||
else if (!strcmp (argv[arg], "2323"))
|
|
||||||
avr_device=2;
|
|
||||||
else if (!strcmp (argv[arg], "2343"))
|
|
||||||
avr_device=3;
|
|
||||||
else if (!strcmp (argv[arg], "4414"))
|
|
||||||
avr_device=4;
|
|
||||||
else if (!strcmp (argv[arg], "8515"))
|
|
||||||
avr_device=5;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("ERROR: Unknown AVR-Device\n");
|
|
||||||
end_prg(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check RS232 device */
|
|
||||||
else if (!strcmp (argv[arg], "-dev"))
|
|
||||||
{
|
|
||||||
if (++arg == argc)
|
|
||||||
{
|
|
||||||
printf(" ERROR: No RS232-device\n");
|
|
||||||
end_prg(0);
|
|
||||||
}
|
|
||||||
strcpy (ser_device, argv[arg]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check flash */
|
|
||||||
else if (!strcmp (argv[arg], "-flash"))
|
|
||||||
flash=1;
|
|
||||||
|
|
||||||
/* check eeprom */
|
|
||||||
else if (!strcmp (argv[arg], "-eeprom"))
|
|
||||||
eeprom=1;
|
|
||||||
|
|
||||||
/* check verify */
|
|
||||||
else if (!strcmp (argv[arg], "-verify"))
|
|
||||||
verify=1;
|
|
||||||
|
|
||||||
/* check reset */
|
|
||||||
else if (!strcmp (argv[arg], "-reset"))
|
|
||||||
reset=1;
|
|
||||||
|
|
||||||
/* get flash-file */
|
|
||||||
else if (flash == 1)
|
|
||||||
{
|
|
||||||
strcpy (flash_file, argv[arg]);
|
|
||||||
flash=2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get eeprom-file */
|
|
||||||
else if (eeprom == 1)
|
|
||||||
{
|
|
||||||
strcpy (eeprom_file, argv[arg]);
|
|
||||||
eeprom=2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* wrong parameter */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf(" ERROR: Unknown parameter\n");
|
|
||||||
end_prg(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for (arg= 1; arg<argc; arg++) {
|
||||||
|
if (!strcmp (argv[arg], "-avr")) {
|
||||||
|
/* check AVR-device */
|
||||||
|
if (++arg == argc) {
|
||||||
|
printf("ERROR: No AVR-Device\n\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
if (!strcmp (argv[arg], "1200"))
|
||||||
|
avr_device=0;
|
||||||
|
else if (!strcmp (argv[arg], "2313"))
|
||||||
|
avr_device=1;
|
||||||
|
else if (!strcmp (argv[arg], "2323"))
|
||||||
|
avr_device=2;
|
||||||
|
else if (!strcmp (argv[arg], "2343"))
|
||||||
|
avr_device=3;
|
||||||
|
else if (!strcmp (argv[arg], "4414"))
|
||||||
|
avr_device=4;
|
||||||
|
else if (!strcmp (argv[arg], "8515"))
|
||||||
|
avr_device=5;
|
||||||
|
else {
|
||||||
|
printf("ERROR: Unknown AVR-Device\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
} else if (!strcmp (argv[arg], "-dev")) {
|
||||||
|
/* check RS232 device */
|
||||||
|
if (++arg == argc) {
|
||||||
|
printf(" ERROR: No RS232-device\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
strcpy (ser_device, argv[arg]);
|
||||||
|
} else if (!strcmp (argv[arg], "-flash")) {
|
||||||
|
/* check flash */
|
||||||
|
flash= 1;
|
||||||
|
} else if (!strcmp (argv[arg], "-eeprom")) {
|
||||||
|
/* check eeprom */
|
||||||
|
eeprom= 1;
|
||||||
|
} else if (!strcmp (argv[arg], "-verify")) {
|
||||||
|
/* check verify */
|
||||||
|
verify= 1;
|
||||||
|
} else if (!strcmp (argv[arg], "-reset")) {
|
||||||
|
/* check reset */
|
||||||
|
reset= 1;
|
||||||
|
} else if (flash == 1) {
|
||||||
|
/* get flash-file */
|
||||||
|
strcpy (flash_file, argv[arg]);
|
||||||
|
flash= 2;
|
||||||
|
} else if (eeprom == 1) {
|
||||||
|
/* get eeprom-file */
|
||||||
|
strcpy (eeprom_file, argv[arg]);
|
||||||
|
eeprom= 2;
|
||||||
|
} else {
|
||||||
|
/* wrong parameter */
|
||||||
|
printf(" ERROR: Unknown parameter\n");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flash == 1) {
|
||||||
/* check flash-file */
|
/* check flash-file */
|
||||||
if (flash == 1)
|
printf (" ERROR: No FLASH-file\n");
|
||||||
{
|
exit(-1);
|
||||||
printf (" ERROR: No FLASH-file\n");
|
}
|
||||||
end_prg(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (eeprom == 1) {
|
||||||
/* check eeprom-file */
|
/* check eeprom-file */
|
||||||
if (eeprom == 1)
|
printf (" ERROR: No EEPROM-file\n");
|
||||||
{
|
exit(-1);
|
||||||
printf (" ERROR: No EEPROM-file\n");
|
}
|
||||||
end_prg(0);
|
|
||||||
}
|
init_ser(ser_device);
|
||||||
|
|
||||||
/* open rs232-device */
|
|
||||||
|
/* open rs232-device */
|
||||||
printf(" Opening %s -----> ", ser_device);
|
printf(" Opening %s -----> ", ser_device);
|
||||||
ser = open(ser_device, O_RDWR | O_NOCTTY );
|
ser = open(ser_device, O_RDWR | O_NOCTTY );
|
||||||
if (ser <0)
|
if (ser <0)
|
||||||
@ -452,23 +419,21 @@ void end_prg(char level)
|
|||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_usage()
|
void show_usage() {
|
||||||
{
|
printf("USAGE:\n");
|
||||||
printf("USAGE:\n");
|
printf(" isp_down [OPTIONS] <flash-file> <eeprom-file>\n\n");
|
||||||
printf(" isp_down [OPTIONS] <flash-file> <eeprom-file>\n\n");
|
printf("OPTIONS:\n");
|
||||||
printf("OPTIONS:\n");
|
printf(" -avr <num> selects AVR-device\n");
|
||||||
printf(" -avr <num> selects AVR-device\n");
|
printf(" 1200 -> AT90S1200 1kB FLASH / 64 bytes EEPROM\n");
|
||||||
printf(" 1200 -> AT90S1200 1kB FLASH / 64 bytes EEPROM\n");
|
printf(" 2313 -> AT90S2313 2kB FLASH / 128 bytes EEPROM\n");
|
||||||
printf(" 2313 -> AT90S2313 2kB FLASH / 128 bytes EEPROM\n");
|
printf(" 2323 -> AT90S2323 2kB FLASH / 128 bytes EEPROM\n");
|
||||||
printf(" 2323 -> AT90S2323 2kB FLASH / 128 bytes EEPROM\n");
|
printf(" 2343 -> AT90S2343 2kB FLASH / 128 bytes EEPROM\n");
|
||||||
printf(" 2343 -> AT90S2343 2kB FLASH / 128 bytes EEPROM\n");
|
printf(" 4414 -> AT90S4414 4kB FLASH / 256 bytes EEPROM\n");
|
||||||
printf(" 4414 -> AT90S4414 4kB FLASH / 256 bytes EEPROM\n");
|
printf(" 8515 -> AT90S8515 8kB FLASH / 512 bytes EEPROM (default)\n\n");
|
||||||
printf(" 8515 -> AT90S8515 8kB FLASH / 512 bytes EEPROM (default)\n\n");
|
printf(" -dev <dev> selects RS232-device (default: /dev/ttyS0)\n");
|
||||||
printf(" -dev <dev> selects RS232-device (default: /dev/ttyS0)\n");
|
printf(" -flash Write (1st) file to FLASH\n");
|
||||||
printf(" -flash Write (1st) file to FLASH\n");
|
printf(" -eeprom Write (2nd) file to EEPROM\n");
|
||||||
printf(" -eeprom Write (2nd) file to EEPROM\n");
|
printf(" -verify Verify writing\n");
|
||||||
printf(" -verify Verify writing\n");
|
printf(" -reset Only resets AVR\n");
|
||||||
printf(" -reset Only resets AVR\n");
|
|
||||||
end_prg(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user