This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

CppUTest Compile for Test Driven Development in the nRF52

Hi there,

I want to use CppUTest on the nRF52 to start developing my personal and not so personal projects. I am using the SDK for nRF52, with PCA10040's board. For the moment, I am trying to compile blinky's blank example using armgcc. 

I modified the example's main.c -> main.cpp to include CppUTest libraries:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
extern "C" {
#include <stdbool.h>
#include <stdint.h>
#include "nrf_delay.h"
#include "boards.h"
}
#include "CommandLineTestRunner.h"
IMPORT_TEST_GROUP(Dummy);
/**
* @brief Function for application main entry.
*/
int main(void)
{
char test[] = "Dummy";
int argc = 2;
char* argv = (char*) test;
RUN_ALL_TESTS(argc, &argv);
/* Configure board. */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

An I also modified the pca10040/blank/armgcc/Makefile to include CppUTest header files and static .a libraries:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
PROJECT_NAME := blinky_pca10040
TARGETS := nrf52832_xxaa
OUTPUT_DIRECTORY := _build
SDK_ROOT := ../../../../../..
PROJ_DIR := ../../..
SDK_CppUTest := $(SDK_ROOT)/../../cpputestbuild/
$(OUTPUT_DIRECTORY)/nrf52832_xxaa.out: \
LINKER_SCRIPT := blinky_gcc_nrf52.ld
# Source files common to all targets
SRC_FILES += \
$(SDK_ROOT)/modules/nrfx/mdk/gcc_startup_nrf52.S \
$(SDK_ROOT)/components/libraries/log/src/nrf_log_frontend.c \
$(SDK_ROOT)/components/libraries/log/src/nrf_log_str_formatter.c \
$(SDK_ROOT)/components/boards/boards.c \
$(SDK_ROOT)/components/libraries/util/app_error.c \
$(SDK_ROOT)/components/libraries/util/app_error_handler_gcc.c \
$(SDK_ROOT)/components/libraries/util/app_error_weak.c \
$(SDK_ROOT)/components/libraries/util/app_util_platform.c \
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Technically the makefile knows what is needed, however I am having troubles with the linker script, which complains:

Fullscreen
1
2
3
4
5
6
Compiling file: main.cpp
Linking target: _build/nrf52832_xxaa.out
../../../../../../../../cpputestbuild//libCppUTest.a: error adding symbols: File format not recognized
collect2: error: ld returned 1 exit status
../../../../../../components/toolchain/gcc/Makefile.common:292: recipe for target '_build/nrf52832_xxaa.out' failed
make: *** [_build/nrf52832_xxaa.out] Error 1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I am really newbie with linker scripts so I am not sure what this message actually means. Googling around I found someone commenting on the linker not being able to read the library? Perhaps you guys could please help me? I am not sure how to proceed, and perhaps someone has solved this issue before.

Thank you,
Pablo G