Closed fabio-mantelli closed 2 years ago
E:M 16421 (2054 blocks)
this is a known issue with TLS - records can be up to 16K in size and it entirely depends on the server. if it decides to send us 16K of data, we hav eno choice but to deal with it. well, the way to deal with it is record fragmentation but as of today it is not supported by mbedtls. the only possible workaround is to manipulate server side to send data in smaller chunks. that is, to flush data more often.
Thanks for the answer. I have noticed in the debug that in the HTTP request header, there is the "Range" field, but only with the range start, but not the end. Perhaps an alteration could be made and a config parameter could be added where we can set the maximum response chunk size and the library automatically sets the range start and end in the HTTP header. Since there is a "extra_http_headers" config in the ota-http-client library, I imagine such functionality is possible. I think this would solve the issue with servers that can reply adequately to such requests.
We are using AWS cloud platform, and we are having trouble finding a way to manipulate the S3 or CloudFront, or any other service to send smaller chunks.
The work around we found was to whenever we get an OTA update request from shadow, we disable some features on the mongoose os and reboot the device with just enough functionalities to perform OTA through a local RPC call. This way we free some RAM when we wish to perform OTA updates. After that we enable the features again in case the update fails and reboot the device.
I would like to recommend that this issue is mentioned somewhere in documentation.
Hello, I am developing a device for my company using mongooseOS, and I am currently having issues during OTA updates through shadow. It appears to be that the OTA fails sometimes when the device tries to allocate memory, but it happens in different stages of the OTA process. Sometimes just after receiving the HTTP header and other times when it is writing the fs.bin file. My suspicion is that memory fragmentation might be an issue.
I am using MJS and lots of different libraries for this project, which makes space an issue. For example, I have removed the comments of most of the mongoose libraries and reduced the ca and certificate files to a minimum in order to save enough space in the fs. However, the issue I am seeing now I believe is in the RAM.
I am using mos tool 2.18.0, because I started the project with this version and for some obscure reason, If I update, my project won't build.
Mostly I have been able to work around the issues I have been facing by sorting through the source code of the libraries, available in the mongoose-os-libs. However, I do not have access to the mgos_ota_core.c source file and others, where I may have wanted to insert a print or something to help on debug.
For the issue with the malloc failing after we get the HTTP headers, I believe this could be fixed by enabling the firmware download through range Get requests.
For the issue with writing the fs.bin file to the new partition, I am not exactly sure what to do to fix it, but to try to find other ways to clear or defragment the RAM. This has become a big issue, since we have just bought a bunch of licenses to release our product and now the OTA update have been failing with our latest FW versions. How can I increase the available RAM memory during runtime? I am not doing any explicit dynamic memory allocation on my code, but perhaps some libaries are. Any suggestions at all?
Small part of the debug log where the failed malloc occurs. complete logs are attached. I have hidden some information that might be sensitive on the log, but it should not make a difference in helping me with this problem. I have also added some prints to help with debug.
HTTP fail
fs.bin fail
log_HTTP_header_fail.txt log_fs_bin_fail.txt