- 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_instructions(dbg, instructions);
+
+#if 1
+ if (!image) {
+ fprintf(stderr, "image create failed\n");
+ exit (1);
+ }
+ if (image->address == 0xf000) {
+ printf("Loading %d bytes to execute from RAM\n", image->length);
+ ccdbg_write_hex_image(dbg, image, 0);
+ } else if (image->address == 0x0000) {
+ printf("Loading code to execute from FLASH\n");
+ ccdbg_flash_hex_image(dbg, image);
+ } else {
+ printf("Cannot load code to 0x%04x\n",
+ image->address);
+ ccdbg_hex_image_free(image);
+ ccdbg_close(dbg);
+ exit(1);
+ }
+ ccdbg_set_pc(dbg, image->address);