in uf2tool/tool.c [95:117]
void send_hid(hid_device *dev, const void *data, int size) {
uint8_t buf[EP_SIZE + 1] = {0};
const uint8_t *ptr = data;
for (;;) {
int s;
if (size <= EP_SIZE - 1) {
s = size;
buf[1] = HF2_FLAG_CMDPKT_LAST | size;
} else {
s = EP_SIZE - 1;
buf[1] = HF2_FLAG_CMDPKT_BODY | (EP_SIZE - 1);
}
memcpy(buf + 2, ptr, s);
int sz = hid_write(dev, buf, EP_SIZE + 1);
if (sz != EP_SIZE + 1)
fatal("write error");
ptr += s;
size -= s;
if (!size)
break;
}
}