[SOLVED] Error when added segger RTT to a Keil project

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] Error when added segger RTT to a Keil project

    Hi,
    I am working on ARM Cortex M4 processor with Keil MDK. While compiling the project, I am getting the following error. From the Error I understood that there is a multiple definition and I need to get rid of one. Can someone please tell me what is the possible solution for the error and how to implement it.

    Build started: Project: Hello World
    *** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
    Build target 'Hello'
    linking...
    .\Objects\Hello World.axf: Error: L6200E: Symbol __stdout_name multiply defined (by C:\Keil_v5\ARM\ARMCC\Bin\..\lib\armlib\c_w.l(sys_io.o) and .\objects\segger_rtt_syscalls_keil.o).
    .\Objects\Hello World.axf: Error: L6200E: Symbol __stderr_name multiply defined (by C:\Keil_v5\ARM\ARMCC\Bin\..\lib\armlib\c_w.l(sys_io.o) and .\objects\segger_rtt_syscalls_keil.o).
    .\Objects\Hello World.axf: Error: L6200E: Symbol _sys_close multiply defined (by C:\Keil_v5\ARM\ARMCC\Bin\..\lib\armlib\c_w.l(sys_io.o) and .\objects\segger_rtt_syscalls_keil.o).
    .\Objects\Hello World.axf: Error: L6200E: Symbol _sys_ensure multiply defined (by C:\Keil_v5\ARM\ARMCC\Bin\..\lib\armlib\c_w.l(sys_io.o) and .\objects\segger_rtt_syscalls_keil.o).
    .\Objects\Hello World.axf: Error: L6200E: Symbol _sys_flen multiply defined (by C:\Keil_v5\ARM\ARMCC\Bin\..\lib\armlib\c_w.l(sys_io.o) and .\objects\segger_rtt_syscalls_keil.o).
    .\Objects\Hello World.axf: Error: L6200E: Symbol _sys_istty multiply defined (by C:\Keil_v5\ARM\ARMCC\Bin\..\lib\armlib\c_w.l(sys_io.o) and .\objects\segger_rtt_syscalls_keil.o).
    .\Objects\Hello World.axf: Error: L6200E: Symbol _sys_open multiply defined (by C:\Keil_v5\ARM\ARMCC\Bin\..\lib\armlib\c_w.l(sys_io.o) and .\objects\segger_rtt_syscalls_keil.o).
    .\Objects\Hello World.axf: Error: L6200E: Symbol _sys_read multiply defined (by C:\Keil_v5\ARM\ARMCC\Bin\..\lib\armlib\c_w.l(sys_io.o) and .\objects\segger_rtt_syscalls_keil.o).
    .\Objects\Hello World.axf: Error: L6200E: Symbol _sys_seek multiply defined (by C:\Keil_v5\ARM\ARMCC\Bin\..\lib\armlib\c_w.l(sys_io.o) and .\objects\segger_rtt_syscalls_keil.o).
    .\Objects\Hello World.axf: Error: L6200E: Symbol _sys_write multiply defined (by C:\Keil_v5\ARM\ARMCC\Bin\..\lib\armlib\c_w.l(sys_io.o) and .\objects\segger_rtt_syscalls_keil.o).
    Not enough information to list image symbols.
    Not enough information to list load addresses in the image map.
    Finished: 2 information, 0 warning and 10 error messages.
    ".\Objects\Hello World.axf" - 10 Error(s), 0 Warning(s).
    Target not created.
  • Hello,

    Thank you for your inquiry.
    To retarget e.g. printf to use RTT the following steps must be considered in your setup:
    wiki.segger.com/Keil_MDK-ARM#RTT_in_uVision

    Additionally it appears that uVision V5 requires some changes in the syscalls file. This will be fixed in the next J-Link software release.
    You can also do this manually if you edit the SEGGER_RTT_Syscalls_KEIL.c as follows:

    Source Code

    1. /*********************************************************************
    2. *
    3. * Public const
    4. *
    5. **********************************************************************
    6. */
    7. #if __ARMCC_VERSION < 5000000
    8. //const char __stdin_name[] = "STDIN";
    9. const char __stdout_name[] = "STDOUT";
    10. const char __stderr_name[] = "STDERR";
    11. #endif
    Display All
    and

    Source Code

    1. /*********************************************************************
    2. *
    3. * _sys_exit
    4. *
    5. * Function description:
    6. * This function is called when the application returns from main
    7. *
    8. * Parameters:
    9. * ReturnCode - Return code from the main function
    10. *
    11. *
    12. */
    13. void _sys_exit(int ReturnCode) {
    14. (void)ReturnCode;
    15. while (1); // Not implemented
    16. }
    17. #if __ARMCC_VERSION >= 5000000
    18. /*********************************************************************
    19. *
    20. * stdout_putchar
    21. *
    22. * Function description:
    23. * Put a character to the stdout
    24. *
    25. * Parameters:
    26. * ch - Character to output
    27. *
    28. *
    29. */
    30. int stdout_putchar(int ch) {
    31. (void)ch;
    32. return ch; // Not implemented
    33. }
    34. #endif
    35. #endif
    36. /*************************** End of file ****************************/
    Display All
    If you make these changes and consider the setup info from the Wiki you should be able to use RTT in your Keil application.
    If you want to avoid retargeting std lib functions you can also call the RTT API functions directly instead of using printf.

    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: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Nino,
    Thanks for the suggestion. I made the changes in ''Run time environment'. After making the additional changes at 'Public const' and '_sys_exit' (can refer to attachments), still i am getting the follwing errors


    *** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
    Build target 'Hello'
    linking...
    .\Objects\Hello World.axf: Error: L6218E: Undefined symbol HAL_ADC_Init (referred from .\objects\main.o).
    .\Objects\Hello World.axf: Error: L6218E: Undefined symbol HAL_DAC_Init (referred from .\objects\main.o).
    .\Objects\Hello World.axf: Error: L6218E: Undefined symbol HAL_DAC_Reset (referred from .\objects\main.o).
    .\Objects\Hello World.axf: Error: L6218E: Undefined symbol HAL_Uart_Init (referred from .\objects\main.o).

    Not enough information to list image symbols.
    Not enough information to list load addresses in the image map.
    Finished: 2 information, 0 warning and 23 error messages.
    ".\Objects\Hello World.axf" - 23 Error(s), 0 Warning(s).
    Target not created.
    Build Time Elapsed: 00:00:00
    Images
    • public_const_changes.PNG

      23.68 kB, 769×357, viewed 918 times
    • _sys_exit.PNG

      31.54 kB, 953×637, viewed 838 times
  • Hello,

    Good to hear that the RTT linking errors are gone.
    The remaining errors are explained by the linker output. In your main.c you are using HAL functions that are undefined. Make sure to include all needed files.
    Please understand that we are not allowed to assist you further here as this remaining issue is not related to SEGGER products.
    For questions about uVision and how to setup generic projects we recommend contacting Keil support.

    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: segger.com/ticket/

    Or you can contact us via e-mail.