Skip to content

Commit 93459de

Browse files
MATTER-5422: Added OTA space check CI (SiliconLabsSoftware#546)
1 parent 783090e commit 93459de

4 files changed

Lines changed: 234 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"standard": {
3+
"window-app": [
4+
{
5+
"boards": ["brd4337a"],
6+
"arguments": [
7+
"--output_suffix lto",
8+
"--with_app toolchain_gcc_lto"
9+
]
10+
}
11+
]
12+
}
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"standard": {
3+
"lighting-app": [
4+
{
5+
"boards": ["brd4116a"],
6+
"arguments": [""]
7+
}
8+
],
9+
"zigbee-matter-light": [
10+
{
11+
"boards": ["brd4116a"],
12+
"arguments": [
13+
"--output_suffix sequential",
14+
"--with_app matter_zigbee_sequential"
15+
]
16+
}
17+
]
18+
}
19+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"standard": {
3+
"zigbee-matter-light": [
4+
{
5+
"boards": ["brd4351a_a02"],
6+
"arguments": [
7+
"--output_suffix sequential",
8+
"--with_app matter_zigbee_sequential"
9+
]
10+
}
11+
]
12+
}
13+
}
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
name: Check OTA Flash Space
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *" # Runs every day at 00:00 UTC
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
actions: write
11+
12+
jobs:
13+
ota-check:
14+
name: OTA flash check (${{ matrix.display }})
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- id: mg24
21+
display: MG24
22+
page_size: 8192 # bytes (8 KiB flash page)
23+
available_flash: 1572864 # bytes (~1.50 MB or 1536KB)
24+
exclude_path: "*/matter-bootloader/*"
25+
json_file: ./.github/silabs-builds-mg24-ota.json
26+
window_app_path: slc/apps/window-app/thread/window-app-series-2-internal.slcw
27+
28+
- id: mg26
29+
display: MG26
30+
page_size: 8192 # bytes (8 KiB flash page)
31+
available_flash: 3276800 # bytes (~3.125 MB or 3200KB)
32+
exclude_path: "*/matter-bootloader/*"
33+
json_file: ./.github/silabs-builds-mg26-ota.json
34+
lighting_path: slc/apps/lighting-app/thread/lighting-app-series-2-internal.slcw
35+
zigbee_matter_light_path: slc/apps/zigbee-matter-light/thread/zigbee-matter-light-series-2-internal.slcw
36+
37+
- id: mgm26
38+
display: MGM26
39+
page_size: 8192 # bytes (8 KiB flash page)
40+
available_flash: 3276800 # bytes (~3.125 MB or 3200KB)
41+
exclude_path: "*/matter-bootloader/*"
42+
json_file: ./.github/silabs-builds-mgm26-ota.json
43+
zigbee_matter_light_path: slc/apps/zigbee-matter-light/thread/zigbee-matter-light-series-2-internal.slcw
44+
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@v5
48+
with:
49+
submodules: "true"
50+
51+
- name: Install tools
52+
uses: ./.github/actions/install-tools
53+
54+
- name: Build window-app
55+
if: matrix.id == 'mg24'
56+
uses: SiliconLabsSoftware/matter_build_action@v2
57+
with:
58+
json-file-path: ${{ matrix.json_file }}
59+
path-to-example-app: ${{ matrix.window_app_path }}
60+
example-app: window-app
61+
build-script: "./slc/build.sh"
62+
output-directory: " "
63+
build-type: standard
64+
65+
- name: Build lighting-app
66+
if: matrix.id == 'mg26'
67+
uses: SiliconLabsSoftware/matter_build_action@v2
68+
with:
69+
json-file-path: ${{ matrix.json_file }}
70+
path-to-example-app: ${{ matrix.lighting_path }}
71+
example-app: lighting-app
72+
build-script: "./slc/build.sh"
73+
output-directory: " "
74+
build-type: standard
75+
76+
- name: Build zigbee-matter-light
77+
if: matrix.id == 'mg26' || matrix.id == 'mgm26'
78+
uses: SiliconLabsSoftware/matter_build_action@v2
79+
with:
80+
json-file-path: ${{ matrix.json_file }}
81+
path-to-example-app: ${{ matrix.zigbee_matter_light_path }}
82+
example-app: zigbee-matter-light
83+
build-script: "./slc/build.sh"
84+
output-directory: " "
85+
build-type: standard
86+
87+
- name: Check OTA image flash size
88+
shell: bash
89+
run: |
90+
set -euo pipefail
91+
92+
PAGE_SIZE=${{ matrix.page_size }}
93+
AVAILABLE_FLASH=${{ matrix.available_flash }}
94+
EXCLUDE_PATH="${{ matrix.exclude_path }}"
95+
PLATFORM="${{ matrix.display }}"
96+
97+
echo "========================================"
98+
echo "OTA flash check (${PLATFORM})"
99+
echo "Workflow: ${{ github.workflow }}"
100+
echo "Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
101+
echo "Event: ${{ github.event_name }} Ref: ${{ github.ref }} SHA: ${{ github.sha }}"
102+
echo "========================================"
103+
104+
{
105+
echo "## OTA flash check (${PLATFORM})"
106+
echo "- **Event:** \`${{ github.event_name }}\`"
107+
echo "- **Ref:** \`${{ github.ref }}\` @ \`${{ github.sha }}\`"
108+
echo "- [Open this run in GitHub](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
109+
echo ""
110+
} >> "$GITHUB_STEP_SUMMARY"
111+
112+
if ! command -v commander >/dev/null 2>&1; then
113+
echo "commander not found, skipping OTA flash size check"
114+
exit 0
115+
fi
116+
117+
IMAGES=$(find out -type f -name "*.s37" ! -path "$EXCLUDE_PATH" 2>/dev/null)
118+
119+
if [[ -z "$IMAGES" ]]; then
120+
echo "No .s37 image found under out/, skipping OTA flash size check"
121+
exit 0
122+
fi
123+
124+
FAIL=0
125+
126+
for IMAGE in $IMAGES; do
127+
board=$(echo "$IMAGE" | cut -d'/' -f2)
128+
[[ -z "$board" ]] && continue
129+
130+
echo ""
131+
echo " Board: $board Image: $IMAGE"
132+
133+
app_name="${board}-$(basename "$IMAGE" .s37)"
134+
pushd /tmp >/dev/null
135+
136+
commander gbl create "temporary-${app_name}.gbl" --app "$GITHUB_WORKSPACE/$IMAGE" 1>/dev/null
137+
file_size_running=$(stat -c "%s" "temporary-${app_name}.gbl")
138+
rounded_running=$(( PAGE_SIZE * (file_size_running + PAGE_SIZE - 1) / PAGE_SIZE ))
139+
140+
commander gbl create --compress lzma "temporary-${app_name}.gbl" --app "$GITHUB_WORKSPACE/$IMAGE" 1>/dev/null
141+
file_size_ota=$(stat -c "%s" "temporary-${app_name}.gbl")
142+
rounded_ota=$(( PAGE_SIZE * (file_size_ota + PAGE_SIZE - 1) / PAGE_SIZE ))
143+
144+
sum=$(( rounded_running + rounded_ota ))
145+
remaining=$(( AVAILABLE_FLASH - sum ))
146+
147+
popd >/dev/null
148+
149+
echo " Running (rounded): $rounded_running B OTA LZMA (rounded): $rounded_ota B Remaining: $remaining B"
150+
151+
if [[ "$sum" -gt "$AVAILABLE_FLASH" ]]; then
152+
echo " FAIL: OTA image will NOT fit in ${AVAILABLE_FLASH} B"
153+
FAIL=1
154+
shortfall=$(( sum - AVAILABLE_FLASH ))
155+
echo "::error title=${PLATFORM} OTA flash exceeded::board=${board} sum=${sum}B limit=${AVAILABLE_FLASH}B shortfall=${shortfall}B image=${IMAGE}"
156+
{
157+
echo "### ${PLATFORM} OTA failure"
158+
echo "| Field | Value |"
159+
echo "| --- | --- |"
160+
echo "| Board | \`$board\` |"
161+
echo "| Image | \`$IMAGE\` |"
162+
echo "| Running (rounded) | ${rounded_running} B |"
163+
echo "| OTA LZMA (rounded) | ${rounded_ota} B |"
164+
echo "| Total (sum) | ${sum} B |"
165+
echo "| Limit | ${AVAILABLE_FLASH} B |"
166+
echo "| Shortfall | ${shortfall} B |"
167+
echo ""
168+
} >> "$GITHUB_STEP_SUMMARY"
169+
else
170+
echo " PASS: OTA image fits"
171+
fi
172+
done
173+
174+
if [[ "$FAIL" -eq 1 ]]; then
175+
echo ""
176+
echo "========================================"
177+
echo "OTA FLASH CHECK FAILED (${PLATFORM})"
178+
echo "Flash limit (running + OTA LZMA): ${AVAILABLE_FLASH} B"
179+
echo "See FAIL lines and annotations above for each image."
180+
echo "========================================"
181+
exit 1
182+
fi
183+
184+
echo ""
185+
echo "All ${PLATFORM} OTA flash checks passed."
186+
{
187+
echo "### Result"
188+
echo "All ${PLATFORM} OTA flash checks **passed**."
189+
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)