Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,31 @@ jobs:
sudo apt-get install -y make python3 python3-pytest
- name: Run tests
run: make tests

image-types-changed:
# On PRs, check only entries changed vs the target branch, so pre-existing
# duplicates don't turn this permanently red. Re-fetches the base at run
# time, so re-running the PR validates against current main.
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y make python3 && pip install pyyaml
- name: Check changed firmware_image_type entries
run: |
git fetch origin ${{ github.base_ref }}
make tools/check_image_types_changed BASE_REF=origin/${{ github.base_ref }}

image-types-all:
# On main the db is deduplicated, so assert the whole db stays collision-free.
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y make python3 && pip install pyyaml
- name: Check all firmware_image_type entries
run: make tools/check_image_types_all
25 changes: 23 additions & 2 deletions board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ CONFIG_STR := $(shell yq -r .$(BOARD).config_str $(DEVICE_DB_FILE))
FROM_STOCK_MANUFACTURER_ID := $(shell yq -r .$(BOARD).stock_manufacturer_id $(DEVICE_DB_FILE))
FROM_STOCK_IMAGE_TYPE := $(shell yq -r .$(BOARD).stock_image_type $(DEVICE_DB_FILE))
FIRMWARE_IMAGE_TYPE := $(shell yq -r .$(BOARD).firmware_image_type $(DEVICE_DB_FILE))
# Superseded image types this device was previously published under (renumbered
# to fix a duplicate). One migration OTA is emitted per id so units still
# reporting an old id get updated once and then report the new id.
MIGRATION_FROM_IMAGE_TYPES := $(shell yq -r '.$(BOARD).migration_from_image_type // [] | .[]' $(DEVICE_DB_FILE))

# ==============================================================================
# Platform Configuration
Expand Down Expand Up @@ -128,7 +132,7 @@ drop-old-files:
rm -f $(BIN_PATH)/*.zigbee

# Generate all three types of OTA files
generate-ota-files: generate-normal-ota generate-tuya-ota generate-force-ota
generate-ota-files: generate-normal-ota generate-tuya-ota generate-force-ota generate-migration-ota

generate-normal-ota:
$(MAKE) $(PLATFORM_PREFIX)/ota \
Expand All @@ -154,6 +158,18 @@ generate-force-ota:
OTA_IMAGE_TYPE=$(FIRMWARE_IMAGE_TYPE) \
OTA_FILE=../../$(FORCE_OTA_FILE)

# Migration OTA per superseded image type: current firmware wrapped in a header
# carrying the old id, so units still reporting it update once (then they report
# the new firmware_image_type). Version stays FILE_VERSION -> no re-verify loop.
generate-migration-ota:
@for old_id in $(MIGRATION_FROM_IMAGE_TYPES); do \
$(MAKE) $(PLATFORM_PREFIX)/ota \
DEVICE_TYPE=$(DEVICE_TYPE) \
FILE_VERSION=$(FILE_VERSION) \
OTA_IMAGE_TYPE=$$old_id \
OTA_FILE=../../$(BIN_PATH)/$(PROJECT_NAME)-$(VERSION_STR)-migration-$$old_id.zigbee; \
done

# Update Zigbee2MQTT index files
update-indexes:
@python3 $(HELPERS_PATH)/make_z2m_ota_index.py --db_file $(DEVICE_DB_FILE) $(OTA_FILE) $(Z2M_INDEX_FILE) --board $(BOARD)
Expand All @@ -165,11 +181,16 @@ endif
endif
endif
@python3 $(HELPERS_PATH)/make_z2m_ota_index.py --db_file $(DEVICE_DB_FILE) $(FORCE_OTA_FILE) $(Z2M_FORCE_INDEX_FILE) --board $(BOARD)
@for old_id in $(MIGRATION_FROM_IMAGE_TYPES); do \
python3 $(HELPERS_PATH)/make_z2m_ota_index.py --db_file $(DEVICE_DB_FILE) \
$(BIN_PATH)/$(PROJECT_NAME)-$(VERSION_STR)-migration-$$old_id.zigbee \
$(Z2M_INDEX_FILE) --board $(BOARD); \
done


flash_telink: build-firmware
@echo "Flashing $(BIN_FILE) to device via $(TLSRPGM_TTY)"
$(MAKE) telink/flasher ARGS="-t25 -a 20 --mrst we 0 ../../$(BIN_FILE)"

.PHONY: help build build-firmware drop-old-files generate-ota-files generate-normal-ota generate-tuya-ota generate-force-ota update-indexes clean_z2m_index update_converters update_zha_quirk update_homed_extension update_supported_devices freeze_ota_links
.PHONY: help build build-firmware drop-old-files generate-ota-files generate-normal-ota generate-tuya-ota generate-force-ota generate-migration-ota update-indexes clean_z2m_index update_converters update_zha_quirk update_homed_extension update_supported_devices freeze_ota_links

Loading
Loading