if (res != ERROR_OK)
goto out;
/* set the TPI clock prescaler */
- res = stlink_usb_write_debug_reg(handle, TPI_ACPR, h->trace.prescale);
+ res = stlink_usb_write_debug_reg(handle, TPIU_ACPR, h->trace.prescale);
if (res != ERROR_OK)
goto out;
/* select the pin protocol. The STLinkv2 only supports asynchronous
* UART emulation (NRZ) mode, so that's what we pick. */
- res = stlink_usb_write_debug_reg(handle, TPI_SPPR, 0x02);
+ res = stlink_usb_write_debug_reg(handle, TPIU_SPPR, 0x02);
if (res != ERROR_OK)
goto out;
/* disable continuous formatting */
- res = stlink_usb_write_debug_reg(handle, TPI_FFCR, (1<<8));
+ res = stlink_usb_write_debug_reg(handle, TPIU_FFCR, (1<<8));
if (res != ERROR_OK)
goto out;
if (res != ERROR_OK)
goto out;
/* trace port enable (port 0) */
- res = stlink_usb_write_debug_reg(handle, ITM_TER, (1<<0));
+ res = stlink_usb_write_debug_reg(handle, ITM_TER0, (1<<0));
if (res != ERROR_OK)
goto out;
}
/** */
-static int stlink_usb_close(void *fd)
+static int stlink_usb_close(void *handle)
{
- struct stlink_usb_handle_s *h = fd;
+ struct stlink_usb_handle_s *h = handle;
- if (h->fd)
+ if (h && h->fd)
jtag_libusb_close(h->fd);
- free(fd);
+ free(h);
return ERROR_OK;
}
err = stlink_usb_init_mode(h, param->connect_under_reset);
if (err != ERROR_OK) {
- LOG_ERROR("init mode failed");
+ LOG_ERROR("init mode failed (unable to connect to the target)");
goto error_open;
}
/* clock speed only supported by stlink/v2 and for firmware >= 22 */
if (h->version.stlink >= 2 && h->version.jtag >= 22) {
- LOG_INFO("Supported clock speeds are:");
+ LOG_DEBUG("Supported clock speeds are:");
for (unsigned i = 0; i < ARRAY_SIZE(stlink_khz_to_speed_map); i++)
- LOG_INFO("%d kHz", stlink_khz_to_speed_map[i].speed);
+ LOG_DEBUG("%d kHz", stlink_khz_to_speed_map[i].speed);
stlink_speed(h, param->initial_interface_speed, false);
}