Hi all,
I'm using the CMSIS ftp client to upload a file to a server.. All the process is ok, create the file in the memory card, write some data, connect to the server, start session and put the file... everything is ok.. but, the file on the server is always empty.
When I debug the program and place a breakpoint on the ftp_client_fread function where is the fread function that reads the file from the SD card requested by the ftp client, the fread function is returning a 0 value that is an error (no data readed)... for this reason the file on the server have size zero.
The function receives a correct file handler but can't read enything. If I place in the ftp_client_fread function a full code to open a file and read (to be sure that the handler is ok) fread returns zero:
__weak uint32_t ftp_client_fread (void *file, uint8_t *buf, uint32_t len) { // Read block of data from local file in FTP client. size_t ret; char data[40]; FILE *f = fopen ("M0:\\hola.txt", "r"); if (f != NULL){ ret = fread (data, 10, 1, (FILE *)f); fclose (f); } return (ret); }
But the file exists and is OK with data.. Also I tested the same with a ramdrive and the same result...
Thanks
You would normally want to download the flash image to the memory card. And not until the FTP transfer has ended and you have verified that you have a complete file - with correct CRC32/MD5/... and some magic marker that indicates that it really is a firmware for your specific platform - would you want to perform the flashing of the firmware.
And you would want to use a boot loader to perform the actual flashing (unless you can afford two separate application regions) so that you can survive a power loss during the flash operation and have the boot loader just continue with the flashing when the power returns. Just writing directly to flash on-the-fly tends to be a great way to get bricked units. Or is it your boot loader that contains the FTP client, so you can restart the FTP transfer after an unexpected reboot or power loss?
Hi,
Don't want to use a SD card for this for many reasons:
1. The SD card add extra cost to the project (this is not a home made project, is for large quantity)
2. If the power fails in a writing to the SD card the card can be broken (this is a problem with the SD cards) and the product will never be upgraded
I'm using a STM32F4 with 1M of flash and I have enough memory for bootloader, firmware (2 partitions), user data.
The process is the next:
1. Bootloader checks the latest firmware version of each of the two partitions 2. Check the MD5 for this partition with the MD5 saves to user data space 3. If the check fails boots from the other partition 4. If a new firmware will be downloaded this will be wrote to the not used partition and then restart. If the ftp fails and the data is corrupted the bootloader will boot from current partition
I think this boot and updating system can't fail