First attempt to support start prog, do not know if it is working
authorNathael Pajani <nathael.pajani@ed3l.fr>
Fri, 18 May 2012 23:47:21 +0000 (01:47 +0200)
committerNathael Pajani <nathael.pajani@ed3l.fr>
Fri, 18 May 2012 23:47:21 +0000 (01:47 +0200)
(Got no way to test for sure)

lpc_prog.c
prog_commands.c
prog_commands.h

index 87841d6..3536ac2 100644 (file)
@@ -318,7 +318,7 @@ static int prog_handle_command(char* cmd, int dev_id, int arg_count, char** args
                        break;
 
                case 4: /* go : no args */
-                       ret = start_prog();
+                       ret = start_prog(part);
                        break;
        }
 
index 4446bb6..782cb6b 100644 (file)
@@ -74,12 +74,39 @@ int erase_flash(struct part_desc* part)
 {
        int ret = 0;
 
+
        return ret;
 }
 
-int start_prog(void)
+int start_prog(struct part_desc* part)
 {
-       int ret = 0;
+       int ret = 0, len = 0;
+       uint32_t addr = 0;
+
+       len = isp_read_memory((char*)&addr, (part->flash_base + part->reset_vector_offset), sizeof(addr));
+       if (len != sizeof(addr)) {
+               printf("Unable to read reset address from flash.\n");
+               return len;
+       }
+       /* FIXME : the following value (0x200) may be LPC111x specific */
+       if (addr < 0x200) {
+               printf("Actual reset address is 0x%08x, which is under the lowest allowed address of 0x200.\n", addr);
+       }
+       /* Unlock device */
+       ret = isp_cmd_unlock(1);
+       if (ret != 0) {
+               printf("Unable to unlock device, aborting.\n");
+               return -1;
+       }
+       /* Read address in thumb or arm mode ? */
+       if (addr & 0x01) {
+               addr &= ~1UL;
+               ret = isp_send_cmd_go(addr, 'T');
+       } else {
+               ret = isp_send_cmd_go(addr, 'A');
+       }
+
+       /* FIXME : start terminal */
 
        return ret;
 }
index 41c17d4..de158e7 100644 (file)
@@ -23,7 +23,7 @@ int flash_target(struct part_desc* part, char* filename, int check);
 
 int get_ids(void);
 
-int start_prog(void);
+int start_prog(struct part_desc* part);
 
 
 #endif /* ISP_CMDS_FLASH_H */