wokwi / rp2040js

A Raspberry Pi Pico Emulator in JavaScript
MIT License
384 stars 40 forks source link

USB read delay implementation is missing #104

Closed mingpepe closed 1 year ago

urish commented 1 year ago

Does it fix some problem for you?

Because the read delay is currently implemented by endpointReadDone():

https://github.com/wokwi/rp2040js/blob/cac702d96ba358d73da4226b6259488c4671fd59/src/peripherals/usb.ts#L214-L219

mingpepe commented 1 year ago

Oh, I miss the detail in endpointReadDone. Just think it is missing. This PR should be closed.

One of issues is small packet (size < max_packet_size) not received. After rp2040 write to DPRAM, the emulator indicate buffer ready immediately, the timing is obviously different from real chip. Though my code should not assume about timing. https://github.com/wokwi/rp2040js/blob/cac702d96ba358d73da4226b6259488c4671fd59/src/peripherals/usb.ts#L199-L209

this.rp2040.clock.createTimer for this.indicateBufferReady solved my problem, but finally I decided to modify my code since the timing assumption is not good. But maybe a delay for this.indicateBufferReady can be considered and seems like it can combine with this.writeDelayMicroseconds.

urish commented 1 year ago

Do you mind testing if adding a timer for indicateBufferReady fixes MicroPython 1.19.1?

USB CDC is broken with the latest release of MicroPython (see #101), and I've not yet been able to figure out how to fix that

mingpepe commented 1 year ago

Sadly, this does not fix it. After adding a timer, even the ">>>" prompt not shown.

urish commented 1 year ago

Bummer! Did you try to send Ctrl+C or a newline? Sometimes these are required to drop into the prompt

mingpepe commented 1 year ago

Yes, it's still not working.

urish commented 1 year ago

Thanks for testing!