Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf246bff

Browse files
committed
fix(msc): set min buffer cap to usb packet size
1 parent9653ca3 commitf246bff

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

‎src/machine/usb/msc/disk.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"machine"
8+
"machine/usb"
89
"time"
910
)
1011

@@ -17,8 +18,8 @@ func (m *msc) RegisterBlockDevice(dev machine.BlockDevice) {
1718
m.dev=dev
1819

1920
ifcap(m.blockCache)!=int(dev.WriteBlockSize()) {
20-
m.blockCache=make([]byte,dev.WriteBlockSize())
21-
m.buf=make([]byte,dev.WriteBlockSize())
21+
m.blockCache=make([]byte,max(usb.EndpointPacketSize,dev.WriteBlockSize()))
22+
m.buf=make([]byte,max(usb.EndpointPacketSize,dev.WriteBlockSize()))
2223
}
2324

2425
m.blockSizeRaw=uint32(m.dev.WriteBlockSize())

‎src/machine/usb/msc/msc.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ func newMSC(dev machine.BlockDevice) *msc {
7272
maxPacketSize:=descriptor.EndpointMSCIN.GetMaxPacketSize()
7373
m:=&msc{
7474
// Some platforms require reads/writes to be aligned to the full underlying hardware block
75-
blockCache:make([]byte,dev.WriteBlockSize()),
75+
blockCache:make([]byte,max(usb.EndpointPacketSize,dev.WriteBlockSize())),
7676
blockSizeUSB:512,
77-
buf:make([]byte,dev.WriteBlockSize()),
77+
buf:make([]byte,max(usb.EndpointPacketSize,dev.WriteBlockSize())),
7878
cswBuf:make([]byte,csw.MsgLen),
7979
cbw:&CBW{Data:make([]byte,31)},
8080
maxPacketSize:uint32(maxPacketSize),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp