示例#1
0
static int print_data(char **av)
{
    stlink_t* sl = NULL;

    // Probe needs all devices unclaimed
    if (strcmp(av[1], "--probe") == 0) {
        stlink_probe();
        return 0;
    } else if (strcmp(av[1], "--version") == 0) {
        printf("v%s\n", STLINK_VERSION);
        return 0;
    }

    sl = stlink_open_first();

    if (sl == NULL) {
        return -1;
    }

    sl->verbose = 0;

    if (stlink_current_mode(sl) == STLINK_DEV_DFU_MODE)
        stlink_exit_dfu_mode(sl);

    if (stlink_current_mode(sl) != STLINK_DEV_DEBUG_MODE)
        stlink_enter_swd_mode(sl);

    if (strcmp(av[1], "--flash") == 0)
        printf("0x%x\n", (unsigned int)sl->flash_size);
    else if (strcmp(av[1], "--sram") == 0)
        printf("0x%x\n", (unsigned int)sl->sram_size);
    else if (strcmp(av[1], "--pagesize") == 0)
        printf("0x%x\n", (unsigned int)sl->flash_pgsz);
    else if (strcmp(av[1], "--chipid") == 0)
        printf("0x%.4x\n", sl->chip_id);
    else if (strcmp(av[1], "--serial") == 0)
        stlink_print_serial(sl, false);
    else if (strcmp(av[1], "--hla-serial") == 0)
        stlink_print_serial(sl, true);
    else if (strcmp(av[1], "--descr") == 0) {
        const struct stlink_chipid_params *params = stlink_chipid_get_params(sl->chip_id);
        if (params == NULL)
            return -1;
        printf("%s\n", params->description);
    }

    if (sl)
    {
        stlink_exit_debug_mode(sl);
        stlink_close(sl);
    }

    return 0;
}
示例#2
0
文件: info.c 项目: QUSIR/stlink
static void stlink_print_info(stlink_t *sl)
{
    const struct stlink_chipid_params *params = NULL;

    if (!sl)
        return;

    printf(" serial: ");
    stlink_print_serial(sl, false);
    printf("openocd: ");
    stlink_print_serial(sl, true);

    printf("  flash: %zu (pagesize: %zu)\n", sl->flash_size, sl->flash_pgsz);
    printf("   sram: %zu\n",       sl->sram_size);
    printf(" chipid: 0x%.4x\n",    sl->chip_id);

	params = stlink_chipid_get_params(sl->chip_id);
	if (params)
		printf("  descr: %s\n", params->description);
}