- status = ccdbg_read_status(dbg);
- printf("Status: 0x%02x\n", status);
- chip_id = ccdbg_get_chip_id(dbg);
- printf("Chip id: 0x%04x\n", chip_id);
- status = ccdbg_halt(dbg);
- printf ("halt status: 0x%02x\n", status);
+ ccdbg_halt(dbg);
+
+#if 1
+ if (!image) {
+ fprintf(stderr, "image create failed\n");
+ exit (1);
+ }
+ if (image->address == 0xf000) {
+ printf("Loading code to execute from RAM\n");
+ ccdbg_execute_hex_image(dbg, image);
+ } else if (image->address == 0x0000) {
+ printf("Loading code to execute from FLASH\n");
+ ccdbg_flash_hex_image(dbg, image);
+ ccdbg_set_pc(dbg, 0);
+ ccdbg_resume(dbg);
+ } else {
+ printf("Cannot load code to 0x%04x\n",
+ image->address);
+ ccdbg_hex_image_free(image);
+ ccdbg_close(dbg);
+ exit(1);
+ }
+#endif
+ for (;;) {
+ pc = ccdbg_get_pc(dbg);
+ status = ccdbg_read_status(dbg);
+ printf("pc: 0x%04x. status: 0x%02x\n", pc, status);
+ }
+#if 0