I have a Keil project that is built using ARMCC, with "use MicroLIB" unchecked. It links multiple libraries, including CppUTest, that are also built with ARMCC.
During Keil debug session with simulator, I set a single breakpoint on a line after my tests are called. I press "run" and it stops somewhere inside; I have to press "run" repeatedly to get it to step through each test call (and output each printf) and eventually reach the breakpoint I set.
However, when I compile the same project with "use MicroLIB" checked, pressing "run" behaves as expected and goes to the first breakpoint.
Does anyone have a good explanation for this behavior? I'd like to understand why this happens since I ultimately want to build without MicroLIB, but also have the debug "run" instead of having to repeatedly step.
Device: ARM Cortex M0 Plus CMSIS pack: 5.4.0 uVision: 5.26.2.0 ARMCC: 5.06 update 6
So I've identified the issue in my 2nd post at least:
My .ini file contains:
LOG > log/command_output.txt ER > log/er_output.csv SLOG > log/test_output.txt printf("Start testing program...\n"); G printf("Finish testing program.\n"); SLOG off ER off LOG off EXIT
Since "G" is not continuing as described in my 1st post, the "SLOG/ER/LOG off" commands are executed before I step through the printf() calls, so no logging occurs. By commenting out those "SLOG/ER/LOG off" commands, the files are logged. However, there is still an issue when running this via command line because "G" does nothing then exits.
So to replace my 2nd post question, how can I ensure "G" actually runs the program instead of automatically stopping?
Has anyone seen this behavior with/without MicroLIB before?
Hello Tom,
Please take a look at this KB article.
It sounds like you are running into semihosting issues. Hopefully these steps will help you get rid of the routines that have breakpoints encoded into them.
http://www.keil.com/support/docs/3614.htm
Thanks for the article link, it's helpful but I'm still running into issues. I think you're right about semihosting, since I can see that my program is indeed stopping at a "BKPT 0xAB" instruction.
1. When trying to solve by using the Keil Compiler Pack as suggested first, I redirect STDIN and STDERR to User (and add the default user template files to my source files). I still have STDOUT redirected to EVR (and Event Recorder DAP enabled), as outlined on the www.keil.com/.../_retarget__examples_er.html page. After compiling this, the same underlying breakpoint occurs as before.
2. I also tried selecting STDOUT redirect to User (with default user template file), but the breakpoint remains. But this is without printf output, which I need anyways.
3. I tried the second suggestion to turn on MicroLIB, but I can't compile ARM's retarget_io.c because of __stdout, fputc, fgetc, and abort conflicts.
4. I also tried the third suggestion to add a retarget.c file according to the http://www.keil.com/support/man/docs/gsac/gsac_retargetcortex.htm page. However, this caused compiler conflicts with __stdout, __stdin, fputc, fgetc, and ferror in <stdio.h> [example warning: #2681-D: name linkage conflicts with previous declaration of variable "std::__stdout" (declared at line 138 of "C:\Keil_v5\ARM\ARMCC\Bin\..\include\stdio.h")].
I feel like I'm getting close... or at least figuring out the right question to ask. How do I basically redirect STDOUT to Event Recorder (or other simulator printf output) and disable the semihosting breakpoints?
Have you seen this thread?
http://www.keil.com/forum/10998/usart-use-of-printf/
Thanks Ron, I have stumbled upon that thread, but I wasn't sure of what to take away from it. Even though my project already compiles (see #1 from my previous post), it's just a matter of getting the compiler to not include the extra semihosting breakpoints. Do I need to somehow compile my Pack-related retarget_io.c/EventRecorder.c files separately without the --cpp11 flag?
I was finally able to solve this problem! After reading many articles including:
www.onarm.com/.../ stackoverflow.com/.../1898523
I built with the following retarget.c file:
#include <stdio.h> #include <rt_misc.h> #include <rt_sys.h> #pragma import(__use_no_semihosting) int stderr_putchar (int ch) { return -1; } int stdin_getchar (void) { return -1; } void ttywrch (int ch) { } void _sys_exit(int return_code) { label: goto label; /* endless loop */ }
The key line not found in most retarget examples is #include <rt_sys.h>... without it I get the L6915E error. Maybe it is only needed for my particular project with external libraries.