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>
This commit is contained in:
Jonathan Rico 2024-03-11 09:10:20 +01:00 committed by Johan Hedberg
parent e1b7b450c8
commit f3f42d363b
4 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,43 @@
#!/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))

View File

@ -0,0 +1,4 @@
name: xterm-native-shell
append:
EXTRA_CONF_FILE: xterm-native-shell.conf
EXTRA_DTC_OVERLAY_FILE: xterm-native-shell.overlay

View File

@ -0,0 +1,4 @@
CONFIG_NATIVE_UART_0_ON_OWN_PTY=y
CONFIG_UART_NATIVE_WAIT_PTS_READY_ENABLE=y
CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=8192
CONFIG_LOG_PRINTK=n

View File

@ -0,0 +1,25 @@
/ {
chosen {
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
};
};
/* Use the PTY driver instead of the UART peripheral emulation that is now the
* default on nrf52_bsim. */
&uart1 {
status = "okay";
compatible = "zephyr,native-posix-uart";
/delete-property/ pinctrl-0;
/delete-property/ pinctrl-1;
/delete-property/ pinctrl-names;
};
&uart0 {
status = "okay";
compatible = "zephyr,native-posix-uart";
/delete-property/ pinctrl-0;
/delete-property/ pinctrl-1;
/delete-property/ pinctrl-names;
};