Added sending of "+++" on reflash. Firmware can detect this and reset, to avoid needing to manually reset the board.
Fixed timeouts.
This commit is contained in:
1 parent
63cf1ee1cc
commit
5c561a9983
2 files changed
+16
-1
No files matched your search
@@ -41,6 +41,9 @@ For usage instructions, run cctl-prog with no arguments:
|
||||
|
||||
If both `--console` and `--flash` are specified, then the device will be reflashed first, then the console will connect.
|
||||
|
||||
Before flashing, `cctl-prog` sends the string "+++", which firmware can detect
|
||||
and reset automatically.
|
||||
|
||||
Preparing your user code for usage with the bootloader is very simple. All you
|
||||
need to do is set your linker to start the code section at 0x400. For an
|
||||
example of this see the `Makefile` file in the `example_payload` subdirectory.
|
||||
|
||||
+13
-1
@@ -250,6 +250,7 @@ int serialRead(int fd, void* buf, int len)
|
||||
return rc;
|
||||
if (rc > 0)
|
||||
return rc;
|
||||
gettimeofday(&now, NULL);
|
||||
}
|
||||
while((now.tv_sec - start.tv_sec) < SERIAL_TIMEOUT);
|
||||
|
||||
@@ -285,6 +286,7 @@ int serialWrite(int fd, void* buf, int len)
|
||||
return rc;
|
||||
if (rc > 0)
|
||||
return rc;
|
||||
gettimeofday(&now, NULL);
|
||||
}
|
||||
while((now.tv_sec - start.tv_sec) < SERIAL_TIMEOUT);
|
||||
|
||||
@@ -449,13 +451,24 @@ int wait_for_bootloader(int fd, int timeout)
|
||||
uint8_t prev_c = 0;
|
||||
struct timeval start, now;
|
||||
int rc;
|
||||
int last_sec = -1;
|
||||
|
||||
gettimeofday(&start, NULL);
|
||||
|
||||
serialWrite(fd, "+++", 3);
|
||||
|
||||
printf("Waiting %ds for bootloader, reset board now\n", timeout);
|
||||
|
||||
do
|
||||
{
|
||||
gettimeofday(&now, NULL);
|
||||
if (((now.tv_sec - start.tv_sec)) != last_sec)
|
||||
{
|
||||
printf(".");
|
||||
fflush(stdout);
|
||||
last_sec = (now.tv_sec - start.tv_sec);
|
||||
}
|
||||
|
||||
if ((rc = serialRead(fd, &c, 1)) < 0)
|
||||
{
|
||||
fprintf(stderr, "read failed\n");
|
||||
@@ -468,7 +481,6 @@ int wait_for_bootloader(int fd, int timeout)
|
||||
break;
|
||||
prev_c = c;
|
||||
}
|
||||
gettimeofday(&now, NULL);
|
||||
}
|
||||
while((now.tv_sec - start.tv_sec) < timeout);
|
||||
if (now.tv_sec - start.tv_sec >= timeout)
|
||||
|
||||
Reference in new issue
Block a user