diff --git a/src/platforms/hosted/bmp_libusb.c b/src/platforms/hosted/bmp_libusb.c index 21ed9542..aff66f9d 100644 --- a/src/platforms/hosted/bmp_libusb.c +++ b/src/platforms/hosted/bmp_libusb.c @@ -1,7 +1,7 @@ /* * This file is part of the Black Magic Debug project. * - * Copyright(C) 2020 - 2021 Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de) + * Copyright(C) 2020 - 2022 Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/platforms/hosted/remote_jtagtap.c b/src/platforms/hosted/remote_jtagtap.c index a5aa3b6c..8a0d91ae 100644 --- a/src/platforms/hosted/remote_jtagtap.c +++ b/src/platforms/hosted/remote_jtagtap.c @@ -126,26 +126,21 @@ static void jtagtap_tdi_tdo_seq( chunk = 64; } ticks -= chunk; - uint8_t di[8]; - memset(di, 0, 8); + uint64_t di = 0; int bytes = (chunk + 7) >> 3; + int i = 0; if (DI) { - memcpy(&di, DI, bytes); - int remainder = chunk & 7; - DI += bytes; - DI += bytes; - if (remainder) { - uint8_t rem = *DI; - rem &= (1 << remainder) - 1; - *di = rem; + for (; i < bytes; i++) { + di |= *DI << (i * 8); + DI++; } - }; + } /* PRIx64 differs with system. Use it explicit in the format string*/ s = snprintf((char *)construct, REMOTE_MAX_MSG_SIZE, "!J%c%02x%" PRIx64 "%c", (!ticks && final_tms) ? REMOTE_TDITDO_TMS : REMOTE_TDITDO_NOTMS, - chunk, *(uint64_t*)di, REMOTE_EOM); + chunk, di, REMOTE_EOM); platform_buffer_write(construct,s); s = platform_buffer_read(construct, REMOTE_MAX_MSG_SIZE); @@ -156,8 +151,10 @@ static void jtagtap_tdi_tdo_seq( } if (DO) { uint64_t res = remotehston(-1, (char *)&construct[1]); - memcpy(DO, &res, bytes); - DO += bytes; + for (i = bytes; i > 0; i--) { + *DO++ = res & 0xff; + res >>= 8; + } } } }