Skip to content

Commit fe4bfc3

Browse files
committed
chore(unoq): add set-to-ram-mode script
1 parent 814ad18 commit fe4bfc3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
3+
# This script sets the micro of the Arduino UNO Q in RAM mode, and allow to flash it
4+
# with menu option flash=ram.
5+
# This is necessary because a flash in RAM mode is possible only if the micro
6+
# isn't running any other sketch (in flash mode).
7+
# The RAM mode is volatile, so after a power cycle the micro will not execute
8+
# the sketch anymore.
9+
# This is used by the arduino-app-cli when uploading sketches to the Arduino UNO Q.
10+
11+
# Requirements:
12+
# - arduino-cli
13+
# - jq
14+
15+
# Usage:
16+
# ./set-to-ram-mode.sh [port]
17+
18+
19+
tmpdir=$(mktemp -d)
20+
trap 'rm -rf "$tmpdir"' EXIT
21+
22+
sketch_path="${tmpdir}/empty"
23+
mkdir ${sketch_path}
24+
25+
bin_path="${sketch_path}/empty.ino.elf-zsk.bin"
26+
dd if=/dev/zero of=${bin_path} bs=50 count=1 > /dev/null 2>&1
27+
28+
if [ -z "$1" ]; then
29+
port=$(arduino-cli board list --format json | jq -r '.detected_ports[] | select(.matching_boards[]?.fqbn == "arduino:zephyr:unoq") | .port.address')
30+
else
31+
port="$1"
32+
fi
33+
34+
arduino-cli upload -p ${port} --input-dir ${sketch_path} -b arduino:zephyr:unoq

0 commit comments

Comments
 (0)