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.

Semihosting support in CCS 5.4?



Hi,

Semihosting support in CCS-

http://processors.wiki.ti.com/index.php/Semihosting. 

From the above link, I have done the following-

1. Enabled Semihosting  in debugger options

2. Added "stdio.h" and printf("Hello world!\n\r");

I am  not able to get console IO. and I have gone through this link also - http://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/t/144904.aspx

 I did not understand- 

1. How to Install SWI exception handler called SVC_Handler?

2. Where to call GEL_SetSemihostingMainArgs() - GEL function must be called prior to the initialization code is executed?

     Is it required any additional header/source files to support?

Could you please provide me more info on the above? Thanks.

 

  • Laxmi,

    CCSv5.4 will have an initialization script called <startup_ARMCA8.S> that already sets the SVC_Handler for you.

    I am not sure if the version you are using already has this file and its correlated script called <AM335n.lds> (replace n with the device variant), but if not, you can download the update from the Device support page.

    The GEL file is only required if you are passing command line parameters (arguments to main()), which are used by the semihosting function SYS_GET_CMDLINE

    Hope this helps,

    Rafael

     

  • I've also added a section to the wiki http://processors.wiki.ti.com/index.php/Semihosting on how to create a example semihosting project that could used as a baseline.

  • Thanks a lot!!!

    Hi desouza,

    I have startup_ARMCA8.S and .lds files. Accordingly i have modified the existing files.

    Hi Mandeep,

    I have created a new project  as specified in the link.

    and I have checked the console IO in console-

     

    But i am not able to see that "printf". Am i checking correctly here?

  • Hi,

    I am able to see console using evm-sk with xds100v2 emulator.

    This is simple application with printf and puts-

    #include <stdio.h>

     /*

     * hello.c

     */

    int main(void) {

          printf("Hello World!\n");

          puts("Semihosting Testing");

          return 0;

    }

    Console output window,-

    But its not working with other boards, its hanging in svc_handler.

    I have made list of boards which have tested and SOC is AM335x- same for all boards

    Test result and difference between gel files is given below,

    Board

    Emulator

    Semihosting Test result

    Remarks

    Difference in Gel File

    BBB

    XDS100v2

    Fail

    Hangs in SVC_Handler

    DDR2

    EVM-SK

    XDS100v2

    Pass

     

    DDR3

    EVM PG1.0

    XDS510

    Fail

    Hangs in SVC_Handler

    DDR2

    EVM PG2.0

    XDS510

    Fail

    Hangs in SVC_Handler

    DDR3

    Any idea, why its hanging?

  • Laxmi,

    Could you please collect and attach the Debug Server Log for the failing cases ( http://processors.wiki.ti.com/index.php/Troubleshooting_CCSv5#Debug_Server_Logging ). 

    Mandeep

  • Hi Mandeep,

    Sure. I will update it.

  • Hi,

    Semihosting - 

    CCS sample example did not work for EVM and Beaglebone boards.

    Beaglebone Semihosting is working fine with GCC compile.

    Here is a current Status of Semihosting issues with EVM(PG1.0 and PG 2.0) GCC Uart echo example.

     

    EVM PG2.0-

    Semihosting is not working but application works properly.

     Will it matter emulator for semihosting support? Because xds510 emulator used for EVM, whereas xds100v2 used for Beaglebone and EVM-SK.

    EVM PG1.0-

    Semihosting as well as application is not working. It hangs in AbortHandler - > UndefInstHandler

    Any idea, what could be the reason?

  • Laxmi, here is some insight into the design and functioning of the semihosting.

    Debugger -> Set’s breakpoint at SVC_Handler to intercept SWI exceptions

    Target -> Sets up target registers and memory and  Invokes Semihosting calls by issuing a SWI exception ( Here is a list of calls http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0471c/CHDJHHDI.html and how they need to be configured )

    Debugger-> If done correctly the SVC_Handler breakpoint should be hit. The debugger will read target content; determine the type semi hosting call  and perform the correct action.

    Debugger-> Return execution to the calling code; outside the SVC_Handler.

     

    Here are some things to verify. (Turn of run to main; so nothing runs before you start debugging )

    1)      Check SVC_Handler breakpoint is configured by debugger

    1. Use the DEBUG_DumpBreakpoints() gel call to dump the info; look at the output to see a  “SVC_Handler” breakpoint is configured. You could also just collect a DS log as I suggested on the forum. I can look through it and tell you what is going on on the host side.

    2)      Check SVC_Handler is being invoked correctly

    1. Set a breakpoint at SVC_Handler
    2. When the breakpoint is hit; make sure semihosting call is being invoked with correct parameters (http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0471c/CHDJHHDI.html)
    Note: The emulator used should not affect semihosting. Also, if you code is going into an AbortHandler; this is pretty good indication there is something wrong with the target code.
  • Mandeep,

    Thanks a lot for your support!!!

    Let me explain what I have understood from your point that DEBUG_DumpBreakpoints() should exist in gel file.

    That function we should add it into view->expressions, so that we can see the info of breakpoints.
    GEl file did not have DEBUG_DumpBreakpoints function.

    When i add this function to expression, below was the error
    DEBUG_DumpBreakpoints unknown Error: identifier not found: DEBUG_DumpBreakpoints

    Correct me, if i am wrong.

    I have already tested it by adding breakpoint at SVC_Handler for GCC compile and CCS debug test, its hitting.

    Let me summerise test cases and issues, which I have noticed during testing

    CCS Semihosting Sample example:

    It works for EVM-SK only, it did not work for Beaglebone and EVM boards.

    ISSUE for Beaglebone and EVM: While loading example application,

    1. It keeps looping in SVC_Handler
    2. It did not enter into main()

    GCC Compile- Uartecho application
    I have modified lds and startup files to support semihosting
    (reference from ccs example lds and .s files).

    Works only for EVM-SK and It did not work for BeagleBone and EVM boards.

    Beaglebone Test Case observation:
    While loading application,
    1. Application enters into main
    Issue:

    1. It prints non-english characters on UART console while running
    2. Semihosting dint work

    Reason: Use of *(.text*) in lds file, Because we must use this for Memory Command.

    Solution: Modified lds without memory command, so that we can use *(.text) to solve the issue.
                     

    Note: May be in future we may need to use memory command, but for now i have updated without memory cammand.


    EVM Test case observation:

    Note: Same code

    EVM PG 2.0
    While loading application,
    1. Application enters into main
    2. Added breakpoint at SVC_Handler
    Issue: While running,

    1. Hits SVC_Handler and loops for 10- times and then application works properly
    2. Semihosting - not working
    EVM PG 1.0

    While loading application,

    1. Application enters into main
    2. Added breakpoint at SVC_Handler 
    Issue: While running,

    1. It will not hit SVC_Handler, instead it will keep looping in AbortHandler/UndefInstHandler
    2. Semihosting - not working
  • Hi Mandeep,

    I have noticed previously that,

    " Will it matter emulator for semihosting support?
    Because xds510 emulator used for EVM, whereas xds100v2 used for Beaglebone and EVM-SK"

    I have tested it xds100v2 for EVM, It's working fine now.

    Current test result status wrt emulators-
    Semihosting for EVM with xds100v2(GCC compile and CCS sample example) emulator is working successfully!!!!!!!!!!!!
    But it’s not working with xds510 emulator.

    As far as I know, wrt operation
    1. only speed differs between xds100v2 and xds510

    Any idea, difference between xds100 and xds510 apart from speed?

    By analysing the above test results, its not the problem wrt Target code, its the problem of emulator.

    So if in case the problem with target code, it should not work for other emulator also.

    Correct me, if i am wrong.

    If possible, can you check semihosting example for EVM with xds510 emulator?

  • Mandeep,

    Here is a DS log and c file for your reference.

    Details:
    Board: EVM PG2.0
    Emulator: Spectrum Digital XDS510USB Emulator

    4265.ds.log

    #include <stdio.h>
    #include "soc_AM335x.h"
    #include "interrupt.h"
    #include "evmAM335x.h"
    #include "uartStdio.h"
    #include "hw_types.h"
    /*
     * hello.c
     */
    int main(void) {
    	
    	unsigned char s1[10];
    	printf("Semihosting Testing\n");
            printf("Target -> Host Testing\n");
    	puts("EVM PG 1.0 UART Echo Application\n");       
           
    	UARTStdioInit();
    	printf("Host -> Target Testing\n");
    	UARTPuts("Host -> Target Testing\n", -1);
    	scanf("%s", s1);
    	puts(s1);
    	UARTPuts(s1, 7);
    	
    	return 0;
    }
    

  • Laxmi,

    There appears to be a bug (SDSCM00046799) in the emulation stack that is causing semihosting to not work correctly with the xds510 emulator.

    Regards,
    Mandeep 

  • Hi Mandeep,

    Thanks for the update of issue.

    Any plan, when it will be fixed up?

    What all features are supported in Semihosting like printf and scanf?

    I had tested puts and gets function also,  its working fine.

    I tried to use fgets, but its showing undefined instHandler?

    I thought we can use all stdio features, am i right in this point of understanding?

    Can i have list of features supported in Semihosting?

  • Laxmi,

    I've added a new section to the wiki http://processors.wiki.ti.com/index.php/Semihosting#Stdio; which explains the relationship of stdio and semihosting. This includes the sample progarm we use to test semihosting support and it does include fgets. Thus, it should work.

    Mandeep

  • Mandeep,

    Thanks.

    Its not fgets, its fopen function in GCC compile.

    In CCS build, all the functions which you have mentioned are working fine.

    fopen in GCC compile means crosscompile, its giving perror as

    : Too many open files

  • Laxmi,

    Where you able to make progress on this?

    Mandeep

  • Mandeep,

    Sorry for the delayed reply.

    Here is progress status-

    I have validated all features of Semihosting.

    Below are the list of functions validated on GCC and CCS build :
    GCC build and  CCS build-
     List of functions tested by block on stdin/stdout-
    fflush(), puts(), fputs(), putc(), putchar(), fputc(), printf(), fwrite()
    gets(), fgets(), getc(), getchar(), fgetc(), scanf(), fread(),
    fprintf(), fscanf(), fread(),fwrite(),ferror(),perror(), clearerr()
    rewind()

    CCS Build - List of files tested by block on Files
    fopen(), fclose(), remove(), fputs(), fgets(), fprintf(), fscanf(), fread(),
    fwrite(), ftell(), rewind(), fgetpos(), fsetpos(), fseek(), ferror(),
    perror(), clearerr(), feof()


    Fopen has issue with GCC build-

    unable to open file
    : Too many open files

    Here is a code used for testing,
    FILE *fp;
    fp = fopen( "F:\\ti\\ccsv5\\eclipse\\semitest1.txt", "w+" );
    if (fp == NULL) {
      perror("unable to open file");
    }
    fputs ("Welcome!!!",fp);

    CCS Build

    1. Build it using CCS
    2. Load it through CCS using Emulator
    3. Run the application -> Application creates empty file in the path F:\ti\ccsv5\eclipse (default)
    4. Application works  properly

    GCC Build

    1. Build it using GCC
    2. Load it through CCS using Emulator
    3. Run the application, It gives an error that “Too many open files”.

    Any idea?

  • Hi Laxmi,

    Are you including the crt0.S start file?

    There is a necessary function initialise_monitor_handles(); that will setup the struct for your file handles. This function is defined in syscalls.c within rdimon.a so you can call it from main() to quickly test.

    Regards,
     Louis Peryea