J-Run is a command-line utility to program embedded hardware with test applications, control the execution, and retrieve test results. It can be used to automate test runs which would otherwise involves considerable manual work.
J-Run works with any Arm or RISC-V device supported by J-Link and works with standard ELF output. During a test, J-Run captures target output via RTT or Semihosting and detects when a test has finished.
Output from a test application can be output to to the terminal or redirected to other tools for further analysis.
J-Run can be used for any test task which needs to be run on target hardware. It is especially useful for automating recurring tests or single test setups which require running various test variations in sequence. The use of J-Run can save a lot of manual work and eliminate errors of manual runs.
When new capabilities are added to a firmware during development, the overall integrity of the firmware needs to be ensured (i.e., that the target executes as expected. While regular debugging usually focuses on finding bugs or testing just changed functions, automated tests can check all aspects of a firmware. A test can run a firmware in some selftest mode, which tests all modules of a firmware and outputs the results.
These tests, especially when peripherals are involved or timing is important, need to run on actual hardware. J-Run enables performing such tests. Its run can be triggered automatically after each build, manually by a developer, or from a continuous integration (CI) system.
Increasing the performance of embedded software can be time consuming. After spots for optimization are identified and changed, execution tests must be rerun to verify the expected results. While some work on performance affects only one firmware in one configuration, some changes might be rolled out to different systems. In such cases multiple tests might have to be done for each change.
J-Run can be completely controlled on the command line and integrated in test scripts or test environments. This enables running different tests without manual interaction.
J-Run downloads the application image from ELF executables. The regular output of a toolchain or build system can be used and requires no further modification. Additional information for output control are taken from the ELF file, too. As for a regular debug build, symbols must be present.
After the application image is programmed to the target device, the target is reset and started. While the test application is running, J-Run captures its output. It supports RTT as well as semihosting.
J-Run runs until it captures the exit string which indicates that the test is done, or receives the semihosting exit command.
J-Run can capture output from the test application via RTT and prints all output to the terminal. RTT enables running tests without interruption and is especially useful for timing-sensitive tasks.
When J-Run captures a line which matches the exit wildcard string (default "*STOP*"), the test is done and J-Run exits.
J-Run can do semihosting operations to capture output from the test application. For semihosting the target application is temporarily halted for each operation,
but it can be used on every target, even those which do not support RTT.
In addition to finishing a test with the exit wildcard string, J-Run supports the semihosting exit operation.
C:> jrun -device STM32F407IE ApplicationTest.elf
J-Run compiled Feb 01 2021 12:09:19
(c) 2018-2021 SEGGER Microcontroller GmbH www.segger.com
Set target device to STM32F407IE...OK
Select SWD interface...OK
Set interface speed to 4000 kHz...OK
SEGGER_SEMIHOST_DebugHalt found at 0x08000734
Start target application...OK
Reading output from target until exit command.
Compiled 02.02.2021 08:11:19
Starting OS... OK.
Testing Hardware... OK. Running at 168 MHz.
Testing IP... OK. Connected at 192.168.12.9
Testing Filesystem... OK. 3.8 GB free.
All tests done. STOP.
J-Run finished. Press any key to exit.
C:> jrun -device STM32F407IE -if SWD --semihost --silent PerformanceTest_sinf_v7EM.elf
Took 2582433 cycles