Skip to content

Commit e129a81

Browse files
committed
fix: print error for msc buffer overflow that should never happen
In this situation the host is sending a new packet of data before the last buffer has been handled. This should never happen and indicates a breakdown in the NAK-sending behavior of the greater USB stack for an MCU. When the buffer is full the USB stack should not ACK the final packet and should NAK any new packets until the buffer is handled. If an ACK is sent prematurely and NAKs are not sent in reply to overflow packets this message will occur and the protocol will de-sync.
1 parent b9182ef commit e129a81

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/machine/usb/msc/scsi.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ func (m *msc) scsiCmdUnmap(cmd scsi.Cmd) {
245245
func (m *msc) scsiQueueTask(cmdType scsi.CmdType, b []byte) bool {
246246
// Check if the incoming data is larger than our buffer
247247
if int(m.queuedBytes)+len(b) > cap(m.buf) {
248+
println("scsiQueueTask: OVERFLOW! queued:", m.queuedBytes, "len(b):", len(b), "cap:", cap(m.buf))
248249
m.sendScsiError(csw.StatusFailed, scsi.SenseIllegalRequest, scsi.SenseCodeInvalidFieldInCDB)
249250
return true
250251
}

0 commit comments

Comments
 (0)