http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka11357.html
then there was an other problem with the clock. This fixed it for me:http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka11357.html
There are two possibility to do retargeting standard I/O to user-defined functions (Direct semihosting C library function
dependencies http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0471k/pge1358787045051.html and
Indirect semihosting C library function
dependencies http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0475k/chr1358938918384.html)
I preffer to use direct semihosting. It seems that you use indirect one, code at platforms_startup is not suitable for that.
I'd like to join Heath Raftery who wrote a very helpful setup-guide. I made the same excercise for Keil uVision lately, here are my findings:
Toolchain:
uVision MDK-ARM Standart Version: V4.70.0.0
Compiler / Linker Toolchain Version: V5.03.0.24
HAL Library:
Standard Peripheral Library for STM32 Cortex M3 Version V3.5.0
Target:
STM32F103VG
I chose to set up a simulator project, most because I like the idea of being able to testdrive code before any HW is present. Furthermore I am testing with the same compiler toolchain as my target will use, and last but not least, code coverage / and performance analysis are available in the same environment. Drawback is, that you are kind of stuck to the keil environment. The editor is not a big revelation, nor is the toolchainsettings and the possibilities to automate the tests. But that is whole different story...
I picked the biggest (memory-wise) available CortexM3 core from ST (STM32F103VG) that has a simulator available, since we are using a core of the same family. Check yourself if Keil provides a simulator for a certain core on the Keil webpage.Here we are. With this I had a working CppUTest environment under Keil. Debug output (Test results) can be listed via "View->serial Windows-> debug (printf) viewer". I am going along this street now, creating a custom testdriven project. If you admins think it would be useful to create a UtestPlatform.cpp for Keil let me know, I am happy to share my files.
- To build the CppUTest library in Keil, I created a new empty Keil project in the root folder of cpputest and made the following changes:
- Target Options->Device Tab->choose "STM32F103VG"
- Target Options->Target Tab->Code Generation->check "Use MicroLib"
- Target Options->Output Tab->Create Executable lib
- Target Options->C/C++ Tab->Define->add "STM32F10X_XL, CPPUTEST_STD_CPP_LIB_DISABLED"
- Target Options->C/C++ Tab->Include Paths->add the CppUTest include directory
- Target Options->C/C++ Tab->Misc Controls->add "--diag_suppress 1300 --diag_suppress 1293 --exceptions"
- Target Options->Linker Tab->Misc Controls->add "--vfemode=off"
- added all *.cpp files in src\CppUTest\
- Added src\Platforms\Iar\UtestPlatform.cpp
- Changed in UtestPlatform.cpp the return value of the function TimeInMillisImplementation from return 1; to return t; which enables timing.
- in UtestPlatform.cpp I declared all the functions except for PlatformSpecificRunTestInASeperateProcess and PlatformSpecificGetWorkingEnvironment as extern "C"
- CppUTest builds with these settings, generating a CppUTest.lib file
- To build the CppUTest tests, I created a new empty Keil project in the root folder of CppUTest, called it CppUTestTest, and made the following changes:
- Target Options->Device Tab->choose "STM32F103VG"
- Target Options->Target Tab->Code Generation->check "Use MicroLib"
- Target Options->Output Tab->Create Executable (not Lib) check "Debug information"
- Target Options->C/C++ Tab->Define->add "STM32F10X_XL, CPPUTEST_STD_CPP_LIB_DISABLED"
- Target Options->C/C++ Tab->Include Paths->add the CppUTest include directory
- Target Options->C/C++ Tab->Misc Controls->add "--diag_suppress 1300 --diag_suppress 1293 --exceptions"
- Added the include path to the Standard Peripheral Library from STMicroelectronics
- Added the include path to the ARMCC standard implementations
- Target Options->Linker Tab->Misc Controls->add "--vfemode=off"
- Target Options->Debug Tab->check "Use Simulator"
- Target Options->Debug Tab->create a map.ini file that contains the memory regions with the appropriate permissions
- Target Options->Debug Tab->Parameter->add "-REMAP"
- Add all *.cpp and *.c files in tests\
- Add the startupfile for the core. In my case it is "startup_stm32f103x_xl.s"
- Add the system init file, in my case "system_stm32f10x.c"
- Add the previously built CppUTest.lib
- change the file AllTests to be able let the tests run in verbose mode
int ac_override = 2;
const char * av_override[] = { "exe", "-v" }; //turn on verbose mode
return RUN_ALL_TESTS(ac_override, av_override);- since Keil does not support semihosting straightaway, you need to retarget some functions. A working retarget sample can be found from this website. Basically what must be done is redefining fputc to redirect the debug output over the ARM ITM interface. Something like this:
#pragma import(__use_no_semihosting_swi)
#define ECHO_FGETC
volatile int ITM_RxBuffer=0x5AA55AA5; /* Buffer to transmit data towards debug system. */
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int ch, FILE *f)
{
return (ITM_SendChar((uint32_t)ch));
}- Furthermore, a working clock definition is needed. Keil provides an example here.
Andreas