* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
#ifdef HAVE_CONFIG_H
static int ublast2_libusb_read(struct ublast_lowlevel *low, uint8_t *buf,
unsigned size, uint32_t *bytes_read)
{
- *bytes_read = jtag_libusb_bulk_read(low->libusb_dev,
+ int ret, tmp = 0;
+
+ ret = jtag_libusb_bulk_read(low->libusb_dev,
USBBLASTER_EPIN | \
LIBUSB_ENDPOINT_IN,
(char *)buf,
size,
- 100);
- return ERROR_OK;
+ 100, &tmp);
+ *bytes_read = tmp;
+
+ return ret;
}
static int ublast2_libusb_write(struct ublast_lowlevel *low, uint8_t *buf,
int size, uint32_t *bytes_written)
{
- *bytes_written = jtag_libusb_bulk_write(low->libusb_dev,
+ int ret, tmp = 0;
+
+ ret = jtag_libusb_bulk_write(low->libusb_dev,
USBBLASTER_EPOUT | \
LIBUSB_ENDPOINT_OUT,
(char *)buf,
size,
- 100);
- return ERROR_OK;
+ 100, &tmp);
+ *bytes_written = tmp;
+
+ return ret;
+
}
static int ublast2_write_firmware_section(struct jtag_libusb_device_handle *libusb_dev,
LOG_DEBUG("section %02i at addr 0x%04x (size 0x%04x)", section_index, addr,
size);
- if (data == NULL)
- return ERROR_FAIL;
-
/* Copy section contents to local buffer */
int ret = image_read_section(firmware_image, section_index, 0, size, data,
&size_read);
bool renumeration = false;
int ret;
- if (jtag_libusb_open(vids, pids, &temp) == ERROR_OK) {
+ if (jtag_libusb_open(vids, pids, NULL, &temp) == ERROR_OK) {
LOG_INFO("Altera USB-Blaster II (uninitialized) found");
LOG_INFO("Loading firmware...");
ret = load_usb_blaster_firmware(temp, low);
const uint16_t pids_renum[] = { low->ublast_pid, 0 };
if (renumeration == false) {
- if (jtag_libusb_open(vids_renum, pids_renum, &low->libusb_dev) != ERROR_OK) {
+ if (jtag_libusb_open(vids_renum, pids_renum, NULL, &low->libusb_dev) != ERROR_OK) {
LOG_ERROR("Altera USB-Blaster II not found");
return ERROR_FAIL;
}
} else {
int retry = 10;
- while (jtag_libusb_open(vids_renum, pids_renum, &low->libusb_dev) != ERROR_OK && retry--) {
+ while (jtag_libusb_open(vids_renum, pids_renum, NULL, &low->libusb_dev) != ERROR_OK && retry--) {
usleep(1000000);
LOG_INFO("Waiting for renumerate...");
}