From: Nathael Pajani Date: Fri, 18 May 2012 23:47:21 +0000 (+0200) Subject: First attempt to support start prog, do not know if it is working X-Git-Tag: v1.0~21 X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=07dfda7e0b417d32d328242f139ddfc069908c57;p=soft%2Ftools%2Flpctools First attempt to support start prog, do not know if it is working (Got no way to test for sure) --- diff --git a/lpc_prog.c b/lpc_prog.c index 87841d6..3536ac2 100644 --- a/lpc_prog.c +++ b/lpc_prog.c @@ -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; } diff --git a/prog_commands.c b/prog_commands.c index 4446bb6..782cb6b 100644 --- a/prog_commands.c +++ b/prog_commands.c @@ -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; } diff --git a/prog_commands.h b/prog_commands.h index 41c17d4..de158e7 100644 --- a/prog_commands.h +++ b/prog_commands.h @@ -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 */