2024-08-22 05:47 PM - last edited on 2024-08-23 02:18 AM by SofLit
I am working on a tftp client program that receives a file from a tftp server.
I found the tftp client library below and ported it.
https://github.com/particle-iot/lwip/blob/master/contrib/examples/tftp/tftp_example.c
The file is received in debugging mode, but it is not received at runtime.
I checked and confirmed that 'fopen' does not work at runtime. I don't know why.
Below is the fopen code.
-------------------------------------------------------------------------------------
static void *
tftp_open_file(const char* fname, u8_t is_write)
{
snprintf(full_filename, sizeof(full_filename), "%s%s", LWIP_TFTP_EXAMPLE_BASE_DIR, fname);
full_filename[sizeof(full_filename)-1] = 0;
if (is_write) {
return (void*)fopen(full_filename, "wb");
} else {
return (void*)fopen(full_filename, "rb");
}
}
-------------------------------------------------------------------------------------
I tried delaying before the tftp_client_init() function because it seemed to be a timing issue.
Please help.
2024-08-23 05:07 AM - edited 2024-08-23 05:08 AM
Do you know why fopen works in debug mode? Do you use semihosting?
2024-08-23 08:54 AM
Hello @jmyoo ,
Ensure that the tftp configuration parameters are correctly set and the tftp server software is up to date and properly configured.
2024-08-25 05:14 PM
I don't know
Please let me know
2024-08-25 05:40 PM
Yes, I found it and read the contents.
How do I make it work at runtime?
2024-08-26 01:37 AM
No
2024-08-26 02:57 AM
Hi, usually fopen on embedded board works via semihosting - unless of course the embedded software has some filesystem, not your case.
So the answer is, without the debugger connection it won't work. If you have some other connection to the host (serial, ethernet, USB and so on) you can write code for STM32 to access files on the host and even your own fopen function.
2024-08-26 06:24 PM
Thank you. Now I understand.
So you mean to use fatfs for embedded. Am I right?
Then can I write files to internal flash memory too?
2024-08-27 08:19 AM
If your files are on some storage device or memory that can work with fatfs then yes, you can use fatfs.
But the internal flash is very limited. Fatfs is not the good way to write to it.