Attachments are accessible only for community members.
Not applicable
Nov 16, 2015
01:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 16, 2015
01:28 AM
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.
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.
- Tags:
- IFX
14 Replies
Nov 16, 2015
04:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 16, 2015
04:47 AM
Hi Daryl,
it's working thanks,
but in your description is a small error. There is a missing "underline" at __SKIP.
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
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
Not applicable
Nov 16, 2015
10:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 16, 2015
10:11 PM
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
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
Not applicable
Nov 19, 2015
04:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 19, 2015
04:56 AM
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
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
Nov 20, 2015
03:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 20, 2015
03:49 AM
Are you looking at the right console?
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
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
Dec 01, 2015
12:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 01, 2015
12:58 AM
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.
Attachments are accessible only for community members.
Not applicable
Mar 23, 2016
12:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 23, 2016
12:46 AM
[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.
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.
Feb 21, 2017
02:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 21, 2017
02:24 AM
I am unable to make it work on Hexagon board XMC4500 and Dave 4.3.2
Here is a simplified source code (from "Blinky" example) :
#include //Declarations from DAVE Code Generation (includes SFR declaration)
#include
#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 :
What am I doing wrong ?
Thanks for any clue...
Jorge
Here is a simplified source code (from "Blinky" example) :
#include
#include
#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 :
What am I doing wrong ?
Thanks for any clue...
Jorge
Apr 02, 2022
03:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 02, 2022
03:00 AM
I hope this is helpful, I just recorded this by following the steps in this thread.
Mar 02, 2017
11:10 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 02, 2017
11:10 PM
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
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
Jun 12, 2019
08:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jun 12, 2019
08:36 AM
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
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
Nov 22, 2019
05:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 22, 2019
05:07 AM
Same issue with DAVE 4.4.2
Nov 02, 2020
11:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 02, 2020
11:22 AM
Hi there
I have issues sending messags to the debug window. I tried using XMC_debug and as well the solution using semihosting.
However, both are not working (at all). I an able to compile but there no messages arrive at the window.
Is there meanwhile an new solution available?
I am using XMC4300 with dave 4.4.2
Thank you!
Regards
Roman
I have issues sending messags to the debug window. I tried using XMC_debug and as well the solution using semihosting.
However, both are not working (at all). I an able to compile but there no messages arrive at the window.
Is there meanwhile an new solution available?
I am using XMC4300 with dave 4.4.2
Thank you!
Regards
Roman
Feb 23, 2022
07:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Feb 23, 2022
07:06 PM
Where is initialise_monitor_handles() defined?
I'm using Dave 4.5 with an xmc4800. I'm just baffled how to get stdio working through the j-link debugger
Are there current/complete instructions someplace?
Marty
Apr 02, 2022
02:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 02, 2022
02:59 AM
I hope this is helpful, I just recorded this by following the steps in this thread.