infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 10 of 10

Thread: DAVE TIP of the day: Semihosting in DAVEv4

  1. #1
    Daryl Neo
    Guest

    DAVE TIP of the day: Semihosting in DAVEv4

    Semihosting is a mechanism for ARM targets to communicate input/output requests from application code to a host computer running a debugger. For example, you can use this mechanism to enable functions in the C library, such as printf() and scanf(), to use the screen and keyboard of the host instead of having a screen and keyboard on the target system.

    In DAVEv4, you can enable semihosting using the following steps. An example for semihosting on XMC1300 is provided in this tip.

    1. Configure the Tool settings:
    - Toolbar: Select “Project  Active Project Settings” to launch the Settings Dialog.
    - Settings Dialog: Select “C/C++ Build  Settings” and click on the “Tool Settings” Tab.
    - Linker Settings: Select “ARM-GCC C Linker  Miscellaneous  Other Flags:” , enter “-specs=rdimon.specs -specs=nosys.specs”
    - Preprocessor Settings: Select “ARM-GCC Assembler  Preprocessor  Defined symbols (-D):” , add “__SKIP_LIBC_INIT_ARRAY”

    2. In the folder Libraries/Newlib, replace syscalls.c by _sbrk.c

    3. In your application, add the following lines to initialize the monitor handles for semihosting. Add “printf” statements in your code for semihosting.

    extern void initialise_monitor_handles(void);

    int main(void)
    {
    initialise_monitor_handles();


    // Example printf statements for semihosting
    printf("XMClib printf using semihosting \n");


    4. Compile and start a debug session. In the debugger settings you need to activate semihosting.

    5. To see the output, in the debugger perspective, you need to activate the Semihosting and SWV in the Console view.
    ?????? ?????? semihosting_assembler_preprocessor.JPG‎   semihosting_linker_options.JPG‎   semihosting_debug_options.JPG‎   semihosting_debug_outputs.JPG‎  
    ?????
    Last edited by Daryl Neo; Nov 16th, 2015 at 10:06 PM.

  2. #2

    Infineon Employee
    Infineon Employee
    Dirk is on a distinguished road
    Join Date
    Aug 2013
    Location
    Dresden
    Posts
    5
    Points
    54.375
    Hi Daryl,

    it's working thanks,
    but in your description is a small error. There is a missing "underline" at __SKIP.
    - Preprocessor Settings: Select “ARM-GCC Assembler  Preprocessor  Defined symbols (-D):” , add “_SKIP_LIBC_INIT_ARRAY”
    Another question. Why u must replace the c file? as if i compare the file its nearly the same, just reduced of some functions. Which functions have to be deleted to activate that function`?

    Regards
    Dirk
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  3. #3
    Daryl Neo
    Guest
    HI Dirk,

    Thanks for pointing it out. I have edited the post.

    For STEP2/replacing the file, the syscall.c file does not support the output functions in semihosting correctly. Therefore, for now, we have to replace the file.
    In the next DAVE update, the syscall.c file will be updated and STEP2 will not be needed.

    Regards,
    Daryl



    Regards,
    Daryl

  4. #4
    Heinz
    Guest
    in order to use XMC_DEBUG() isn't it necessary to #define XMC_DEBUG_ENABLE ?

    Anyway, I followed the steps, the project compiles put it seems that printf() is not working.
    I can't see any output. Whether in step mode or running the example.
    Using a simple project for an XMC1404

  5. #5
    Beginner Beginner
    Infineon Employee
    Infineon Employee
    elm0 will become famous soon enough
    Join Date
    Nov 2015
    Location
    Duisburg
    Posts
    13
    Points
    152.5
    Are you looking at the right console?

    Click image for larger version

Name:	Semihosting_Console.png
Views:	0
Size:	24.7 KB
ID:	1874

    A mistake I made first was to define the symbol "__SKIP_LIBC_INIT_ARRAY" in the ARM-GCC C Compiler preprocessor settings, and not in the ARM-GCC Assembler preprocessor settings as it should be.

    To use the XMC_DEBUG() function, it is necessary to #define XMC_DEBUG_ENABLE, but not in the main.c, but e.g. in the xmc_common.h
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  6. #6
    Beginner Beginner
    Infineon Employee
    Infineon Employee
    elm0 will become famous soon enough
    Join Date
    Nov 2015
    Location
    Duisburg
    Posts
    13
    Points
    152.5
    Did someone try semihosting input? For me, it doesn't work ... or maybe I don't know how to send something. Simply typing in the console and pressing enter seems not to work.
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  7. #7
    Daryl Neo
    Guest
    [Updated for DAVE 4.2.4]

    Semihosting is a mechanism for ARM targets to communicate input/output requests from application code to a host computer running a debugger. For example, you can use this mechanism to enable functions in the C library, such as printf() and scanf(), to use the screen and keyboard of the host instead of having a screen and keyboard on the target system.

    In DAVEv4, you can enable semihosting using the following steps. An example for semihosting on XMC1300 is provided in this tip.

    1. Configure the Tool settings:
    - Toolbar: Select “Project  Active Project Settings” to launch the Settings Dialog.
    - Settings Dialog: Select “C/C++ Build  Settings” and click on the “Tool Settings” Tab.
    - Linker Settings: Select “ARM-GCC C Linker  Miscellaneous  Other Flags:” , enter “-specs=rdimon.specs”

    2. In your application, add the following lines to initialize the monitor handles for semihosting. Add “printf” statements in your code for semihosting.

    extern void initialise_monitor_handles(void);

    int main(void)
    {
    initialise_monitor_handles();


    // Example printf statements for semihosting
    printf("XMClib printf using semihosting \n");


    3. Compile and start a debug session. In the debugger settings you need to activate semihosting.

    4. To see the output, in the debugger perspective, you need to activate the Semihosting and SWV in the Console view.
    ?????

  8. #8
    New Member New Member Jorge66 is on a distinguished road Jorge66's Avatar
    Join Date
    Jun 2016
    Location
    Geneva
    Posts
    29
    Points
    107.1875

    Debug printf Semihosting on Hexagon XMC4500 ?

    I am unable to make it work on Hexagon board XMC4500 and Dave 4.3.2
    Click image for larger version

Name:	Blinky45Semihosting.PNG
Views:	20
Size:	77.9 KB
ID:	2790
    Click image for larger version

Name:	Blinky45define.PNG
Views:	9
Size:	46.1 KB
ID:	2793
    Click image for larger version

Name:	Blinky45GDBDebug.PNG
Views:	9
Size:	54.9 KB
ID:	2791

    Here is a simplified source code (from "Blinky" example) :


    #include <DAVE.h> //Declarations from DAVE Code Generation (includes SFR declaration)
    #include <stdio.h>

    #include "GPIO.h"
    #include "board.h"

    extern void initialise_monitor_handles(void);

    volatile unsigned long timingdelay, adc_result;

    void ADC0_Init(void);
    void Delay100US (unsigned long time);


    /*Main function*/
    int main(void)
    {
    initialise_monitor_handles();
    /* Setup the system */
    SysTick_Config(12000); // Systick every 0.1 ms = 100us

    /* Configure P3.9 (LED) */
    // P3.9 is used as GPIO for LED indication. Macros can be find in GPIO.h
    Control_P3_9(OUTPUT_PP_GP, STRONG);

    printf("Welcome into Blink45\n");

    /* Infinite loop */
    while (1)
    {
    Delay100US (0x0FFF);
    Toggle(P3_9); // toggle P3.9 (toggle LED) using GPIO.h macros

    printf("Welcome into Blink45\n");
    }

    Does not seem to do the job :
    Click image for larger version

Name:	Blinky45MonitorDebug.PNG
Views:	11
Size:	25.4 KB
ID:	2792
    What am I doing wrong ?
    Thanks for any clue...

    Jorge

  9. #9
    New Member New Member mrdata is on a distinguished road
    Join Date
    Nov 2016
    Posts
    4
    Points
    37.5
    Hello together :-)

    printf is working well and will help me very much. Would be nice to have the same for sending data to uC.
    I have tried scanf, gehtchar,... But it doesn't work.
    Here is an example:

    char buff[1];

    if (fgets(buff, sizeof(buff), stdin) != NULL ) {
    printf("yes :-) \n");
    }


    What am I doing wrong? Any ideas? Would be very happy if someone could help me.
    Regards, Dirk

  10. #10
    New Member New Member lapierro is on a distinguished road
    Join Date
    Jun 2019
    Location
    France
    Posts
    1
    Points
    20
    Hi.
    I did the steps 1 to 3 above, and the linker fails.

    make: *** [EP6V43_relax.elf] Error 1
    makefile:72: recipe for target 'EP6V43_relax.elf' failed

    There are no other messages to help understand what is missing.


    I am with an XMC4300 with Ethercat and a software a bit more complex than the example. But it runs perfectly on the Relax kit when I don't try semihosting.

    Thans in advance for your help.
    Olivier

+ Reply to Thread
Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.