I have already posted my question on NXP comunity forum but the team says that LWIP is open source and not related to NXP. which I agree. I have the following scenario :
- PC will run a TFTP server containing all SW files
- MCU will run a TFTP client that will ask (by file name) the server for the flash file
- MCU will receive the flash file and start the SW update (erase all flash memory and write).
for TFTP server I used the TFTPD64 . MCU will run the client, most of the code is taking from this github repo TFTP client is started correctly on port 69, when I request a file from the server I get the error 'Failed to open file', even though the server is poiting to it and is available
void tftp_example_init_client(void)
{
void *f;
err_t err;
ip_addr_t srv;
int ret = ipaddr_aton(LWIP_TFTP_SERVER_IP, &srv);
if(ret != 1)
{
printf("ipaddr_aton failed \r\n");
}
err = tftp_init_client(&tftp);
if(err != ERR_OK)
{
printf("tftp_init_client failed, error : %d \r\n", err);
}
f = tftp_open_file(LWIP_TFTP_FILENAME, 1);
if(f == NULL)
{
printf("failed to open file , %d \r\n", f);
}
err = tftp_get(f, &srv, TFTP_PORT, LWIP_TFTP_FILENAME,
TFTP_MODE_OCTET);
if(err != ERR_OK)
{
printf("tftp_get failed \r\n");
}
}
the tftp_open_file
function is defined as follow :
static void * tftp_open_file(const char* fname, u8_t is_write)
{
snprintf(full_filename, sizeof(full_filename), "%s%s", LWIP_TFTP_BASE_DIR,
fname);
full_filename[sizeof(full_filename)-1] = 0;
printf("%s \r\n",fname);
if (is_write) {
return (void*)fopen(full_filename, "wb");
} else {
return (void*)fopen(full_filename, "rb");
}
}
static void* tftp_open(const char* fname, const char* mode, u8_t is_write)
{
LWIP_UNUSED_ARG(mode);
return tftp_open_file(fname, is_write);
}
EDIT
#define LWIP_TFTP_SERVER_IP "192.168.225.20"
#define LWIP_TFTP_FILENAME "0223.bin"
#define LWIP_TFTP_BASE_DIR "\\"
Thank you.