shell

If the Zephyr shell firmware sample exposes lots of HW internals over a serial connection to the DUT, useful for test setups with off-the-shelf firmware.

UART Interaction

Example PLT Test plan using UART interaction with the Zephyr shell firmware image, using the kernel version shell command to extract the Zephyr kernel version.

- ident: SHELL
  title: Shell interaction
  steps:
  # Check availability of Zephyr shell
  - command: uart UART0
    send: "\r\nkernel version\r\n"
    extract: "\r\n(.*) version (.*)\r\n"
    extractKey: KERNEL_NAME KERNEL_VERSION

Shell Commands

This section describes some useful commands included in the Zephyr shell firmware sample.

device list: List configured devices

plt-demo:~$ device list
devices:
- CLOCK (READY)
- UART_0 (READY)
- RNG (READY)
- sys_clock (READY)
- GPIO_0 (READY)
- PWM_0 (READY)
- I2C_0 (READY)
- SPI_1 (READY)
- APA102 (READY)
  requires: SPI_1
- BMI270 (READY)
  requires: I2C_0
- TEMP_0 (READY)
- SHT3XD (READY)
  requires: I2C_0

hwinfo devid: Device ID

plt-demo:~$ hwinfo devid

gpio conf: Configure GPIO

plt-demo:~$ gpio conf GPIO_0 1 out
Configuring GPIO_0 pin 1

gpio get: Get GPIO value

plt-demo:~$ gpio get GPIO_0 1
Reading GPIO_0 pin 1
Value 0

gpio set: Set GPIO

plt-demo:~$ gpio set GPIO_0 1 0
Writing to GPIO_0 pin 1

i2c scan: Scan I2C devices

plt-demo:~$ i2c scan I2C_0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:             -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
2 devices found on I2C_0
plt-demo:~$

kernel cycles: Kernel cycles

plt-demo:~$ kernel cycles
cycles: 2221011598 hw cycles

kernel version: Kernel version

plt-demo:~$ kernel version
Zephyr version 2.7.0

sensor get: Get sensor data

plt-demo:~$ sensor get SHT3XD
channel idx=13 ambient_temp =  16.948958
channel idx=16 humidity =  45.137710
plt-demo:~$ sensor get SHT3XD 13
channel idx=13 ambient_temp =  16.948958
plt-demo:~$ sensor get BMI270
channel idx=0 accel_x =  -0.328614
channel idx=1 accel_y =  -0.271750
channel idx=2 accel_z =  10.042785
channel idx=3 accel_xyz x =  -0.328614 y =  -0.271750 z =  10.042785
channel idx=4 gyro_x =   0.000000
channel idx=5 gyro_y =  -0.022371
channel idx=6 gyro_z =   0.000798
channel idx=7 gyro_xyz x =   0.000000 y =  -0.022371 z =   0.000798
plt-demo:~$ sensor get BMI270 2
channel idx=2 accel_z =  10.046376
plt-demo:~$ sensor get TEMP_0
channel idx=12 die_temp =  16.250000
plt-demo:~$ sensor get TEMP_0 12
channel idx=12 die_temp =  16.250000
plt-demo:~$

BLE Direct Test Mode

If the Zephyr shell firmware sample is compiled with CONFIG_BT_CTLR_DTM, additional commands are available enabling BLE Direct Test Mode testing with a DUT, without requiring custom software to be written.

bt test_tx <chan> <len> <type> <phy>
bt test_rx <chan> <phy> <mod_idx>
bt test_end

All parameters for Zephyr BT shell DTM commands are interpreted
as hex values.

- `type`: BT_HCI_LE_TEST_CTE_TYPE_ANY = 0
- `phy`: BT_HCI_LE_RX_PHY_1M = 0x01
- `mod_idx`: BT_HCI_LE_MOD_INDEX_STANDARD = 0

Receive Test

# Start receive by PLT
- command: ble test recv 14
:
# Stop receive by PLT
- command: ble test stop
  extractKey: BLE_RX_COUNT
# Evaluate number of packets received from DUT
- command: eval "%BLE_RX_COUNT% > 3000"

Transmit Test

# Ensure dongle is not in DTM
- command: ble test stop
# Start receive by DUT
- command: uart UART0
  send: "\r\nbt test_rx 0x0e 0x01 0x00\r\n"
  expect: "test_rx..."
# Start transmit by PLT
- command: ble test xmit 14
:
# Stop transmit by PLT
- command: ble test stop
# Stop receive by DUT
- command: uart UART0
  send: "\r\nbt test_end\r\n"
  #  'num_rx=33035\r\n'
  expect: "num_rx="
  extract: "num_rx= (.*).\r\n"
  extractKey: BLE_TX_COUNT
# Evaluate number of packets received by DUT
- command: eval "%BLE_TX_COUNT% > 3000"