1 /* simple wrapper around the stlink_flash_write function */
3 // TODO - this should be done as just a simple flag to the st-util command line...
10 #include "stlink-common.h"
12 static void usage(void)
14 puts("st-info --flash");
15 puts("st-info --sram");
16 puts("st-info --descr");
17 puts("st-info --pagesize");
18 puts("st-info --chipid");
21 static int print_data(stlink_t* sl, char** av)
24 if (strcmp(av[1], "--flash") == 0)
25 printf("0x%zx\n", sl->flash_size);
26 else if (strcmp(av[1], "--sram") == 0)
27 printf("0x%zx\n", sl->sram_size);
28 else if (strcmp(av[1], "--pagesize") == 0)
29 printf("0x%zx\n", sl->flash_pgsz);
30 else if (strcmp(av[1], "--chipid") == 0)
31 printf("0x%.4x\n", sl->chip_id);
32 else if (strcmp(av[1], "--descr")==0) {
33 const chip_params_t *params = NULL;
34 for (size_t i = 0; i < sizeof(devices) / sizeof(devices[0]); i++) {
35 if(devices[i].chip_id == sl->chip_id) {
43 printf("%s\n", params->description);
49 stlink_t* open_sl(void)
52 sl = stlink_v1_open(0, 1);
54 sl = stlink_open_usb(0, 1, NULL);
59 int main(int ac, char** av)
74 if (stlink_current_mode(sl) == STLINK_DEV_DFU_MODE)
75 stlink_exit_dfu_mode(sl);
77 if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE)
78 stlink_enter_swd_mode(sl);
80 err = print_data(sl, av);
84 stlink_exit_debug_mode(sl);