summaryrefslogtreecommitdiffstats
path: root/src/nolo.c
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2014-11-18 18:07:59 +0100
committerPali Rohár <pali.rohar@gmail.com>2014-11-18 18:07:59 +0100
commit26b6f86f84f04c1b1461e257bb843881a58ff057 (patch)
tree523c5b54ec47c42d6d6e84b097cb10e70db85c08 /src/nolo.c
parentf3d203c205c9d4f1192f7e989eeeb80187c230fc (diff)
download0xFFFF-26b6f86f84f04c1b1461e257bb843881a58ff057.tar.bz2
nolo: Fix parsing cmt status
Now flashing cmt images should work without problems
Diffstat (limited to 'src/nolo.c')
-rw-r--r--src/nolo.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/nolo.c b/src/nolo.c
index 77d49e9..86a39eb 100644
--- a/src/nolo.c
+++ b/src/nolo.c
@@ -419,8 +419,8 @@ int nolo_flash_image(struct usb_device_info * dev, struct image * image) {
unsigned long long int part;
unsigned long long int total;
unsigned long long int last_total;
- char status[20];
char buf[128];
+ char * ptr;
if ( image->type == IMAGE_ROOTFS )
flash = 1;
@@ -491,18 +491,29 @@ int nolo_flash_image(struct usb_device_info * dev, struct image * image) {
state = 4;
+ } else if ( strncmp(buf, "error", sizeof("error")-1) == 0 ) {
+
+ PRINTF_ERROR_RETURN("cmt:status error", -1);
+
} else {
- if ( sscanf(buf, "%s:%llu/%llu", status, &part, &total) != 3 )
+ ptr = strchr(buf, ':');
+ if ( ! ptr )
+ PRINTF_ERROR_RETURN("cmt:status unknown", -1);
+
+ *ptr = 0;
+ ptr++;
+
+ if ( sscanf(ptr, "%llu/%llu", &part, &total) != 2 )
PRINTF_ERROR_RETURN("cmt:status unknown", -1);
- if ( strcmp(status, "program") == 0 && state <= 0 ) {
+ if ( strcmp(buf, "program") == 0 && state <= 0 ) {
printf_progressbar(last_total, last_total);
printf("Done\n");
state = 1;
}
- if ( strcmp(status, "program") == 0 && state <= 1 ) {
+ if ( strcmp(buf, "program") == 0 && state <= 1 ) {
printf("Programming CMT...\n");
state = 2;
}
@@ -510,12 +521,12 @@ int nolo_flash_image(struct usb_device_info * dev, struct image * image) {
printf_progressbar(part, total);
last_total = total;
- if ( strcmp(status, "erase") == 0 && state <= 0 && part == total ) {
+ if ( strcmp(buf, "erase") == 0 && state <= 0 && part == total ) {
printf("Done\n");
state = 1;
}
- if ( strcmp(status, "program") == 0 && state <= 2 && part == total ) {
+ if ( strcmp(buf, "program") == 0 && state <= 2 && part == total ) {
printf("Done\n");
state = 3;
}