This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] AM62A7: Enabling Semihosting to work with System Calls

Part Number: AM62A7

Tool/software:

We have fopen() / fprintf() / fclose() - function calls on A53 which are not working as expected.

The fopen function always return NULL. We are using GCC compiler.

Is this related to semihosting? If yes, how to enable it?

  • To make the semihosting enable while compiling through GCC, you will need to link the libc.a and librdimon.a library.

    To link the above mentioned library, add the -lc and -lrdimon flag to linker command. Also remove the -nostartfiles flag to allow linking of standard libraries.

    In CCS project, open the Project Properties and navigate to Build -> GNU Linker -> Libraries and add the above flags. 

    Please refer below image.

    Also Add the --specs=rdimon.specs flag in GCC compiler args to use the semihosted version of the syscalls.

    Inside CCS Project properties, navigate to Build -> GNU Compiler -> Miscellaneous and add above mentioned flag.

    Please refer below image.

  • Once the above changes is done, add the below function declaration in *.c file.

    extern void initialise_monitor_handles(void);

    Also call the above function before making any system calls. Please refer below image.

    Make sure you enable the semihosting option in the debugger. Navigate to Tools -> Debugger -> Program/Memory Load Options.

    Rebuild the program and run it again.

    After performing the above steps, you will be able to make your application code to work correctly.