Skip to content

Conversation

kanishkatn
Copy link

@kanishkatn kanishkatn commented Jul 19, 2025

OTA Firmware Updates for Omi Glass

Note: Tested only on iOS.

Changes

Flutter

  • Added firmware update method for BLE-based OTA
  • Robust error handling and retry logic
  • Code cleanup in firmware management

OpenGlass Firmware

  • Added dedicated OTA BLE service
  • Implemented firmware transfer handling
  • Fixed memory management issues during updates
  • Added a release script

Testing

  • Flash OpenGlass with firmware from this PR
  • Create GitHub release with version 2.1.1. Here's a sample
  • Test OTA update via Flutter app
  • Verify successful firmware installation

Demo

omiglass_ota_demo.mov

TODO

  • test on Android and macOS

# Make GitHub API request if not cached
async with httpx.AsyncClient() as client:
url = "https://api.github.com/repos/BasedHardware/omi/releases?per_page=100"
url = "https://api.github.com/repos/kanishkatn/omi/releases?per_page=100"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
url = "https://api.github.com/repos/kanishkatn/omi/releases?per_page=100"
url = "https://api.github.com/repos/basedhardware/omi/releases?per_page=100"

@beastoin
Copy link
Collaborator

@kanishkatn cool!!! i guess it works well. btw, what is this? > the photo capture is currently disabled. haha. also, could you clean up your PR a bit:

1/ the app already has the firmware download functionality - you don’t need to handle it, right?

2/ please check the app > lib > services > devices > omi_connection.dart for having a better way to handle the custom OTA BLE services.

3/ const chunkSize = 480; could we use the exchanged MTU to calculate the chunk size? some phones limit it to 247 or even 30 bytes data length.

4/ why do we need to change the partition?
board_build.partitions = huge_app.csv
board_build.partitions = min_spiffs.csv

5/ it’s omiglass, not openglass. also, remove the print logs etc.

@kanishkatn
Copy link
Author

kanishkatn commented Jul 22, 2025

Hey @beastoin ! Thank you for taking a look!

what is this? > the photo capture is currently disabled

There were few crashes related to memory access during the upload so I had to disable it. I can no longer re-create them and have reverted the changes.

1/ the app already has the firmware download functionality - you don’t need to handle it, right?

I've only renamed the method here

2/ please check the app > lib > services > devices > omi_connection.dart for having a better way to handle the custom OTA BLE services.

I will take a look. Thanks.

3/ const chunkSize = 480; could we use the exchanged MTU to calculate the chunk size? some phones limit it to 247 or even 30 bytes data length.

That's a good idea! I will check if we could get the sender's config as well.

4/ why do we need to change the partition?

Using huge_app.csv led to memory related crashes during OTA updates. I believe it is due to the scheme not allocating memory to ota updates and SPIFFS.

I've ensured that the min_spiffs.csv allocates sufficient memory for the application. It does need more testing.

5/ it’s omiglass, not openglass. also, remove the print logs etc.

In the backend it is defined as OpenGlass. It currently fails to get the release details for the firmware.

I will remove all the debug logs.

@beastoin
Copy link
Collaborator

how's it going man, should i review the PR now?

@kanishkatn

@aaravgarg
Copy link
Collaborator

@kanishkatn any updates?

@kanishkatn
Copy link
Author

Hey @beastoin @aaravgarg ,

Thank you for waiting! I was away for a while and will look into addressing the review comments in a couple of days.

@kanishkatn
Copy link
Author

Hello @beastoin @aaravgarg ,

I have addressed the following in the commit

  1. const chunkSize = 480; could we use the exchanged MTU to calculate the chunk size? some phones limit it to 247 or even 30 bytes data length.

I've replaced the hardcoded chunkSize with a dynamic calculation. Here are the details

  • Replaced hardcoded 480 bytes with MTU - 3 - 20 (ATT header + safety margin)
  • Clamps between 20-500 bytes for compatibility with restrictive phones and ESP32 limits
  • Accounts for 3-byte ATT header and 20-byte BLE stack safety margin

2/ please check the app > lib > services > devices > omi_connection.dart for having a better way to handle the custom OTA BLE services.

However, for the above feedback, I wasn't able to find a module/method that already handles OTA updates. The module used in this PR seems to be used for OTA updates on the omi necklace as well.

If the feedback was to move the OTA updates completely to omi_connection.dart, I think it is out of scope for this PR.

I have rebased the branch and have ensured that the OTA updates still work in my iPhone. Please let me know if you need any further inputs or assistance!

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

Successfully merging this pull request may close these issues.

3 participants