SPI Driver Sample Application
Description
The SPI Driver sample application validates SPI data transfer on SR110 in multiple execution modes.
It supports:
Single-board mode: controller and peripheral both run on the same board.
Double-board mode: one board runs controller image, second board runs peripheral image.
Transfer styles: blocking, non-blocking, and DMA-based transfer paths.
The app sends known data patterns and checks received data match counts on both controller and peripheral sides. Logs report pass/fail status and transfer timing.
Hardware Requirements
Astra Machina Micro Kit (SR110)
UART bridge adapter (required for logging)
SPI jumper wires
For double-board mode: 2x Astra Machina Micro boards
Prerequisites
Choose one setup path:
Mode Configuration (Important)
Update spi_sample_app.h before build.
Single-board non-blocking mode (requested baseline)
Set:
SPI_NON_BLOCKING_XFER = 1SPI_SINGLE_BOARD_MODE = 1SPI_DMA_XFER = 0SPI_DOUBLE_BOARD_MODE = 0
Single-board DMA mode
Set:
SPI_DMA_XFER = 1Keep
SPI_SINGLE_BOARD_MODE = 1Keep
SPI_DOUBLE_BOARD_MODE = 0
Double-board mode
Set:
SPI_DOUBLE_BOARD_MODE = 1SPI_SINGLE_BOARD_MODE = 0Build two different images:
Controller board image:
SPI_CONTROLLER_MODE = 1,SPI_PERIPHERAL_MODE = 0Peripheral board image:
SPI_CONTROLLER_MODE = 0,SPI_PERIPHERAL_MODE = 1
Logger Interface Configuration
SPI sample logs are expected on UART0 logger.
Ensure logger interface is UART0 during build:
CONFIG_LOGGER_IF_UART_0=y
Important: Enable logger_if_uart0 when building SPI sample app.
(It is already enabled in cm55_spi_sample_app_defconfig, but verify if you changed config.)
Wiring
SPI wiring (single-board loopback)
Connect:
G24 -> G9G22 -> G6G23 -> G7G21 -> G8
SPI wiring (double-board mode)
Connect Controller board to Peripheral board:
Controller
G22-> PeripheralG6(CLK)Controller
G21-> PeripheralG8(CS)Controller
G24-> PeripheralG7(MISO)Controller
G23-> PeripheralG9(MOSI)Connect GND between both boards
UART0 logging wiring (UART bridge)
Connect UART bridge:
UART TX -> G45UART RX -> G44GND -> any board GND
Building and Flashing the Example using VS Code
Use the VS Code flow described in the SR110 guide and the VS Code Extension guide:
Build (VS Code):
Update
spi_sample_app.hmode macros as required.Ensure logger interface is UART0 (
CONFIG_LOGGER_IF_UART_0=y).Open Build and Deploy -> Build Configurations.
Select spi_sample_app in the Application dropdown.
Build with Build (SDK + App) for the first build, or Build App for rebuilds.
Flash (VS Code):
Use Image Conversion to generate the flash image.
Use Image Flashing (SWD/JTAG) to flash the firmware image.
Building and Flashing the Example using CLI
Use the CLI flow described in the SR110 guide:
Build (CLI):
Update
spi_sample_app.hmode macros as required.Ensure logger interface is UART0 (
CONFIG_LOGGER_IF_UART_0=y).From
<sdk-root>/examples, build the example:cd <sdk-root>/examples export SRSDK_DIR=<sdk-root> make cm55_spi_sample_app_defconfig BOARD=SR110_RDK BUILD=SRSDK
If you need to edit config (for logger/mode options):
make cm55_spi_sample_app_defconfig BOARD=SR110_RDK BUILD=SRSDK EDIT=1
Flash (CLI):
Activate the SDK venv (required for image generation tools):
# Linux/macOS source <sdk-root>/.venv/bin/activate # Windows PowerShell .\.venv\Scripts\Activate.ps1
Generate the flash image:
cd <sdk-root>/tools/srsdk_image_generator python srsdk_image_generator.py \ -B0 \ -flash_image \ -sdk_secured \ -spk "<sdk-root>/tools/srsdk_image_generator/B0_Input_examples/spk_rc4_1_0_secure_otpk.bin" \ -apbl "<sdk-root>/tools/srsdk_image_generator/B0_Input_examples/sr100_b0_bootloader_ver_0x012F_ASIC.axf" \ -m55_image "<sdk-root>/examples/out/sr110_cm55_fw/release/sr110_cm55_fw.elf" \ -flash_type "GD25LE128" \ -flash_freq "67"
Flash the firmware image:
cd <sdk-root> python tools/openocd/scripts/flash_xspi_tcl.py \ --cfg_path tools/openocd/configs/sr110_m55.cfg \ --image tools/srsdk_image_generator/Output/B0_Flash/B0_flash_full_image_GD25LE128_67Mhz_secured.bin \ --erase-all
Running the Application
Single-board mode
Complete SPI jumper wiring and UART0 bridge wiring listed above.
Flash SPI sample app image.
Press RESET.
Open serial terminal on UART bridge port and observe SPI transfer logs and match-count results.
Double-board mode
Configure and build two images:
Controller-mode image
Peripheral-mode image
Flash controller image on board-1 and peripheral image on board-2.
Complete the double-board SPI wiring from the Wiring section.
Connect each board to a different PC (recommended) for independent flashing/logging.
Connect UART0 bridge for logs:
UART TX -> G45UART RX -> G44GND -> any board GND
Power both boards, then reset both boards (peripheral first, then controller if needed).
Open serial terminal(s) and monitor SPI transfer logs and match-count results.
Expected Logs
SR100.Logger info 1771926848.982818 SYS 0 M55 00:00:00:003:917 Application drivers initialization complete without errors.
SR100.Logger info 1771926848.982818 SYS 0 M55 00:00:00:008:111 ------------------------------------------
SR100.Logger info 1771926848.982818 SYS 0 M55 00:00:00:011:477 Hello ASTRA
SR100.Logger info 1771926848.982818 SYS 0 M55 00:00:00:014:844 ------------------------------------------
SR100.Logger info 1771926848.982818 SYS 0 M55 00:00:00:018:206 System initialization done
SR100.Logger info 1771926848.982818 SYS 0 M55 00:00:00:020:807 sr110 SDK version 1.3.0
SR100.Logger info 1771926848.982818 HAPI 0 M55 00:00:00:023:281 SPI PERIPHERAL INIT FOR HOST API
SR100.Logger info 1771926848.982818 HAPI 0 M55 00:00:00:026:189 SPI Peripheral Initialized Successfully for Host API.
SR100.Logger debug 1771926848.982818 HAPI 0 M55 00:00:00:030:080 ------------------------------------------
SR100.Logger debug 1771926848.982818 HAPI 0 M55 00:00:00:033:443 Host API Router task
SR100.Logger debug 1771926848.982818 HAPI 0 M55 00:00:00:036:810 ------------------------------------------
SR100.Logger info 1771926848.982818 HAPI 0 M55 00:00:00:040:163 Active interface is USB
SR100.Logger info 1771926848.998146 SPI 0 M55 00:00:00:051:582 Controller Transfer Status = 4
SR100.Logger info 1771926848.998146 SPI 0 M55 00:00:00:051:609 Peripheral Transfer Status = 4
SR100.Logger info 1771926848.998146 SPI 0 M55 00:00:00:052:282 CONTROLLER RX
SR100.Logger info 1771926848.998146 SPI 0 M55 00:00:00:052:305 Controller Match Count: 256 / 256
SR100.Logger info 1771926848.998146 SPI 0 M55 00:00:00:052:331 Expected match count does match
SR100.Logger info 1771926848.998146 SPI 0 M55 00:00:00:052:355 PERIPHERAL RX
SR100.Logger info 1771926848.998146 SPI 0 M55 00:00:00:052:378 Peripheral Match Count: 256 / 256
SR100.Logger info 1771926848.998146 SPI 0 M55 00:00:00:052:404 Expected match count does match
SR100.Logger debug 1771926848.998146 SPI 0 M55 00:00:00:052:428 SPI Sample App Completed