From: Rene Hopf Date: Wed, 11 Dec 2013 19:31:37 +0000 (+0100) Subject: st-term magic byte via commandline argument X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=93c070d84c00bf3f6fa75d41ddacbdd0bb757f5a;hp=a1e4a6d51c0b33c5ae08eae72ba701906a749d61;p=fw%2Fstlink st-term magic byte via commandline argument --- diff --git a/.gitignore b/.gitignore index d7df95e..0902570 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ compile st-flash st-util st-term +st-info test_usb test_sg *.deps* diff --git a/src/st-term.c b/src/st-term.c index a6a97fc..4f2f9f7 100644 --- a/src/st-term.c +++ b/src/st-term.c @@ -39,7 +39,7 @@ struct stlinky* stlinky_detect(stlink_t* sl) if (STLINKY_MAGIC == READ_UINT32_LE(sl->q_buf)) { if (multiple > 0) - printf("WARNING: another "); + printf("WARNING: another "); printf("stlinky detected at 0x%x\n", sram_base + off); st->off = sram_base + off; stlink_read_mem32(sl, st->off + 4, 4); @@ -148,10 +148,8 @@ void cleanup(int dummy) int main(int ac, char** av) { stlink_t* sl; - - /* unused */ - ac = ac; - av = av; + struct stlinky *st; + sl = stlink_open_usb(10, 1); if (sl != NULL) { printf("ST-Linky proof-of-concept terminal :: Created by Necromant for lulz\n"); @@ -174,7 +172,19 @@ int main(int ac, char** av) { /* TODO: Make timeout adjustable via command line */ sleep(1); - struct stlinky *st = stlinky_detect(sl); + if(ac == 1){ + st = stlinky_detect(sl); + }else if(ac == 2){ + st = malloc(sizeof(struct stlinky)); + st->sl = sl; + st->off = (int)strtol(av[1], NULL, 16); + printf("using stlinky at 0x%x\n", st->off); + stlink_read_mem32(sl, st->off + 4, 4); + st->bufsize = (size_t) *(unsigned char*) sl->q_buf; + printf("stlinky buffer size 0x%zu \n", st->bufsize); + }else{ + goto bailout; + } if (st == NULL) { printf("stlinky magic not found in sram :(\n");