Skip to content

Commit 689f2a6

Browse files
authored
Merge pull request #72 from danielinux/m33mu-on-tap
Added m33mu workflow to test DHCP client + TCP echo
2 parents 53f78e5 + 0f8c392 commit 689f2a6

1 file changed

Lines changed: 111 additions & 0 deletions

File tree

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: STM32H563 m33mu (echo only)
2+
3+
on:
4+
push:
5+
branches: [ 'master', 'main', 'release/**' ]
6+
pull_request:
7+
branches: [ '*' ]
8+
9+
jobs:
10+
stm32h563_m33mu_echo:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 20
13+
container:
14+
image: ghcr.io/danielinux/m33mu-ci:1.5
15+
options: --privileged
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install host tools
21+
run: |
22+
set -euo pipefail
23+
apt-get update
24+
apt-get install -y sudo dnsmasq iproute2 netcat-openbsd
25+
26+
- name: Build STM32H563 echo firmware
27+
run: |
28+
set -euo pipefail
29+
make -C src/port/stm32h563 CC=arm-none-eabi-gcc OBJCOPY=arm-none-eabi-objcopy
30+
31+
- name: Run m33mu + DHCP + echo test
32+
timeout-minutes: 10
33+
run: |
34+
set -euo pipefail
35+
36+
cleanup() {
37+
set +e
38+
if [ -f /tmp/m33mu.pid ]; then
39+
sudo kill "$(cat /tmp/m33mu.pid)" 2>/dev/null || true
40+
fi
41+
sudo pkill -x m33mu 2>/dev/null || true
42+
if [ -f /tmp/dnsmasq.pid ]; then
43+
sudo kill "$(cat /tmp/dnsmasq.pid)" 2>/dev/null || true
44+
fi
45+
sudo ip link del tap0 2>/dev/null || true
46+
}
47+
trap cleanup EXIT
48+
49+
sudo ip tuntap add dev tap0 mode tap
50+
sudo ip addr add 192.168.12.1/24 dev tap0
51+
sudo ip link set tap0 up
52+
53+
cat > /tmp/dnsmasq.conf <<'EOF'
54+
interface=tap0
55+
bind-interfaces
56+
dhcp-range=192.168.12.50,192.168.12.100,255.255.255.0,12h
57+
dhcp-leasefile=/tmp/dnsmasq.leases
58+
log-dhcp
59+
EOF
60+
sudo dnsmasq --conf-file=/tmp/dnsmasq.conf --pid-file=/tmp/dnsmasq.pid
61+
62+
sudo m33mu src/port/stm32h563/app.bin \
63+
--cpu stm32h563 --tap:tap0 --uart-stdout --timeout 120 \
64+
2>&1 | tee /tmp/m33mu.log &
65+
sleep 1
66+
m33mu_pid="$(pgrep -n -x m33mu || true)"
67+
if [ -n "${m33mu_pid}" ]; then
68+
echo "${m33mu_pid}" > /tmp/m33mu.pid
69+
fi
70+
71+
ip=""
72+
for _ in $(seq 1 60); do
73+
if [ -s /tmp/dnsmasq.leases ]; then
74+
ip="$(tail -n1 /tmp/dnsmasq.leases | cut -d' ' -f3)"
75+
fi
76+
if [ -n "${ip}" ]; then
77+
break
78+
fi
79+
sleep 1
80+
done
81+
if [ -z "${ip}" ]; then
82+
echo "No DHCP lease acquired."
83+
echo "m33mu log:"
84+
tail -n 200 /tmp/m33mu.log || true
85+
exit 1
86+
fi
87+
echo "Leased IP: ${ip}"
88+
89+
ok=0
90+
for _ in $(seq 1 20); do
91+
if ! pgrep -x m33mu >/dev/null 2>&1; then
92+
echo "m33mu exited before echo check."
93+
tail -n 200 /tmp/m33mu.log || true
94+
exit 1
95+
fi
96+
if printf "ping" | nc -w 2 "${ip}" 7 | grep -q "ping"; then
97+
ok=1
98+
break
99+
fi
100+
sleep 0.2
101+
done
102+
if [ "${ok}" -ne 1 ]; then
103+
echo "Echo test failed."
104+
echo "m33mu log:"
105+
tail -n 200 /tmp/m33mu.log || true
106+
exit 1
107+
fi
108+
echo "Echo test succeeded."
109+
if [ -f /tmp/m33mu.pid ]; then
110+
sudo kill "$(cat /tmp/m33mu.pid)" 2>/dev/null || true
111+
fi

0 commit comments

Comments
 (0)