- ccdbg_write_hex(dbg, hex);
- ccdbg_hex_file_free(hex);
- for (i = 0; i < sizeof (memory); i++)
- printf (" %02x", memory[i]);
- printf ("\n");
- ccdbg_execute(dbg, jump_mem);
- pc = ccdbg_get_pc(dbg);
- printf ("pc starts at 0x%04x\n", pc);
- status = ccdbg_resume(dbg);
- printf ("resume status: 0x%02x\n", status);
-#if 0
-/* ccdbg_execute(dbg, instructions); */
- ccdbg_write_memory(dbg, 0xf000, mem_instr, sizeof (mem_instr));
- ccdbg_read_memory(dbg, 0xf000, memory, sizeof (memory));
+#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);