[SOLVED] Semihosting and JLink 6.32a

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] Semihosting and JLink 6.32a

    I'm testing some semihosting APIs on the chip we're using and I noticed that SYS_RENAME and SYS_REMOVE are not working in latest JLink as documented in the manual. What are the actual tested set of semihosting calls?

    I was able to use:
    * SYS_OPEN
    * SYS_CLOSE
    * SYS_WRITE
    * SYS_READ
    * SYS_WRITE0
    * SYS_WRITEC
    * SYS_FLEN

    Unsure/untested:
    * SYS_SEEK
    * SYS_ISTTY
    * SYS_GETCMDLINE
    * SYS_EXIT
  • Hello,

    Thank you for your inquiry.
    Such an issue is not known to us.
    The commands listed in the user manual are tested and supported.
    Could you give us more information about your test setup?
    What is your target device?
    How are you interfacing with J-Link and how are you calling semihosting commands?
    Through an IDE, GDB, other application?

    Best regards,
    Nino
    Please read the forum rules before posting: Forum Rules

    Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • I'm using a Cortex M-7 device in thumb2 mode which is supported by the tools. I'm invoking the semihosting calls using the same entry code:

    C Source Code

    1. int semihosting(int op, void *arg) {
    2. int ret = 0;
    3. __asm__("mov r0, %[op]\r\n"
    4. "mov r1, %[arg]\r\n"
    5. "bkpt 0xAB\r\n"
    6. "mov %[ret], r0\r\n"
    7. : [ret] "=r" (ret)
    8. : [op] "r" (op), [arg] "r" (arg)
    9. : "r0", "r1");
    10. return ret;
    11. }
    Display All


    The rename argument I've defined as a struct:

    C Source Code

    1. struct {
    2. const char *src;
    3. uint32_t src_len;
    4. const char *dst;
    5. uint32_t dst_len;
    6. } arg;


    The operations above which work return expected codes (>0) and the SYS_RENAME and SYS_REMOVE return -1.
  • Hi,

    As described, Semihosting is handled by the debugger, in this case GDB/GDB Server.
    Therefore the actual implementation and available commands as well as the expected target behavior is dependent on the debugger.
    The J-Link User Guide describes the common available Semihosting commands in general.

    For GDB Server SYS_RENAME and SYS_REMOVE are disabled for security reasons.
    You could otherwise, intended or not intended, severely mess up the debugger host.
    In the GDB Server you should have seen a message about this when you tried to execute those commands:
    "Semi hosting error: SYS_RENAME: Target tries to rename file. Declined for security reasons."

    All other Semihosting commands are available and tested with GDB Server.

    Regards
    Johannes

    PS: Nino sent you a PM. Feel free to contact us via mail if there are any other questions.