Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions variants/arduino_uno_q_stm32u585xx/scripts/set-to-ram-mode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

# This script sets the micro of the Arduino UNO Q in RAM mode, and allow to flash it
# with menu option flash=ram.
# This is necessary because a flash in RAM mode is possible only if the micro
# isn't running any other sketch (in flash mode).
# The RAM mode is volatile, so after a power cycle the micro will not execute
# the sketch anymore.
# This is used by the arduino-app-cli when uploading sketches to the Arduino UNO Q.

# Requirements:
# - arduino-cli
# - jq

# Usage:
# ./set-to-ram-mode.sh [port]


tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT

sketch_path="${tmpdir}/empty"
mkdir ${sketch_path}

bin_path="${sketch_path}/empty.ino.elf-zsk.bin"
dd if=/dev/zero of=${bin_path} bs=50 count=1 > /dev/null 2>&1

if [ -z "$1" ]; then
port=$(arduino-cli board list --format json | jq -r '.detected_ports[] | select(.matching_boards[]?.fqbn == "arduino:zephyr:unoq") | .port.address')
else
port="$1"
fi

arduino-cli upload -p ${port} --input-dir ${sketch_path} -b arduino:zephyr:unoq