-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTaskfile.yml
More file actions
148 lines (127 loc) · 4.85 KB
/
Taskfile.yml
File metadata and controls
148 lines (127 loc) · 4.85 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
version: '3'
tasks:
default:
cmds:
- task --list-all
buildFirmware:
desc: This pulls in the idf tools and examples from expressif. This is the approach to build/compile the firmware, enabling you to customize steps inbetween. It takes about 10-20 mins to build.
cmds:
- sudo apt install cmake git
- git clone --branch v5.4.1 https://github.com/espressif/esp-idf # version 5.4.1
- task: _configure_idfpy
- task: _build_firmware
- task: _flash_firmware_from_build
_configure_idfpy:
desc: helper task to configure repo after pull
internal: true
dir: esp-idf/
cmds:
- git submodule update --init --recursive # the repo contains many sub-modules that needs to be configured
- ./install.sh esp32,esp32h2
- bash -c "source ./export.sh"
_build_firmware:
desc: helper to build firmware
internal: true
dir: esp-idf/examples/openthread/ot_rcp
interactive: true
cmds:
- echo "Injecting sdkconfig.defaults..."
- |
cat << 'EOF' > sdkconfig.defaults
CONFIG_IDF_TARGET="esp32h2"
CONFIG_OPENTHREAD_RCP=y
CONFIG_OPENTHREAD_NCP=n
CONFIG_OPENTHREAD_NCP_SPI_ENABLE=n
CONFIG_OPENTHREAD_NCP_UART_ENABLE=n
CONFIG_BT_ENABLED=n
CONFIG_WIFI_ENABLED=n
CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y
CONFIG_PARTITION_TABLE_CUSTOM=y
EOF
- >
bash -c "source ../../../export.sh && idf.py -DSDKCONFIG_DEFAULTS=\"sdkconfig.defaults\" set-target esp32h2 build"
_flash_firmware_from_build:
internal: true
desc: helper to flash firmware
dir: esp-idf/examples/openthread/ot_rcp
cmds:
- idf.py flash /dev/ttyACM0
flashPrefabFirmware:
desc: This flashes the ESP32-H2 with a precompiled firmware, therefore not needing to install de idf.py tooling and negating compilation from source. The code assumes working on a Raspberry Pi Architecture.
cmds:
- wget https://github.com/espressif/esptool/releases/download/v4.9.0/esptool-v4.9.0-linux-aarch64.tar.gz
- tar -xvf esptool-v4.9.0-linux-aarch64.tar.gz
- ./esptool-linux-aarch64/esptool --port /dev/ACM0 --chip esp32h2 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 2MB --flash_freq 48m 0x0 firmware/build_idypyv5.4.1_esp32H2/bootloader.bin 0x8000 firmware/build_idypyv5.4.1_esp32H2/partition-table.bin 0x10000 firmware/build_idypyv5.4.1_esp32H2/esp_ot_rcp.bin
start:
desc: Start the Thread Border Router stack
cmds:
- docker-compose up -d
stop:
desc: Stop the Thread Border Router stack
cmds:
- docker-compose down
restart:
desc: Restart the Thread Border Router stack
cmds:
- task: stop
- task: start
network-scan:
desc: Scan for Thread networks
cmds:
- docker compose exec otbr ot-ctl scan
network-info:
desc: Get Thread network information
cmds:
- docker compose exec otbr ot-ctl networkinfo
setup-raspberry-pi:
desc: Complete system setup for Raspberry Pi
cmds:
- sudo apt-get update
- sudo apt-get upgrade -y
- sudo apt-get install -y docker.io docker-compose python3-pip git curl wget netcat
- sudo systemctl enable docker
- sudo systemctl start docker
- sudo usermod -aG docker "$USER"
- wget https://github.com/espressif/esptool/releases/download/v4.9.0/esptool-v4.9.0-linux-aarch64.tar.gz
- tar -xvf esptool-v4.9.0-linux-aarch64.tar.gz
ping-thread-devices:
desc: Ping all Thread devices on the network
cmds:
- |
PREFIX=$(docker-compose exec -T otbr ot-ctl prefix)
PREFIX=$(echo $PREFIX | grep -oE 'fd[a-f0-9:]+' | head -1)
if [ -z "$PREFIX" ]; then
echo "Error: Could not determine Thread network prefix"
exit 1
fi
echo "Thread network prefix: $PREFIX"
DEVICES=$(docker-compose exec -T otbr ot-ctl neighbor table | grep -oE '([a-f0-9]{4}|\[([a-f0-9:]+)\])')
if [ -z "$DEVICES" ]; then
echo "No Thread devices found in neighbor table"
exit 1
fi
echo "Found Thread devices:"
echo "$DEVICES"
for DEVICE in $DEVICES; do
# Remove brackets if present
DEVICE=$(echo $DEVICE | sed 's/\[\|\]//g')
# If device is a short address (4 hex digits), convert to IPv6
if [[ $DEVICE =~ ^[0-9a-f]{4}$ ]]; then
# Check if we have full prefix
if [[ $PREFIX =~ ^fd[0-9a-f:]+$ ]]; then
IP="${PREFIX}:0:ff:fe00:${DEVICE}"
else
echo "Skipping device $DEVICE (cannot form IPv6 address)"
continue
fi
else
IP="$DEVICE"
fi
echo "Pinging $IP (device $DEVICE)..."
docker-compose exec -T otbr ping -c 3 "$IP"
echo "-----------------------"
done
clean:
desc: Clean up downloaded files
cmds:
- rm -rf ./firmware/binaries/*