zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10k stars 6.15k forks source link

Enable simulator to be selected from twister's command line #71190

Open ithinuel opened 2 months ago

ithinuel commented 2 months ago

Is your enhancement proposal related to a problem? Please describe.

Switching between QEMU and another simulator (such as Arm FVP) requires editing the board yaml file.

Describe the solution you'd like

I'd like to have an argument to twister to select the simulator, similarly to what --west-runner does.

Describe alternatives you've considered

For now the solution is to patch zephyr in CI before running the tests. It may be possible to do something with CMake's property to alter a yaml file (like it is possible to configure tfm's hex file name before flashing with pyocd).

Additional context

-

henrikbrixandersen commented 2 months ago

Can you give an example of a board and the needed patch for switching between the two? Perhaps a board variant could solve this.

ithinuel commented 2 months ago

The gist of the patch more or less what https://docs.zephyrproject.org/latest/develop/test/twister.html#running-tests-on-custom-emulator.

For example, on Corstone-300 (aka mps3/an547) this line does enable run_armfvp as a west build ... -t run_armfvp target.

Without the changes to simulation and simulation_exec in boards/arm/mps3/mps3_an547.yaml, west twister won't run those tests on FVP, but with those changes they can no longer be run on Qemu.

EDIT:

With regards to variant, although I guess it could work to some extent, lets consider a system such as the mps2/an521 that has two cores each with a security extension we'd get:

  1. mps2/an521/cpu0/qemu
  2. mps2/an521/cpu0/armfvp
  3. mps2/an521/cpu0/ns/qemu
  4. mps2/an521/cpu0/ns/armfvp
  5. mps2/an521/cpu1/qemu
  6. mps2/an521/cpu1/armfvp
  7. mps2/an521/cpu1/ns/qemu
  8. mps2/an521/cpu1/ns/armfvp

That would be a lot of code duplication (unless zephyr supports a way to include/extend another yaml file).