This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

no_semihosting - sys_open still referenced

Hi
I am implement a project on the microsemi cortex M3 ARM with the RTX OS and the TCP stack.

I have spend hours reading through posts on the forum and web about implementing no_semihosting and the retarget.c file. I do understand what semihosting is trying to do and why a retarget.c file is needed.

But I have not found an answer or idea about how to resolve the one remaining linker error I am getting.

Error: L6915E: Library reports error: __use_no_semihosting_swi was requested, but _sys_open was referenced

I have been trying figure out what is referencing _sys_open. It is already defined in io_sys.o so I cannot add it to my retarget.c file.

I have removed all references to printf() and there are none to open().

I have run out of ideas as how to remove the offending reference. I'm guessing that it is coming from a library function, maybe.

I know this topic has been brought up over and over again but I just could not find a answer/clue to this specific sys_open reference. I was able to resolve all of the others.

Does anyone have an ideas as to where I could look or what I could to to resolve this one? :-)

Parents
  • The target.c/serial.c is trying to tailor console io to your specific hardware, on a Cortex-M3/4 I'd be tempted to push it out the ITM (SWV/SWO Serial Wire Viewer channel) absent a serial port. USART are vendor specific, not part of the core, and presumably the OS isn't providing console or file system functionality.

    How it works with RTX, I don't know, you could GREP the files you're pulling in, and those in the library directory.

    Check also for putchar/getchar/puts etc.

Reply
  • The target.c/serial.c is trying to tailor console io to your specific hardware, on a Cortex-M3/4 I'd be tempted to push it out the ITM (SWV/SWO Serial Wire Viewer channel) absent a serial port. USART are vendor specific, not part of the core, and presumably the OS isn't providing console or file system functionality.

    How it works with RTX, I don't know, you could GREP the files you're pulling in, and those in the library directory.

    Check also for putchar/getchar/puts etc.

Children
  • You are correct RTX is not providing a console. Microsemi's fpga design tool creates a keil project with a retarget.c file which is a good place to start.

    It uses their uart driver for i/o which is fine. I have search the code for any reference to fopen() to resolve what is referencing _sys_open

    I was looking at the map as well and it looks like malloc might be referencing fopen(). If it is, then that is going to be a problem to replace it with one that does not call the C library function fopen().

    I don't understand why malloc which I am using for heap management would use fopen() though.

        fopen.o(.text) refers to h1_alloc_mt.o(.text) for malloc
        fopen.o(.text) refers to fclose.o(.text) for _fclose_internal
        fopen.o(.text) refers to sys_io.o(.text) for _sys_open
        fopen.o(.text) refers to fseek.o(.text) for _fseek
        fopen.o(.text) refers to rt_memclr_w.o(.text) for __aeabi_memclr4
        fopen.o(.text) refers to stdio_streams.o(.bss) for __stdin
    

  • malloc() doesn't call fopen(). It's some logic in fopen() that makes use of malloc(). Probably to allocate a buffer and possibly also some state information.

  • Ok that makes sense. I was just trying to use the map to somehow track down the fopen user.

    I just when through my code and commented out stdio.h and recompiled to hopefully cause a undefined function error to see if there is something I missed.

    They only two functions to be undefined were snprintf and sscanf for string manipulation.

    I really am out of ideas right now as to how to find what is referencing fopen (aka sys_open)

    Do you have any ideas about how to expose the statement?