2020-10-19 06:16 PM
I was struggling to get LwIP TFTP server working on MCU boards (NUCELO-H743ZI). After debugging I have found:
So, it results in:
OK, working now (if you need details or code ... don't hesitate ...).
Just to bear in mind as well: you had to set macro LWIP_UDP to 1 as well! (even TCP HTTPD server runs already fine).
So, LwIP TFTP server works, but not from scratch, some settings are needed to be modified.
2020-10-19 06:22 PM
BTW: if you want to test LwIP TFTP - no need to have FatFS, SD Card etc. on your system running. You can 'satisfy' TFTP with dummy functions, e.g.:
static FILE tftpFileHandle;
static int xLen = 0; //just to manage READ requests
void* TFTP_open(const char* fname, const char* mode, u8_t write)
{
xLen = 256; //for testing - the file length
/* open a file, use the write flag for creating new file or open for read */
return (void *)&tftpFileHandle;
/*
* return a valid file pointer handle (not NULL), not used in LwIP TFTP, just forwarded
* to the Read, Write and Close file system functions
*/
}
void TFTP_close(void* handle)
{
/* close the file handle */
}
int TFTP_read(void* handle, void* buf, int bytes)
{
int availBytes = 0;
int xbytes = bytes > xLen ? xLen : bytes;
char *xbuf = (char *)buf;
while (xLen)
{
*xbuf++ = xLen--;
availBytes++;
}
/* function returns the number of bytes read, e.g. a full chunk, or shorter last chunk,
* or <0 for EOF
*/
if (availBytes > 0)
return availBytes; //how many bytes were available, could be read
else
return -1; //EOF
}
int TFTP_write(void* handle, struct pbuf* p)
{
/* return how many bytes were written */
return p->len;
}
/* initialize the TFTP handler functions for the file system */
const struct tftp_context TFTPctx = {
TFTP_open,
TFTP_close,
TFTP_read,
TFTP_write
};
2022-07-11 12:40 AM
Hello, Torsten Jaekel !
It would be very nice to see your code, can you please share it?
Best regards, IOvch
2024-08-28 07:51 AM
Hello @Torsten Jaekel',
I would like to see your code if there is a chance could you share it with me?
Best regards,
Eray