- ccdbg_debug(CC_DEBUG_FLASH, "chip status is 0x%02x\n", status);
- sleep(1);
- } while ((status & CC_STATUS_CPU_HALTED) == 0);
-
+ ccdbg_debug(CC_DEBUG_FLASH, ".");
+ ccdbg_flush(CC_DEBUG_FLASH);
+ if ((status & CC_STATUS_CPU_HALTED) != 0)
+ break;
+ usleep(10000);
+ }
+ ccdbg_debug(CC_DEBUG_FLASH, "\n");
+ if (times == 10) {
+ fprintf(stderr, "flash page timed out\n");
+ return 1;
+ }
+
+ ccdbg_debug(CC_DEBUG_FLASH, "Verify %d bytes in flash\n", this_time);
+ ccdbg_read_memory(dbg, flash_addr, verify, this_time);
+ if (memcmp (image->data + start, verify, this_time) != 0) {
+ int i;
+ fprintf(stderr, "flash verify failed\n");
+ for (i = 0; i < this_time; i++) {
+ if (image->data[start + i] != verify[i])
+ fprintf(stderr, "0x%04x: 0x%02x != 0x%02x\n",
+ start + i, image->data[start+i], verify[i]);
+ }
+ return 1;
+ }