-
Notifications
You must be signed in to change notification settings - Fork 1
153 lines (127 loc) · 5 KB
/
test-flash.yml
File metadata and controls
153 lines (127 loc) · 5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Test Flash
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
env:
VNET_BASE: 192.168.3
VNET_MASK: 24
jobs:
test-flash:
runs-on: self-hosted
steps:
- name: Cleanup before start
if: always()
run: |
pkill -9 -f JLinkRemoteServer || true
docker rm -f jlink100 jlink101 jlink102 2>/dev/null || true
docker network rm jlink-net 2>/dev/null || true
sleep 2
- uses: actions/checkout@v4
- name: Install package
run: |
python3 -m venv .venv
. .venv/bin/activate
pip install -e ".[dev]"
- name: Detect devices and save serials
run: |
. .venv/bin/activate
bmlab-scan | tee scan.txt
count=$(grep -c "Target: *STM32F103RE" scan.txt)
awk '/JLink Programmer/ {serial=""} /Serial:/ {serial=$2} /Target: *STM32F103RE/ && serial {print serial}' scan.txt | sort | uniq > serials.txt
if [ "$count" -ne 3 ]; then
echo "Test failed: expected 3 STM32F103RE, found $count"
cat scan.txt
exit 1
fi
- name: Test 1 — Flash single device by serial
run: |
. .venv/bin/activate
serial=$(sed -n '1p' serials.txt)
bmlab-flash .github/workflows/fw.bin --serial $serial --mcu STM32F103RE | tee flash-serial1.txt
if ! grep -q "Success" flash-serial1.txt; then
echo "Test 1 failed: flash not successful"
cat flash-serial1.txt
exit 1
fi
- name: Test 2 — Flash without mcu (auto-detect target)
run: |
. .venv/bin/activate
serial=$(sed -n '1p' serials.txt)
bmlab-flash .github/workflows/fw.bin --serial $serial | tee flash-serial2.txt
if ! grep -q "Success" flash-serial2.txt; then
echo "Test 2 failed: flash not successful"
cat flash-serial2.txt
exit 1
fi
- name: Test 3 — Flash multiple by serial
run: |
. .venv/bin/activate
serial1=$(sed -n '1p' serials.txt)
serial2=$(sed -n '2p' serials.txt)
serial3=$(sed -n '3p' serials.txt)
bmlab-flash .github/workflows/fw.bin --serial $serial1 $serial2 $serial3 --mcu STM32F103RE | tee flash-serial3.txt
if ! grep -q "Success" flash-serial3.txt; then
echo "Test 3 failed: flash not successful"
cat flash-serial3.txt
exit 1
fi
- name: Build JLinkRemoteServer Docker image
run: |
docker build -t my-jlink-image -f .github/workflows/jlinkRemoteServerEmu.dockerfile .
- name: Setup JLinkRemoteServer Docker containers
run: |
docker network rm jlink-net 2>/dev/null || true
docker network create --driver bridge --subnet=$VNET_BASE.0/$VNET_MASK --gateway=$VNET_BASE.1 jlink-net
serial1=$(sed -n '1p' serials.txt)
serial2=$(sed -n '2p' serials.txt)
serial3=$(sed -n '3p' serials.txt)
docker run -d --rm \
--device=/dev/bus/usb:/dev/bus/usb \
--name jlink100 \
--network jlink-net \
--ip $VNET_BASE.100 \
my-jlink-image \
-select usb=$serial1 -device STM32F103RE -endian little -speed 4000 -if swd
sleep 3
docker run -d --rm \
--device=/dev/bus/usb:/dev/bus/usb \
--name jlink101 \
--network jlink-net \
--ip $VNET_BASE.101 \
my-jlink-image \
-select usb=$serial2 -device STM32F103RE -endian little -speed 4000 -if swd
sleep 3
docker run -d --rm \
--device=/dev/bus/usb:/dev/bus/usb \
--name jlink102 \
--network jlink-net \
--ip $VNET_BASE.102 \
my-jlink-image \
-select usb=$serial3 -device STM32F103RE -endian little -speed 4000 -if swd
sleep 3
- name: Test 4 — Flash three devices in parallel
run: |
. .venv/bin/activate
bmlab-flash .github/workflows/fw.bin --ip $VNET_BASE.100 $VNET_BASE.101 $VNET_BASE.102 --mcu STM32F103RE | tee flash4.txt
success_count=$(grep -c "Success" flash4.txt || echo 0)
if [ "$success_count" -ne 3 ]; then
echo "Test 4 failed: expected 3 successful flashes, found $success_count"
cat flash4.txt
exit 1
fi
for ip in 100 101 102; do
if ! grep -q "$VNET_BASE\.$ip" flash4.txt; then
echo "Test 4 failed: no result for $VNET_BASE.$ip"
cat flash4.txt
exit 1
fi
done
- name: Cleanup after tests
if: always()
run: |
docker rm -f jlink100 jlink101 jlink102 || true
docker network rm jlink-net || true
pkill -9 -f JLinkRemoteServer || true
sleep 2