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

firmware: fix race conditions in control out transfers (-2 bytes XRAM). #703

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions firmware/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,13 @@ void handle_pending_usb_setup() {
}
SETUP_EP0_BUF(chunk_len);
} else {
SETUP_EP0_BUF(0);
SETUP_EP0_OUT_BUF();
while(EP0CS & _BUSY);
if(!eeprom_write(arg_chip, arg_addr, EP0BUF, chunk_len, /*double_byte=*/true,
page_size, timeout)) {
goto stall_ep0_return;
}
ACK_EP0();
}

arg_len -= chunk_len;
Expand All @@ -505,9 +506,10 @@ void handle_pending_usb_setup() {
return;
}
} else {
SETUP_EP0_BUF(0);
SETUP_EP0_OUT_BUF();
while(EP0CS & _BUSY);
fpga_reg_write(EP0BUF, arg_len);
ACK_EP0();
return;
}
}
Expand Down Expand Up @@ -547,12 +549,13 @@ void handle_pending_usb_setup() {
while(arg_len > 0) {
uint8_t chunk_len = arg_len < 64 ? arg_len : 64;

SETUP_EP0_BUF(0);
SETUP_EP0_OUT_BUF();
while(EP0CS & _BUSY);
fpga_load(EP0BUF, chunk_len);

arg_len -= chunk_len;
}
ACK_EP0();

bitstream_idx = arg_idx;
return;
Expand All @@ -569,9 +572,10 @@ void handle_pending_usb_setup() {
SETUP_EP0_BUF(CONFIG_SIZE_BITSTREAM_ID);
} else {
if(fpga_start()) {
SETUP_EP0_BUF(0);
SETUP_EP0_OUT_BUF();
while(EP0CS & _BUSY);
xmemcpy(glasgow_config.bitstream_id, EP0BUF, CONFIG_SIZE_BITSTREAM_ID);
ACK_EP0();
} else {
goto stall_ep0_return;
}
Expand Down
Loading