zephyr/tests/bluetooth/shell/run-bsim.sh
Jonathan Rico f3f42d363b Bluetooth: shell: add bsim runner script
Spawns n instances of the bt-shell in separate xterm windows.

Assumes in-tree build of the shell, can optionally specify another .exe
image.

Also add snippet for that use-case (`-S xterm-native-shell`).

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-03-13 18:47:50 +02:00

44 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Copyright (c) 2024 Nordic Semiconductor
# SPDX-License-Identifier: Apache-2.0
set -e
set -u
if [ $# -eq 0 ]; then
echo "Usage: run.sh <number_of_devices> [exe_image]"
shift
fi
if [ $# -gt 2 ]; then
echo "Too many args"
shift
fi
echo "Starting simulation. Hit Ctrl-C to exit."
# Build it with e.g.
# cd $ZEPHYR_BASE/tests/bluetooth/shell
# west build -d build -b nrf52_bsim -S xterm-native-shell $ZEPHYR_BASE/tests/bluetooth/shell
default_image=${ZEPHYR_BASE}/tests/bluetooth/shell/build/zephyr/zephyr.exe
num_devices=$1
image="${2:-"${default_image}"}"
# Cleanup all existing sims
$BSIM_OUT_PATH/components/common/stop_bsim.sh
# Force sim to real-time
pushd $BSIM_OUT_PATH/components/device_handbrake
./bs_device_handbrake -s=shell-sim -r=10 -d=0 &
popd
for dev_id in $(seq 1 ${num_devices}); do
echo "Start device $dev_id"
$image -s=shell-sim -d=$dev_id -RealEncryption=1 -rs=$dev_id -attach_uart -wait_uart &
done
# Start the PHY
pushd $BSIM_OUT_PATH/bin
$BSIM_OUT_PATH/bin/bs_2G4_phy_v1 -s=shell-sim -D=$((num_devices+=1))