Skip to content

Commit e51136e

Browse files
committed
Improve tools
1 parent aef35b8 commit e51136e

8 files changed

Lines changed: 746 additions & 30 deletions

File tree

l9/l9_e1_test/tools/dfu_update.sh

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/bin/bash
2+
# MCUboot DFU update script.
3+
#
4+
# Performs a full update cycle:
5+
# 1. Print current image info
6+
# 2. Upload new image (marked for test swap)
7+
# 3. Reset device
8+
# 4. Confirm the running image
9+
# 5. Print image info again
10+
#
11+
# Usage:
12+
# ./dfu_update.sh --port /dev/ttyACM2 --image path/to/zephyr.signed.bin
13+
# ./dfu_update.sh --port /dev/ttyACM2 --image path/to/zephyr.signed.bin --wait 8
14+
15+
set -euo pipefail
16+
17+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18+
MCUBOOT_MGR="$SCRIPT_DIR/mcuboot_mgr.py"
19+
20+
# Defaults
21+
PORT=""
22+
IMAGE=""
23+
WAIT=5
24+
25+
usage() {
26+
cat <<EOF
27+
Usage: $(basename "$0") [OPTIONS]
28+
29+
Options:
30+
--port PORT Serial port for SMP (required)
31+
--image PATH Path to signed firmware image (required)
32+
--wait SECONDS Seconds to wait after reset for device to boot (default: $WAIT)
33+
-h, --help Show this help
34+
EOF
35+
exit 1
36+
}
37+
38+
# Parse arguments
39+
while [[ $# -gt 0 ]]; do
40+
case "$1" in
41+
--port) PORT="$2"; shift 2 ;;
42+
--image) IMAGE="$2"; shift 2 ;;
43+
--wait) WAIT="$2"; shift 2 ;;
44+
-h|--help) usage ;;
45+
*) echo "ERROR: Unknown option: $1"; usage ;;
46+
esac
47+
done
48+
49+
# Validate
50+
if [[ -z "$PORT" ]]; then
51+
echo "ERROR: --port is required"
52+
usage
53+
fi
54+
if [[ -z "$IMAGE" ]]; then
55+
echo "ERROR: --image is required"
56+
usage
57+
fi
58+
if [[ ! -f "$IMAGE" ]]; then
59+
echo "ERROR: Image file not found: $IMAGE"
60+
exit 1
61+
fi
62+
63+
echo "============================================================"
64+
echo " MCUboot DFU Update"
65+
echo "============================================================"
66+
echo " Port: $PORT"
67+
echo " Image: $IMAGE"
68+
echo " Wait: ${WAIT}s"
69+
echo "============================================================"
70+
echo
71+
72+
# Step 1: Print current image info
73+
echo ">>> Step 1: Current image info"
74+
python3 "$MCUBOOT_MGR" -p "$PORT" info
75+
echo
76+
77+
# Step 2: Upload image (mark for test swap)
78+
echo ">>> Step 2: Upload image"
79+
python3 "$MCUBOOT_MGR" -p "$PORT" upload "$IMAGE" --test
80+
echo
81+
82+
# Step 3: Reset device
83+
echo ">>> Step 3: Reset device"
84+
python3 "$MCUBOOT_MGR" -p "$PORT" reset
85+
echo "Waiting ${WAIT}s for device to boot..."
86+
sleep "$WAIT"
87+
echo
88+
89+
# Step 4: Confirm running image
90+
echo ">>> Step 4: Confirm running image"
91+
python3 "$MCUBOOT_MGR" -p "$PORT" confirm --slot 0
92+
echo
93+
94+
# Step 5: Print image info after update
95+
echo ">>> Step 5: Image info after update"
96+
python3 "$MCUBOOT_MGR" -p "$PORT" info
97+
echo
98+
99+
echo "============================================================"
100+
echo " DFU update complete"
101+
echo "============================================================"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22
# Example: Build & flash for nRF54L15 with dual-slot (app DFU) and 200ms blink
3-
cd "$(dirname "$0")"
4-
./prepare.sh ../l9_e1_sol -b nrf54l15dk/nrf54l15/cpuapp --sleep-ms 200 --no-single-app
3+
cd "$(dirname "$0")"/..
4+
python3 prepare.py ../../l9_e1_sol -b nrf54l15dk/nrf54l15/cpuapp --sleep-ms 200 --no-single-app
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22
# Example: Build & flash for nRF54L15 with serial recovery (single-app) and 200ms blink
3-
cd "$(dirname "$0")"
4-
./prepare.sh ../l9_e1_sol -b nrf54l15dk/nrf54l15/cpuapp --sleep-ms 200
3+
cd "$(dirname "$0")"/..
4+
python3 prepare.py ../../l9_e1_sol -b nrf54l15dk/nrf54l15/cpuapp --sleep-ms 200
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22
# Example: Update via app DFU (dual-slot) on nRF54L15, change blink to 500ms
3-
cd "$(dirname "$0")"
4-
./update.sh ../l9_e1_sol -p /dev/ttyACM1 -b nrf54l15dk/nrf54l15/cpuapp --sleep-ms 500 --no-single-app
3+
cd "$(dirname "$0")"/..
4+
python3 update.py ../../l9_e1_sol -p /dev/ttyACM1 -b nrf54l15dk/nrf54l15/cpuapp --sleep-ms 500 --no-single-app
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22
# Example: Update via serial recovery on nRF54L15, change blink to 500ms
3-
cd "$(dirname "$0")"
4-
./update.sh ../l9_e1_sol -p /dev/ttyACM1 -b nrf54l15dk/nrf54l15/cpuapp --sleep-ms 500
3+
cd "$(dirname "$0")"/..
4+
python3 update.py ../../l9_e1_sol -p /dev/ttyACM1 -b nrf54l15dk/nrf54l15/cpuapp --sleep-ms 500

0 commit comments

Comments
 (0)