libusb0: add compatibility define for transfer type bulk
[openocd.git] / src / jtag / aice / aice_usb.c
index 917d795b075ad4c34050a8c31ba40d231530d229..f67ea7ca32bcf3351985a24f37c1fdb592644446 100644 (file)
@@ -13,9 +13,7 @@
  *   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, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1858,7 +1856,7 @@ static int aice_check_dbger(uint32_t coreid, uint32_t expect_status)
                if ((i % 30) == 0)
                        keep_alive();
 
-               long long then = 0;
+               int64_t then = 0;
                if (i == aice_count_to_check_dbger)
                        then = timeval_ms();
                if (i >= aice_count_to_check_dbger) {
@@ -2099,7 +2097,7 @@ static int aice_usb_open(struct aice_port_param_s *param)
        const uint16_t pids[] = { param->pid, 0 };
        struct jtag_libusb_device_handle *devh;
 
-       if (jtag_libusb_open(vids, pids, &devh) != ERROR_OK)
+       if (jtag_libusb_open(vids, pids, NULL, &devh) != ERROR_OK)
                return ERROR_FAIL;
 
        /* BE ***VERY CAREFUL*** ABOUT MAKING CHANGES IN THIS
@@ -2123,7 +2121,7 @@ static int aice_usb_open(struct aice_port_param_s *param)
        /* reopen jlink after usb_reset
         * on win32 this may take a second or two to re-enumerate */
        int retval;
-       while ((retval = jtag_libusb_open(vids, pids, &devh)) != ERROR_OK) {
+       while ((retval = jtag_libusb_open(vids, pids, NULL, &devh)) != ERROR_OK) {
                usleep(1000);
                timeout--;
                if (!timeout)
@@ -2136,13 +2134,14 @@ static int aice_usb_open(struct aice_port_param_s *param)
 #endif
 
        /* usb_set_configuration required under win32 */
-       struct jtag_libusb_device *udev = jtag_libusb_get_device(devh);
        jtag_libusb_set_configuration(devh, 0);
        jtag_libusb_claim_interface(devh, 0);
 
        unsigned int aice_read_ep;
        unsigned int aice_write_ep;
-       jtag_libusb_get_endpoints(udev, &aice_read_ep, &aice_write_ep);
+
+       jtag_libusb_choose_interface(devh, &aice_read_ep, &aice_write_ep, -1, -1, -1, LIBUSB_TRANSFER_TYPE_BULK);
+       LOG_DEBUG("aice_read_ep=0x%x, aice_write_ep=0x%x", aice_read_ep, aice_write_ep);
 
        aice_handler.usb_read_ep = aice_read_ep;
        aice_handler.usb_write_ep = aice_write_ep;
@@ -2287,37 +2286,39 @@ get_delay:
 
 static int aice_usb_set_clock(int set_clock)
 {
-       if (aice_write_ctrl(AICE_WRITE_CTRL_TCK_CONTROL,
-                               AICE_TCK_CONTROL_TCK_SCAN) != ERROR_OK)
-               return ERROR_FAIL;
+       if (set_clock & AICE_TCK_CONTROL_TCK_SCAN) {
+               if (aice_write_ctrl(AICE_WRITE_CTRL_TCK_CONTROL,
+                                       AICE_TCK_CONTROL_TCK_SCAN) != ERROR_OK)
+                       return ERROR_FAIL;
 
-       /* Read out TCK_SCAN clock value */
-       uint32_t scan_clock;
-       if (aice_read_ctrl(AICE_READ_CTRL_GET_ICE_STATE, &scan_clock) != ERROR_OK)
-               return ERROR_FAIL;
+               /* Read out TCK_SCAN clock value */
+               uint32_t scan_clock;
+               if (aice_read_ctrl(AICE_READ_CTRL_GET_ICE_STATE, &scan_clock) != ERROR_OK)
+                       return ERROR_FAIL;
 
-       scan_clock &= 0x0F;
+               scan_clock &= 0x0F;
 
-       uint32_t scan_base_freq;
-       if (scan_clock & 0x8)
-               scan_base_freq = 48000; /* 48 MHz */
-       else
-               scan_base_freq = 30000; /* 30 MHz */
+               uint32_t scan_base_freq;
+               if (scan_clock & 0x8)
+                       scan_base_freq = 48000; /* 48 MHz */
+               else
+                       scan_base_freq = 30000; /* 30 MHz */
 
-       uint32_t set_base_freq;
-       if (set_clock & 0x8)
-               set_base_freq = 48000;
-       else
-               set_base_freq = 30000;
+               uint32_t set_base_freq;
+               if (set_clock & 0x8)
+                       set_base_freq = 48000;
+               else
+                       set_base_freq = 30000;
 
-       uint32_t set_freq;
-       uint32_t scan_freq;
-       set_freq = set_base_freq >> (set_clock & 0x7);
-       scan_freq = scan_base_freq >> (scan_clock & 0x7);
+               uint32_t set_freq;
+               uint32_t scan_freq;
+               set_freq = set_base_freq >> (set_clock & 0x7);
+               scan_freq = scan_base_freq >> (scan_clock & 0x7);
 
-       if (scan_freq < set_freq) {
-               LOG_ERROR("User specifies higher jtag clock than TCK_SCAN clock");
-               return ERROR_FAIL;
+               if (scan_freq < set_freq) {
+                       LOG_ERROR("User specifies higher jtag clock than TCK_SCAN clock");
+                       return ERROR_FAIL;
+               }
        }
 
        if (aice_write_ctrl(AICE_WRITE_CTRL_TCK_CONTROL, set_clock) != ERROR_OK)
@@ -3001,7 +3002,7 @@ static int aice_usb_step(uint32_t coreid)
                if (AICE_TARGET_HALTED == state)
                        break;
 
-               long long then = 0;
+               int64_t then = 0;
                if (i == 30)
                        then = timeval_ms();
 
@@ -3428,10 +3429,10 @@ static int aice_usb_memory_mode(uint32_t coreid, enum nds_memory_select mem_sele
        return ERROR_OK;
 }
 
-static int aice_usb_read_tlb(uint32_t coreid, uint32_t virtual_address,
-               uint32_t *physical_address)
+static int aice_usb_read_tlb(uint32_t coreid, target_addr_t virtual_address,
+               target_addr_t *physical_address)
 {
-       LOG_DEBUG("aice_usb_read_tlb, virtual address: 0x%08" PRIx32, virtual_address);
+       LOG_DEBUG("aice_usb_read_tlb, virtual address: 0x%08" TARGET_PRIxADDR, virtual_address);
 
        uint32_t instructions[4];
        uint32_t probe_result;

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)