Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOGGLE error handling #2

Open
tmk opened this issue Oct 1, 2019 · 3 comments
Open

TOGGLE error handling #2

tmk opened this issue Oct 1, 2019 · 3 comments
Labels

Comments

@tmk
Copy link
Owner

tmk commented Oct 1, 2019

On the error data should be ignored and do nothing on data toggle bit.

tmk/tmk_keyboard#657

MAX3421 Programming Guide p.13

If the IN data was error-free but there was a data toggle mismatch (the DATA0 or DATA1 PID
send by the peripheral did not match the endpoint toggle value), the SIE sends the ACK
handshake, but it does not complement the data toggle or assert the RCVDAVIRQ. The SIE sets
HRSL = 0110 (Toggle Error) for this condition. This situation would happen if the peripheral
received a corrupted ACK handshake from the previous IN transfer. In this case the host ignores
the data in the RCVDATA FIFO, because it represents data that the peripheral mistakenly resent
when it missed the last ACK handshake. By ACK-ing the transfer and not updating its own
toggle bit, the SIE causes the peripheral to complement its toggle bit, thus forcing the data toggle
mechanism back into sync. 

felis#438 (felis@a361b72)

tmk added a commit that referenced this issue Oct 31, 2020
On the error data should be ignored and do nothing on
data toggle bit.

felis#438

----
If the IN data was error-free but there was a data toggle mismatch (the
DATA0 or DATA1 PID send by the peripheral did not match the endpoint
toggle value), the SIE sends the ACK handshake, but it does not
complement the data toggle or assert the RCVDAVIRQ. The SIE sets HRSL =
0110 (Toggle Error) for this condition. This situation would happen if
the peripheral received a corrupted ACK handshake from the previous IN
transfer. In this case the host ignores the data in the RCVDATA FIFO,
because it represents data that the peripheral mistakenly resent when it
missed the last ACK handshake. By ACK-ing the transfer and not updating
its own toggle bit, the SIE causes the peripheral to complement its
toggle bit, thus forcing the data toggle mechanism back into sync.
----
MAX3421 Programming Guide p.13
tmk added a commit that referenced this issue Oct 31, 2020
On the error data should be ignored and do nothing on
data toggle bit.

felis#438

----
If the IN data was error-free but there was a data toggle mismatch (the
DATA0 or DATA1 PID send by the peripheral did not match the endpoint
toggle value), the SIE sends the ACK handshake, but it does not
complement the data toggle or assert the RCVDAVIRQ. The SIE sets HRSL =
0110 (Toggle Error) for this condition. This situation would happen if
the peripheral received a corrupted ACK handshake from the previous IN
transfer. In this case the host ignores the data in the RCVDATA FIFO,
because it represents data that the peripheral mistakenly resent when it
missed the last ACK handshake. By ACK-ing the transfer and not updating
its own toggle bit, the SIE causes the peripheral to complement its
toggle bit, thus forcing the data toggle mechanism back into sync.
----
MAX3421 Programming Guide p.13
@tmk
Copy link
Owner Author

tmk commented Dec 27, 2020

Confirmed the problem on Rosewill RK-9200BR was solved with tmk/tmk_keyboard@e7aa9e5 on 2020-12-27.
(Test report was received via PM).

Problem:
https://geekhack.org/index.php?topic=69169.msg2897297#msg2897297
https://geekhack.org/index.php?topic=69169.msg2897581#msg2897581

@tmk
Copy link
Owner Author

tmk commented Dec 27, 2020

MAX3421 Programming Guide p.11

About MAX3421E Data Toggles
USB protocol tags every data packet with one of two PIDs (Packet ID’s) called DATA0 and
DATA1. These PIDs help detect USB errors. Associated with every endpoint is a data toggle
value, which determines which DATA PIDs to use. The first data packet (after reset) to or from
an endpoint is sent using the DATA0 PID. When both sides, the sending and receiving ends,
agree that the data is accurate (by generating/receiving the ACK handshake), they both
complement their toggle values. Therefore, consecutive data packets sent to or received from an
endpoint normally will have toggling PID values—DATA0, DATA1, DATA0, etc.
The MAX3421E provides four bits to maintain the data toggles. After a data transfer to an
endpoint, the SIE updates bits RCVTOGRD and SNDTOGRD (page 36) to indicate the toggle
values for the selected endpoint. The CPU reads and stores these bits to re-initialize the toggle
value for the same endpoint when necessary. To initialize the toggle state before transferring to
an endpoint, the CPU sets one of the bit pairs SNDTOG1-SNDTOG0 for OUT data, or
RCVTOG1-RCVTOG0 for IN data (page 59). Only one of these bit pairs should be set at a time.
The CPU does not need to initialize an endpoint’s toggle value for multiple consecutive transfers
to the same endpoint. The MAX3421E updates the data toggle value as it performs transfers to
the endpoint. Only when the CPU switches endpoints does it need to restore the data toggle bits
to the values that it saved for the endpoint.

@tmk tmk added the SOLVED label Nov 23, 2021
@tmk
Copy link
Owner Author

tmk commented Nov 23, 2021

Fixed at 352f79f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant