IoT MQTT OTA error: The cache block with block id [4] does not exist.

0

I got this error when I do a MQTT OTA update from AWS IOT Core. The funny thing is, depending on the file I push over OTA, I some time successful, and sometime I don't.

When I am not successful, I usually failed on the last block the date stream.

payload(164): {"code":"InvalidRequest","o":"InvalidRequest","message":"The cache block with block id [4] does not exist.","m":"The cache block with block id [4] does not exist."}

  • Hi. What device software are you using? What parameters do you pass to CreateOTAUpdate? What is the file size when it works and when it fails? Can you share the job document of a failure?

  • I am running an embedded linux, this is how I request the next block of data

    {"f":"0","l":"60000","n":"1","o":"0"}

  • This is a successful one, file size about 700+KB

    { "afr_ota": { "protocols": [ "MQTT" ], "streamname": "AFR_OTA-f27422c0-9bd7-46a3-afd9-hidden", "files": [ { "filepath": "none", "filesize": 733072, "fileid": 0, "certfile": "none", "fileType": 0, "update_data_url": null, "auth_scheme": null, "sig-sha256-rsa": "mysecret" } ] } }

  • Here are one of the job documents that failed, file size about 500+KB

    This is the error message from a 500+KB file: { "afr_ota": { "protocols": [ "MQTT" ], "streamname": "AFR_OTA-4fe0cc0e-111d-41fa-a6fb-hidden", "files": [ { "filepath": "none", "filesize": 908976, "fileid": 0, "certfile": "none", "fileType": 0, "update_data_url": null, "auth_scheme": null, "sig-sha256-rsa": "my_secret" } ] } }

    { "afr_ota": { "protocols": [ "MQTT" ], "streamname": "AFR_OTA-b2627f90-06c3-43dd-bc50-hidden", "files": [ { "filepath": "none", "filesize": 516624, "fileid": 0, "certfile": "none", "fileType": 0, "update_data_url": null, "auth_scheme": null, "sig-sha256-rsa": "mysecret" } ] } }

asked 2 years ago419 views
1 Answer
0

Hi. Thanks for the information. I don't see anything wrong with the GetStream request you're sending: {"f":"0","l":"60000","n":"1","o":"0"}. But that's just the request for the first block. Have you checked the sequence of requests you're sending in the lead-up to the error? It's clear that AWS IoT is rejecting your GetStream request as invalid. What's the final request message before the error?

Also, are you using the AWS OTA library on your device? Based on your GetStream request, I think not. It may be worth comparing your implementation: https://github.com/aws/ota-for-aws-iot-embedded-sdk/blob/a8106b7ea254ec5237d24d6454d88750c01b988a/source/ota_cbor.c#L236

profile pictureAWS
EXPERT
Greg_B
answered 2 years ago
  • my request for the last block is {"f":"0","l":"60000","n":"1","o":"9"} for the 500+KB file, but the error is per my OP, saying can't find block id[4].

  • OK. I'm not sure why it says block_id[4], but that request is overshooting the file length.

  • Sorry, my bad, my last request is actually {"f":"0","l":"60000","n":"1","o":"8"}. I just conveniently typed my debug print out number.

  • Interestingly, I came across this. https://github.com/aws/amazon-freertos/blob/a02a2b5f3295b85396a008abdc344195960f40bf/vendors/pc/boards/windows/aws_demos/config_files/ota_config.h. This example use the block size of power 2, and I changed my block size to something like this: {"f":"0","l":"65536","n":"1","o":"0"}, it works with all my previously failed OTA test...

  • The power of 2 stuff there is just an implementation detail of the OTA library (because it uses the bitmap request method instead of the block offset). The GetStream request itself does not require the block size to be a power of 2.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions