Open phalox opened 8 years ago
About the device driver modification: One cannot simply remove the memcpy(buffer, buf, len); This buffer was allocated by the stack (using PICO_ZALLOC), and will be freed after pico_eth_send() has been called. If that buffer is just attached to the DMA, chances are that the contents get corrupted, since the stacked released this memory back into the malloc-pool.
A zero-copy implementation is needed to eliminate the memcpy(), but it exists only for the RX-side at this moment... (See pico_stack_recv_zerocopy() at https://github.com/tass-belgium/picotcp/blob/72848bdc0c8bd84fe66ecf329d39957c5598fd0c/include/pico_stack.h)
the goal was not to remove memcpy (saddly) but to avoid modification of a used (by DMA) buffer please read these line before the highlighted code:
// if in use, avoid crashing the buffer
if ((heth->TxDesc->Status & ETH_DMATXDESC_OWN) != (uint32_t)RESET) <<< you should have added something like that before (this code is for discovery stm32F7 / i can give you the full source for this board)
return 0;
Etienne Cochard suggests these changes, to assosiate data with a connection
Create two new functions void pico_http_set_user_data(uint16_t conn, void* data) { struct http_client *client = find_client(conn); if (!client) { dbg("Wrong connection ID\n"); return; }
client->user_data = data; }
void* pico_http_get_user_data(uint16_t conn) { struct http_client *client = find_client(conn); if (!client) { dbg("Wrong connection ID\n"); return NULL; }
}
in pico_f4x7_eth.c (https://github.com/tass-belgium/cyassl-picotcp/blob/master/src/pico_f4x7_eth.c)
int16_t f4x7_frame_push(ETH_HandleTypeDef heth, uint8_t buf, uint16_t len) { // if in use, avoid crashing the buffer if ((heth->TxDesc->Status & ETH_DMATXDESC_OWN) != (uint32_t)RESET) <<< you should have added something like that before (this code is for discovery stm32F7 / i can give you the full source for this board) return 0;
}