[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.

    Keep in mind, this is *not* a support forum.
    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: https://www.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:

    The rename argument I've defined as a struct:

    C
    struct {
        	const char *src;
        	uint32_t src_len;
        	const char *dst;
        	uint32_t dst_len;
    	} 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.

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    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: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!