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.
|
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
|
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
|
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.
|
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;
|
return rc;
|
||||||
if (rc > 0)
|
if (rc > 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
gettimeofday(&now, NULL);
|
||||||
}
|
}
|
||||||
while((now.tv_sec - start.tv_sec) < SERIAL_TIMEOUT);
|
while((now.tv_sec - start.tv_sec) < SERIAL_TIMEOUT);
|
||||||
|
|
||||||
@@ -285,6 +286,7 @@ int serialWrite(int fd, void* buf, int len)
|
|||||||
return rc;
|
return rc;
|
||||||
if (rc > 0)
|
if (rc > 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
gettimeofday(&now, NULL);
|
||||||
}
|
}
|
||||||
while((now.tv_sec - start.tv_sec) < SERIAL_TIMEOUT);
|
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;
|
uint8_t prev_c = 0;
|
||||||
struct timeval start, now;
|
struct timeval start, now;
|
||||||
int rc;
|
int rc;
|
||||||
|
int last_sec = -1;
|
||||||
|
|
||||||
gettimeofday(&start, NULL);
|
gettimeofday(&start, NULL);
|
||||||
|
|
||||||
|
serialWrite(fd, "+++", 3);
|
||||||
|
|
||||||
printf("Waiting %ds for bootloader, reset board now\n", timeout);
|
printf("Waiting %ds for bootloader, reset board now\n", timeout);
|
||||||
|
|
||||||
do
|
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)
|
if ((rc = serialRead(fd, &c, 1)) < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "read failed\n");
|
fprintf(stderr, "read failed\n");
|
||||||
@@ -468,7 +481,6 @@ int wait_for_bootloader(int fd, int timeout)
|
|||||||
break;
|
break;
|
||||||
prev_c = c;
|
prev_c = c;
|
||||||
}
|
}
|
||||||
gettimeofday(&now, NULL);
|
|
||||||
}
|
}
|
||||||
while((now.tv_sec - start.tv_sec) < timeout);
|
while((now.tv_sec - start.tv_sec) < timeout);
|
||||||
if (now.tv_sec - start.tv_sec >= timeout)
|
if (now.tv_sec - start.tv_sec >= timeout)
|
||||||
|
|||||||
Reference in new issue
Block a user