Hi. I'm a newbie coding for an STM32F4 Discovery board. I'm working with some modified sample code and when I try to debug it, I'm getting stuck at "BKPT 0XAB", and I can't progress any further.
Can someone help me understand what causes this and how I can fix it?
#pragma import(__use_no_semihosting_swi)
Look at what's in the retarget file as functions to replace the libraries versions.
This project doesn't use any retarget files. The snippet I showed earlier is in main.c.
As for the Include line, if I add that, then upon build, I get the following errors:
.\Objects\Template.axf: Error: L6915E: Library reports error: __use_no_semihosting_swi was requested, but _sys_exit was referenced .\Objects\Template.axf: Error: L6915E: Library reports error: __use_no_semihosting_swi was requested, but _sys_open was referenced .\Objects\Template.axf: Error: L6915E: Library reports error: __use_no_semihosting_swi was requested, but _ttywrch was referenced
Okay, I found the retarget.c file and by adding that to the project, I get rid of the errors I listed above. However, now I get different errors:
.\Objects\Template.axf: Error: L6200E: Symbol __stdout multiply defined (by main.o and retarget.o). .\Objects\Template.axf: Error: L6200E: Symbol __stdin multiply defined (by main.o and retarget.o). .\Objects\Template.axf: Error: L6200E: Symbol fputc multiply defined (by main.o and retarget.o). .\Objects\Template.axf: Error: L6200E: Symbol fgetc multiply defined (by main.o and retarget.o). .\Objects\Template.axf: Error: L6200E: Symbol ferror multiply defined (by main.o and retarget.o). .\Objects\Template.axf: Error: L6200E: Symbol _ttywrch multiply defined (by main.o and retarget.o). .\Objects\Template.axf: Error: L6200E: Symbol _sys_exit multiply defined (by main.o and retarget.o).
What is the correct way to address this?
To only have ONE instance of those functions?
Remove the ones from main.c
That's just it - there wasn't a set of duplicates there, other than the fputc() snippet I showed you earlier.
So I took out the Include for retarget.c, and just copied over the snippets for _ttywrch and _sys_exit.
That got rid of the other errors and gave me:
Source\Main.c(395): warning: #223-D: function "sendchar" declared implicitly .\Objects\Template.axf: Error: L6218E: Undefined symbol sendchar (referred from main.o).
So I commented out the sendchar() line out of _ttywrch, hoping that it wasn't necessary.
That leaves me with the sole error of:
.\Objects\Template.axf: Error: L6915E: Library reports error: __use_no_semihosting_swi was requested, but _sys_open was referenced
_sys_open doesn't appear in main.c, so I'm not sure where this is coming from.
p.s. Thank you for staying with me and trying to help. From the perspective of someone new to this, I'm sure you can understand how frustrating this issue is for me.
Ok, but just be clear you shouldn't be #include'ing .C files, this will charge the ownership to the file doing the #include, you simply add the .C file to the project.
If you don't want to add files to the project, you'd paste something like this directly into the primary source file.
//****************************************************************************** // Hosting of stdio functionality through ITM/SWV //****************************************************************************** #include <stdio.h> #include <rt_misc.h> #pragma import(__use_no_semihosting_swi) struct __FILE { int handle; /* Add whatever you need here */ }; FILE __stdout; FILE __stdin; int fputc(int ch, FILE *f) { ITM_SendChar(ch); return(ch); } int fgetc(FILE *f) { char ch = 0; return((int)ch); } int ferror(FILE *f) { /* Your implementation of ferror */ return EOF; } void _ttywrch(int ch) { ITM_SendChar(ch); } void _sys_exit(int return_code) { label: goto label; /* endless loop */ } //******************************************************************************
When using SWV via the trace set up you must set the frequency of the processor correctly for the data to show up in the Serial Debug (printf) tab.