From 8167ddea6cf12b364f59b8e55b8d14611557c1cd Mon Sep 17 00:00:00 2001 From: Glenn Anderson Date: Wed, 1 Jun 2022 12:44:05 -0700 Subject: [PATCH 1/3] Move TRANSCEIVER_IO_SET out of writeDataLoop. Add matching TRANSCEIVER_IO_SET(vTR_DBP,TR_INPUT) to writeDataPhase() and writeDataPhaseSD() --- src/BlueSCSI.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/BlueSCSI.cpp b/src/BlueSCSI.cpp index 1733ebd..c663f74 100644 --- a/src/BlueSCSI.cpp +++ b/src/BlueSCSI.cpp @@ -920,9 +920,6 @@ void writeDataLoop(uint32_t blocksize, const byte* srcptr) // Start the first bus cycle. FETCH_BSRR_DB(); REQ_OFF_DB_SET(bsrr_val); -#ifdef XCVR - TRANSCEIVER_IO_SET(vTR_DBP,TR_OUTPUT) -#endif REQ_ON(); FETCH_BSRR_DB(); WAIT_ACK_ACTIVE(); @@ -959,9 +956,15 @@ void writeDataPhase(int len, const byte* p) LOGN("DATAIN PHASE"); SCSI_PHASE_CHANGE(SCSI_PHASE_DATAIN); // Bus settle delay 400ns. Following code was measured at 800ns before REQ asserted. STM32F103. +#ifdef XCVR + TRANSCEIVER_IO_SET(vTR_DBP,TR_OUTPUT) +#endif SCSI_DB_OUTPUT() writeDataLoop(len, p); SCSI_DB_INPUT() +#ifdef XCVR + TRANSCEIVER_IO_SET(vTR_DBP,TR_INPUT) +#endif } /* @@ -977,6 +980,9 @@ void writeDataPhaseSD(uint32_t adds, uint32_t len) uint64_t pos = (uint64_t)adds * m_img->m_blocksize; m_img->m_file.seekSet(pos); +#ifdef XCVR + TRANSCEIVER_IO_SET(vTR_DBP,TR_OUTPUT) +#endif SCSI_DB_OUTPUT() for(uint32_t i = 0; i < len; i++) { // Asynchronous reads will make it faster ... From 1aecf323e1ac6e6545c3a326b2d7fc03cc7b225b Mon Sep 17 00:00:00 2001 From: Glenn Anderson Date: Fri, 3 Jun 2022 16:11:53 -0700 Subject: [PATCH 2/3] Remove unnecessary SCSI_DB_INPUT() and TRANSCEIVER_IO_SET(vTR_DBP,TR_INPUT) --- src/BlueSCSI.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/BlueSCSI.cpp b/src/BlueSCSI.cpp index c663f74..6d3ea4f 100644 --- a/src/BlueSCSI.cpp +++ b/src/BlueSCSI.cpp @@ -961,10 +961,6 @@ void writeDataPhase(int len, const byte* p) #endif SCSI_DB_OUTPUT() writeDataLoop(len, p); - SCSI_DB_INPUT() -#ifdef XCVR - TRANSCEIVER_IO_SET(vTR_DBP,TR_INPUT) -#endif } /* @@ -992,10 +988,6 @@ void writeDataPhaseSD(uint32_t adds, uint32_t len) writeDataLoop(m_img->m_blocksize, m_buf); } - SCSI_DB_INPUT() -#ifdef XCVR - TRANSCEIVER_IO_SET(vTR_DBP,TR_INPUT) -#endif } #pragma GCC push_options From dcbb7df80d26b10204289a970ff89a77a53bd8df Mon Sep 17 00:00:00 2001 From: Glenn Anderson Date: Sat, 4 Jun 2022 23:33:19 -0700 Subject: [PATCH 3/3] Alignment adjustment to make XCVR perform the same as non-XCVR --- src/BlueSCSI.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/BlueSCSI.cpp b/src/BlueSCSI.cpp index 6d3ea4f..dfae9e6 100644 --- a/src/BlueSCSI.cpp +++ b/src/BlueSCSI.cpp @@ -1768,5 +1768,11 @@ BusFree: SCSI_TARGET_INACTIVE() // Turn off BSY, REQ, MSG, CD, IO output #ifdef XCVR TRANSCEIVER_IO_SET(vTR_TARGET,TR_INPUT); + // Something in code linked after this function is performing better with a +4 alignment. + // Adding this nop is causing the next function (_GLOBAL__sub_I_SD) to have an address with a last digit of 0x4. + // Last digit of 0xc also works. + // This affects both with and without XCVR, currently without XCVR doesn't need any padding. + // Until the culprit can be tracked down and fixed, it may be necessary to do manual adjustment. + asm("nop.w"); #endif }