From fe4bfc31fbcedc91aaa017e9d3b3baf147ec7765 Mon Sep 17 00:00:00 2001 From: lucarin91 Date: Thu, 18 Dec 2025 10:41:42 +0100 Subject: [PATCH] chore(unoq): add set-to-ram-mode script --- .../scripts/set-to-ram-mode.sh | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 variants/arduino_uno_q_stm32u585xx/scripts/set-to-ram-mode.sh diff --git a/variants/arduino_uno_q_stm32u585xx/scripts/set-to-ram-mode.sh b/variants/arduino_uno_q_stm32u585xx/scripts/set-to-ram-mode.sh new file mode 100755 index 00000000..63df41fd --- /dev/null +++ b/variants/arduino_uno_q_stm32u585xx/scripts/set-to-ram-mode.sh @@ -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