-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LwM2M: Fix incorrect last_block handling in the firmware write callback #16158
Comments
@lodup29 Thank you for bringing this up. It might be that over time the logic to the last_block handling has been broken (from the callback perspective). We calculate last_block here: And then check for a write callback here: With the actual callback happening here: As I get some time, I'll run a few tests and see what needs to happen there. |
@mike-scott is this bug still present? If so, will you address this for 2.0.0? |
Yes, I will test and address for 2.0 if there's a bug. |
@mike-scott ping :) |
@ioannisg thanks for the ping. seems I had a rather large backlog for LwM2M this cycle. |
@lodup29 I think I know what's causing the issue you're seeing. The proxy uses ETAG CoAP options which are longer than the default of 12. Can you add these 2 configs to the exact setup that you have and see if it fixes it?
On a side note, I did find a bug in how the last_block calculation is sent to the callbacks. When the user buffer has a smaller size than the BLOCK_SIZE, multiple callbacks are sent with last_block=true. I'll submit that PR today. |
To be clear, I reproduced the behavior in the issue and after adding the above 2 items to my prj.conf I see the following (this includes a patch here: #18757):
|
When the firmware_pull mechansim sends the callback to notify the sample of a new firmware block, the user supplied buffer can be smaller than the CoAP BLOCK_SIZE setting. To handle this case, we loop through the payload and fill the user supplied buffer with smaller chunks. Unfortunately, the last_block calculation is done outside this loop which causes several callbacks (while in this loop) to have last_block true. Let's fix this by adding a small check to make sure we're at the end of the current payload block before notifying the user of a last_block. Fixes: zephyrproject-rtos#16158 Signed-off-by: Michael Scott <mike@foundries.io>
When the firmware_pull mechansim sends the callback to notify the sample of a new firmware block, the user supplied buffer can be smaller than the CoAP BLOCK_SIZE setting. To handle this case, we loop through the payload and fill the user supplied buffer with smaller chunks. Unfortunately, the last_block calculation is done outside this loop which causes several callbacks (while in this loop) to have last_block true. Let's fix this by adding a small check to make sure we're at the end of the current payload block before notifying the user of a last_block. Fixes: #16158 Signed-off-by: Michael Scott <mike@foundries.io>
When the firmware_pull mechansim sends the callback to notify the sample of a new firmware block, the user supplied buffer can be smaller than the CoAP BLOCK_SIZE setting. To handle this case, we loop through the payload and fill the user supplied buffer with smaller chunks. Unfortunately, the last_block calculation is done outside this loop which causes several callbacks (while in this loop) to have last_block true. Let's fix this by adding a small check to make sure we're at the end of the current payload block before notifying the user of a last_block. Fixes: zephyrproject-rtos#16158 Signed-off-by: Michael Scott <mike@foundries.io>
At least using a coap to http proxy (I never manager to trigger the callback otherwise) the last_block parameter provided though the callback function (implemented through firmware_block_received_cb in the LWM2M client example) is never set to true although the firmware is fully downloaded.
To Reproduce
and monitor last_block.
The download should go fine but last_block is never set to to true.
The text was updated successfully, but these errors were encountered: