Skip to content
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

Using AWS OTA with ESP-Matter (CON-840) #691

Closed
anuarrozman opened this issue Oct 19, 2023 · 13 comments
Closed

Using AWS OTA with ESP-Matter (CON-840) #691

anuarrozman opened this issue Oct 19, 2023 · 13 comments

Comments

@anuarrozman
Copy link

Im planning on using AWS OTA features with Matter. My OTA function is ready and has been tested. Ive created my AWS OTA as component in ESP-Matter. Any resources or help i can get regarding this thing ?

@github-actions github-actions bot changed the title Using AWS OTA with ESP-Matter Using AWS OTA with ESP-Matter (CON-840) Oct 19, 2023
@shubhamdp
Copy link
Contributor

We have a some docs which talks about Matter OTA. It also includes how to use encrypted OTA, you can take a look at that.

You may need to increment version number which matter basic information cluster reads. Take a look at this FAQ.

@anuarrozman
Copy link
Author

Thanks a bunch !! Ive done ESP AWS OTA demo and it works just fine. I've managed to make the AWS OTA as a component in my Matter project folder. When running with Matter, it has problem on connecting to my AWS endpoint which is not an issue when running AWS OTA without Matter.

@anuarrozman
Copy link
Author

From my reading, Matter CSA allows any method of OTA update right ? Not strictly bind to their OTA method.

@shubhamdp
Copy link
Contributor

13.5. Firmware
a. Nodes SHALL support OTA firmware updates, either using Matter-provided means (see Section 11.19, “Over-the-Air (OTA) Software Update”) or proprietary means. [CM58 for T59, T226]

This is from Matter Core Specification v1.2.

There has to be some means to OTA the device either Matter OTA or proprietary one.

@dhrishi
Copy link
Collaborator

dhrishi commented Nov 1, 2023

Closing as the question is answered

@dhrishi dhrishi closed this as completed Nov 1, 2023
@shubhamdp
Copy link
Contributor

Thanks a bunch !! Ive done ESP AWS OTA demo and it works just fine. I've managed to make the AWS OTA as a component in my Matter project folder. When running with Matter, it has problem on connecting to my AWS endpoint which is not an issue when running AWS OTA without Matter.

Can you check the free memory when using Matter. You can refer the below snippet for getting the values.

static esp_err_t mem_dump_console_handler(int argc, char *argv[])
{
printf("\tDescription\tInternal\tSPIRAM\n");
printf("Current Free Memory\t%d\t\t%d\n",
heap_caps_get_free_size(MALLOC_CAP_8BIT) - heap_caps_get_free_size(MALLOC_CAP_SPIRAM),
heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
printf("Largest Free Block\t%d\t\t%d\n", heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL),
heap_caps_get_largest_free_block(MALLOC_CAP_SPIRAM));
printf("Min. Ever Free Size\t%d\t\t%d\n", heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL),
heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM));
return ESP_OK;
}

@dhrishi dhrishi reopened this Nov 1, 2023
@dhrishi
Copy link
Collaborator

dhrishi commented Nov 1, 2023

When running with Matter, it has problem on connecting to my AWS endpoint which is not an issue when running AWS OTA without Matter.

Sorry for missing this. I have reopened the issue

@anuarrozman
Copy link
Author

Hiii, Thanks for the responses.

13.5. Firmware
a. Nodes SHALL support OTA firmware updates, either using Matter-provided means (see Section 11.19, “Over-the-Air (OTA) Software Update”) or proprietary means. [CM58 for T59, T226]

This is from Matter Core Specification v1.2.

There has to be some means to OTA the device either Matter OTA or proprietary one.

Yeap, Ive read this and think this could work.

Thanks a bunch !! Ive done ESP AWS OTA demo and it works just fine. I've managed to make the AWS OTA as a component in my Matter project folder. When running with Matter, it has problem on connecting to my AWS endpoint which is not an issue when running AWS OTA without Matter.

Can you check the free memory when using Matter. You can refer the below snippet for getting the values.

static esp_err_t mem_dump_console_handler(int argc, char *argv[])
{
printf("\tDescription\tInternal\tSPIRAM\n");
printf("Current Free Memory\t%d\t\t%d\n",
heap_caps_get_free_size(MALLOC_CAP_8BIT) - heap_caps_get_free_size(MALLOC_CAP_SPIRAM),
heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
printf("Largest Free Block\t%d\t\t%d\n", heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL),
heap_caps_get_largest_free_block(MALLOC_CAP_SPIRAM));
printf("Min. Ever Free Size\t%d\t\t%d\n", heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL),
heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM));
return ESP_OK;
}

For this, Ive check the heap memory using ESP_LOGI(TAG, "[APP] Free memory: %"PRIu32" bytes", esp_get_free_heap_size()); this one is from ESP-IDF. When running both Matter and AWS, free heap memory during establishing connection to AWS is around 40000 - 50000 bytes. Without Matter, establishing connection to AWS will left around 100000+ bytes of free heap memory. Can this be the cause ? Sometimes when esp try to reestablish the AWS connection to the endpoint, the free heap memory become 900 bytes only, this is status when running with Matter.

@anuarrozman
Copy link
Author

Thanks a bunch !! Ive done ESP AWS OTA demo and it works just fine. I've managed to make the AWS OTA as a component in my Matter project folder. When running with Matter, it has problem on connecting to my AWS endpoint which is not an issue when running AWS OTA without Matter.

Can you check the free memory when using Matter. You can refer the below snippet for getting the values.

static esp_err_t mem_dump_console_handler(int argc, char *argv[])
{
printf("\tDescription\tInternal\tSPIRAM\n");
printf("Current Free Memory\t%d\t\t%d\n",
heap_caps_get_free_size(MALLOC_CAP_8BIT) - heap_caps_get_free_size(MALLOC_CAP_SPIRAM),
heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
printf("Largest Free Block\t%d\t\t%d\n", heap_caps_get_largest_free_block(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL),
heap_caps_get_largest_free_block(MALLOC_CAP_SPIRAM));
printf("Min. Ever Free Size\t%d\t\t%d\n", heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL),
heap_caps_get_minimum_free_size(MALLOC_CAP_SPIRAM));
return ESP_OK;
}

Thanks @shubhamdp , I currently looking at this.

@shubhamdp
Copy link
Contributor

the free heap memory become 900 bytes only, this is status when running with Matter

This could be a problem. You may need to optimize the RAM usage. There's a guide from esp-idf to minimize the RAM usage. There's another blog post which talks about the minimizing the memory. Please take a look at them and see if you can reduce the RAM usage.

Also, can you share the following details, which could help to try out this situation?
Environment

  • ESP-Matter Commit Id:
  • ESP-IDF Commit Id:
  • AWS IoT Commit Id:
  • SoC (eg: ESP32 or ESP32-C3):
  • Device Logs (Please attach the log file):
  • Host Machine OS:
  • Commissioner app and versions if present:
  • Commissioner's logs if present:

@anuarrozman
Copy link
Author

Hi @shubhamdp, Im so sorry for the late response. I tried to recreate the RAM issues as well as unable to reconnect to AWS endpoint after device completed the update but suddenly no RAM issue. RAM start at around 199Kb at the start of the firmware, once ble deinit (matter) and RAM value at the start of OTA function is around 85Kb to 90Kb which is enough. I cant find my previous log where the problem occured but I'll just provide with you guys the commit hash of my ESP-Matter and ESP-IDF. I'll also provide the same RAM issue on my team environment.

Here are my environment details:
ESP-Matter Commit Id: 198db12
ESP-IDF Commit Id: ea5e0ff298e6257b31d8e0c81435e6d3937f04c7
AWS IoT Commit Id: d37fd63002b4fda99523e1ac4c9822fce485e76d
SoC (eg: ESP32 or ESP32-C3): ESP32S3

Here are one of my team environment details:
ESP-Matter Commit Id: cd325c6
ESP-IDF Commit Id: ea5e0ff298e6257b31d8e0c81435e6d3937f04c7
AWS IoT Commit Id: d37fd63002b4fda99523e1ac4c9822fce485e76d
SoC (eg: ESP32 or ESP32-C3): ESP32S3

The log i provide is one of my team, since I cant recreate the issue.
idf_py_stdout_output_68121.txt

@dhrishi
Copy link
Collaborator

dhrishi commented Dec 5, 2024

@anuarrozman With the latest main branch, some RAM optimizations are done. Please check those out. Please close the issue if resolved.

@dhrishi
Copy link
Collaborator

dhrishi commented Jan 13, 2025

@anuarrozman Any updates you can share?

@dhrishi dhrishi closed this as completed Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants