How to pass multi arguments to main() in Arm Development Studio?

我想将配置文本作为 argv[1] 传递给 main() 函数,并且已经尝试过命令行。set semihosting args "config txt" ,but it seems like the config txt is argv[0] not argv[1],so how to pass multi arguments to main()?

Parents
  • Thanks, I tried to use the way you said,and adds a  .ds script in Debug Cofigurations as the target initialization scripts,  and set debug from symbol main, The content of of the .ds script is:

    set semihosting enabled on 

    set semihosting args 1 2 3

    and then connected in Arm development Studio, it doesn't work successfully, print argc equals 0.

    But when I add -C semihosting-cmd_line="1 2 3" in model parameters Tab, it works successfully, the only question is that 1 passed to argv[0] not argv[1], and 2 passed to argv[1]. Is there something wrong?

Reply
  • Thanks, I tried to use the way you said,and adds a  .ds script in Debug Cofigurations as the target initialization scripts,  and set debug from symbol main, The content of of the .ds script is:

    set semihosting enabled on 

    set semihosting args 1 2 3

    and then connected in Arm development Studio, it doesn't work successfully, print argc equals 0.

    But when I add -C semihosting-cmd_line="1 2 3" in model parameters Tab, it works successfully, the only question is that 1 passed to argv[0] not argv[1], and 2 passed to argv[1]. Is there something wrong?

Children
  • Hi again,

    The method I gave above works when used with real hardware via DSTREAM, where the Debugger handles the semihosting.

    If you are using an FVP model, then the method is slightly different, because the FVP model handles the semihosting automatically itself by default.  By default, the FVP model traps semihosting calls very early, and the Debugger never sees them.  This behaviour can be overridden (see 2) below)

    If you are using an FVP model, you can either:

    1) launch the FVP model with -C semihosting-cmd_line="1 2 3" in the Model Parameters field (no .ds script needed)
    This works, but as you have seen, the args are handled differently - argv[0] is no longer the name of the image, but is now the first parameter ("1" in our test case)

    or

    2) launch the FVP model with e.g. "-C cluster.cpu0.semihosting-enable=0" in the Model Parameters field, _and_ have "set semihosting args 1 2 3" in the .ds script.
    The "semihosting-enable=0" switch tells the model to _not_ handle semihosting.  So the semihosting will be passed to the Debugger to handle.  The Debugger will then handle the semihosting, in the same way as for hardware.  The exact form of the  "semihosting-enable" switch will vary depending on the FVP model you are using.

    Hope this explains things

    Stephen

  • I tried to launch the FVP model with e.g. "-C cluster.cpu0.semihosting-enable=0" in the Model Parameters field, _and_ have "set semihosting args 1 2 3" in the .ds script.When connected it shows that semihosting breakpoint address has not be specified. By the way,I wanna ask why diable_sve_traps is necessary  in sve examples but not necessary in hardware device like mobile phones.

  • Hi again

    You wrote:
    >I tried to launch the FVP model with e.g. "-C cluster.cpu0.semihosting-enable=0" in the Model Parameters field, _and_ have "set semihosting args 1 2 3" in the .ds script.
    >When connected it shows that semihosting breakpoint address has not be specified.

    Yes, for an Armv8/9-A/R target system that uses HLT-based semihosting, you must specify the semihosting breakpoint address.  This tells the debugger at what address it should set a breakpoint to trap semihosting requests.

    By default on an Armv8/9-A/R FVP model, the semihosting breakpoint address is at EL3:0x00000200. 
    So you must update your .ds script to, e.g.

    set semihosting vector ADDR EL3:0x00000200
    set semihosting enabled on
    set semihosting args 1 2 3

    I've tested this on the Cortex-A53 FVP model in Arm DS and it works as expected.
    The "Model parameters" I used for this were:
    -C cluster0.NUM_CORES=1 -C bp.secure_memory=false -C semihosting-enable=0

    The semihosting breakpoint address will depend on (and is an offset from) the Vector Base Address Register (VBAR) for the current EL.

    >why disable_sve_traps is necessary in sve examples but not necessary in hardware device like mobile phones.

    It depends how the target system is initially configured.  For an Arm FVP model running bare-metal code, the SVE traps must be disabled to allow SVE code to execute.
    In a hardware device like a mobile phone, that has an OS running, the OS might have disabled the traps for the application environment for you already.


    Hope this helps

    Stephen

  • Thanks,the .ds script using 

    set semihosting vector ADDR EL3:0x00000200
    set semihosting enabled on
    set semihosting args 1 2 3

    it works successfuly when using AEM vAx1 FVP model,

    but crashed in NeoverN2x1 FVP model, the disassembly code wrote: EL3:0x0000000000000200  DEADDEAD DCI 0xdeaddead,

    seems like semihosting vector ADDR not right.

    Is there documents than can find the different FVP models semihosting settings?

  • Hi again

    The same setup works for me with the Neoverse N2x1 FVP model - see screenshot:



    Have you set the Model Parameters correctly?  They should be
    -C cluster0.NUM_CORES=1 -C bp.secure_memory=false -C semihosting-enable=0

    I can reproduce the crash that you see if I remove the last two parameters.

    Stephen

  • The same settings in a simple hello_world project works suceessfully, But failed when the project using sve intrinsics, the command line error info is:

    Semihosting stack/heap configured using values:
    Stack: 0x800185A0 ~ 0x80017DA0
    Heap: 0x800085A0 ~ 0x80017D9C
    WARNING(TAB186): Unknown semihosting operation 0x800085A0 (returning to EL3:0x00000000800001B4)
    WARNING(TAB186): Unknown semihosting operation 0x800085A0 (returning to EL3:0x00000000800001DC)
    WARNING(TAB186): Unknown semihosting operation 0x800085A0 (returning to EL3:0x00000000800001E4)
    WARNING(TAB186): Unknown semihosting operation 0x800085A0 (returning to EL3:0x00000000800001E8)
    ERROR(TAD11-NAL23):
    ! Failed to write 49 bytes to address EL3:0xDEADDEADDEADDEB5
    ! Memory write at address 0xDEADDEADDEADDEB5 failed with error code E_error_memory_abort (this error code also occurred at other addresses)
    Execution stopped in EL3h mode at breakpoint -1: EL3:0x0000000000000200

    This error occurs using .ds script pass arguments.

    When choosing another method pass arguments like FVP model parameter "semihosgin-cmd_line="1 2 3"", no error occurs.

  • Hi again

    You wrote:
    >The same settings in a simple hello_world project works successfully, But failed when the project using sve intrinsics.

    Sorry, I can't think of any reason why SVE intrinsics themselves would cause such a failure.

    The semihosting vector/breakpoint address will depend on (and is an offset from) the Vector Base Address Register (VBAR) for the current EL.

    For a simple Hello World project, with no assembler startup code, the VBARs will contain zero (default for the FVPs), and so the "set semihosting vector ADDR" should be EL3:0x00000200.

    However, if you have a more complex project, with assembler startup code that changes the VBARs, or changes the EL, then you may have to change the address.  Does your SVE intrinsics project have assembler startup code?  If so, I suggest you check the value of VBAR_EL3.

    Stephen