{"id":15571358,"url":"https://github.com/fishwaldo/esp_ghota","last_synced_at":"2025-04-05T17:09:08.617Z","repository":{"id":64761408,"uuid":"567360123","full_name":"Fishwaldo/esp_ghota","owner":"Fishwaldo","description":"esp32 OTA Component to update firmware from Github Releases","archived":false,"fork":false,"pushed_at":"2024-02-17T15:20:42.000Z","size":71,"stargazers_count":437,"open_issues_count":3,"forks_count":44,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-29T16:09:53.487Z","etag":null,"topics":["esp","esp-idf","esp32","ota","ota-firmware-updates"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fishwaldo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"Fishwaldo","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-11-17T16:14:24.000Z","updated_at":"2025-03-20T15:34:29.000Z","dependencies_parsed_at":"2024-10-27T00:55:26.926Z","dependency_job_id":null,"html_url":"https://github.com/Fishwaldo/esp_ghota","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fishwaldo%2Fesp_ghota","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fishwaldo%2Fesp_ghota/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fishwaldo%2Fesp_ghota/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fishwaldo%2Fesp_ghota/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fishwaldo","download_url":"https://codeload.github.com/Fishwaldo/esp_ghota/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369952,"owners_count":20927928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esp","esp-idf","esp32","ota","ota-firmware-updates"],"created_at":"2024-10-02T17:59:33.622Z","updated_at":"2025-04-05T17:09:08.595Z","avatar_url":"https://github.com/Fishwaldo.png","language":"C","funding_links":["https://github.com/sponsors/Fishwaldo"],"categories":[],"sub_categories":[],"readme":"# GITHUB OTA for ESP32 devices\n\nAutomate your OTA and CI/CD pipeline with Github Actions to update your ESP32 devices in the field direct from github releases\n\n## Features\n* Uses the esp_htps_ota library under the hood to update firmware images\n* Can also update spiffs/littlefs/fatfs partitions\n* Uses SemVer to compare versions and only update if a newer version is available\n* Plays nicely with App rollback and anti-rollback features of the esp-idf bootloader\n* Download firmware and partitiion images from the github release page directly\n* Supports multiple devices with different firmware images\n* Includes a sample Github Actions that builds and releases images when a new tag is pushed\n* Updates can be triggered manually, or via a interval timer\n* Uses a streaming JSON parser for to reduce memory usage (Github API responses can be huge)\n* Supports Private Repositories (Github API token required*)\n* Supports Github Enterprise\n* Supports Github Personal Access Tokens to overcome Github API Ratelimits\n* Sends progress of Updates via the esp_event_loop\n\nNote:\nYou should be careful with your GitHub PAT and putting it in the source code. I would suggest that you store the PAT in NVS, and the user enters it when running, as otherwise the PAT would be easily extractable from your firmware images. \n\n## Usage\n\n### esp-idf via Espressif Component Registry:\n\n```bash\nidf.py add-dependency Fishwaldo/ghota^1.0.0\n```\n\n#### Platform IO Registry:\n\nadd this to your platform.ini file:\n\n```ini \nlib_deps = \n    fishwaldo/ghota@^1.0.0\n```\n\nYou also need to copy the contents of [Kconfig](Kconfig) into your project's Kconfig file, and run pio run -t menuconfig to configure the component.\n\n#### API Documentation:\n\nMore details on the API are available [here](https://esp-github-ota.readthedocs.io/en/latest/index.html)\n\n## Example\nAfter Initilizing Network Access, Start a timer to periodically check for new releases:\n\n(if you a reading this from https://components.espressif.com, please note that this website munges the examples below. Please refer to https://github.com/Fishwaldo/esp_ghota for the correct examples)\n\n```c\n    ghota_config_t ghconfig = {\n        .filenamematch = \"GithubOTA-esp32.bin\", // Glob Pattern to match against the Firmware file\n        .storagenamematch = \"storage-esp32.bin\", // Glob Pattern to match against the storage firmware file\n        .storagepartitionname = \"storage\", // Update the storage partition\n        .updateInterval = 60, // Check for updates every 60 minuites\n    };\n    ghota_client_handle_t *ghota_client = ghota_init(\u0026ghconfig);\n    if (ghota_client == NULL) {\n        ESP_LOGE(TAG, \"ghota_client_init failed\");\n        return;\n    }\n    esp_event_handler_register(GHOTA_EVENTS, ESP_EVENT_ANY_ID, \u0026ghota_event_callback, ghota_client); // Register a handler to get updates on progress \n    ESP_ERROR_CHECK(ghota_start_update_timer(ghota_client)); // Start the timer to check for updates\n```\n\nManually Checking for updates:\n\n```c\n    ghota_config_t ghconfig = {\n        .filenamematch = \"GithubOTA-esp32.bin\",\n        .storagenamematch = \"storage-esp32.bin\",\n        .storagepartitionname = \"storage\",\n        .updateInterval = 60,\n    };\n    ghota_client_handle_t *ghota_client = ghota_init(\u0026ghconfig);\n    if (ghota_client == NULL) {\n        ESP_LOGE(TAG, \"ghota_client_init failed\");\n        return;\n    }\n    esp_event_handler_register(GHOTA_EVENTS, ESP_EVENT_ANY_ID, \u0026ghota_event_callback, ghota_client);\n    ESP_ERROR_CHECK(ghota_check(ghota_client));\n\n    semver_t *cur = ghota_get_current_version(ghota_client);\n    if (cur) {\n        ESP_LOGI(TAG, \"Current version: %d.%d.%d\", cur-\u003emajor, cur-\u003eminor, cur-\u003epatch);\n        semver_free(cur);\n    }\n\n    semver_t *new = ghota_get_latest_version(ghota_client);\n    if (new) {\n        ESP_LOGI(TAG, \"New version: %d.%d.%d\", new-\u003emajor, new-\u003eminor, new-\u003epatch);\n        semver_free(new);\n    }\n    ESP_ERROR_CHECK(ghota_update(ghota_client));\n    ESP_ERROR_CHECK(ghota_free(ghota_client));\n```\n\n## Configuration\nThe following configuration options are available:\n\n    * config.filenamematch \u003c- Glob pattern to match against the firmware file from the Github Releases page. \n    * config.storagenamematch \u003c- Glob pattern to match against the storage file from the Github Releases page.\n    * config.storagepartitionname \u003c- Name of the storage partition to update (as defined in partitions.csv)\n    * config.hostname \u003c- Hostname of the Github API (default: api.github.com)\n    * config.orgname \u003c- Name of the Github User or Organization\n    * config.reponame \u003c- Name of the Github Repository\n    * config.updateInterval \u003c- Interval in minutes to check for updates\n\n## Github Actions\nThe Github Actions included in this repository can be used to build and release firmware images to Github Releases.\nThis is a good way to automate your CI/CD pipeline, and update your devices in the field.\nIn this example, we build two variants of the Firmware - on for a ESP32 and one for a ESP32-S3 device\nUsing the filenamematch and storagenamematch config options, we can match against the correct firmware image for the device.\n\n```yaml\non:\n  push:\n  pull_request:\n    branches: [master]\n\npermissions:\n  contents: write\nname: Build\njobs:\n  build:\n    strategy:\n      fail-fast: true\n      matrix: \n        targets: [esp32, esp32s3]\n    runs-on: ubuntu-latest\n    steps:\n    - name: Checkout repo\n      uses: actions/checkout@v3\n      with:\n        submodules: 'recursive'\n    - name: esp-idf build\n      uses: Fishwaldo/esp-idf-ci-action@v1.1\n      with:\n        esp_idf_version: v4.4.3\n        target: ${{ matrix.targets }}\n        path: 'examples/esp_ghota_example'\n    - name: Rename artifact\n      run: |\n        ls -lah \n        cp examples/esp_ghota_example/build/esp_ghota_example.bin esp_ghota_example-${{ matrix.targets }}.bin\n        cp examples/esp_ghota_example/build/storage.bin storage-${{ matrix.targets }}.bin\n    - name: Archive Firmware Files\n      uses: actions/upload-artifact@v3\n      with: \n        name: ${{ matrix.targets }}-firmware\n        path: \"*-${{ matrix.targets }}.bin\"\n\n  release:\n    needs: build\n    runs-on: ubuntu-latest\n    steps:\n    - name: Download Firmware Files\n      uses: actions/download-artifact@v2\n      with:\n        path: release\n    - name: Release Firmware\n      uses: ncipollo/release-action@v1\n      if: startsWith(github.ref, 'refs/tags/') \n      with:\n        artifacts: release/*/*.bin\n        generateReleaseNotes: true\n        allowUpdates: true\n        token: ${{ secrets.GITHUB_TOKEN }}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffishwaldo%2Fesp_ghota","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffishwaldo%2Fesp_ghota","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffishwaldo%2Fesp_ghota/lists"}