CCHL, a hardware ChipCon programmer following swra124, running on CC1110.

Follows (almost) same protocol as CCTL, so same client s/w runs on osx/linux/win
This commit is contained in:
Joby Taffey committed 2012-03-12 00:21:27 +00:00
1 parent ce3b5b77a7
commit 07ff76a515
10 files changed
+1785 -6

No files matched your search

+25 -4
View File
@@ -34,6 +34,7 @@ static struct option long_options[] =
{"flash", required_argument, 0, 'f'},
{"device", required_argument, 0, 'd'},
{"timeout", required_argument, 0, 't'},
{"passthrough", no_argument, 0, 'p'},
{0, 0, 0, 0}
};
@@ -49,6 +50,7 @@ void usage(void)
fprintf(stderr, " --console -c Connect console to serial port on device\n");
fprintf(stderr, " --flash=file.hex -f file.hex Reflash device with intel hex file\n");
fprintf(stderr, " --timeout=n -t n Search for bootload string for n seconds\n");
fprintf(stderr, " --passthrough -p Program remote device over passthrough\n");
}
static bool opt_console = false;
@@ -57,6 +59,7 @@ static int opt_timeout = 10;
static bool opt_device = false;
static char *flash_filename = NULL;
static char *device_name = NULL;
static bool opt_passthrough = 0;
#ifndef WIN32
static struct termios orig_termios;
@@ -69,7 +72,7 @@ int parse_options(int argc, char **argv)
while(1)
{
c = getopt_long (argc, argv, "hcf:d:t:", long_options, &option_index);
c = getopt_long (argc, argv, "hcf:d:t:p", long_options, &option_index);
if (c == -1)
break;
switch(c)
@@ -77,6 +80,9 @@ int parse_options(int argc, char **argv)
case 'h':
return 1;
break;
case 'p':
opt_passthrough = 1;
break;
case 't':
opt_timeout = atoi(optarg);
break;
@@ -352,11 +358,15 @@ int read_page(int fd, uint8_t page, uint8_t *data)
return 0;
}
static int already_erased = 0; // passthrough programmer only supports mass erase
int erase_page(int fd, uint8_t page)
{
char cmd = 'e';
char rsp;
if (already_erased && opt_passthrough)
return 0;
if (serialWrite(fd, &cmd, 1) <= 0)
return 1;
@@ -369,6 +379,8 @@ int erase_page(int fd, uint8_t page)
return 1;
}
already_erased = 1;
return 0;
}
@@ -457,7 +469,8 @@ int wait_for_bootloader(int fd, int timeout)
gettimeofday(&start, NULL);
serialWrite(fd, "+++", 3);
if (!opt_passthrough)
serialWrite(fd, "+++", 3);
printf("Waiting %ds for bootloader, reset board now\n", timeout);
@@ -479,8 +492,16 @@ int wait_for_bootloader(int fd, int timeout)
else
if (rc == 1)
{
if (c == 'B' && prev_c == 'B')
break;
if (opt_passthrough)
{
if (c == 'P' && prev_c == 'P')
break;
}
else
{
if (c == 'B' && prev_c == 'B')
break;
}
prev_c = c;
}
}