Cannot pass command line arguments to main function on FVP SSE-320

I’m bringing up toolchain at our company to run model inference on Ethos-U85. I was able to build and run the use cases in ml-embedded-evaluation-kit on FVP SSE-320. Our internal testing framework requires parameter passing to the executable running on the bare metal, so I used the following to pass arguments in command line:

FVP_Corstone_SSE-320 \
-C mps4_board.visualisation.disable-visualisation=1 \
-C vis_hdlcd.disable_visualisation=1 \
-C mps4_board.telnetterminal0.start_telnet=0 \
-C mps4_board.uart0.out_file=- \
-C mps4_board.uart0.shutdown_on_eot=1 \
-C mps4_board.subsystem.cpu0.semihosting-enable=1 \
-C mps4_board.subsystem.cpu0.semihosting-cwd=/tmp \
-C mps4_board.subsystem.cpu0.semihosting-cmd_line="/tmp/model_runner arg1 arg2" \
--stat \
-a /tmp/model_runner

But the arguments (arg1 arg2) are not passed to the main function. Not only it doesn’t work in our internal code, it doesn’t work in the example code in ml-embedded-evaluation-kit, either. If I add the following code in the main function

info("argc = %d\n", argc);
for (int i = 0; i < argc; i++) {
    info("argv[%d] = %s\n", i, argv[i]);
}

The output on FVP SSE-320 is
INFO - argc = 0

No output of argv[].

Any clue on how to solve this issue?

Parameter passing on FVP SSE-300 works fine for us. The command line used is:

FVP_Corstone_SSE-300 \
-C mps3_board.visualisation.disable-visualisation=1 \
-C mps3_board.telnetterminal0.start_telnet=0 \
-C mps3_board.uart0.out_file=- \
-C mps3_board.uart0.shutdown_on_eot=1 \
-C cpu0.semihosting-enable=1 \
-C cpu0.semihosting-cwd=/tmp \
-C cpu0.semihosting-cmd_line="/tmp/model_runner arg1 arg2" \
--stat \
-a /tmp/model_runner

Hi @limintang,

To avoid confusion, worth highlighting that the repository will be maintained here going forward.

We will deprecate the mlplatform instance in coming weeks but it will still stay up as a read mirror for the time being. The links I’ve included below will refer to gitlab.

Unfortunately we don’t use semihosting to have parity between FVP and FPGA, but the software should allow you to use it with trivial changes. Assuming you are using the GNU toolchain, I don’t see how vanilla code for SSE-300 also will work unless you have other changes in the repository. Below is a summary of expected changes:

  1. Configure semihosting for the cmsis device target (used by all SSE-3XX subsystems). You can do this by enabling the option in line 88 of source/hal/source/components/cmsis_device/CMakeLists.txt.
  2. Move #endif guard from line 289 in source/hal/source/components/stdout/source/retarget.c to the end of the file (after line 337).
  3. Include your code snippet from above in Main.cc to verify the above changes do work.
    info("argc = %d\n", argc);
    for (int i = 0; i < argc; i++) {
        info("argv[%d] = %s\n", i, argv[i]);
    }
    
  4. Build the application (again, assuming you’re using GNU toolchain here).

The above changes should work for all SSE-3XX target. For the FVP command however, try setting these parameters: -C mps4_board.subsystem.cpu0.semihosting-stack_base=0 -C mps4_board.subsystem.cpu0.semihosting-stack_limit=0 to your list. See more on this here.

Thanks for raising this, we will:

  • add a CMake configuration option for point 1 to the project;
  • address the compilation issue that needs point 2

Hope this is useful.

Kshitij

Kshitij,

Thanks for the reply! This solves the issue.

Regards,

Limin

1 Like